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