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 //
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_FAD_DVFAD_HPP
31 #define SACADO_FAD_DVFAD_HPP
32 
33 #include "Sacado_ConfigDefs.h"
34 
35 #ifdef SACADO_NEW_FAD_DESIGN_IS_DEFAULT
36 
37 #include "Sacado_Fad_Exp_DVFad.hpp"
38 
39 namespace Sacado {
40  namespace Fad {
41  template <typename T>
42  using DVFad = Exp::GeneralFad< Exp::VectorDynamicStorage<T> >;
43  }
44 }
45 
46 #else
47 
51 
52 namespace Sacado {
53 
54  namespace Fad {
55 
66  template <typename ValueT>
67  class DVFad :
68  public Expr< GeneralFad<ValueT,VectorDynamicStorage<ValueT> > > {
69 
70  public:
71 
76 
78  typedef typename ExprType::value_type value_type;
79 
81  typedef typename ExprType::scalar_type scalar_type;
82 
85 
87  template <typename T>
88  struct apply {
89  typedef DVFad<T> type;
90  };
91 
96 
98 
101  DVFad() :
102  ExprType() {}
103 
105 
108  template <typename S>
110  ExprType(x) {}
111 
113 
116  DVFad(const int sz, const ValueT& x, const DerivInit zero_out = InitDerivArray) :
117  ExprType(sz,x,zero_out) {}
118 
120 
125  DVFad(const int sz, const int i, const ValueT & x) :
126  ExprType(sz,i,x) {}
127 
129 
133  DVFad(const int sz, ValueT* x, ValueT* dx, bool zero_out = false) :
134  ExprType(sz,x,dx,zero_out) {}
135 
137 
142  DVFad(const int sz, const int i, ValueT* x, ValueT* dx) :
143  ExprType(sz,i,x,dx) {}
144 
146  DVFad(const DVFad& x) :
147  ExprType(x) {}
148 
150  template <typename S>
152  ExprType(x) {}
153 
155 
157  ~DVFad() {}
158 
160  template <typename S>
161  SACADO_ENABLE_VALUE_FUNC(DVFad&) operator=(const S& v) {
162  GeneralFadType::operator=(v);
163  return *this;
164  }
165 
167  DVFad& operator=(const DVFad& x) {
168  GeneralFadType::operator=(static_cast<const GeneralFadType&>(x));
169  return *this;
170  }
171 
173  template <typename S>
174  SACADO_ENABLE_EXPR_FUNC(DVFad&) operator=(const Expr<S>& x)
175  {
176  GeneralFadType::operator=(x);
177  return *this;
178  }
179 
181  template <typename S>
183  SACADO_ENABLE_VALUE_FUNC(DVFad&) operator += (const S& x) {
184  GeneralFadType::operator+=(x);
185  return *this;
186  }
187 
189  template <typename S>
191  SACADO_ENABLE_VALUE_FUNC(DVFad&) operator -= (const S& x) {
192  GeneralFadType::operator-=(x);
193  return *this;
194  }
195 
197  template <typename S>
199  SACADO_ENABLE_VALUE_FUNC(DVFad&) operator *= (const S& x) {
200  GeneralFadType::operator*=(x);
201  return *this;
202  }
203 
205  template <typename S>
207  SACADO_ENABLE_VALUE_FUNC(DVFad&) operator /= (const S& x) {
208  GeneralFadType::operator/=(x);
209  return *this;
210  }
211 
213  DVFad& operator += (const DVFad& x) {
214  GeneralFadType::operator+=(static_cast<const GeneralFadType&>(x));
215  return *this;
216  }
217 
219  DVFad& operator -= (const DVFad& x) {
220  GeneralFadType::operator-=(static_cast<const GeneralFadType&>(x));
221  return *this;
222  }
223 
225  DVFad& operator *= (const DVFad& x) {
226  GeneralFadType::operator*=(static_cast<const GeneralFadType&>(x));
227  return *this;
228  }
229 
231  DVFad& operator /= (const DVFad& x) {
232  GeneralFadType::operator/=(static_cast<const GeneralFadType&>(x));
233  return *this;
234  }
235 
237  template <typename S>
239  SACADO_ENABLE_EXPR_FUNC(DVFad&) operator += (const Expr<S>& x) {
240  GeneralFadType::operator+=(x);
241  return *this;
242  }
243 
245  template <typename S>
247  SACADO_ENABLE_EXPR_FUNC(DVFad&) operator -= (const Expr<S>& x) {
248  GeneralFadType::operator-=(x);
249  return *this;
250  }
251 
253  template <typename S>
255  SACADO_ENABLE_EXPR_FUNC(DVFad&) operator *= (const Expr<S>& x) {
256  GeneralFadType::operator*=(x);
257  return *this;
258  }
259 
261  template <typename S>
263  SACADO_ENABLE_EXPR_FUNC(DVFad&) operator /= (const Expr<S>& x) {
264  GeneralFadType::operator/=(x);
265  return *this;
266  }
267 
268  }; // class DVFad<ValueT>
269 
270  template <typename T>
273  };
274 
275  template <typename T>
276  struct ExprLevel< DVFad<T> > {
277  static const unsigned value =
279  };
280 
281  template <typename T>
282  struct IsFadExpr< DVFad<T> > {
283  static const bool value = true;
284  };
285 
286  } // namespace Fad
287 
288  template <typename T>
289  struct IsExpr< Fad::DVFad<T> > {
290  static const bool value = true;
291  };
292 
293  template <typename T>
294  struct BaseExprType< Fad::DVFad<T> > {
296  };
297 
299  template< class ValueType, unsigned length, unsigned stride >
300  struct ViewFadType< Sacado::Fad::DVFad< ValueType >, length, stride > {
302  };
303 
305  template< class ValueType, unsigned length, unsigned stride >
306  struct ViewFadType< const Sacado::Fad::DVFad< ValueType >, length, stride > {
308  };
309 
310 } // namespace Sacado
311 
312 #endif // SACADO_NEW_FAD_DESIGN_IS_DEFAULT
313 
314 #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 KOKKOS_INLINE_FUNCTION
#define T
Definition: Sacado_rad.hpp:573
#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
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.