42 #ifndef SACADO_PCE_SCALARTRAITSIMP_HPP
43 #define SACADO_PCE_SCALARTRAITSIMP_HPP
48 #include "Sacado_mpl_apply.hpp"
57 template <
typename PCEType>
59 typedef typename Sacado::ValueType<PCEType>::type
ValueT;
64 typedef typename mpl::apply<PCEType,typename Teuchos::ScalarTraits<ValueT>::halfPrecision>::type
halfPrecision;
65 typedef typename mpl::apply<PCEType,typename Teuchos::ScalarTraits<ValueT>::doublePrecision>::type
doublePrecision;
105 TEUCHOS_SCALAR_TRAITS_NAN_INF_ERR(
106 a,
"Error, the input value to magnitude(...) a = " << a <<
107 " can not be NaN!" );
109 "Complex magnitude is not a differentiable "
110 "function of complex inputs.");
116 TEUCHOS_SCALAR_TRAITS_NAN_INF_ERR(
117 a,
"Error, the input value to innerProduct(...) a = " << a <<
118 " can not be NaN!" );
119 TEUCHOS_SCALAR_TRAITS_NAN_INF_ERR(
120 b,
"Error, the input value to innerProduct(...) b = " << b <<
121 " can not be NaN!" );
123 return a.inner_product(b);
136 "Complex conjugate is not a differentiable "
137 "function of complex inputs.");
149 "Real component is not a differentiable "
150 "function of complex inputs.");
162 "Imaginary component is not a differentiable "
163 "function of complex inputs.");
172 for (
int i=0; i<x.size(); i++)
184 return Sacado::StringName<PCEType>::eval();
188 TEUCHOS_SCALAR_TRAITS_NAN_INF_ERR(
189 x,
"Error, the input value to squareroot(...) a = " << x <<
190 " can not be NaN!" );
215 for (
int i=0; i<x.size(); i++)
225 template <
typename TypeTo,
typename PCEType>
227 typedef typename Sacado::ValueType<PCEType>::type
ValueT;
239 template <
typename Ordinal,
typename PCEType>
241 typedef typename Sacado::ValueType<PCEType>::type
ValueT;
258 for (
Ordinal i=0; i<count; i++) {
259 int sz = buffer[i].size();
273 for (
Ordinal i=0; i<count; i++) {
275 int sz = buffer[i].size();
292 const char charBuffer[]) {
295 while (bytes_used < bytes) {
317 const char charBuffer[],
320 for (
Ordinal i=0; i<count; i++) {
330 if (buffer[i].size() != *sz)
331 buffer[i].reset(buffer[i].expansion(), *sz);
332 buffer[i].copyForWrite();
350 template <
typename Ordinal,
typename PCEType,
typename ValueSerializer>
363 typedef typename Sacado::ValueType<PCEType>::type
ValueT;
393 const PCEType buffer[])
const {
397 for (
Ordinal i=0; i<count; i++) {
398 int my_sz = buffer[i].size();
409 Ordinal b2 =
vs->fromCountToIndirectBytes(
sz, cx->coeff());
422 char charBuffer[])
const {
425 for (
Ordinal i=0; i<count; i++) {
427 int my_sz = buffer[i].size();
442 Ordinal b2 =
vs->fromCountToIndirectBytes(
sz, cx->coeff());
446 vs->serialize(
sz, cx->coeff(), b2, charBuffer);
455 const char charBuffer[])
const {
458 while (bytes_used < bytes) {
480 const char charBuffer[],
483 for (
Ordinal i=0; i<count; i++) {
497 vs->deserialize(*b2, charBuffer, *my_sz, buffer[i].coeff());
511 #endif // SACADO_FAD_SCALARTRAITSIMP_HPP
KOKKOS_INLINE_FUNCTION PCE< Storage > sqrt(const PCE< Storage > &a)
static void deserialize(const Ordinal bytes, const char charBuffer[], const Ordinal count, PCEType buffer[])
Deserialize from an indirect char[] buffer.
static void serialize(const Ordinal count, const intbuffer[], const Ordinal bytes, char charBuffer[])
static Ordinal fromCountToIndirectBytes(const Ordinal count, const intbuffer[])
static Ordinal fromCountToDirectBytes(const Ordinal count)
static Teuchos::ScalarTraits< ValueT >::magnitudeType eps()
static Teuchos::ScalarTraits< ValueT >::magnitudeType rmin()
SerializerImp(const Teuchos::RCP< expansion_type > &expansion_, const Teuchos::RCP< const ValueSerializer > &vs_)
Teuchos::RCP< expansion_type > getSerializerExpansion() const
Return specified serializer size.
Implementation for Teuchos::ScalarTraits for all PCE types.
Teuchos::RCP< const ValueSerializer > vs
PCEType::expansion_type expansion_type
Typename of expansion.
static magnitudeType eps()
Ordinal fromCountToIndirectBytes(const Ordinal count, const PCEType buffer[]) const
Return the number of bytes for count objects.
static Teuchos::ScalarTraits< ValueT >::magnitudeType emax()
Serializer object for all PCE types.
KOKKOS_INLINE_FUNCTION PCE< Storage > pow(const PCE< Storage > &a, const PCE< Storage > &b)
static TypeTo safeConvert(const TypeFrom t)
static PCEType log(const PCEType &x)
static Ordinal fromCountToIndirectBytes(const Ordinal count, const T buffer[])
static Teuchos::ScalarTraits< ValueT >::magnitudeType sfmin()
Teuchos::RCP< const value_serializer_type > getValueSerializer() const
Get nested value serializer.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
static TypeTo convert(const TypeFrom t)
static magnitudeType real(T a)
static Teuchos::ScalarTraits< ValueT >::magnitudeType rmax()
static PCEType log10(const PCEType &x)
static void deserialize(const Ordinal bytes, const char charBuffer[], const Ordinal count, T buffer[])
static const bool isComparable
static TypeTo safeConvert(const PCEType t)
Sacado::ValueType< PCEType >::type ValueT
Teuchos::RCP< expansion_type > expansion
Teuchos::SerializationTraits< Ordinal, ValueT > vSerT
static bool isnaninf(const PCEType &x)
Sacado::ValueType< PCEType >::type ValueT
static magnitudeType emax()
static magnitudeType base()
ValueSerializer value_serializer_type
Typename of value serializer.
static magnitudeType rmax()
static magnitudeType sfmin()
Teuchos::ScalarTraits< ValueT >::magnitudeType magnitudeType
static Teuchos::ScalarTraits< ValueT >::magnitudeType rnd()
static Teuchos::ScalarTraits< ValueT >::magnitudeType base()
static PCEType squareroot(const PCEType &x)
static const bool isOrdinal
static int * convertFromCharPtr(char *ptr)
static PCEType real(const PCEType &x)
Teuchos::SerializationTraits< Ordinal, Ordinal > oSerT
Ordinal fromIndirectBytesToCount(const Ordinal bytes, const char charBuffer[]) const
Return the number of objects for bytes of storage.
static magnitudeType prec()
Sacado::ValueType< PCEType >::type ValueT
static bool is_complex_real(const ValueT &x)
Teuchos::SerializationTraits< Ordinal, int > iSerT
static const bool supportsDirectSerialization
Whether the type T supports direct serialization.
static T * convertFromCharPtr(char *ptr)
static bool is_pce_real(const PCEType &x)
Teuchos::ValueTypeConversionTraits< TypeTo, ValueT > VTCT
static void seedrandom(unsigned int s)
static PCEType imag(const PCEType &x)
static magnitudeType rmin()
Implementation for Teuchos::ValueTypeConversionTraits for all PCE types.
static const bool hasMachineParameters
static Ordinal fromCountToIndirectBytes(const Ordinal count, const PCEType buffer[])
Return the number of bytes for count objects.
static magnitudeType magnitude(const PCEType &a)
Implementation of Teuchos::SerializationTraits for all PCE types.
static void seedrandom(unsigned int s)
static Teuchos::ScalarTraits< ValueT >::magnitudeType prec()
static innerProductType innerProduct(const PCEType &a, const PCEType &b)
static magnitudeType magnitude(T a)
static void serialize(const Ordinal count, const PCEType buffer[], const Ordinal bytes, char charBuffer[])
Serialize to an indirect char[] buffer.
Sacado::UQ::PCE< storage_type > PCEType
static TypeTo convert(const PCEType t)
static std::string name()
void deserialize(const Ordinal bytes, const char charBuffer[], const Ordinal count, PCEType buffer[]) const
Deserialize from an indirect char[] buffer.
Teuchos::SerializationTraits< Ordinal, Ordinal > oSerT
static PCEType pow(const PCEType &x, const PCEType &y)
Teuchos::SerializationTraits< Ordinal, int > iSerT
static Teuchos::ScalarTraits< ValueT >::magnitudeType emin()
void serialize(const Ordinal count, const PCEType buffer[], const Ordinal bytes, char charBuffer[]) const
Serialize to an indirect char[] buffer.
static PCEType conjugate(const PCEType &x)
Sacado::ValueType< PCEType >::type ValueT
mpl::apply< PCEType, typename Teuchos::ScalarTraits< ValueT >::halfPrecision >::type halfPrecision
static Ordinal fromIndirectBytesToCount(const Ordinal bytes, const char charBuffer[])
Return the number of objects for bytes of storage.
KOKKOS_INLINE_FUNCTION PCE< Storage > log(const PCE< Storage > &a)
static const bool isComplex
KOKKOS_INLINE_FUNCTION PCE< Storage > log10(const PCE< Storage > &a)
static magnitudeType emin()
static magnitudeType rnd()
static void serialize(const Ordinal count, const T buffer[], const Ordinal bytes, char charBuffer[])
static Ordinal fromCountToDirectBytes(const Ordinal count)
static Teuchos::ScalarTraits< ValueT >::magnitudeType t()
mpl::apply< PCEType, typename Teuchos::ScalarTraits< ValueT >::doublePrecision >::type doublePrecision
static const bool supportsDirectSerialization
Whether the type T supports direct serialization.