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_SLFadTraits.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_SLFADTRAITS_HPP
11 #define SACADO_FAD_SLFADTRAITS_HPP
12 
13 #include "Sacado_ConfigDefs.h"
14 
15 #ifdef SACADO_NEW_FAD_DESIGN_IS_DEFAULT
16 
18 
19 #else
20 
21 #include "Sacado_Traits.hpp"
22 #include <sstream>
23 
24 // Forward declarations
25 namespace Sacado {
26  namespace Fad {
27  template <typename T, int Num> class SLFad;
28  }
29 }
30 
31 namespace Sacado {
32 
35 
36 
37  template <typename ValueT, int Num>
38  struct ScalarType< Fad::SLFad<ValueT,Num> > {
40  };
41 
43  template <typename ValueT, int Num>
44  struct ValueType< Fad::SLFad<ValueT,Num> > {
45  typedef ValueT type;
46  };
47 
49  template <typename ValueT, int Num>
50  struct IsADType< Fad::SLFad<ValueT,Num> > {
51  static const bool value = true;
52  };
53 
55  template <typename ValueT, int Num>
56  struct IsScalarType< Fad::SLFad<ValueT,Num> > {
57  static const bool value = false;
58  };
59 
61  template <typename ValueT, int Num>
62  struct IsSimdType< Fad::SLFad<ValueT,Num> > {
63  static const bool value = IsSimdType<ValueT>::value;
64  };
65 
67  template <typename ValueT, int Num>
68  struct Value< Fad::SLFad<ValueT,Num> > {
71  static const value_type& eval(const Fad::SLFad<ValueT,Num>& x) {
72  return x.val(); }
73  };
74 
76  template <typename ValueT, int Num>
77  struct ScalarValue< Fad::SLFad<ValueT,Num> > {
81  static const scalar_type& eval(const Fad::SLFad<ValueT,Num>& x) {
82  return ScalarValue<value_type>::eval(x.val()); }
83  };
84 
86  template <typename ValueT, int Num>
87  struct StringName< Fad::SLFad<ValueT,Num> > {
88  static std::string eval() {
89  std::stringstream ss;
90  ss << "Sacado::Fad::SLFad< "
91  << StringName<ValueT>::eval() << ", " << Num << " >";
92  return ss.str();
93  }
94  };
95 
97  template <typename ValueT, int Num>
98  struct IsEqual< Fad::SLFad<ValueT,Num> > {
100  static bool eval(const Fad::SLFad<ValueT,Num>& x,
101  const Fad::SLFad<ValueT,Num>& y) {
102  return x.isEqualTo(y);
103  }
104  };
105 
107  template <typename ValueT, int Num>
108  struct IsStaticallySized< Fad::SLFad<ValueT,Num> > {
109  static const bool value = false;
110  };
111 
113  template <typename ValueT, int Num>
114  struct IsStaticallySized< const Fad::SLFad<ValueT,Num> > {
115  static const bool value = false;
116  };
117 
118 } // namespace Sacado
119 
120 //
121 // Define Teuchos traits classes
122 //
123 
124 // Promotion traits
125 #ifdef HAVE_SACADO_TEUCHOSNUMERICS
127 namespace Teuchos {
128  template <typename ValueT, int Num>
129  struct PromotionTraits< Sacado::Fad::SLFad<ValueT,Num>,
130  Sacado::Fad::SLFad<ValueT,Num> > {
133  promote;
134  };
135 
136  template <typename ValueT, int Num, typename R>
137  struct PromotionTraits< Sacado::Fad::SLFad<ValueT,Num>, R > {
138  typedef typename Sacado::Promote< Sacado::Fad::SLFad<ValueT,Num>, R >::type
139  promote;
140  };
141 
142  template <typename L, typename ValueT, int Num>
143  struct PromotionTraits< L, Sacado::Fad::SLFad<ValueT,Num> > {
144  public:
146  promote;
147  };
148 }
149 #endif
150 
151 // Scalar traits
152 #ifdef HAVE_SACADO_TEUCHOSCORE
154 namespace Teuchos {
155  template <typename ValueT, int Num>
156  struct ScalarTraits< Sacado::Fad::SLFad<ValueT,Num> > :
157  public Sacado::Fad::ScalarTraitsImp< Sacado::Fad::SLFad<ValueT,Num> >
158  {};
159 }
160 #endif
161 
162 // Serialization traits
163 #ifdef HAVE_SACADO_TEUCHOSCOMM
165 namespace Teuchos {
166  template <typename Ordinal, typename ValueT, int Num>
167  struct SerializationTraits<Ordinal, Sacado::Fad::SLFad<ValueT,Num> > :
168  public Sacado::Fad::SerializationTraitsImp< Ordinal,
169  Sacado::Fad::SLFad<ValueT,Num> >
170  {};
171 
172  template <typename Ordinal, typename ValueT, int Num>
173  struct ValueTypeSerializer<Ordinal, Sacado::Fad::SLFad<ValueT,Num> > :
174  public Sacado::Fad::SerializerImp< Ordinal,
175  Sacado::Fad::SLFad<ValueT,Num>,
176  ValueTypeSerializer<Ordinal,ValueT> >
177  {
179  typedef ValueTypeSerializer<Ordinal,ValueT> ValueSerializer;
180  typedef Sacado::Fad::SerializerImp< Ordinal,FadType,ValueSerializer> Base;
181  ValueTypeSerializer(const Teuchos::RCP<const ValueSerializer>& vs,
182  Ordinal sz = 0) :
183  Base(vs, sz) {}
184  };
185 }
186 #endif
187 
188 // KokkosComm
189 #if defined(HAVE_SACADO_KOKKOS) && defined(HAVE_SACADO_TEUCHOSKOKKOSCOMM) && defined(HAVE_SACADO_VIEW_SPEC) && !defined(SACADO_DISABLE_FAD_VIEW_SPEC)
190 #include "KokkosExp_View_Fad.hpp"
191 #endif
192 
193 #endif // SACADO_NEW_FAD_DESIGN_IS_DEFAULT
194 
195 #endif // SACADO_FAD_SFADTRAITS_HPP
static SACADO_INLINE_FUNCTION const T & eval(const T &x)
static std::string eval()
static SACADO_INLINE_FUNCTION const scalar_type & eval(const Fad::SLFad< ValueT, Num > &x)
Base template specification for ScalarValue.
Base template specification for ScalarType.
Base template specification for string names of types.
GeneralFad< StaticStorage< T, Num > > SLFad
Base template specification for IsADType.
Sacado::Fad::DFad< double > FadType
Base template specification for Value.
Base template specification for IsSimdType.
static SACADO_INLINE_FUNCTION const value_type & eval(const Fad::SLFad< ValueT, Num > &x)
static const bool value
Base template specification for testing equivalence.
ScalarType< Fad::SLFad< ValueT, Num > >::type scalar_type
ValueType< Fad::SLFad< ValueT, Num > >::type value_type
static const bool value
int Ordinal
ValueType< Fad::SLFad< ValueT, Num > >::type value_type
static const bool value
Base template specification for IsScalarType.
#define SACADO_SFAD_PROMOTE_SPEC(NS, FAD)
#define SACADO_INLINE_FUNCTION
static SACADO_INLINE_FUNCTION bool eval(const Fad::SLFad< ValueT, Num > &x, const Fad::SLFad< ValueT, Num > &y)
Base template specification for ValueType.
Base template specification for Promote.
const double y
Base template specification for testing whether type is statically sized.