Sacado Package Browser (Single Doxygen Collection) Version of the Day
Loading...
Searching...
No Matches
Sacado_ELRCacheFad_SFadTraits.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// The forward-mode AD classes in Sacado are a derivative work of the
30// expression template classes in the Fad package by Nicolas Di Cesare.
31// The following banner is included in the original Fad source code:
32//
33// ************ DO NOT REMOVE THIS BANNER ****************
34//
35// Nicolas Di Cesare <Nicolas.Dicesare@ann.jussieu.fr>
36// http://www.ann.jussieu.fr/~dicesare
37//
38// CEMRACS 98 : C++ courses,
39// templates : new C++ techniques
40// for scientific computing
41//
42//********************************************************
43//
44// NumericalTraits class to illustrate TRAITS
45//
46//********************************************************
47// @HEADER
48
49#ifndef SACADO_ELRCACHEFAD_SFADTRAITS_HPP
50#define SACADO_ELRCACHEFAD_SFADTRAITS_HPP
51
52#include "Sacado_Traits.hpp"
53#include <sstream>
54
55// Forward declarations
56namespace Sacado {
57 namespace ELRCacheFad {
58 template <typename T, int Num> class SFad;
59 }
60}
61
62namespace Sacado {
63
65 SACADO_SFAD_PROMOTE_SPEC( ELRCacheFad, SFad )
66
67
68 template <typename ValueT, int Num>
69 struct ScalarType< ELRCacheFad::SFad<ValueT,Num> > {
71 };
72
74 template <typename ValueT, int Num>
75 struct ValueType< ELRCacheFad::SFad<ValueT,Num> > {
76 typedef ValueT type;
77 };
78
80 template <typename ValueT, int Num>
81 struct IsADType< ELRCacheFad::SFad<ValueT,Num> > {
82 static const bool value = true;
83 };
84
86 template <typename ValueT, int Num>
87 struct IsScalarType< ELRCacheFad::SFad<ValueT,Num> > {
88 static const bool value = false;
89 };
90
92 template <typename ValueT, int Num>
93 struct Value< ELRCacheFad::SFad<ValueT,Num> > {
97 return x.val(); }
98 };
99
101 template <typename ValueT, int Num>
102 struct ScalarValue< ELRCacheFad::SFad<ValueT,Num> > {
107 return ScalarValue<value_type>::eval(x.val()); }
108 };
109
111 template <typename ValueT, int Num>
112 struct StringName< ELRCacheFad::SFad<ValueT,Num> > {
113 static std::string eval() {
114 std::stringstream ss;
115 ss << "Sacado::ELRCacheFad::SFad< "
116 << StringName<ValueT>::eval() << ", " << Num << " >";
117 return ss.str();
118 }
119 };
120
122 template <typename ValueT, int Num>
123 struct IsEqual< ELRCacheFad::SFad<ValueT,Num> > {
127 return x.isEqualTo(y);
128 }
129 };
130
132 template <typename ValueT, int Num>
133 struct IsStaticallySized< ELRCacheFad::SFad<ValueT,Num> > {
134 static const bool value = true;
135 };
136
138 template <typename ValueT, int Num>
139 struct IsStaticallySized< const ELRCacheFad::SFad<ValueT,Num> > {
140 static const bool value = true;
141 };
142
144 template <typename ValueT, int Num>
145 struct StaticSize< ELRCacheFad::SFad<ValueT,Num> > {
146 static const unsigned value = Num;
147 };
148
150 template <typename ValueT, int Num>
151 struct StaticSize< const ELRCacheFad::SFad<ValueT,Num> > {
152 static const unsigned value = Num;
153 };
154
155} // namespace Sacado
156
157//
158// Define Teuchos traits classes
159//
160
161// Promotion traits
162#ifdef HAVE_SACADO_TEUCHOSNUMERICS
163#include "Teuchos_PromotionTraits.hpp"
164namespace Teuchos {
165 template <typename ValueT, int Num>
166 struct PromotionTraits< Sacado::ELRCacheFad::SFad<ValueT,Num>,
167 Sacado::ELRCacheFad::SFad<ValueT,Num> > {
170 promote;
171 };
172
173 template <typename ValueT, int Num, typename R>
174 struct PromotionTraits< Sacado::ELRCacheFad::SFad<ValueT,Num>, R > {
176 promote;
177 };
178
179 template <typename L, typename ValueT, int Num>
180 struct PromotionTraits< L, Sacado::ELRCacheFad::SFad<ValueT,Num> > {
181 public:
183 promote;
184 };
185}
186#endif
187
188// Scalar traits
189#ifdef HAVE_SACADO_TEUCHOSCORE
191namespace Teuchos {
192 template <typename ValueT, int Num>
193 struct ScalarTraits< Sacado::ELRCacheFad::SFad<ValueT,Num> > :
194 public Sacado::Fad::ScalarTraitsImp< Sacado::ELRCacheFad::SFad<ValueT,Num> >
195 {};
196}
197#endif
198
199// Serialization traits
200#ifdef HAVE_SACADO_TEUCHOSCOMM
202namespace Teuchos {
203 template <typename Ordinal, typename ValueT, int Num>
204 struct SerializationTraits<Ordinal, Sacado::ELRCacheFad::SFad<ValueT,Num> > :
205 public Sacado::Fad::SerializationTraitsImp< Ordinal,
206 Sacado::ELRCacheFad::SFad<ValueT,Num> >
207 {};
208
209 template <typename Ordinal, typename ValueT, int Num>
210 struct ValueTypeSerializer<Ordinal, Sacado::ELRCacheFad::SFad<ValueT,Num> > :
211 public Sacado::Fad::SerializerImp< Ordinal,
212 Sacado::ELRCacheFad::SFad<ValueT,Num>,
213 ValueTypeSerializer<Ordinal,ValueT> >
214 {
216 typedef ValueTypeSerializer<Ordinal,ValueT> ValueSerializer;
217 typedef Sacado::Fad::SerializerImp< Ordinal,FadType,ValueSerializer> Base;
218 ValueTypeSerializer(const Teuchos::RCP<const ValueSerializer>& vs,
219 Ordinal sz = 0) :
220 Base(vs, sz) {}
221 };
222}
223#endif
224
225// KokkosComm
226#if defined(HAVE_SACADO_KOKKOSCORE) && defined(HAVE_SACADO_TEUCHOSKOKKOSCOMM) && defined(HAVE_SACADO_VIEW_SPEC) && !defined(SACADO_DISABLE_FAD_VIEW_SPEC)
227#include "KokkosExp_View_Fad.hpp"
228#endif
229
230#endif // SACADO_ELRCACHEFAD_SFADTRAITS_HPP
int Ordinal
#define SACADO_INLINE_FUNCTION
#define SACADO_SFAD_PROMOTE_SPEC(NS, FAD)
Sacado::Fad::DFad< double > FadType
const double y
GeneralFad< StaticFixedStorage< T, Num > > SFad
Base template specification for IsADType.
static const bool value
static SACADO_INLINE_FUNCTION bool eval(const ELRCacheFad::SFad< ValueT, Num > &x, const ELRCacheFad::SFad< ValueT, Num > &y)
Base template specification for testing equivalence.
Base template specification for IsScalarType.
static const bool value
Base template specification for testing whether type is statically sized.
Base template specification for Promote.
Base template specification for ScalarType.
static SACADO_INLINE_FUNCTION const scalar_type & eval(const ELRCacheFad::SFad< ValueT, Num > &x)
ValueType< ELRCacheFad::SFad< ValueT, Num > >::type value_type
ScalarType< ELRCacheFad::SFad< ValueT, Num > >::type scalar_type
Base template specification for ScalarValue.
static SACADO_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 SACADO_INLINE_FUNCTION const value_type & eval(const ELRCacheFad::SFad< ValueT, Num > &x)
ValueType< ELRCacheFad::SFad< ValueT, Num > >::type value_type
Base template specification for Value.