Sacado Package Browser (Single Doxygen Collection)  Version of the Day
Sacado_Fad_Exp_GeneralFadTraits.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Sacado Package
5 // Copyright (2006) Sandia Corporation
6 //
7 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
8 // the U.S. Government retains certain rights in this software.
9 //
10 // This library is free software; you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as
12 // published by the Free Software Foundation; either version 2.1 of the
13 // License, or (at your option) any later version.
14 //
15 // This library is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public
21 // License along with this library; if not, write to the Free Software
22 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
23 // USA
24 // Questions? Contact David M. Gay (dmgay@sandia.gov) or Eric T. Phipps
25 // (etphipp@sandia.gov).
26 //
27 // ***********************************************************************
28 //
29 // @HEADER
30 
31 #ifndef SACADO_FAD_EXP_GENERALFADTRAITS_HPP
32 #define SACADO_FAD_EXP_GENERALFADTRAITS_HPP
33 
34 #include "Sacado_Traits.hpp"
35 
36 // Forward declarations
37 namespace Sacado {
38  namespace Fad {
39  namespace Exp {
40  template <typename S> class GeneralFad;
41  }
42  }
43 }
44 
45 namespace Sacado {
46 
48  SACADO_FAD_PROMOTE_SPEC( Fad::Exp, GeneralFad )
49 
50 
51  template <typename Storage>
52  struct ScalarType< Fad::Exp::GeneralFad<Storage> > {
54  };
55 
57  template <typename Storage>
58  struct ValueType< Fad::Exp::GeneralFad<Storage> > {
60  };
61 
63  template <typename Storage>
64  struct IsADType< Fad::Exp::GeneralFad<Storage> > {
65  static const bool value = true;
66  };
67 
69  template <typename Storage>
70  struct IsScalarType< Fad::Exp::GeneralFad<Storage> > {
71  static const bool value = false;
72  };
73 
75  template <typename Storage>
76  struct IsSimdType< Fad::Exp::GeneralFad<Storage> > {
77  static const bool value =
79  };
80 
82  template <typename Storage>
83  struct Value< Fad::Exp::GeneralFad<Storage> > {
86  static const value_type& eval(const Fad::Exp::GeneralFad<Storage>& x) {
87  return x.val(); }
88  };
89 
91  template <typename Storage>
92  struct ScalarValue< Fad::Exp::GeneralFad<Storage> > {
97  return ScalarValue<value_type>::eval(x.val()); }
98  };
99 
101  template <typename Storage>
102  struct StringName< Fad::Exp::GeneralFad<Storage> > {
103  static std::string eval() {
104  return std::string("Sacado::Fad::Exp::GeneralFad< ") +
106  };
107 
109  template <typename Storage>
110  struct IsEqual< Fad::Exp::GeneralFad<Storage> > {
112  static bool eval(const Fad::Exp::GeneralFad<Storage>& x,
114  return x.isEqualTo(y);
115  }
116  };
117 
119  template <typename Storage>
120  struct IsStaticallySized< Fad::Exp::GeneralFad<Storage> > {
121  static const bool value = Storage::is_statically_sized;
122  };
123 
125  template <typename Storage>
126  struct IsStaticallySized< const Fad::Exp::GeneralFad<Storage> > {
127  static const bool value = Storage::is_statically_sized;
128  };
129 
131  template <typename Storage>
132  struct StaticSize< Fad::Exp::GeneralFad<Storage> > {
133  static const unsigned value = Storage::static_size;
134  };
135 
137  template <typename Storage>
138  struct StaticSize< const Fad::Exp::GeneralFad<Storage> > {
139  static const unsigned value = Storage::static_size;
140  };
141 
142 } // namespace Sacado
143 
144 //
145 // Define Teuchos traits classes
146 //
147 
148 // Promotion traits
149 #ifdef HAVE_SACADO_TEUCHOSNUMERICS
150 #include "Teuchos_PromotionTraits.hpp"
151 namespace Teuchos {
152  template <typename Storage>
153  struct PromotionTraits< Sacado::Fad::Exp::GeneralFad<Storage>,
154  Sacado::Fad::Exp::GeneralFad<Storage> > {
157  promote;
158  };
159 
161  template <typename Storage, typename R>
162  struct PromotionTraits< Sacado::Fad::Exp::GeneralFad<Storage>, R > {
164  R >::type
165  promote;
166  };
167 
169  template <typename L, typename Storage>
170  struct PromotionTraits< L, Sacado::Fad::Exp::GeneralFad<Storage> > {
171  public:
172  typedef typename Sacado::Promote< L,
174  promote;
175  };
176 }
177 #endif
178 
179 // Scalar traits
180 #ifdef HAVE_SACADO_TEUCHOSCORE
182 namespace Teuchos {
183  template <typename Storage>
184  struct ScalarTraits< Sacado::Fad::Exp::GeneralFad<Storage> > :
185  public Sacado::Fad::ScalarTraitsImp< Sacado::Fad::Exp::GeneralFad<Storage> >
186  {};
187 }
188 #endif
189 
190 // Serialization traits
191 #ifdef HAVE_SACADO_TEUCHOSCOMM
193 namespace Teuchos {
194  template <typename Ordinal, typename Storage>
195  struct SerializationTraits<Ordinal, Sacado::Fad::Exp::GeneralFad<Storage> > :
196  public Sacado::Fad::SerializationTraitsImp< Ordinal,
197  Sacado::Fad::Exp::GeneralFad<Storage> >
198  {};
199 
200  template <typename Ordinal, typename Storage>
201  struct ValueTypeSerializer<Ordinal, Sacado::Fad::Exp::GeneralFad<Storage> > :
202  public Sacado::Fad::SerializerImp< Ordinal,
203  Sacado::Fad::Exp::GeneralFad<Storage>,
204  ValueTypeSerializer<Ordinal,typename Storage::value_type> >
205  {
207  typedef ValueTypeSerializer<Ordinal,typename Storage::value_type> ValueSerializer;
208  typedef Sacado::Fad::SerializerImp< Ordinal,FadType,ValueSerializer> Base;
209  ValueTypeSerializer(const Teuchos::RCP<const ValueSerializer>& vs,
210  Ordinal sz = 0) :
211  Base(vs, sz) {}
212  };
213 }
214 #endif
215 
216 // KokkosComm
217 #if defined(HAVE_SACADO_KOKKOSCORE) && defined(HAVE_SACADO_TEUCHOSKOKKOSCOMM) && defined(HAVE_SACADO_VIEW_SPEC) && !defined(SACADO_DISABLE_FAD_VIEW_SPEC)
218 #include "KokkosExp_View_Fad.hpp"
219 #endif
220 
221 #endif // SACADO_FAD_EXP_GENERALFADTRAITS_HPP
int Ordinal
#define KOKKOS_INLINE_FUNCTION
#define SACADO_FAD_PROMOTE_SPEC(NS, FAD)
Sacado::Fad::DFad< double > FadType
Forward-mode AD class templated on the storage for the derivative array.
ScalarType< value_type >::type scalar_type
Typename of scalar's (which may be different from T)
Base template specification for IsADType.
static const bool value
static KOKKOS_INLINE_FUNCTION bool eval(const Fad::Exp::GeneralFad< Storage > &x, const Fad::Exp::GeneralFad< Storage > &y)
Base template specification for testing equivalence.
Base template specification for IsScalarType.
static const bool value
Base template specification for IsSimdType.
static const bool value
Base template specification for testing whether type is statically sized.
Base template specification for Promote.
Base template specification for ScalarType.
ValueType< Fad::Exp::GeneralFad< Storage > >::type value_type
static KOKKOS_INLINE_FUNCTION const scalar_type & eval(const Fad::Exp::GeneralFad< Storage > &x)
ScalarType< Fad::Exp::GeneralFad< Storage > >::type scalar_type
Base template specification for ScalarValue.
static KOKKOS_INLINE_FUNCTION const T & eval(const T &x)
Base template specification for static size.
static const unsigned value
Base template specification for string names of types.
static std::string eval()
Base template specification for ValueType.
static KOKKOS_INLINE_FUNCTION const value_type & eval(const Fad::Exp::GeneralFad< Storage > &x)
ValueType< Fad::Exp::GeneralFad< Storage > >::type value_type
Base template specification for Value.