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 Value< Fad::Exp::GeneralFad<Storage> > {
79  static const value_type& eval(const Fad::Exp::GeneralFad<Storage>& x) {
80  return x.val(); }
81  };
82 
84  template <typename Storage>
85  struct ScalarValue< Fad::Exp::GeneralFad<Storage> > {
90  return ScalarValue<value_type>::eval(x.val()); }
91  };
92 
94  template <typename Storage>
95  struct StringName< Fad::Exp::GeneralFad<Storage> > {
96  static std::string eval() {
97  return std::string("Sacado::Fad::Exp::GeneralFad< ") +
99  };
100 
102  template <typename Storage>
103  struct IsEqual< Fad::Exp::GeneralFad<Storage> > {
105  static bool eval(const Fad::Exp::GeneralFad<Storage>& x,
107  return x.isEqualTo(y);
108  }
109  };
110 
112  template <typename Storage>
113  struct IsStaticallySized< Fad::Exp::GeneralFad<Storage> > {
114  static const bool value = Storage::is_statically_sized;
115  };
116 
118  template <typename Storage>
119  struct IsStaticallySized< const Fad::Exp::GeneralFad<Storage> > {
120  static const bool value = Storage::is_statically_sized;
121  };
122 
124  template <typename Storage>
125  struct StaticSize< Fad::Exp::GeneralFad<Storage> > {
126  static const unsigned value = Storage::static_size;
127  };
128 
130  template <typename Storage>
131  struct StaticSize< const Fad::Exp::GeneralFad<Storage> > {
132  static const unsigned value = Storage::static_size;
133  };
134 
135 } // namespace Sacado
136 
137 // Define Teuchos traits classes
138 #ifdef HAVE_SACADO_TEUCHOS
140 #include "Teuchos_ScalarTraits.hpp"
143 
144 namespace Teuchos {
145 
147  template <typename Storage>
148  struct PromotionTraits< Sacado::Fad::Exp::GeneralFad<Storage>,
149  Sacado::Fad::Exp::GeneralFad<Storage> > {
152  promote;
153  };
154 
156  template <typename Storage, typename R>
157  struct PromotionTraits< Sacado::Fad::Exp::GeneralFad<Storage>, R > {
159  R >::type
160  promote;
161  };
162 
164  template <typename L, typename Storage>
165  struct PromotionTraits< L, Sacado::Fad::Exp::GeneralFad<Storage> > {
166  public:
167  typedef typename Sacado::Promote< L,
169  promote;
170  };
171 
173  template <typename Storage>
174  struct ScalarTraits< Sacado::Fad::Exp::GeneralFad<Storage> > :
175  public Sacado::Fad::ScalarTraitsImp< Sacado::Fad::Exp::GeneralFad<Storage> >
176  {};
177 
179  template <typename Ordinal, typename Storage>
180  struct SerializationTraits<Ordinal, Sacado::Fad::Exp::GeneralFad<Storage> > :
181  public Sacado::Fad::SerializationTraitsImp< Ordinal,
182  Sacado::Fad::Exp::GeneralFad<Storage> >
183  {};
184 
186  template <typename Ordinal, typename Storage>
187  struct ValueTypeSerializer<Ordinal, Sacado::Fad::Exp::GeneralFad<Storage> > :
188  public Sacado::Fad::SerializerImp< Ordinal,
189  Sacado::Fad::Exp::GeneralFad<Storage>,
190  ValueTypeSerializer<Ordinal,typename Storage::value_type> >
191  {
193  typedef ValueTypeSerializer<Ordinal,typename Storage::value_type> ValueSerializer;
194  typedef Sacado::Fad::SerializerImp< Ordinal,FadType,ValueSerializer> Base;
195  ValueTypeSerializer(const Teuchos::RCP<const ValueSerializer>& vs,
196  Ordinal sz = 0) :
197  Base(vs, sz) {}
198  };
199 }
200 #endif // HAVE_SACADO_TEUCHOS
201 
202 #endif // SACADO_FAD_EXP_GENERALFADTRAITS_HPP
static std::string eval()
static KOKKOS_INLINE_FUNCTION bool eval(const Fad::Exp::GeneralFad< Storage > &x, const Fad::Exp::GeneralFad< Storage > &y)
Base template specification for ScalarValue.
Base template specification for ScalarType.
Base template specification for string names of types.
static KOKKOS_INLINE_FUNCTION const value_type & eval(const Fad::Exp::GeneralFad< Storage > &x)
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.
#define SACADO_FAD_PROMOTE_SPEC(NS, FAD)
#define KOKKOS_INLINE_FUNCTION
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.
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.
static const unsigned value
static KOKKOS_INLINE_FUNCTION const scalar_type & eval(const Fad::Exp::GeneralFad< Storage > &x)
Base template specification for ValueType.
Base template specification for Promote.
static KOKKOS_INLINE_FUNCTION const T & eval(const T &x)
Base template specification for testing whether type is statically sized.