Sacado Package Browser (Single Doxygen Collection)  Version of the Day
Sacado_Fad_DMFad.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_DMFAD_HPP
31 #define SACADO_FAD_DMFAD_HPP
32 
36 
37 namespace Sacado {
38 
39  namespace Fad {
40 
51  template <typename ValueT>
52  class DMFad : public Expr< GeneralFad<ValueT,MemPoolStorage<ValueT> > > {
53 
54  public:
55 
60 
62  typedef typename ExprType::value_type value_type;
63 
65  typedef typename ExprType::scalar_type scalar_type;
66 
69 
71  template <typename T>
72  struct apply {
73  typedef DMFad<T> type;
74  };
75 
80 
82 
85  DMFad() :
86  ExprType() {}
87 
89 
92  template <typename S>
94  ExprType(x) {}
95 
97 
100  DMFad(const int sz, const ValueT& x, const DerivInit zero_out = InitDerivArray) :
101  ExprType(sz,x,zero_out) {}
102 
104 
109  DMFad(const int sz, const int i, const ValueT & x) :
110  ExprType(sz,i,x) {}
111 
113  DMFad(const DMFad& x) :
114  ExprType(x) {}
115 
117  template <typename S>
119  ExprType(x) {}
120 
122 
124  ~DMFad() {}
125 
127  template <typename S>
128  SACADO_ENABLE_VALUE_FUNC(DMFad&) operator=(const S& v) {
129  GeneralFadType::operator=(v);
130  return *this;
131  }
132 
134  DMFad& operator=(const DMFad& x) {
135  GeneralFadType::operator=(static_cast<const GeneralFadType&>(x));
136  return *this;
137  }
138 
140  template <typename S>
141  SACADO_ENABLE_EXPR_FUNC(DMFad&) operator=(const Expr<S>& x)
142  {
143  GeneralFadType::operator=(x);
144  return *this;
145  }
146 
148  static void setDefaultPool(MemPool* pool) {
150  }
151 
153  template <typename S>
155  SACADO_ENABLE_VALUE_FUNC(DMFad&) operator += (const S& x) {
156  GeneralFadType::operator+=(x);
157  return *this;
158  }
159 
161  template <typename S>
163  SACADO_ENABLE_VALUE_FUNC(DMFad&) operator -= (const S& x) {
164  GeneralFadType::operator-=(x);
165  return *this;
166  }
167 
169  template <typename S>
171  SACADO_ENABLE_VALUE_FUNC(DMFad&) operator *= (const S& x) {
172  GeneralFadType::operator*=(x);
173  return *this;
174  }
175 
177  template <typename S>
179  SACADO_ENABLE_VALUE_FUNC(DMFad&) operator /= (const S& x) {
180  GeneralFadType::operator/=(x);
181  return *this;
182  }
183 
185  DMFad& operator += (const DMFad& x) {
186  GeneralFadType::operator+=(static_cast<const GeneralFadType&>(x));
187  return *this;
188  }
189 
191  DMFad& operator -= (const DMFad& x) {
192  GeneralFadType::operator-=(static_cast<const GeneralFadType&>(x));
193  return *this;
194  }
195 
197  DMFad& operator *= (const DMFad& x) {
198  GeneralFadType::operator*=(static_cast<const GeneralFadType&>(x));
199  return *this;
200  }
201 
203  DMFad& operator /= (const DMFad& x) {
204  GeneralFadType::operator/=(static_cast<const GeneralFadType&>(x));
205  return *this;
206  }
207 
209  template <typename S>
211  SACADO_ENABLE_EXPR_FUNC(DMFad&) operator += (const Expr<S>& x) {
212  GeneralFadType::operator+=(x);
213  return *this;
214  }
215 
217  template <typename S>
219  SACADO_ENABLE_EXPR_FUNC(DMFad&) operator -= (const Expr<S>& x) {
220  GeneralFadType::operator-=(x);
221  return *this;
222  }
223 
225  template <typename S>
227  SACADO_ENABLE_EXPR_FUNC(DMFad&) operator *= (const Expr<S>& x) {
228  GeneralFadType::operator*=(x);
229  return *this;
230  }
231 
233  template <typename S>
235  SACADO_ENABLE_EXPR_FUNC(DMFad&) operator /= (const Expr<S>& x) {
236  GeneralFadType::operator/=(x);
237  return *this;
238  }
239 
240  }; // class DMFad<ValueT>
241 
242  template <typename T>
243  struct BaseExpr< GeneralFad<T,Fad::MemPoolStorage<T> > > {
245  };
246 
247  template <typename T>
248  struct ExprLevel< DMFad<T> > {
249  static const unsigned value =
251  };
252 
253  template <typename T>
254  struct IsFadExpr< DMFad<T> > {
255  static const bool value = true;
256  };
257 
258  } // namespace Fad
259 
260  template <typename T>
261  struct IsExpr< Fad::DMFad<T> > {
262  static const bool value = true;
263  };
264 
265  template <typename T>
266  struct BaseExprType< Fad::DMFad<T> > {
268  };
269 
271  template< class ValueType, unsigned length, unsigned stride >
272  struct ViewFadType< Sacado::Fad::DMFad< ValueType >, length, stride > {
274  };
275 
277  template< class ValueType, unsigned length, unsigned stride >
278  struct ViewFadType< const Sacado::Fad::DMFad< ValueType >, length, stride > {
280  };
281 
282 } // namespace Sacado
283 
284 #endif // SACADO_FAD_DMFAD_HPP
Wrapper for a generic expression template.
ExprType::value_type value_type
Typename of values.
DMFad(const int sz, const int i, const ValueT &x)
Constructor with size sz, index i, and value x.
Turn DMFad into a meta-function class usable with mpl::apply.
Sacado::Fad::ViewFad< ValueType, length, stride, Sacado::Fad::DMFad< ValueType > > type
Expr< GeneralFadType > ExprType
#define SACADO_ENABLE_VALUE_CTOR_DECL
DMFad(const Expr< S > &x, SACADO_ENABLE_EXPR_CTOR_DECL)
Copy constructor from any Expression object.
Sacado::Fad::MemPool * defaultPool_
static const bool value
#define SACADO_ENABLE_EXPR_CTOR_DECL
Is a type an expression.
#define KOKKOS_INLINE_FUNCTION
#define T
Definition: Sacado_rad.hpp:573
Fad::DMFad< T >::base_expr_type type
MemPoolStorage< ValueT > StorageType
Base classes.
#define SACADO_ENABLE_VALUE_FUNC(RETURN_TYPE)
Determine whether a given type is an expression.
DMFad(const S &x, SACADO_ENABLE_VALUE_CTOR_DECL)
Constructor with supplied value x convertible to ValueT.
Meta-function for determining concrete base expression.
Derivative array storage class using dynamic memory allocation.
Get the base Fad type from a view/expression.
ExprType::scalar_type scalar_type
Typename of scalar&#39;s (which may be different from value_type)
#define SACADO_ENABLE_EXPR_FUNC(RETURN_TYPE)
Meta-function for determining nesting with an expression.
DerivInit
Enum use to signal whether the derivative array should be initialized in AD object constructors...
Sacado::Fad::ViewFad< const ValueType, length, stride, Sacado::Fad::DMFad< const ValueType > > type
DMFad(const DMFad &x)
Copy constructor.
static const unsigned value
Initialize the derivative array.
Forward-mode AD class using dynamic memory allocation and expression templates.
ScalarType< ValueT >::type ScalarT
Typename of scalar&#39;s (which may be different from ValueT)
DMFad(const int sz, const ValueT &x, const DerivInit zero_out=InitDerivArray)
Constructor with size sz and value x.
GeneralFad< ValueT, StorageType > GeneralFadType
DMFad< typename GeneralFad< T, Fad::MemPoolStorage< T > >::value_type > type
DMFad()
Default constructor.
Forward-mode AD class templated on the storage for the derivative array.
Get view type for any Fad type.