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