Sacado Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 //
127 // Define Teuchos traits classes
128 //
129 
130 // Promotion traits
131 #ifdef HAVE_SACADO_TEUCHOSNUMERICS
133 namespace Teuchos {
134  template <typename ValueT, int Num>
135  struct PromotionTraits< Sacado::ELRCacheFad::SLFad<ValueT,Num>,
136  Sacado::ELRCacheFad::SLFad<ValueT,Num> > {
139  promote;
140  };
141 
142  template <typename ValueT, int Num, typename R>
143  struct PromotionTraits< Sacado::ELRCacheFad::SLFad<ValueT,Num>, R > {
145  promote;
146  };
147 
148  template <typename L, typename ValueT, int Num>
149  struct PromotionTraits< L, Sacado::ELRCacheFad::SLFad<ValueT,Num> > {
150  public:
152  promote;
153  };
154 }
155 #endif
156 
157 // Scalar traits
158 #ifdef HAVE_SACADO_TEUCHOSCORE
160 namespace Teuchos {
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 }
166 #endif
167 
168 // Serialization traits
169 #ifdef HAVE_SACADO_TEUCHOSCOMM
171 namespace Teuchos {
172  template <typename Ordinal, typename ValueT, int Num>
173  struct SerializationTraits<Ordinal, Sacado::ELRCacheFad::SLFad<ValueT,Num> > :
174  public Sacado::Fad::SerializationTraitsImp< Ordinal,
175  Sacado::ELRCacheFad::SLFad<ValueT,Num> >
176  {};
177 
178  template <typename Ordinal, typename ValueT, int Num>
179  struct ValueTypeSerializer<Ordinal, Sacado::ELRCacheFad::SLFad<ValueT,Num> > :
180  public Sacado::Fad::SerializerImp< Ordinal,
181  Sacado::ELRCacheFad::SLFad<ValueT,Num>,
182  ValueTypeSerializer<Ordinal,ValueT> >
183  {
185  typedef ValueTypeSerializer<Ordinal,ValueT> ValueSerializer;
186  typedef Sacado::Fad::SerializerImp< Ordinal,FadType,ValueSerializer> Base;
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_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.