Sacado Package Browser (Single Doxygen Collection) Version of the Day
Loading...
Searching...
No Matches
Sacado_CacheFad_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_CACHEFAD_SLFADTRAITS_HPP
31#define SACADO_CACHEFAD_SLFADTRAITS_HPP
32
33#include "Sacado_Traits.hpp"
34#include <sstream>
35
36// Forward declarations
37namespace Sacado {
38 namespace CacheFad {
39 template <typename T, int Num> class SLFad;
40 }
41}
42
43namespace Sacado {
44
46 SACADO_SFAD_PROMOTE_SPEC( CacheFad, SLFad )
47
48
49 template <typename ValueT, int Num>
50 struct ScalarType< CacheFad::SLFad<ValueT,Num> > {
52 };
53
55 template <typename ValueT, int Num>
56 struct ValueType< CacheFad::SLFad<ValueT,Num> > {
57 typedef ValueT type;
58 };
59
61 template <typename ValueT, int Num>
62 struct IsADType< CacheFad::SLFad<ValueT,Num> > {
63 static const bool value = true;
64 };
65
67 template <typename ValueT, int Num>
68 struct IsScalarType< CacheFad::SLFad<ValueT,Num> > {
69 static const bool value = false;
70 };
71
73 template <typename ValueT, int Num>
74 struct Value< CacheFad::SLFad<ValueT,Num> > {
78 return x.val(); }
79 };
80
82 template <typename ValueT, int Num>
83 struct ScalarValue< CacheFad::SLFad<ValueT,Num> > {
88 return ScalarValue<value_type>::eval(x.val()); }
89 };
90
92 template <typename ValueT, int Num>
93 struct StringName< CacheFad::SLFad<ValueT,Num> > {
94 static std::string eval() {
95 std::stringstream ss;
96 ss << "Sacado::CacheFad::SLFad< "
97 << StringName<ValueT>::eval() << ", " << Num << " >";
98 return ss.str();
99 }
100 };
101
103 template <typename ValueT, int Num>
104 struct IsEqual< CacheFad::SLFad<ValueT,Num> > {
108 return x.isEqualTo(y);
109 }
110 };
111
113 template <typename ValueT, int Num>
114 struct IsStaticallySized< CacheFad::SLFad<ValueT,Num> > {
115 static const bool value = false;
116 };
117
119 template <typename ValueT, int Num>
120 struct IsStaticallySized< const CacheFad::SLFad<ValueT,Num> > {
121 static const bool value = false;
122 };
123
124} // namespace Sacado
125
126//
127// Define Teuchos traits classes
128//
129
130// Promotion traits
131#ifdef HAVE_SACADO_TEUCHOSNUMERICS
132#include "Teuchos_PromotionTraits.hpp"
133namespace Teuchos {
134 template <typename ValueT, int Num>
135 struct PromotionTraits< Sacado::CacheFad::SLFad<ValueT,Num>,
136 Sacado::CacheFad::SLFad<ValueT,Num> > {
139 promote;
140 };
141
142 template <typename ValueT, int Num, typename R>
143 struct PromotionTraits< Sacado::CacheFad::SLFad<ValueT,Num>, R > {
145 promote;
146 };
147
148 template <typename L, typename ValueT, int Num>
149 struct PromotionTraits< L, Sacado::CacheFad::SLFad<ValueT,Num> > {
150 public:
152 promote;
153 };
154}
155#endif
156
157// Scalar traits
158#ifdef HAVE_SACADO_TEUCHOSCORE
160namespace Teuchos {
161 template <typename ValueT, int Num>
162 struct ScalarTraits< Sacado::CacheFad::SLFad<ValueT,Num> > :
163 public Sacado::Fad::ScalarTraitsImp< Sacado::CacheFad::SLFad<ValueT,Num> >
164 {};
165}
166#endif
167
168// Serialization traits
169#ifdef HAVE_SACADO_TEUCHOSCOMM
171namespace Teuchos {
172 template <typename Ordinal, typename ValueT, int Num>
173 struct SerializationTraits<Ordinal, Sacado::CacheFad::SLFad<ValueT,Num> > :
175 Sacado::CacheFad::SLFad<ValueT,Num> >
176 {};
177
178 template <typename Ordinal, typename ValueT, int Num>
179 struct ValueTypeSerializer<Ordinal, Sacado::CacheFad::SLFad<ValueT,Num> > :
180 public Sacado::Fad::SerializerImp< Ordinal,
181 Sacado::CacheFad::SLFad<ValueT,Num>,
182 ValueTypeSerializer<Ordinal,ValueT> >
183 {
185 typedef ValueTypeSerializer<Ordinal,ValueT> ValueSerializer;
187 ValueTypeSerializer(const Teuchos::RCP<const ValueSerializer>& vs,
188 Ordinal sz = 0) :
189 Base(vs, sz) {}
190 };
191}
192#endif
193
194// KokkosComm
195#if defined(HAVE_SACADO_KOKKOSCORE) && defined(HAVE_SACADO_TEUCHOSKOKKOSCOMM) && defined(HAVE_SACADO_VIEW_SPEC) && !defined(SACADO_DISABLE_FAD_VIEW_SPEC)
196#include "KokkosExp_View_Fad.hpp"
197#endif
198
199#endif // SACADO_CACHEFAD_SLFADTRAITS_HPP
int Ordinal
#define SACADO_INLINE_FUNCTION
#define SACADO_SFAD_PROMOTE_SPEC(NS, FAD)
Sacado::Fad::DFad< double > FadType
Fad specializations for Teuchos::BLAS wrappers.
const double y
Base template specification for IsADType.
static const bool value
static SACADO_INLINE_FUNCTION bool eval(const CacheFad::SLFad< ValueT, Num > &x, const CacheFad::SLFad< 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.
ScalarType< CacheFad::SLFad< ValueT, Num > >::type scalar_type
static SACADO_INLINE_FUNCTION const scalar_type & eval(const CacheFad::SLFad< ValueT, Num > &x)
ValueType< CacheFad::SLFad< ValueT, Num > >::type value_type
Base template specification for ScalarValue.
static SACADO_INLINE_FUNCTION const T & eval(const T &x)
Base template specification for string names of types.
static std::string eval()
Base template specification for ValueType.
ValueType< CacheFad::SLFad< ValueT, Num > >::type value_type
static SACADO_INLINE_FUNCTION const value_type & eval(const CacheFad::SLFad< ValueT, Num > &x)
Base template specification for Value.