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_DVFadTraits.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_FAD_DVFADTRAITS_HPP
31 #define SACADO_FAD_DVFADTRAITS_HPP
32 
33 #include "Sacado_ConfigDefs.h"
34 
35 #ifdef SACADO_NEW_FAD_DESIGN_IS_DEFAULT
36 
38 
39 #else
40 
41 #include "Sacado_Traits.hpp"
42 
43 // Forward declarations
44 namespace Sacado {
45  namespace Fad {
46  template <typename T> class DVFad;
47  }
48 }
49 
50 namespace Sacado {
51 
54 
55 
56  template <typename ValueT>
57  struct ScalarType< Fad::DVFad<ValueT> > {
59  };
60 
62  template <typename ValueT>
63  struct ValueType< Fad::DVFad<ValueT> > {
64  typedef ValueT type;
65  };
66 
68  template <typename ValueT>
69  struct IsADType< Fad::DVFad<ValueT> > {
70  static const bool value = true;
71  };
72 
74  template <typename ValueT>
75  struct IsScalarType< Fad::DVFad<ValueT> > {
76  static const bool value = false;
77  };
78 
80  template <typename ValueT>
81  struct IsSimdType< Fad::DVFad<ValueT> > {
82  static const bool value = IsSimdType<ValueT>::value;
83  };
84 
86  template <typename ValueT>
87  struct Value< Fad::DVFad<ValueT> > {
88  typedef typename ValueType< Fad::DVFad<ValueT> >::type value_type;
89  static const value_type& eval(const Fad::DVFad<ValueT>& x) {
90  return x.val(); }
91  };
92 
94  template <typename ValueT>
95  struct ScalarValue< Fad::DVFad<ValueT> > {
96  typedef typename ValueType< Fad::DVFad<ValueT> >::type value_type;
97  typedef typename ScalarType< Fad::DVFad<ValueT> >::type scalar_type;
98  static const scalar_type& eval(const Fad::DVFad<ValueT>& x) {
99  return ScalarValue<value_type>::eval(x.val()); }
100  };
101 
103  template <typename ValueT>
104  struct StringName< Fad::DVFad<ValueT> > {
105  static std::string eval() {
106  return std::string("Sacado::Fad::DVFad< ") +
107  StringName<ValueT>::eval() + " >"; }
108  };
109 
111  template <typename ValueT>
112  struct IsEqual< Fad::DVFad<ValueT> > {
113  static bool eval(const Fad::DVFad<ValueT>& x, const Fad::DVFad<ValueT>& y) {
114  return x.isEqualTo(y);
115  }
116  };
117 
119  template <typename ValueT>
120  struct IsStaticallySized< Fad::DVFad<ValueT> > {
121  static const bool value = false;
122  };
123 
124  template <typename T>
125  struct IsFad< Fad::DVFad<T> > {
126  static const bool value = true;
127  };
128 
129 } // namespace Sacado
130 
131 //
132 // Define Teuchos traits classes
133 //
134 
135 // Promotion traits
136 #ifdef HAVE_SACADO_TEUCHOSNUMERICS
138 namespace Teuchos {
139  template <typename ValueT>
140  struct PromotionTraits< Sacado::Fad::DVFad<ValueT>,
141  Sacado::Fad::DVFad<ValueT> > {
144  promote;
145  };
146 
147  template <typename ValueT, typename R>
148  struct PromotionTraits< Sacado::Fad::DVFad<ValueT>, R > {
149  typedef typename Sacado::Promote< Sacado::Fad::DVFad<ValueT>, R >::type
150  promote;
151  };
152 
153  template <typename L, typename ValueT>
154  struct PromotionTraits< L, Sacado::Fad::DVFad<ValueT> > {
155  public:
156  typedef typename Sacado::Promote< L, Sacado::Fad::DVFad<ValueT> >::type
157  promote;
158  };
159 }
160 #endif
161 
162 // Scalar traits
163 #ifdef HAVE_SACADO_TEUCHOSCORE
165 namespace Teuchos {
166  template <typename ValueT>
167  struct ScalarTraits< Sacado::Fad::DVFad<ValueT> > :
168  public Sacado::Fad::ScalarTraitsImp< Sacado::Fad::DVFad<ValueT> >
169  {};
170 }
171 #endif
172 
173 #endif // SACADO_NEW_FAD_DESIGN_IS_DEFAULT
174 
175 #endif // SACADO_FAD_DVFADTRAITS_HPP
static SACADO_INLINE_FUNCTION const T & eval(const T &x)
ValueType< Fad::DVFad< ValueT > >::type value_type
ScalarType< Fad::DVFad< ValueT > >::type scalar_type
static std::string eval()
static bool eval(const Fad::DVFad< ValueT > &x, const Fad::DVFad< ValueT > &y)
Base template specification for ScalarValue.
Base template specification for ScalarType.
Base template specification for whether a type is a Fad type.
Base template specification for string names of types.
Base template specification for IsADType.
Base template specification for Value.
static const scalar_type & eval(const Fad::DVFad< ValueT > &x)
Base template specification for IsSimdType.
#define SACADO_FAD_PROMOTE_SPEC(NS, FAD)
static const bool value
Base template specification for testing equivalence.
GeneralFad< VectorDynamicStorage< T > > DVFad
static const bool value
Forward-mode AD class using dynamic memory allocation and expression templates.
ValueType< Fad::DVFad< ValueT > >::type value_type
ScalarType< ValueT >::type ScalarT
Typename of scalar&#39;s (which may be different from ValueT)
static const bool value
static const value_type & eval(const Fad::DVFad< ValueT > &x)
Base template specification for IsScalarType.
static const bool value
Base template specification for ValueType.
Base template specification for Promote.
const double y
Base template specification for testing whether type is statically sized.