Sacado Package Browser (Single Doxygen Collection) Version of the Day
Loading...
Searching...
No Matches
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
38
39namespace Sacado {
40 namespace Fad {
41 template <typename T>
42 using DVFad = Exp::GeneralFad< Exp::VectorDynamicStorage<T> >;
43 }
44}
45
46#else
47
51
52namespace 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
82
85
87 template <typename T>
88 struct apply {
89 typedef DVFad<T> type;
90 };
91
96
98
102 ExprType() {}
103
105
108 template <typename S>
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>
153
155
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>
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 >
303
305 template< class ValueType, unsigned length, unsigned stride >
309
310} // namespace Sacado
311
312#endif // SACADO_NEW_FAD_DESIGN_IS_DEFAULT
313
314#endif // SACADO_FAD_DFAD_HPP
#define SACADO_INLINE_FUNCTION
expr expr dx(i)
#define SACADO_ENABLE_VALUE_FUNC(RETURN_TYPE)
#define SACADO_ENABLE_VALUE_CTOR_DECL
#define SACADO_ENABLE_EXPR_FUNC(RETURN_TYPE)
#define SACADO_ENABLE_EXPR_CTOR_DECL
Fad specializations for Teuchos::BLAS wrappers.
Sacado::ScalarType< FadType >::type scalar_type
Forward-mode AD class using dynamic memory allocation and expression templates.
ScalarType< ValueT >::type ScalarT
Typename of scalar's (which may be different from ValueT)
DVFad(const int sz, const int i, const ValueT &x)
Constructor with size sz, index i, and value x.
DVFad()
Default constructor.
DVFad(const int sz, const ValueT &x, const DerivInit zero_out=InitDerivArray)
Constructor with size sz and value x.
DVFad(const Expr< S > &x, SACADO_ENABLE_EXPR_CTOR_DECL)
Copy constructor from any Expression object.
DVFad(const int sz, ValueT *x, ValueT *dx, bool zero_out=false)
Constructor with supplied memory.
GeneralFad< ValueT, StorageType > GeneralFadType
ExprType::scalar_type scalar_type
Typename of scalar's (which may be different from T)
DVFad(const int sz, const int i, ValueT *x, ValueT *dx)
Constructor with supplied memory and index i.
VectorDynamicStorage< ValueT > StorageType
Base classes.
ExprType::value_type value_type
Typename of values.
DVFad(const DVFad &x)
Copy constructor.
DVFad(const S &x, SACADO_ENABLE_VALUE_CTOR_DECL)
Constructor with supplied value x convertible to ValueT.
Expr< GeneralFadType > ExprType
Wrapper for a generic expression template.
Forward-mode AD class templated on the storage for the derivative array.
Derivative array storage class using dynamic memory allocation.
GeneralFad< VectorDynamicStorage< T > > DVFad
DerivInit
Enum use to signal whether the derivative array should be initialized in AD object constructors.
@ InitDerivArray
Initialize the derivative array.
Fad::DVFad< T >::base_expr_type type
Get the base Fad type from a view/expression.
DVFad< typename GeneralFad< T, Fad::VectorDynamicStorage< T > >::value_type > type
Meta-function for determining concrete base expression.
Turn DVFad into a meta-function class usable with mpl::apply.
Meta-function for determining nesting with an expression.
Determine whether a given type is an expression.
Is a type an expression.
static const bool value
Sacado::Fad::ViewFad< ValueType, length, stride, Sacado::Fad::DVFad< ValueType > > type
Sacado::Fad::ViewFad< const ValueType, length, stride, Sacado::Fad::DVFad< const ValueType > > type
Get view type for any Fad type.