10 #ifndef SACADO_PCE_SCALARTRAITSIMP_HPP
11 #define SACADO_PCE_SCALARTRAITSIMP_HPP
16 #include "Sacado_mpl_apply.hpp"
25 template <
typename PCEType>
27 typedef typename Sacado::ValueType<PCEType>::type
ValueT;
32 typedef typename mpl::apply<PCEType,typename Teuchos::ScalarTraits<ValueT>::halfPrecision>::type
halfPrecision;
33 typedef typename mpl::apply<PCEType,typename Teuchos::ScalarTraits<ValueT>::doublePrecision>::type
doublePrecision;
73 TEUCHOS_SCALAR_TRAITS_NAN_INF_ERR(
74 a,
"Error, the input value to magnitude(...) a = " << a <<
77 "Complex magnitude is not a differentiable "
78 "function of complex inputs.");
84 TEUCHOS_SCALAR_TRAITS_NAN_INF_ERR(
85 a,
"Error, the input value to innerProduct(...) a = " << a <<
87 TEUCHOS_SCALAR_TRAITS_NAN_INF_ERR(
88 b,
"Error, the input value to innerProduct(...) b = " << b <<
91 return a.inner_product(b);
104 "Complex conjugate is not a differentiable "
105 "function of complex inputs.");
117 "Real component is not a differentiable "
118 "function of complex inputs.");
130 "Imaginary component is not a differentiable "
131 "function of complex inputs.");
140 for (
int i=0; i<x.size(); i++)
152 return Sacado::StringName<PCEType>::eval();
156 TEUCHOS_SCALAR_TRAITS_NAN_INF_ERR(
157 x,
"Error, the input value to squareroot(...) a = " << x <<
158 " can not be NaN!" );
183 for (
int i=0; i<x.size(); i++)
193 template <
typename TypeTo,
typename PCEType>
195 typedef typename Sacado::ValueType<PCEType>::type
ValueT;
207 template <
typename Ordinal,
typename PCEType>
209 typedef typename Sacado::ValueType<PCEType>::type
ValueT;
226 for (
Ordinal i=0; i<count; i++) {
227 int sz = buffer[i].size();
241 for (
Ordinal i=0; i<count; i++) {
243 int sz = buffer[i].size();
260 const char charBuffer[]) {
263 while (bytes_used < bytes) {
285 const char charBuffer[],
288 for (
Ordinal i=0; i<count; i++) {
298 if (buffer[i].size() != *sz)
299 buffer[i].reset(buffer[i].expansion(), *sz);
300 buffer[i].copyForWrite();
318 template <
typename Ordinal,
typename PCEType,
typename ValueSerializer>
331 typedef typename Sacado::ValueType<PCEType>::type
ValueT;
361 const PCEType buffer[])
const {
365 for (
Ordinal i=0; i<count; i++) {
366 int my_sz = buffer[i].size();
377 Ordinal b2 =
vs->fromCountToIndirectBytes(
sz, cx->coeff());
390 char charBuffer[])
const {
393 for (
Ordinal i=0; i<count; i++) {
395 int my_sz = buffer[i].size();
410 Ordinal b2 =
vs->fromCountToIndirectBytes(
sz, cx->coeff());
414 vs->serialize(
sz, cx->coeff(), b2, charBuffer);
423 const char charBuffer[])
const {
426 while (bytes_used < bytes) {
448 const char charBuffer[],
451 for (
Ordinal i=0; i<count; i++) {
465 vs->deserialize(*b2, charBuffer, *my_sz, buffer[i].coeff());
479 #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.