Sacado Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Sacado_trad_Traits.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_TRAD_TRAITS_HPP
31 #define SACADO_TRAD_TRAITS_HPP
32 
33 #include "Sacado_Traits.hpp"
34 
35 // Forward declarations
36 namespace Sacado {
37  namespace Rad {
38  template <typename T> class ADvar;
39  template <typename T> class ADvari;
40  }
41 }
42 
43 namespace Sacado {
44 
47 
48 
49  template <typename T>
50  struct ScalarType< Rad::ADvar<T> > {
51  typedef typename ScalarType<T>::type type;
52  };
53 
55  template <typename T>
56  struct ScalarType< Rad::ADvari<T> > {
57  typedef typename ScalarType<T>::type type;
58  };
59 
61  template <typename T>
62  struct ValueType< Rad::ADvar<T> > {
63  typedef T type;
64  };
65 
67  template <typename T>
68  struct ValueType< Rad::ADvari<T> > {
69  typedef T type;
70  };
71 
73  template <typename T>
74  struct IsADType< Rad::ADvar<T> > {
75  static const bool value = true;
76  };
77 
79  template <typename T>
80  struct IsADType< Rad::ADvari<T> > {
81  static const bool value = true;
82  };
83 
85  template <typename T>
86  struct IsScalarType< Rad::ADvar<T> > {
87  static const bool value = false;
88  };
89 
91  template <typename T>
92  struct IsScalarType< Rad::ADvari<T> > {
93  static const bool value = false;
94  };
95 
97  template <typename T>
98  struct Value< Rad::ADvar<T> > {
99  typedef typename ValueType< Rad::ADvar<T> >::type value_type;
100  static value_type eval(const Rad::ADvar<T>& x) {
101  return x.val(); }
102  };
103 
105  template <typename T>
106  struct MarkConstant< Rad::ADvar<T> > {
107  static void eval(Rad::ADvar<T>& x) { AD_Const(x); }
108  };
109 
111  template <typename T>
112  struct MarkConstant< Rad::ADvari<T> > {
113  static void eval(Rad::ADvari<T>& x) { AD_Const(x); }
114  };
115 
117  template <typename T>
118  struct ScalarValue< Rad::ADvar<T> > {
119  typedef typename ValueType< Rad::ADvar<T> >::type value_type;
120  typedef typename ScalarType< Rad::ADvar<T> >::type scalar_type;
121  static scalar_type eval(const Rad::ADvar<T>& x) {
122  return ScalarValue<value_type>::eval(x.val()); }
123  };
124 
126  template <typename T>
127  struct StringName< Rad::ADvar<T> > {
128  static std::string eval() {
129  return std::string("Sacado::Rad::ADvar< ") +
130  StringName<T>::eval() + " >"; }
131  };
132 
133 } // namespace Sacado
134 
135 #endif // SACADO_TRAD_TRAITS_HPP
ValueType< Rad::ADvar< T > >::type value_type
Base template specification for marking constants.
static std::string eval()
Base template specification for ScalarValue.
Base template specification for ScalarType.
ScalarType< Rad::ADvar< T > >::type scalar_type
Base template specification for string names of types.
Base template specification for IsADType.
Base template specification for Value.
#define SACADO_RAD_PROMOTE_SPEC(NS)
#define T
Definition: Sacado_rad.hpp:573
static const bool value
static void eval(Rad::ADvar< T > &x)
static scalar_type eval(const Rad::ADvar< T > &x)
static const bool value
Base template specification for IsScalarType.
ValueType< Rad::ADvar< T > >::type value_type
void AD_Const(const IndepADvar &v)
Definition: Sacado_rad.hpp:454
static value_type eval(const Rad::ADvar< T > &x)
Base template specification for ValueType.
static KOKKOS_INLINE_FUNCTION const T & eval(const T &x)
static void eval(Rad::ADvari< T > &x)