Debian Codegraph @

packages/stokhos/src/sacado/Sacado_PCE_OrthogPolyTraits.hpp

raw
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_PCE_ORTHOGPOLYTRAITS_HPP
11 #define SACADO_PCE_ORTHOGPOLYTRAITS_HPP
12
13 #include "Sacado_Traits.hpp"
14
15 // Forward declarations
16 namespace Sacado {
17 namespace PCE {
18 template <typename T, typename S> class OrthogPoly;
19 }
20 }
21
22 namespace Sacado {
23
24 //! Specialization of %Promote to OrthogPoly types
25 SACADO_AD_PROMOTE_SPEC2( PCE, OrthogPoly )
26
27 //! Specialization of %ScalarType to OrthogPoly types
28 template <typename T, typename S>
29 struct ScalarType< PCE::OrthogPoly<T,S> > {
30 typedef typename ScalarType<typename PCE::OrthogPoly<T,S>::value_type>::type type;
31 };
32
33 //! Specialization of %ValueType to OrthogPoly types
34 template <typename T, typename S>
35 struct ValueType< PCE::OrthogPoly<T,S> > {
36 typedef typename PCE::OrthogPoly<T,S>::value_type type;
37 };
38
39 //! Specialization of %IsADType to OrthogPoly types
40 template <typename T, typename S>
41 struct IsADType< PCE::OrthogPoly<T,S> > {
42 static const bool value = true;
43 };
44
45 //! Specialization of %IsADType to OrthogPoly types
46 template <typename T, typename S>
47 struct IsScalarType< PCE::OrthogPoly<T,S> > {
48 static const bool value = false;
49 };
50
51 //! Specialization of %Value to OrthogPoly types
52 template <typename T, typename S>
53 struct Value< PCE::OrthogPoly<T,S> > {
54 typedef typename ValueType< PCE::OrthogPoly<T,S> >::type value_type;
55 static const value_type& eval(const PCE::OrthogPoly<T,S>& x) {
56 return x.val(); }
57 };
58
59 //! Specialization of %ScalarValue to OrthogPoly types
60 template <typename T, typename S>
61 struct ScalarValue< PCE::OrthogPoly<T,S> > {
62 typedef typename ValueType< PCE::OrthogPoly<T,S> >::type value_type;
63 typedef typename ScalarType< PCE::OrthogPoly<T,S> >::type scalar_type;
64 static const scalar_type& eval(const PCE::OrthogPoly<T,S>& x) {
65 return ScalarValue<value_type>::eval(x.val()); }
66 };
67
68 //! Specialization of %StringName to OrthogPoly types
69 template <typename T, typename S>
70 struct StringName< PCE::OrthogPoly<T,S> > {
71 static std::string eval() {
72 return std::string("Sacado::PCE::OrthogPoly< ") +
73 StringName<T>::eval() + " >"; }
74 };
75
76 //! Specialization of %IsEqual to OrthogPoly types
77 template <typename T, typename S>
78 struct IsEqual< PCE::OrthogPoly<T,S> > {
79 static bool eval(const PCE::OrthogPoly<T,S>& x,
80 const PCE::OrthogPoly<T,S>& y) {
81 return x.isEqualTo(y);
82 }
83 };
84
85 //! Specialization of %IsStaticallySized to OrthogPoly types
86 template <typename T, typename S>
87 struct IsStaticallySized< PCE::OrthogPoly<T,S> > {
88 static const bool value = false;
89 };
90
91 } // namespace Sacado
92
93 // Define Teuchos traits classes
94 // Note Stokhos has required dependency on all Teuchos sub-packages
95 #include "Teuchos_PromotionTraits.hpp"
96 #include "Teuchos_ScalarTraits.hpp"
97 #include "Sacado_PCE_ScalarTraitsImp.hpp"
98 #include "Teuchos_SerializationTraits.hpp"
99
100 namespace Teuchos {
101
102 //! Specialization of %Teuchos::PromotionTraits to DFad types
103 template <typename T, typename S>
104 struct PromotionTraits< Sacado::PCE::OrthogPoly<T,S>,
105 Sacado::PCE::OrthogPoly<T,S> > {
106 typedef typename Sacado::Promote< Sacado::PCE::OrthogPoly<T,S>,
107 Sacado::PCE::OrthogPoly<T,S> >::type
108 promote;
109 };
110
111 //! Specialization of %Teuchos::PromotionTraits to DFad types
112 template <typename T, typename S, typename R>
113 struct PromotionTraits< Sacado::PCE::OrthogPoly<T,S>, R > {
114 typedef typename Sacado::Promote< Sacado::PCE::OrthogPoly<T,S>, R >::type
115 promote;
116 };
117
118 //! Specialization of %Teuchos::PromotionTraits to DFad types
119 template <typename L, typename T, typename S>
120 struct PromotionTraits< L, Sacado::PCE::OrthogPoly<T,S> > {
121 public:
122 typedef typename Sacado::Promote< L, Sacado::PCE::OrthogPoly<T,S> >::type
123 promote;
124 };
125
126 //! Specializtion of %Teuchos::ScalarTraits
127 template <typename T, typename S>
128 struct ScalarTraits< Sacado::PCE::OrthogPoly<T,S> > :
129 public Sacado::PCE::ScalarTraitsImp< Sacado::PCE::OrthogPoly<T,S> > {};
130
131 //! Specializtion of %Teuchos::ValueTypeConversionTraits
132 template <typename TypeTo, typename T, typename S>
133 struct ValueTypeConversionTraits< TypeTo, Sacado::PCE::OrthogPoly<T,S> > :
134 public Sacado::PCE::ValueTypeConversionTraitsImp< TypeTo,
135 Sacado::PCE::OrthogPoly<T,S> > {};
136
137 //! Specialization of %Teuchos::SerializationTraits
138 template <typename Ordinal, typename T, typename S>
139 struct SerializationTraits<Ordinal, Sacado::PCE::OrthogPoly<T,S> > :
140 public Sacado::PCE::SerializationTraitsImp< Ordinal,
141 Sacado::PCE::OrthogPoly<T,S> >
142 {};
143
144 //! Specialization of %Teuchos::ValueTypeSerializer
145 template <typename Ordinal, typename T, typename S>
146 struct ValueTypeSerializer<Ordinal, Sacado::PCE::OrthogPoly<T,S> > :
147 public Sacado::PCE::SerializerImp< Ordinal,
148 Sacado::PCE::OrthogPoly<T,S>,
149 ValueTypeSerializer<Ordinal,T> >
150 {
151 typedef Sacado::PCE::OrthogPoly<T,S> PCEType;
152 typedef ValueTypeSerializer<Ordinal,T> ValueSerializer;
153 typedef Sacado::PCE::SerializerImp< Ordinal,PCEType,ValueSerializer> Base;
154 typedef typename Base::expansion_type expansion_type;
155 ValueTypeSerializer(const Teuchos::RCP<expansion_type>& expansion,
156 const Teuchos::RCP<const ValueSerializer>& vs) :
157 Base(expansion,vs) {}
158 };
159
160 }
161
162 #endif // SACADO_PCE_UNIVARIATEHERMITETRAITS_HPP