Sacado Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Sacado_Fad_DVFad.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_FAD_DVFAD_HPP
11 #define SACADO_FAD_DVFAD_HPP
12 
13 #include "Sacado_ConfigDefs.h"
14 
15 #ifdef SACADO_NEW_FAD_DESIGN_IS_DEFAULT
16 
17 #include "Sacado_Fad_Exp_DVFad.hpp"
18 
19 namespace Sacado {
20  namespace Fad {
21  template <typename T>
22  using DVFad = Exp::GeneralFad< Exp::VectorDynamicStorage<T> >;
23  }
24 }
25 
26 #else
27 
31 
32 namespace Sacado {
33 
34  namespace Fad {
35 
46  template <typename ValueT>
47  class DVFad :
48  public Expr< GeneralFad<ValueT,VectorDynamicStorage<ValueT> > > {
49 
50  public:
51 
56 
58  typedef typename ExprType::value_type value_type;
59 
61  typedef typename ExprType::scalar_type scalar_type;
62 
65 
67  template <typename T>
68  struct apply {
69  typedef DVFad<T> type;
70  };
71 
76 
78 
81  DVFad() :
82  ExprType() {}
83 
85 
88  template <typename S>
90  ExprType(x) {}
91 
93 
96  DVFad(const int sz, const ValueT& x, const DerivInit zero_out = InitDerivArray) :
97  ExprType(sz,x,zero_out) {}
98 
100 
105  DVFad(const int sz, const int i, const ValueT & x) :
106  ExprType(sz,i,x) {}
107 
109 
113  DVFad(const int sz, ValueT* x, ValueT* dx, bool zero_out = false) :
114  ExprType(sz,x,dx,zero_out) {}
115 
117 
122  DVFad(const int sz, const int i, ValueT* x, ValueT* dx) :
123  ExprType(sz,i,x,dx) {}
124 
126  DVFad(const DVFad& x) :
127  ExprType(x) {}
128 
130  template <typename S>
132  ExprType(x) {}
133 
135 
137  ~DVFad() {}
138 
140  template <typename S>
141  SACADO_ENABLE_VALUE_FUNC(DVFad&) operator=(const S& v) {
142  GeneralFadType::operator=(v);
143  return *this;
144  }
145 
147  DVFad& operator=(const DVFad& x) {
148  GeneralFadType::operator=(static_cast<const GeneralFadType&>(x));
149  return *this;
150  }
151 
153  template <typename S>
154  SACADO_ENABLE_EXPR_FUNC(DVFad&) operator=(const Expr<S>& x)
155  {
156  GeneralFadType::operator=(x);
157  return *this;
158  }
159 
161  template <typename S>
163  SACADO_ENABLE_VALUE_FUNC(DVFad&) operator += (const S& x) {
164  GeneralFadType::operator+=(x);
165  return *this;
166  }
167 
169  template <typename S>
171  SACADO_ENABLE_VALUE_FUNC(DVFad&) operator -= (const S& x) {
172  GeneralFadType::operator-=(x);
173  return *this;
174  }
175 
177  template <typename S>
179  SACADO_ENABLE_VALUE_FUNC(DVFad&) operator *= (const S& x) {
180  GeneralFadType::operator*=(x);
181  return *this;
182  }
183 
185  template <typename S>
187  SACADO_ENABLE_VALUE_FUNC(DVFad&) operator /= (const S& x) {
188  GeneralFadType::operator/=(x);
189  return *this;
190  }
191 
193  DVFad& operator += (const DVFad& x) {
194  GeneralFadType::operator+=(static_cast<const GeneralFadType&>(x));
195  return *this;
196  }
197 
199  DVFad& operator -= (const DVFad& x) {
200  GeneralFadType::operator-=(static_cast<const GeneralFadType&>(x));
201  return *this;
202  }
203 
205  DVFad& operator *= (const DVFad& x) {
206  GeneralFadType::operator*=(static_cast<const GeneralFadType&>(x));
207  return *this;
208  }
209 
211  DVFad& operator /= (const DVFad& x) {
212  GeneralFadType::operator/=(static_cast<const GeneralFadType&>(x));
213  return *this;
214  }
215 
217  template <typename S>
219  SACADO_ENABLE_EXPR_FUNC(DVFad&) operator += (const Expr<S>& x) {
220  GeneralFadType::operator+=(x);
221  return *this;
222  }
223 
225  template <typename S>
227  SACADO_ENABLE_EXPR_FUNC(DVFad&) operator -= (const Expr<S>& x) {
228  GeneralFadType::operator-=(x);
229  return *this;
230  }
231 
233  template <typename S>
235  SACADO_ENABLE_EXPR_FUNC(DVFad&) operator *= (const Expr<S>& x) {
236  GeneralFadType::operator*=(x);
237  return *this;
238  }
239 
241  template <typename S>
243  SACADO_ENABLE_EXPR_FUNC(DVFad&) operator /= (const Expr<S>& x) {
244  GeneralFadType::operator/=(x);
245  return *this;
246  }
247 
248  }; // class DVFad<ValueT>
249 
250  template <typename T>
253  };
254 
255  template <typename T>
256  struct ExprLevel< DVFad<T> > {
257  static const unsigned value =
259  };
260 
261  template <typename T>
262  struct IsFadExpr< DVFad<T> > {
263  static const bool value = true;
264  };
265 
266  } // namespace Fad
267 
268  template <typename T>
269  struct IsExpr< Fad::DVFad<T> > {
270  static const bool value = true;
271  };
272 
273  template <typename T>
274  struct BaseExprType< Fad::DVFad<T> > {
276  };
277 
279  template< class ValueType, unsigned length, unsigned stride >
280  struct ViewFadType< Sacado::Fad::DVFad< ValueType >, length, stride > {
282  };
283 
285  template< class ValueType, unsigned length, unsigned stride >
286  struct ViewFadType< const Sacado::Fad::DVFad< ValueType >, length, stride > {
288  };
289 
290 } // namespace Sacado
291 
292 #endif // SACADO_NEW_FAD_DESIGN_IS_DEFAULT
293 
294 #endif // SACADO_FAD_DFAD_HPP
Wrapper for a generic expression template.
DVFad< typename GeneralFad< T, Fad::VectorDynamicStorage< T > >::value_type > type
expr expr dx(i)
#define SACADO_ENABLE_VALUE_CTOR_DECL
ExprType::value_type value_type
Typename of values.
GeneralFad< ValueT, StorageType > GeneralFadType
Sacado::Fad::ViewFad< const ValueType, length, stride, Sacado::Fad::DVFad< const ValueType > > type
static const bool value
#define SACADO_ENABLE_EXPR_CTOR_DECL
DVFad(const Expr< S > &x, SACADO_ENABLE_EXPR_CTOR_DECL)
Copy constructor from any Expression object.
Is a type an expression.
DVFad(const int sz, const int i, ValueT *x, ValueT *dx)
Constructor with supplied memory and index i.
ExprType::scalar_type scalar_type
Typename of scalar&#39;s (which may be different from T)
#define T
Definition: Sacado_rad.hpp:553
#define SACADO_ENABLE_VALUE_FUNC(RETURN_TYPE)
Determine whether a given type is an expression.
Sacado::Fad::ViewFad< ValueType, length, stride, Sacado::Fad::DVFad< ValueType > > type
Meta-function for determining concrete base expression.
Fad::DVFad< T >::base_expr_type type
Get the base Fad type from a view/expression.
GeneralFad< VectorDynamicStorage< T > > DVFad
VectorDynamicStorage< ValueT > StorageType
Base classes.
#define SACADO_ENABLE_EXPR_FUNC(RETURN_TYPE)
Forward-mode AD class using dynamic memory allocation and expression templates.
Meta-function for determining nesting with an expression.
DerivInit
Enum use to signal whether the derivative array should be initialized in AD object constructors...
DVFad()
Default constructor.
DVFad(const DVFad &x)
Copy constructor.
Turn DVFad into a meta-function class usable with mpl::apply.
DVFad(const int sz, const ValueT &x, const DerivInit zero_out=InitDerivArray)
Constructor with size sz and value x.
ScalarType< ValueT >::type ScalarT
Typename of scalar&#39;s (which may be different from ValueT)
Derivative array storage class using dynamic memory allocation.
static const unsigned value
DVFad(const S &x, SACADO_ENABLE_VALUE_CTOR_DECL)
Constructor with supplied value x convertible to ValueT.
DVFad(const int sz, ValueT *x, ValueT *dx, bool zero_out=false)
Constructor with supplied memory.
Initialize the derivative array.
Expr< GeneralFadType > ExprType
#define SACADO_INLINE_FUNCTION
DVFad(const int sz, const int i, const ValueT &x)
Constructor with size sz, index i, and value x.
Forward-mode AD class templated on the storage for the derivative array.
Get view type for any Fad type.