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 //
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 IsSimdType< Fad::SLFad<ValueT,Num> > {
83  static const bool value = IsSimdType<ValueT>::value;
84  };
85 
87  template <typename ValueT, int Num>
88  struct Value< Fad::SLFad<ValueT,Num> > {
91  static const value_type& eval(const Fad::SLFad<ValueT,Num>& x) {
92  return x.val(); }
93  };
94 
96  template <typename ValueT, int Num>
97  struct ScalarValue< Fad::SLFad<ValueT,Num> > {
101  static const scalar_type& eval(const Fad::SLFad<ValueT,Num>& x) {
102  return ScalarValue<value_type>::eval(x.val()); }
103  };
104 
106  template <typename ValueT, int Num>
107  struct StringName< Fad::SLFad<ValueT,Num> > {
108  static std::string eval() {
109  std::stringstream ss;
110  ss << "Sacado::Fad::SLFad< "
111  << StringName<ValueT>::eval() << ", " << Num << " >";
112  return ss.str();
113  }
114  };
115 
117  template <typename ValueT, int Num>
118  struct IsEqual< Fad::SLFad<ValueT,Num> > {
120  static bool eval(const Fad::SLFad<ValueT,Num>& x,
121  const Fad::SLFad<ValueT,Num>& y) {
122  return x.isEqualTo(y);
123  }
124  };
125 
127  template <typename ValueT, int Num>
128  struct IsStaticallySized< Fad::SLFad<ValueT,Num> > {
129  static const bool value = false;
130  };
131 
133  template <typename ValueT, int Num>
134  struct IsStaticallySized< const Fad::SLFad<ValueT,Num> > {
135  static const bool value = false;
136  };
137 
138 } // namespace Sacado
139 
140 //
141 // Define Teuchos traits classes
142 //
143 
144 // Promotion traits
145 #ifdef HAVE_SACADO_TEUCHOSNUMERICS
147 namespace Teuchos {
148  template <typename ValueT, int Num>
149  struct PromotionTraits< Sacado::Fad::SLFad<ValueT,Num>,
150  Sacado::Fad::SLFad<ValueT,Num> > {
153  promote;
154  };
155 
156  template <typename ValueT, int Num, typename R>
157  struct PromotionTraits< Sacado::Fad::SLFad<ValueT,Num>, R > {
158  typedef typename Sacado::Promote< Sacado::Fad::SLFad<ValueT,Num>, R >::type
159  promote;
160  };
161 
162  template <typename L, typename ValueT, int Num>
163  struct PromotionTraits< L, Sacado::Fad::SLFad<ValueT,Num> > {
164  public:
166  promote;
167  };
168 }
169 #endif
170 
171 // Scalar traits
172 #ifdef HAVE_SACADO_TEUCHOSCORE
174 namespace Teuchos {
175  template <typename ValueT, int Num>
176  struct ScalarTraits< Sacado::Fad::SLFad<ValueT,Num> > :
177  public Sacado::Fad::ScalarTraitsImp< Sacado::Fad::SLFad<ValueT,Num> >
178  {};
179 }
180 #endif
181 
182 // Serialization traits
183 #ifdef HAVE_SACADO_TEUCHOSCOMM
185 namespace Teuchos {
186  template <typename Ordinal, typename ValueT, int Num>
187  struct SerializationTraits<Ordinal, Sacado::Fad::SLFad<ValueT,Num> > :
188  public Sacado::Fad::SerializationTraitsImp< Ordinal,
189  Sacado::Fad::SLFad<ValueT,Num> >
190  {};
191 
192  template <typename Ordinal, typename ValueT, int Num>
193  struct ValueTypeSerializer<Ordinal, Sacado::Fad::SLFad<ValueT,Num> > :
194  public Sacado::Fad::SerializerImp< Ordinal,
195  Sacado::Fad::SLFad<ValueT,Num>,
196  ValueTypeSerializer<Ordinal,ValueT> >
197  {
199  typedef ValueTypeSerializer<Ordinal,ValueT> ValueSerializer;
200  typedef Sacado::Fad::SerializerImp< Ordinal,FadType,ValueSerializer> Base;
201  ValueTypeSerializer(const Teuchos::RCP<const ValueSerializer>& vs,
202  Ordinal sz = 0) :
203  Base(vs, sz) {}
204  };
205 }
206 #endif
207 
208 // KokkosComm
209 #if defined(HAVE_SACADO_KOKKOSCORE) && defined(HAVE_SACADO_TEUCHOSKOKKOSCOMM) && defined(HAVE_SACADO_VIEW_SPEC) && !defined(SACADO_DISABLE_FAD_VIEW_SPEC)
210 #include "KokkosExp_View_Fad.hpp"
211 #endif
212 
213 #endif // SACADO_NEW_FAD_DESIGN_IS_DEFAULT
214 
215 #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)
Base template specification for IsSimdType.
#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
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)
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.