Sacado Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Sacado_ELRCacheFad_DFadTraits.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 // ***********************************************************************
9 //
10 // The forward-mode AD classes in Sacado are a derivative work of the
11 // expression template classes in the Fad package by Nicolas Di Cesare.
12 // The following banner is included in the original Fad source code:
13 //
14 // ************ DO NOT REMOVE THIS BANNER ****************
15 //
16 // Nicolas Di Cesare <Nicolas.Dicesare@ann.jussieu.fr>
17 // http://www.ann.jussieu.fr/~dicesare
18 //
19 // CEMRACS 98 : C++ courses,
20 // templates : new C++ techniques
21 // for scientific computing
22 //
23 //********************************************************
24 //
25 // NumericalTraits class to illustrate TRAITS
26 //
27 //********************************************************
28 // @HEADER
29 
30 #ifndef SACADO_ELRCACHEFAD_DFADTRAITS_HPP
31 #define SACADO_ELRCACHEFAD_DFADTRAITS_HPP
32 
33 #include "Sacado_Traits.hpp"
34 
35 // Forward declarations
36 namespace Sacado {
37  namespace ELRCacheFad {
38  template <typename T> class DFad;
39  }
40 }
41 
42 namespace Sacado {
43 
45  SACADO_FAD_PROMOTE_SPEC( ELRCacheFad, DFad )
46 
47 
48  template <typename ValueT>
49  struct ScalarType< ELRCacheFad::DFad<ValueT> > {
51  };
52 
54  template <typename ValueT>
55  struct ValueType< ELRCacheFad::DFad<ValueT> > {
56  typedef ValueT type;
57  };
58 
60  template <typename ValueT>
61  struct IsADType< ELRCacheFad::DFad<ValueT> > {
62  static const bool value = true;
63  };
64 
66  template <typename ValueT>
67  struct IsScalarType< ELRCacheFad::DFad<ValueT> > {
68  static const bool value = false;
69  };
70 
72  template <typename ValueT>
73  struct Value< ELRCacheFad::DFad<ValueT> > {
76  static const value_type& eval(const ELRCacheFad::DFad<ValueT>& x) {
77  return x.val(); }
78  };
79 
81  template <typename ValueT>
82  struct ScalarValue< ELRCacheFad::DFad<ValueT> > {
86  static const scalar_type& eval(const ELRCacheFad::DFad<ValueT>& x) {
87  return ScalarValue<value_type>::eval(x.val()); }
88  };
89 
91  template <typename ValueT>
92  struct StringName< ELRCacheFad::DFad<ValueT> > {
93  static std::string eval() {
94  return std::string("Sacado::ELRCacheFad::DFad< ") +
95  StringName<ValueT>::eval() + " >"; }
96  };
97 
99  template <typename ValueT>
100  struct IsEqual< ELRCacheFad::DFad<ValueT> > {
102  static bool eval(const ELRCacheFad::DFad<ValueT>& x,
103  const ELRCacheFad::DFad<ValueT>& y) {
104  return x.isEqualTo(y);
105  }
106  };
107 
109  template <typename ValueT>
110  struct IsStaticallySized< ELRCacheFad::DFad<ValueT> > {
111  static const bool value = false;
112  };
113 
115  template <typename ValueT>
116  struct IsStaticallySized< const ELRCacheFad::DFad<ValueT> > {
117  static const bool value = false;
118  };
119 
120 } // namespace Sacado
121 
122 //
123 // Define Teuchos traits classes
124 //
125 
126 // Promotion traits
127 #ifdef HAVE_SACADO_TEUCHOSNUMERICS
129 namespace Teuchos {
130  template <typename ValueT>
131  struct PromotionTraits< Sacado::ELRCacheFad::DFad<ValueT>,
132  Sacado::ELRCacheFad::DFad<ValueT> > {
135  promote;
136  };
137 
138  template <typename ValueT, typename R>
139  struct PromotionTraits< Sacado::ELRCacheFad::DFad<ValueT>, R > {
140  typedef typename Sacado::Promote< Sacado::ELRCacheFad::DFad<ValueT>, R >::type
141  promote;
142  };
143 
144  template <typename L, typename ValueT>
145  struct PromotionTraits< L, Sacado::ELRCacheFad::DFad<ValueT> > {
146  public:
148  promote;
149  };
150 }
151 #endif
152 
153 // Scalar traits
154 #ifdef HAVE_SACADO_TEUCHOSCORE
156 namespace Teuchos {
157  template <typename ValueT>
158  struct ScalarTraits< Sacado::ELRCacheFad::DFad<ValueT> > :
159  public Sacado::Fad::ScalarTraitsImp< Sacado::ELRCacheFad::DFad<ValueT> >
160  {};
161 }
162 #endif
163 
164 // Serialization traits
165 #ifdef HAVE_SACADO_TEUCHOSCOMM
167 namespace Teuchos {
168  template <typename Ordinal, typename ValueT>
169  struct SerializationTraits<Ordinal, Sacado::ELRCacheFad::DFad<ValueT> > :
170  public Sacado::Fad::SerializationTraitsImp< Ordinal,
171  Sacado::ELRCacheFad::DFad<ValueT> >
172  {};
173 
174  template <typename Ordinal, typename ValueT>
175  struct ValueTypeSerializer<Ordinal, Sacado::ELRCacheFad::DFad<ValueT> > :
176  public Sacado::Fad::SerializerImp< Ordinal,
177  Sacado::ELRCacheFad::DFad<ValueT>,
178  ValueTypeSerializer<Ordinal,ValueT> >
179  {
181  typedef ValueTypeSerializer<Ordinal,ValueT> ValueSerializer;
182  typedef Sacado::Fad::SerializerImp< Ordinal,FadType,ValueSerializer> Base;
183  ValueTypeSerializer(const Teuchos::RCP<const ValueSerializer>& vs,
184  Ordinal sz = 0) :
185  Base(vs, sz) {}
186  };
187 }
188 #endif
189 
190 // KokkosComm
191 #if defined(HAVE_SACADO_KOKKOS) && defined(HAVE_SACADO_TEUCHOSKOKKOSCOMM) && defined(HAVE_SACADO_VIEW_SPEC) && !defined(SACADO_DISABLE_FAD_VIEW_SPEC)
192 #include "KokkosExp_View_Fad.hpp"
193 #endif
194 
195 #endif // SACADO_ELRCACHEFAD_DFADTRAITS_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.
Base template specification for string names of types.
Base template specification for IsADType.
static SACADO_INLINE_FUNCTION const scalar_type & eval(const ELRCacheFad::DFad< ValueT > &x)
Sacado::Fad::DFad< double > FadType
Base template specification for Value.
#define SACADO_FAD_PROMOTE_SPEC(NS, FAD)
static const bool value
ScalarType< ELRCacheFad::DFad< ValueT > >::type scalar_type
GeneralFad< DynamicStorage< T > > DFad
Base template specification for testing equivalence.
static SACADO_INLINE_FUNCTION bool eval(const ELRCacheFad::DFad< ValueT > &x, const ELRCacheFad::DFad< ValueT > &y)
int Ordinal
static SACADO_INLINE_FUNCTION const value_type & eval(const ELRCacheFad::DFad< ValueT > &x)
ValueType< ELRCacheFad::DFad< ValueT > >::type value_type
static const bool value
Base template specification for IsScalarType.
#define SACADO_INLINE_FUNCTION
ValueType< ELRCacheFad::DFad< ValueT > >::type value_type
Base template specification for ValueType.
Base template specification for Promote.
const double y
Base template specification for testing whether type is statically sized.