Sacado Package Browser (Single Doxygen Collection)  Version of the Day
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
36 namespace Sacado {
37  namespace Tay {
38  template <typename T> class CacheTaylor;
39  template <typename T> class Expr;
40  }
41 }
42 
43 namespace 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> > {
78  typedef typename ValueType< Tay::CacheTaylor<T> >::type value_type;
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> > {
86  typedef typename ValueType< Tay::CacheTaylor<T> >::type value_type;
87  typedef typename ScalarType< Tay::CacheTaylor<T> >::type scalar_type;
88  static const scalar_type& eval(const Tay::CacheTaylor<T>& x) {
89  return ScalarValue<value_type>::eval(x.val()); }
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 // Define Teuchos traits classes
118 #ifdef HAVE_SACADO_TEUCHOS
119 #include "Teuchos_PromotionTraits.hpp"
120 #include "Teuchos_ScalarTraits.hpp"
122 #include "Teuchos_SerializationTraits.hpp"
123 
124 namespace Teuchos {
125 
127  template <typename ValueT>
128  struct PromotionTraits< Sacado::Tay::CacheTaylor<ValueT>,
129  Sacado::Tay::CacheTaylor<ValueT> > {
132  promote;
133  };
134 
136  template <typename ValueT, typename R>
137  struct PromotionTraits< Sacado::Tay::CacheTaylor<ValueT>, R > {
138  typedef typename Sacado::Promote< Sacado::Tay::CacheTaylor<ValueT>, R >::type
139  promote;
140  };
141 
143  template <typename L, typename ValueT>
144  struct PromotionTraits< L, Sacado::Tay::CacheTaylor<ValueT> > {
145  public:
147  promote;
148  };
149 
151  template <typename ValueT>
152  struct ScalarTraits< Sacado::Tay::CacheTaylor<ValueT> > :
153  public Sacado::Tay::ScalarTraitsImp< Sacado::Tay::CacheTaylor<ValueT> >
154  {};
155 
157  template <typename Ordinal, typename ValueT>
158  struct SerializationTraits<Ordinal, Sacado::Tay::CacheTaylor<ValueT> > :
159  public Sacado::Tay::SerializationTraitsImp< Ordinal,
160  Sacado::Tay::CacheTaylor<ValueT> >
161  {};
162 
164  template <typename Ordinal, typename ValueT>
165  struct ValueTypeSerializer<Ordinal, Sacado::Tay::CacheTaylor<ValueT> > :
166  public Sacado::Tay::SerializerImp< Ordinal,
167  Sacado::Tay::CacheTaylor<ValueT>,
168  ValueTypeSerializer<Ordinal,ValueT> >
169  {
170  typedef Sacado::Tay::CacheTaylor<ValueT> TayType;
171  typedef ValueTypeSerializer<Ordinal,ValueT> ValueSerializer;
172  typedef Sacado::Tay::SerializerImp< Ordinal,TayType,ValueSerializer> Base;
173  ValueTypeSerializer(const Teuchos::RCP<const ValueSerializer>& vs,
174  Ordinal sz = 0) :
175  Base(vs, sz) {}
176  };
177 }
178 #endif // HAVE_SACADO_TEUCHOS
179 
180 #endif // SACADO_TAYLOR_DTAYLORTRAITS_HPP
static std::string eval()
Base template specification for ScalarValue.
Base template specification for ScalarType.
Forward-mode AD class using dynamic memory allocation.
Base template specification for string names of types.
ValueType< Tay::CacheTaylor< T > >::type value_type
Base template specification for IsADType.
Base template specification for Value.
#define SACADO_AD_PROMOTE_SPEC(NS, AD)
ScalarType< Tay::CacheTaylor< T > >::type scalar_type
#define T
Definition: Sacado_rad.hpp:573
static const bool value
#define SACADO_EXPR_PROMOTE_SPEC(NS)
ValueType< Tay::CacheTaylor< T > >::type value_type
Base template specification for testing equivalence.
int Ordinal
static bool eval(const Tay::CacheTaylor< T > &x, const Tay::CacheTaylor< T > &y)
static const value_type & eval(const Tay::CacheTaylor< T > &x)
static const bool value
bool isEqualTo(const Expr< S > &x) const
Returns whether two Taylor objects have the same values.
Base template specification for IsScalarType.
Base template specification for ValueType.
Base template specification for Promote.
static KOKKOS_INLINE_FUNCTION const T & eval(const T &x)
static const scalar_type & eval(const Tay::CacheTaylor< T > &x)
Base template specification for testing whether type is statically sized.