Sacado Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Sacado_trad2_Traits.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Sacado Package
4 //
5 // Copyright 2006 NTESS and the Sacado contributors.
6 // SPDX-License-Identifier: LGPL-2.1-or-later
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef SACADO_TRAD2_TRAITS_HPP
11 #define SACADO_TRAD2_TRAITS_HPP
12 
13 #include "Sacado_Traits.hpp"
14 
15 // Forward declarations
16 namespace Sacado {
17  namespace Rad2 {
18  template <typename T> class ADvar;
19  template <typename T> class ADvari;
20  }
21 }
22 
23 namespace Sacado {
24 
27 
28 
29  template <typename T>
30  struct ScalarType< Rad2::ADvar<T> > {
31  typedef typename ScalarType<T>::type type;
32  };
33 
35  template <typename T>
36  struct ScalarType< Rad2::ADvari<T> > {
37  typedef typename ScalarType<T>::type type;
38  };
39 
41  template <typename T>
42  struct ValueType< Rad2::ADvar<T> > {
43  typedef T type;
44  };
45 
47  template <typename T>
48  struct ValueType< Rad2::ADvari<T> > {
49  typedef T type;
50  };
51 
53  template <typename T>
54  struct IsADType< Rad2::ADvar<T> > {
55  static const bool value = true;
56  };
57 
59  template <typename T>
60  struct IsADType< Rad2::ADvari<T> > {
61  static const bool value = true;
62  };
63 
65  template <typename T>
66  struct IsScalarType< Rad2::ADvar<T> > {
67  static const bool value = false;
68  };
69 
71  template <typename T>
72  struct IsScalarType< Rad2::ADvari<T> > {
73  static const bool value = false;
74  };
75 
77  template <typename T>
78  struct Value< Rad2::ADvar<T> > {
79  typedef typename ValueType< Rad2::ADvar<T> >::type value_type;
80  static value_type eval(const Rad2::ADvar<T>& x) {
81  return x.val(); }
82  };
83 
85  template <typename T>
86  struct MarkConstant< Rad2::ADvar<T> > {
87  static void eval(Rad2::ADvar<T>& x) { AD_Const(x); }
88  };
89 
91  template <typename T>
92  struct MarkConstant< Rad2::ADvari<T> > {
93  static void eval(Rad2::ADvari<T>& x) { AD_Const(x); }
94  };
95 
97  template <typename T>
98  struct ScalarValue< Rad2::ADvar<T> > {
99  typedef typename ValueType< Rad2::ADvar<T> >::type value_type;
100  typedef typename ScalarType< Rad2::ADvar<T> >::type scalar_type;
101  static scalar_type eval(const Rad2::ADvar<T>& x) {
102  return ScalarValue<value_type>::eval(x.val()); }
103  };
104 
106  template <typename T>
107  struct StringName< Rad2::ADvar<T> > {
108  static std::string eval() {
109  return std::string("Sacado::Rad2::ADvar< ") +
110  StringName<T>::eval() + " >"; }
111  };
112 
113 } // namespace Sacado
114 
115 #endif // SACADO_TRAD_TRAITS_HPP
static SACADO_INLINE_FUNCTION const T & eval(const T &x)
Base template specification for marking constants.
static std::string eval()
static void eval(Rad2::ADvari< T > &x)
static value_type eval(const Rad2::ADvar< T > &x)
Base template specification for ScalarValue.
Base template specification for ScalarType.
Base template specification for string names of types.
Base template specification for IsADType.
ScalarType< Rad2::ADvar< T > >::type scalar_type
ValueType< Rad2::ADvar< T > >::type value_type
Base template specification for Value.
#define SACADO_RAD_PROMOTE_SPEC(NS)
#define T
Definition: Sacado_rad.hpp:553
static const bool value
static scalar_type eval(const Rad2::ADvar< T > &x)
ValueType< Rad2::ADvar< T > >::type value_type
static void eval(Rad2::ADvar< T > &x)
static const bool value
Base template specification for IsScalarType.
void AD_Const(const IndepADvar &v)
Definition: Sacado_rad.hpp:434
Base template specification for ValueType.