Sacado Package Browser (Single Doxygen Collection)  Version of the Day
Sacado_Fad_SLFadTraits.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 // @HEADER
29 
30 #ifndef SACADO_FAD_SLFADTRAITS_HPP
31 #define SACADO_FAD_SLFADTRAITS_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 #include <sstream>
43 
44 // Forward declarations
45 namespace Sacado {
46  namespace Fad {
47  template <typename T, int Num> class SLFad;
48  }
49 }
50 
51 namespace Sacado {
52 
55 
56 
57  template <typename ValueT, int Num>
58  struct ScalarType< Fad::SLFad<ValueT,Num> > {
60  };
61 
63  template <typename ValueT, int Num>
64  struct ValueType< Fad::SLFad<ValueT,Num> > {
65  typedef ValueT type;
66  };
67 
69  template <typename ValueT, int Num>
70  struct IsADType< Fad::SLFad<ValueT,Num> > {
71  static const bool value = true;
72  };
73 
75  template <typename ValueT, int Num>
76  struct IsScalarType< Fad::SLFad<ValueT,Num> > {
77  static const bool value = false;
78  };
79 
81  template <typename ValueT, int Num>
82  struct Value< Fad::SLFad<ValueT,Num> > {
85  static const value_type& eval(const Fad::SLFad<ValueT,Num>& x) {
86  return x.val(); }
87  };
88 
90  template <typename ValueT, int Num>
91  struct ScalarValue< Fad::SLFad<ValueT,Num> > {
95  static const scalar_type& eval(const Fad::SLFad<ValueT,Num>& x) {
96  return ScalarValue<value_type>::eval(x.val()); }
97  };
98 
100  template <typename ValueT, int Num>
101  struct StringName< Fad::SLFad<ValueT,Num> > {
102  static std::string eval() {
103  std::stringstream ss;
104  ss << "Sacado::Fad::SLFad< "
105  << StringName<ValueT>::eval() << ", " << Num << " >";
106  return ss.str();
107  }
108  };
109 
111  template <typename ValueT, int Num>
112  struct IsEqual< Fad::SLFad<ValueT,Num> > {
114  static bool eval(const Fad::SLFad<ValueT,Num>& x,
115  const Fad::SLFad<ValueT,Num>& y) {
116  return x.isEqualTo(y);
117  }
118  };
119 
121  template <typename ValueT, int Num>
122  struct IsStaticallySized< Fad::SLFad<ValueT,Num> > {
123  static const bool value = false;
124  };
125 
127  template <typename ValueT, int Num>
128  struct IsStaticallySized< const Fad::SLFad<ValueT,Num> > {
129  static const bool value = false;
130  };
131 
132 } // namespace Sacado
133 
134 // Define Teuchos traits classes
135 #ifdef HAVE_SACADO_TEUCHOS
136 #include "Teuchos_PromotionTraits.hpp"
137 #include "Teuchos_ScalarTraits.hpp"
139 
140 namespace Teuchos {
141 
143  template <typename ValueT, int Num>
144  struct PromotionTraits< Sacado::Fad::SLFad<ValueT,Num>,
145  Sacado::Fad::SLFad<ValueT,Num> > {
148  promote;
149  };
150 
152  template <typename ValueT, int Num, typename R>
153  struct PromotionTraits< Sacado::Fad::SLFad<ValueT,Num>, R > {
154  typedef typename Sacado::Promote< Sacado::Fad::SLFad<ValueT,Num>, R >::type
155  promote;
156  };
157 
159  template <typename L, typename ValueT, int Num>
160  struct PromotionTraits< L, Sacado::Fad::SLFad<ValueT,Num> > {
161  public:
163  promote;
164  };
165 
167  template <typename ValueT, int Num>
168  struct ScalarTraits< Sacado::Fad::SLFad<ValueT,Num> > :
169  public Sacado::Fad::ScalarTraitsImp< Sacado::Fad::SLFad<ValueT,Num> >
170  {};
171 
173  template <typename Ordinal, typename ValueT, int Num>
174  struct SerializationTraits<Ordinal, Sacado::Fad::SLFad<ValueT,Num> > :
175  public Sacado::Fad::SerializationTraitsImp< Ordinal,
176  Sacado::Fad::SLFad<ValueT,Num> >
177  {};
178 
180  template <typename Ordinal, typename ValueT, int Num>
181  struct ValueTypeSerializer<Ordinal, Sacado::Fad::SLFad<ValueT,Num> > :
182  public Sacado::Fad::SerializerImp< Ordinal,
183  Sacado::Fad::SLFad<ValueT,Num>,
184  ValueTypeSerializer<Ordinal,ValueT> >
185  {
187  typedef ValueTypeSerializer<Ordinal,ValueT> ValueSerializer;
188  typedef Sacado::Fad::SerializerImp< Ordinal,FadType,ValueSerializer> Base;
189  ValueTypeSerializer(const Teuchos::RCP<const ValueSerializer>& vs,
190  Ordinal sz = 0) :
191  Base(vs, sz) {}
192  };
193 }
194 #endif // HAVE_SACADO_TEUCHOS
195 
196 #endif // SACADO_NEW_FAD_DESIGN_IS_DEFAULT
197 
198 #endif // SACADO_FAD_SFADTRAITS_HPP
static std::string eval()
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
static KOKKOS_INLINE_FUNCTION const value_type & eval(const Fad::SLFad< ValueT, Num > &x)
Base template specification for Value.
static KOKKOS_INLINE_FUNCTION const scalar_type & eval(const Fad::SLFad< ValueT, Num > &x)
#define KOKKOS_INLINE_FUNCTION
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
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)
static KOKKOS_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.
static KOKKOS_INLINE_FUNCTION const T & eval(const T &x)
Base template specification for testing whether type is statically sized.