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
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
Sacado::StringName::eval
static std::string eval()
Definition: Sacado_Traits.hpp:377
KOKKOS_INLINE_FUNCTION
#define KOKKOS_INLINE_FUNCTION
Definition: Sacado_ConfigDefs.h:90
Sacado::ScalarType
Base template specification for ScalarType.
Definition: Sacado_Traits.hpp:303
Sacado::ValueType
Base template specification for ValueType.
Definition: Sacado_Traits.hpp:320
Sacado::StringName
Base template specification for string names of types.
Definition: Sacado_Traits.hpp:376
Sacado::ScalarValue< Fad::SLFad< ValueT, Num > >::scalar_type
ScalarType< Fad::SLFad< ValueT, Num > >::type scalar_type
Definition: Sacado_Fad_SLFadTraits.hpp:93
Sacado::Value
Base template specification for Value.
Definition: Sacado_Traits.hpp:354
Sacado::IsEqual< Fad::SLFad< ValueT, Num > >::eval
static KOKKOS_INLINE_FUNCTION bool eval(const Fad::SLFad< ValueT, Num > &x, const Fad::SLFad< ValueT, Num > &y)
Definition: Sacado_Fad_SLFadTraits.hpp:114
Sacado::Rad::ADvar
Definition: Sacado_trad.hpp:213
Sacado::IsADType::value
static const bool value
Definition: Sacado_Traits.hpp:338
Sacado_Fad_ScalarTraitsImp.hpp
Sacado::Fad::Exp::SLFad
GeneralFad< StaticStorage< T, Num > > SLFad
Definition: Sacado_Fad_Exp_SLFad.hpp:42
Teuchos_PromotionTraits.hpp
Sacado::Promote
Base template specification for Promote.
Definition: Sacado_Traits.hpp:106
Sacado::ScalarValue::eval
static const KOKKOS_INLINE_FUNCTION T & eval(const T &x)
Definition: Sacado_Traits.hpp:366
SACADO_SFAD_PROMOTE_SPEC
#define SACADO_SFAD_PROMOTE_SPEC(NS, FAD)
Definition: Sacado_Traits.hpp:241
Sacado_Traits.hpp
Teuchos::RCP
Sacado::Value< Fad::SLFad< ValueT, Num > >::eval
static const KOKKOS_INLINE_FUNCTION value_type & eval(const Fad::SLFad< ValueT, Num > &x)
Definition: Sacado_Fad_SLFadTraits.hpp:85
Sacado_Fad_Exp_GeneralFadTraits.hpp
Sacado::ScalarValue< Fad::SLFad< ValueT, Num > >::value_type
ValueType< Fad::SLFad< ValueT, Num > >::type value_type
Definition: Sacado_Fad_SLFadTraits.hpp:92
Sacado::IsEqual
Base template specification for testing equivalence.
Definition: Sacado_Traits.hpp:381
Sacado::IsStaticallySized
Base template specification for testing whether type is statically sized.
Definition: Sacado_Traits.hpp:387
Sacado::Value< Fad::SLFad< ValueT, Num > >::value_type
ValueType< Fad::SLFad< ValueT, Num > >::type value_type
Definition: Sacado_Fad_SLFadTraits.hpp:83
Sacado::ScalarType< Fad::SLFad< ValueT, Num > >::type
Fad::SLFad< ValueT, Num >::ScalarT type
Definition: Sacado_Fad_SLFadTraits.hpp:59
Sacado
Definition: Sacado_mpl_apply.hpp:39
Sacado::Fad::DFad< double >
FadType
Sacado::Fad::DFad< double > FadType
Definition: blas_example.cpp:49
Sacado::Fad::SLFad
Definition: Sacado_Fad_SLFadTraits.hpp:47
Sacado::IsScalarType
Base template specification for IsScalarType.
Definition: Sacado_Traits.hpp:346
Sacado::IsStaticallySized::value
static const bool value
Definition: Sacado_Traits.hpp:388
Sacado::ScalarValue
Base template specification for ScalarValue.
Definition: Sacado_Traits.hpp:364
Sacado::StringName< Fad::SLFad< ValueT, Num > >::eval
static std::string eval()
Definition: Sacado_Fad_SLFadTraits.hpp:102
Sacado_ConfigDefs.h
Teuchos_ScalarTraits.hpp
Sacado::IsADType
Base template specification for IsADType.
Definition: Sacado_Traits.hpp:337
Teuchos
Sacado::ScalarValue< Fad::SLFad< ValueT, Num > >::eval
static const KOKKOS_INLINE_FUNCTION scalar_type & eval(const Fad::SLFad< ValueT, Num > &x)
Definition: Sacado_Fad_SLFadTraits.hpp:95
Sacado::IsScalarType::value
static const bool value
Definition: Sacado_Traits.hpp:347
Ordinal
int Ordinal
Definition: CacheFad_CommTests.cpp:36
Sacado::ValueType< Fad::SLFad< ValueT, Num > >::type
ValueT type
Definition: Sacado_Fad_SLFadTraits.hpp:65