Sacado Package Browser (Single Doxygen Collection)  Version of the Day
Sacado_ELRCacheFad_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_ELRCACHEFAD_SLFADTRAITS_HPP
31 #define SACADO_ELRCACHEFAD_SLFADTRAITS_HPP
32 
33 #include "Sacado_Traits.hpp"
34 #include <sstream>
35 
36 // Forward declarations
37 namespace Sacado {
38  namespace ELRCacheFad {
39  template <typename T, int Num> class SLFad;
40  }
41 }
42 
43 namespace Sacado {
44 
46  SACADO_SFAD_PROMOTE_SPEC( ELRCacheFad, SLFad )
47 
48 
49  template <typename ValueT, int Num>
50  struct ScalarType< ELRCacheFad::SLFad<ValueT,Num> > {
52  };
53 
55  template <typename ValueT, int Num>
56  struct ValueType< ELRCacheFad::SLFad<ValueT,Num> > {
57  typedef ValueT type;
58  };
59 
61  template <typename ValueT, int Num>
62  struct IsADType< ELRCacheFad::SLFad<ValueT,Num> > {
63  static const bool value = true;
64  };
65 
67  template <typename ValueT, int Num>
68  struct IsScalarType< ELRCacheFad::SLFad<ValueT,Num> > {
69  static const bool value = false;
70  };
71 
73  template <typename ValueT, int Num>
74  struct Value< ELRCacheFad::SLFad<ValueT,Num> > {
78  return x.val(); }
79  };
80 
82  template <typename ValueT, int Num>
83  struct ScalarValue< ELRCacheFad::SLFad<ValueT,Num> > {
88  return ScalarValue<value_type>::eval(x.val()); }
89  };
90 
92  template <typename ValueT, int Num>
93  struct StringName< ELRCacheFad::SLFad<ValueT,Num> > {
94  static std::string eval() {
95  std::stringstream ss;
96  ss << "Sacado::ELRCacheFad::SLFad< "
97  << StringName<ValueT>::eval() << ", " << Num << " >";
98  return ss.str();
99  }
100  };
101 
103  template <typename ValueT, int Num>
104  struct IsEqual< ELRCacheFad::SLFad<ValueT,Num> > {
106  static bool eval(const ELRCacheFad::SLFad<ValueT,Num>& x,
108  return x.isEqualTo(y);
109  }
110  };
111 
113  template <typename ValueT, int Num>
114  struct IsStaticallySized< ELRCacheFad::SLFad<ValueT,Num> > {
115  static const bool value = false;
116  };
117 
119  template <typename ValueT, int Num>
120  struct IsStaticallySized< const ELRCacheFad::SLFad<ValueT,Num> > {
121  static const bool value = false;
122  };
123 
124 } // namespace Sacado
125 
126 // Define Teuchos traits classes
127 #ifdef HAVE_SACADO_TEUCHOS
129 #include "Teuchos_ScalarTraits.hpp"
131 
132 namespace Teuchos {
133 
135  template <typename ValueT, int Num>
136  struct PromotionTraits< Sacado::ELRCacheFad::SLFad<ValueT,Num>,
137  Sacado::ELRCacheFad::SLFad<ValueT,Num> > {
140  promote;
141  };
142 
144  template <typename ValueT, int Num, typename R>
145  struct PromotionTraits< Sacado::ELRCacheFad::SLFad<ValueT,Num>, R > {
147  R >::type
148  promote;
149  };
150 
152  template <typename L, typename ValueT, int Num>
153  struct PromotionTraits< L, Sacado::ELRCacheFad::SLFad<ValueT,Num> > {
154  public:
155  typedef typename Sacado::Promote< L,
157  promote;
158  };
159 
161  template <typename ValueT, int Num>
162  struct ScalarTraits< Sacado::ELRCacheFad::SLFad<ValueT,Num> > :
163  public Sacado::Fad::ScalarTraitsImp< Sacado::ELRCacheFad::SLFad<ValueT,Num> >
164  {};
165 
167  template <typename Ordinal, typename ValueT, int Num>
168  struct SerializationTraits<Ordinal, Sacado::ELRCacheFad::SLFad<ValueT,Num> > :
169  public Sacado::Fad::SerializationTraitsImp< Ordinal,
170  Sacado::ELRCacheFad::SLFad<ValueT,Num> >
171  {};
172 
174  template <typename Ordinal, typename ValueT, int Num>
175  struct ValueTypeSerializer<Ordinal, Sacado::ELRCacheFad::SLFad<ValueT,Num> > :
176  public Sacado::Fad::SerializerImp< Ordinal,
177  Sacado::ELRCacheFad::SLFad<ValueT,Num>,
178  ValueTypeSerializer<Ordinal,ValueT> >
179  {
181  typedef ValueTypeSerializer<Ordinal,ValueT> ValueSerializer;
182  typedef Sacado::Fad::SerializerImp< Ordinal,FadType,ValueSerializer> Base;
183  ValueTypeSerializer(const Teuchos::RCP<const ValueSerializer>& vs,
184  Ordinal sz = 0) :
185  Base(vs, sz) {}
186  };
187 }
188 #endif // HAVE_SACADO_TEUCHOS
189 
190 #endif // SACADO_ELRCACHEFAD_SLFADTRAITS_HPP
static std::string eval()
Base template specification for ScalarValue.
static KOKKOS_INLINE_FUNCTION const value_type & eval(const ELRCacheFad::SLFad< ValueT, Num > &x)
Base template specification for ScalarType.
static KOKKOS_INLINE_FUNCTION bool eval(const ELRCacheFad::SLFad< ValueT, Num > &x, const ELRCacheFad::SLFad< ValueT, Num > &y)
Base template specification for string names of types.
GeneralFad< StaticStorage< T, Num > > SLFad
Base template specification for IsADType.
Sacado::Fad::DFad< double > FadType
ValueType< ELRCacheFad::SLFad< ValueT, Num > >::type value_type
Base template specification for Value.
ValueType< ELRCacheFad::SLFad< ValueT, Num > >::type value_type
#define KOKKOS_INLINE_FUNCTION
ScalarType< ELRCacheFad::SLFad< ValueT, Num > >::type scalar_type
static const bool value
Base template specification for testing equivalence.
static KOKKOS_INLINE_FUNCTION const scalar_type & eval(const ELRCacheFad::SLFad< ValueT, Num > &x)
int Ordinal
static const bool value
Base template specification for IsScalarType.
#define SACADO_SFAD_PROMOTE_SPEC(NS, FAD)
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.