Sacado Package Browser (Single Doxygen Collection) Version of the Day
Loading...
Searching...
No Matches
Sacado_Tay_CacheTaylorTraits.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_TAYLOR_DTAYLORTRAITS_HPP
31#define SACADO_TAYLOR_DTAYLORTRAITS_HPP
32
33#include "Sacado_Traits.hpp"
34
35// Forward declarations
36namespace Sacado {
37 namespace Tay {
38 template <typename T> class CacheTaylor;
39 template <typename T> class Expr;
40 }
41}
42
43namespace Sacado {
44
46 SACADO_AD_PROMOTE_SPEC( Tay, CacheTaylor )
47
48
50
51
52 template <typename T>
53 struct ScalarType< Tay::CacheTaylor<T> > {
54 typedef typename ScalarType<T>::type type;
55 };
56
58 template <typename T>
59 struct ValueType< Tay::CacheTaylor<T> > {
60 typedef T type;
61 };
62
64 template <typename T>
65 struct IsADType< Tay::CacheTaylor<T> > {
66 static const bool value = true;
67 };
68
70 template <typename T>
71 struct IsScalarType< Tay::CacheTaylor<T> > {
72 static const bool value = false;
73 };
74
76 template <typename T>
77 struct Value< Tay::CacheTaylor<T> > {
79 static const value_type& eval(const Tay::CacheTaylor<T>& x) {
80 return x.val(); }
81 };
82
84 template <typename T>
85 struct ScalarValue< Tay::CacheTaylor<T> > {
88 static const scalar_type& eval(const Tay::CacheTaylor<T>& x) {
90 };
91
93 template <typename T>
94 struct StringName< Tay::CacheTaylor<T> > {
95 static std::string eval() {
96 return std::string("Sacado::Tay::CacheTaylor< ") +
97 StringName<T>::eval() + " >"; }
98 };
99
101 template <typename T>
102 struct IsEqual< Tay::CacheTaylor<T> > {
103 static bool eval(const Tay::CacheTaylor<T>& x,
104 const Tay::CacheTaylor<T>& y) {
105 return x.isEqualTo(y);
106 }
107 };
108
110 template <typename T>
111 struct IsStaticallySized< Tay::CacheTaylor<T> > {
112 static const bool value = false;
113 };
114
115} // namespace Sacado
116
117//
118// Define Teuchos traits classes
119//
120
121// Promotion traits
122#ifdef HAVE_SACADO_TEUCHOSNUMERICS
123#include "Teuchos_PromotionTraits.hpp"
124namespace Teuchos {
125 template <typename ValueT>
126 struct PromotionTraits< Sacado::Tay::CacheTaylor<ValueT>,
127 Sacado::Tay::CacheTaylor<ValueT> > {
130 promote;
131 };
132
134 template <typename ValueT, typename R>
135 struct PromotionTraits< Sacado::Tay::CacheTaylor<ValueT>, R > {
136 typedef typename Sacado::Promote< Sacado::Tay::CacheTaylor<ValueT>, R >::type
137 promote;
138 };
139
141 template <typename L, typename ValueT>
142 struct PromotionTraits< L, Sacado::Tay::CacheTaylor<ValueT> > {
143 public:
144 typedef typename Sacado::Promote< L, Sacado::Tay::CacheTaylor<ValueT> >::type
145 promote;
146 };
147}
148#endif
149
150// Scalar traits
151#ifdef HAVE_SACADO_TEUCHOSCORE
153namespace Teuchos {
154 template <typename ValueT>
155 struct ScalarTraits< Sacado::Tay::CacheTaylor<ValueT> > :
156 public Sacado::Tay::ScalarTraitsImp< Sacado::Tay::CacheTaylor<ValueT> >
157 {};
158}
159#endif
160
161// Serialization traits
162#ifdef HAVE_SACADO_TEUCHOSCOMM
164namespace Teuchos {
165 template <typename Ordinal, typename ValueT>
166 struct SerializationTraits<Ordinal, Sacado::Tay::CacheTaylor<ValueT> > :
167 public Sacado::Tay::SerializationTraitsImp< Ordinal,
168 Sacado::Tay::CacheTaylor<ValueT> >
169 {};
170
171 template <typename Ordinal, typename ValueT>
172 struct ValueTypeSerializer<Ordinal, Sacado::Tay::CacheTaylor<ValueT> > :
173 public Sacado::Tay::SerializerImp< Ordinal,
174 Sacado::Tay::CacheTaylor<ValueT>,
175 ValueTypeSerializer<Ordinal,ValueT> >
176 {
177 typedef Sacado::Tay::CacheTaylor<ValueT> TayType;
178 typedef ValueTypeSerializer<Ordinal,ValueT> ValueSerializer;
179 typedef Sacado::Tay::SerializerImp< Ordinal,TayType,ValueSerializer> Base;
180 ValueTypeSerializer(const Teuchos::RCP<const ValueSerializer>& vs,
181 Ordinal sz = 0) :
182 Base(vs, sz) {}
183 };
184}
185#endif
186
187#endif // SACADO_TAYLOR_DTAYLORTRAITS_HPP
int Ordinal
#define SACADO_EXPR_PROMOTE_SPEC(NS)
#define SACADO_AD_PROMOTE_SPEC(NS, AD)
#define T
#define R
bool isEqualTo(const Expr< S > &x) const
Returns whether two Taylor objects have the same values.
Forward-mode AD class using dynamic memory allocation.
Wrapper for a generic expression template.
Namespace for Taylor polynomial AD classes.
Base template specification for IsADType.
static bool eval(const Tay::CacheTaylor< T > &x, const Tay::CacheTaylor< T > &y)
Base template specification for testing equivalence.
Base template specification for IsScalarType.
Base template specification for testing whether type is statically sized.
Base template specification for ScalarType.
ScalarType< Tay::CacheTaylor< T > >::type scalar_type
ValueType< Tay::CacheTaylor< T > >::type value_type
static const scalar_type & eval(const Tay::CacheTaylor< T > &x)
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< Tay::CacheTaylor< T > >::type value_type
static const value_type & eval(const Tay::CacheTaylor< T > &x)
Base template specification for Value.