Sacado Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Sacado_ELRCacheFad_GeneralFadExpr.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_ELRCACHEFAD_GENERALFADEXPR_HPP
11 #define SACADO_ELRCACHEFAD_GENERALFADEXPR_HPP
12 
14 
15 namespace Sacado {
16 
17  namespace ELRCacheFad {
18 
20 
26  template <typename T, typename Storage>
27  class Expr< GeneralFad<T,Storage> > : public GeneralFad<T,Storage> {
28 
29  public:
30 
33 
36 
38  static const int num_args = 1;
39 
41  static const bool is_linear = true;
42 
45  Expr() :
46  GeneralFad<T,Storage>() {}
47 
49 
52  template <typename S>
55  GeneralFad<T,Storage>(x) {}
56 
58 
62  Expr(const int sz, const T & x, const DerivInit zero_out = InitDerivArray) :
63  GeneralFad<T,Storage>(sz,x,zero_out) {}
64 
66 
72  Expr(const int sz, const int i, const T & x) :
73  GeneralFad<T,Storage>(sz,i,x) {}
74 
77  Expr(const Storage& s) :
78  GeneralFad<T,Storage>(s) {}
79 
82  Expr(const Expr& x) :
83  GeneralFad<T,Storage>(static_cast<const GeneralFad<T,Storage>&>(x)) {}
84 
86  template <typename S>
89  GeneralFad<T,Storage>(x) {}
90 
93  ~Expr() {}
94 
97  void computePartials(const T& bar, value_type partials[]) const {
98  partials[0] = bar;
99  }
100 
103  void getTangents(int i, value_type dots[]) const {
104  if (i<this->size())
105  dots[0] = this->fastAccessDx(i);
106  else
107  dots[0] = 0.0;
108  }
109 
111  template <int Arg>
113  bool isActive() const { return this->size() > 0; }
114 
117  bool isLinear() const { return true; }
118 
120  template <int Arg>
122  T getTangent(int i) const { return this->fastAccessDx(i); }
123 
126  const value_type* getDx(int j) const { return this->dx(); }
127 
128  }; // class Expr<GeneralFad>
129 
130  } // namespace ELRCacheFad
131 
132 } // namespace Sacado
133 
135 
136 #endif // SACADO_ELRCACHEFAD_GENERALFADEXPR_HPP
SACADO_INLINE_FUNCTION Expr(const int sz, const T &x, const DerivInit zero_out=InitDerivArray)
Constructor with size sz and value x.
expr expr dx(i)
#define SACADO_ENABLE_VALUE_CTOR_DECL
SACADO_INLINE_FUNCTION bool isLinear() const
Return whether expression is linear.
SACADO_INLINE_FUNCTION Expr(const Expr< S > &x, SACADO_ENABLE_EXPR_CTOR_DECL)
Copy constructor from any Expression object.
RemoveConst< T >::type value_type
Typename of values.
expr bar
#define SACADO_ENABLE_EXPR_CTOR_DECL
SACADO_INLINE_FUNCTION Expr(const int sz, const int i, const T &x)
Constructor with size sz, index i, and value x.
SACADO_INLINE_FUNCTION Expr(const Expr &x)
Copy constructor.
SACADO_INLINE_FUNCTION bool isActive() const
Return whether argument is active.
Meta-function for determining concrete base expression.
SACADO_INLINE_FUNCTION const value_type * getDx(int j) const
Get dx array.
#define T
Definition: Sacado_rad.hpp:553
Wrapper for a generic expression template.
SACADO_INLINE_FUNCTION T getTangent(int i) const
Return tangent component i of argument Arg.
DerivInit
Enum use to signal whether the derivative array should be initialized in AD object constructors...
SACADO_INLINE_FUNCTION void getTangents(int i, value_type dots[]) const
Return tangent component i of arguments.
ScalarType< value_type >::type scalar_type
Typename of scalar&#39;s (which may be different from T)
expr expr expr fastAccessDx(i)) FAD_UNARYOP_MACRO(exp
Forward-mode AD class templated on the storage for the derivative array.
BaseExpr< GeneralFad< T, Storage > >::type base_expr_type
Typename of base-expressions.
Initialize the derivative array.
#define SACADO_INLINE_FUNCTION
SACADO_INLINE_FUNCTION Expr(const S &x, SACADO_ENABLE_VALUE_CTOR_DECL)
Constructor with supplied value x.
SACADO_INLINE_FUNCTION Expr(const Storage &s)
Constructor with supplied storage s.
SACADO_INLINE_FUNCTION void computePartials(const T &bar, value_type partials[]) const
Return partials w.r.t. arguments.