Sacado Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Sacado_Fad_Exp_GeneralFadTraits.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Sacado Package
4 //
5 // Copyright 2006 NTESS and the Sacado contributors.
6 // SPDX-License-Identifier: LGPL-2.1-or-later
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef SACADO_FAD_EXP_GENERALFADTRAITS_HPP
11 #define SACADO_FAD_EXP_GENERALFADTRAITS_HPP
12 
13 #include "Sacado_Traits.hpp"
14 
15 // Forward declarations
16 namespace Sacado {
17  namespace Fad {
18  namespace Exp {
19  template <typename S> class GeneralFad;
20  }
21  }
22 }
23 
24 namespace Sacado {
25 
27  SACADO_FAD_PROMOTE_SPEC( Fad::Exp, GeneralFad )
28 
29 
30  template <typename Storage>
31  struct ScalarType< Fad::Exp::GeneralFad<Storage> > {
33  };
34 
36  template <typename Storage>
37  struct ValueType< Fad::Exp::GeneralFad<Storage> > {
39  };
40 
42  template <typename Storage>
43  struct IsADType< Fad::Exp::GeneralFad<Storage> > {
44  static const bool value = true;
45  };
46 
48  template <typename Storage>
49  struct IsScalarType< Fad::Exp::GeneralFad<Storage> > {
50  static const bool value = false;
51  };
52 
54  template <typename Storage>
55  struct IsSimdType< Fad::Exp::GeneralFad<Storage> > {
56  static const bool value =
58  };
59 
61  template <typename Storage>
62  struct Value< Fad::Exp::GeneralFad<Storage> > {
66  return x.val(); }
67  };
68 
70  template <typename Storage>
71  struct ScalarValue< Fad::Exp::GeneralFad<Storage> > {
76  return ScalarValue<value_type>::eval(x.val()); }
77  };
78 
80  template <typename Storage>
81  struct StringName< Fad::Exp::GeneralFad<Storage> > {
82  static std::string eval() {
83  return std::string("Sacado::Fad::Exp::GeneralFad< ") +
85  };
86 
88  template <typename Storage>
89  struct IsEqual< Fad::Exp::GeneralFad<Storage> > {
91  static bool eval(const Fad::Exp::GeneralFad<Storage>& x,
93  return x.isEqualTo(y);
94  }
95  };
96 
98  template <typename Storage>
99  struct IsStaticallySized< Fad::Exp::GeneralFad<Storage> > {
100  static const bool value = Storage::is_statically_sized;
101  };
102 
104  template <typename Storage>
105  struct IsStaticallySized< const Fad::Exp::GeneralFad<Storage> > {
106  static const bool value = Storage::is_statically_sized;
107  };
108 
110  template <typename Storage>
111  struct StaticSize< Fad::Exp::GeneralFad<Storage> > {
112  static const unsigned value = Storage::static_size;
113  };
114 
116  template <typename Storage>
117  struct StaticSize< const Fad::Exp::GeneralFad<Storage> > {
118  static const unsigned value = Storage::static_size;
119  };
120 
121 } // namespace Sacado
122 
123 //
124 // Define Teuchos traits classes
125 //
126 
127 // Promotion traits
128 #ifdef HAVE_SACADO_TEUCHOSNUMERICS
130 namespace Teuchos {
131  template <typename Storage>
132  struct PromotionTraits< Sacado::Fad::Exp::GeneralFad<Storage>,
133  Sacado::Fad::Exp::GeneralFad<Storage> > {
136  promote;
137  };
138 
140  template <typename Storage, typename R>
141  struct PromotionTraits< Sacado::Fad::Exp::GeneralFad<Storage>, R > {
143  R >::type
144  promote;
145  };
146 
148  template <typename L, typename Storage>
149  struct PromotionTraits< L, Sacado::Fad::Exp::GeneralFad<Storage> > {
150  public:
151  typedef typename Sacado::Promote< L,
153  promote;
154  };
155 }
156 #endif
157 
158 // Scalar traits
159 #ifdef HAVE_SACADO_TEUCHOSCORE
161 namespace Teuchos {
162  template <typename Storage>
163  struct ScalarTraits< Sacado::Fad::Exp::GeneralFad<Storage> > :
164  public Sacado::Fad::ScalarTraitsImp< Sacado::Fad::Exp::GeneralFad<Storage> >
165  {};
166 }
167 #endif
168 
169 // Serialization traits
170 #ifdef HAVE_SACADO_TEUCHOSCOMM
172 namespace Teuchos {
173  template <typename Ordinal, typename Storage>
174  struct SerializationTraits<Ordinal, Sacado::Fad::Exp::GeneralFad<Storage> > :
175  public Sacado::Fad::SerializationTraitsImp< Ordinal,
176  Sacado::Fad::Exp::GeneralFad<Storage> >
177  {};
178 
179  template <typename Ordinal, typename Storage>
180  struct ValueTypeSerializer<Ordinal, Sacado::Fad::Exp::GeneralFad<Storage> > :
181  public Sacado::Fad::SerializerImp< Ordinal,
182  Sacado::Fad::Exp::GeneralFad<Storage>,
183  ValueTypeSerializer<Ordinal,typename Storage::value_type> >
184  {
186  typedef ValueTypeSerializer<Ordinal,typename Storage::value_type> ValueSerializer;
187  typedef Sacado::Fad::SerializerImp< Ordinal,FadType,ValueSerializer> Base;
188  ValueTypeSerializer(const Teuchos::RCP<const ValueSerializer>& vs,
189  Ordinal sz = 0) :
190  Base(vs, sz) {}
191  };
192 }
193 #endif
194 
195 // KokkosComm
196 #if defined(HAVE_SACADO_KOKKOS) && defined(HAVE_SACADO_TEUCHOSKOKKOSCOMM) && defined(HAVE_SACADO_VIEW_SPEC) && !defined(SACADO_DISABLE_FAD_VIEW_SPEC)
197 #include "KokkosExp_View_Fad.hpp"
198 #endif
199 
200 #endif // SACADO_FAD_EXP_GENERALFADTRAITS_HPP
static SACADO_INLINE_FUNCTION const T & eval(const T &x)
static std::string eval()
Base template specification for ScalarValue.
Base template specification for ScalarType.
static SACADO_INLINE_FUNCTION bool eval(const Fad::Exp::GeneralFad< Storage > &x, const Fad::Exp::GeneralFad< Storage > &y)
Base template specification for string names of types.
Base template specification for IsADType.
Sacado::Fad::DFad< double > FadType
ScalarType< Fad::Exp::GeneralFad< Storage > >::type scalar_type
Base template specification for static size.
Base template specification for Value.
Base template specification for IsSimdType.
#define SACADO_FAD_PROMOTE_SPEC(NS, FAD)
ValueType< Fad::Exp::GeneralFad< Storage > >::type value_type
static const bool value
ValueType< Fad::Exp::GeneralFad< Storage > >::type value_type
Base template specification for testing equivalence.
Forward-mode AD class templated on the storage for the derivative array.
static SACADO_INLINE_FUNCTION const value_type & eval(const Fad::Exp::GeneralFad< Storage > &x)
static const bool value
ScalarType< value_type >::type scalar_type
Typename of scalar&#39;s (which may be different from T)
int Ordinal
static const bool value
Base template specification for IsScalarType.
#define SACADO_INLINE_FUNCTION
static const unsigned value
Base template specification for ValueType.
Base template specification for Promote.
static SACADO_INLINE_FUNCTION const scalar_type & eval(const Fad::Exp::GeneralFad< Storage > &x)
const double y
Base template specification for testing whether type is statically sized.