Stokhos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Sacado_UQ_PCE_Traits.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Stokhos Package
4 //
5 // Copyright 2009 NTESS and the Stokhos contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef SACADO_UQ_PCE_TRAITS_HPP
11 #define SACADO_UQ_PCE_TRAITS_HPP
12 
13 #include "Sacado_Traits.hpp"
14 #include "Sacado_mpl_apply.hpp"
15 
16 // Forward declarations
17 namespace Sacado {
18  namespace UQ {
19  template <typename S> class PCE;
20  }
21 }
22 
23 namespace Sacado {
24 
26  SACADO_AD_PROMOTE_SPEC( UQ, PCE )
27 
28 
29  template <typename S>
30  struct ScalarType< UQ::PCE<S> > {
32  };
33 
35  template <typename S>
36  struct ValueType< UQ::PCE<S> > {
37  typedef typename UQ::PCE<S>::value_type type;
38  };
39 
41  template <typename S>
42  struct IsADType< UQ::PCE<S> > {
43  static const bool value = true;
44  };
45 
47  template <typename S>
48  struct IsScalarType< UQ::PCE<S> > {
49  static const bool value = false;
50  };
51 
53  template <typename S>
54  struct Value< UQ::PCE<S> > {
55  typedef typename ValueType< UQ::PCE<S> >::type value_type;
56  KOKKOS_INLINE_FUNCTION
57  static const value_type& eval(const UQ::PCE<S>& x) {
58  return x.val(); }
59  };
60 
62  template <typename S>
63  struct ScalarValue< UQ::PCE<S> > {
64  typedef typename ValueType< UQ::PCE<S> >::type value_type;
65  typedef typename ScalarType< UQ::PCE<S> >::type scalar_type;
66  KOKKOS_INLINE_FUNCTION
67  static const scalar_type& eval(const UQ::PCE<S>& x) {
68  return ScalarValue<value_type>::eval(x.val()); }
69  };
70 
72  template <typename S>
73  struct StringName< UQ::PCE<S> > {
74  static std::string eval() {
75  return std::string("Sacado::UQ::PCE< ") +
76  StringName<S>::eval() + " >"; }
77  };
78 
80  template <typename S>
81  struct IsEqual< UQ::PCE<S> > {
82  KOKKOS_INLINE_FUNCTION
83  static bool eval(const UQ::PCE<S>& x,
84  const UQ::PCE<S>& y) {
85  return x.isEqualTo(y);
86  }
87  };
88 
90  template <typename S>
91  struct IsStaticallySized< UQ::PCE<S> > {
92  static const bool value = S::is_static;
93  };
94 
95 } // namespace Sacado
96 
97 // Define Teuchos traits classes
98 // Note Stokhos has required dependency on all Teuchos sub-packages
100 #include "Teuchos_ScalarTraits.hpp"
103 
104 namespace Teuchos {
105 
107  template <typename S>
108  struct PromotionTraits< Sacado::UQ::PCE<S>,
109  Sacado::UQ::PCE<S> > {
110  typedef typename Sacado::Promote< Sacado::UQ::PCE<S>,
111  Sacado::UQ::PCE<S> >::type
113  };
114 
116  template <typename S, typename R>
117  struct PromotionTraits< Sacado::UQ::PCE<S>, R > {
118  typedef typename Sacado::Promote< Sacado::UQ::PCE<S>, R >::type
120  };
121 
123  template <typename L, typename S>
124  struct PromotionTraits< L, Sacado::UQ::PCE<S> > {
125  public:
126  typedef typename Sacado::Promote< L, Sacado::UQ::PCE<S> >::type
128  };
129 
131  template <typename S>
132  struct ScalarTraits< Sacado::UQ::PCE<S> > :
133  public Sacado::UQ::PCEScalarTraitsImp< Sacado::UQ::PCE<S> > {};
134 
136  template <typename TypeTo, typename S>
137  struct ValueTypeConversionTraits< TypeTo, Sacado::UQ::PCE<S> > :
139  Sacado::UQ::PCE<S> > {};
140 
142  template <typename Ordinal, typename S>
143  struct SerializationTraits<Ordinal, Sacado::UQ::PCE<S> > :
145  Sacado::UQ::PCE<S> >
146  {};
147 
149  template <typename Ordinal, typename S>
150  struct ValueTypeSerializer<Ordinal, Sacado::UQ::PCE<S> > :
151  public Sacado::UQ::PCESerializerImp< Ordinal,
152  Sacado::UQ::PCE<S>,
153  ValueTypeSerializer<Ordinal,typename S::value_type> >
154  {
158  typedef typename Base::cijk_type cijk_type;
161  Base(cijk,vs) {}
162  };
163 
164 // Should also do TypeTo, and TypeTo,TypeFrom as UQ::PCE, but the real way
165 // to fix is to make sure it is never called at all (requires fixing
166 // magnitudeType)
167 
168 }
169 
170 #endif // SACADO_UQ_PCE_TRAITS_HPP
ScalarType< UQ::PCE< S > >::type scalar_type
Serializer object for all PCE types.
Implementation for Teuchos::ScalarTraits for all PCE types.
Implementation for Teuchos::ValueTypeConversionTraits for all PCE types.
Sacado::Promote< Sacado::UQ::PCE< S >, R >::type promote
ValueTypeSerializer< Ordinal, typename S::value_type > ValueSerializer
static KOKKOS_INLINE_FUNCTION bool eval(const UQ::PCE< S > &x, const UQ::PCE< S > &y)
ValueType< UQ::PCE< S > >::type value_type
ScalarType< typename UQ::PCE< S >::value_type >::type type
PCEType::cijk_type cijk_type
Typename of cijk.
Sacado::Promote< Sacado::UQ::PCE< S >, Sacado::UQ::PCE< S > >::type promote
ValueTypeSerializer(const cijk_type &cijk, const Teuchos::RCP< const ValueSerializer > &vs)
Sacado::UQ::PCESerializerImp< Ordinal, PCEType, ValueSerializer > Base
static KOKKOS_INLINE_FUNCTION const scalar_type & eval(const UQ::PCE< S > &x)
KOKKOS_INLINE_FUNCTION constexpr std::enable_if< is_view_uq_pce< view_type >::value, typename CijkType< view_type >::type >::type cijk(const view_type &view)
Implementation of Teuchos::SerializationTraits for all PCE types.
static KOKKOS_INLINE_FUNCTION const value_type & eval(const UQ::PCE< S > &x)
ValueType< UQ::PCE< S > >::type value_type
Sacado::Promote< L, Sacado::UQ::PCE< S > >::type promote