Sacado Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Sacado_ELRFad_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_ELRFAD_GENERALFADEXPR_HPP
11 #define SACADO_ELRFAD_GENERALFADEXPR_HPP
12 
14 
15 namespace Sacado {
16 
17  namespace ELRFad {
18 
20 
25  template <typename T, typename Storage>
26  class Expr< GeneralFad<T,Storage> > : public GeneralFad<T,Storage> {
27 
28  public:
29 
32 
35 
38 
40  static const int num_args = 1;
41 
43  static const bool is_linear = true;
44 
47  Expr() :
48  GeneralFad<T,Storage>() {}
49 
51 
54  template <typename S>
57  GeneralFad<T,Storage>(x) {}
58 
60 
64  Expr(const int sz, const T & x, const DerivInit zero_out = InitDerivArray) :
65  GeneralFad<T,Storage>(sz,x,zero_out) {}
66 
68 
74  Expr(const int sz, const int i, const T & x) :
75  GeneralFad<T,Storage>(sz,i,x) {}
76 
79  Expr(const Storage& s) :
80  GeneralFad<T,Storage>(s) {}
81 
84  Expr(const Expr& x) :
85  GeneralFad<T,Storage>(static_cast<const GeneralFad<T,Storage>&>(x)) {}
86 
88  template <typename S>
91  GeneralFad<T,Storage>(x) {}
92 
95  ~Expr() {}
96 
99  void computePartials(const T& bar, value_type partials[]) const {
100  partials[0] = bar;
101  }
102 
105  void getTangents(int i, value_type dots[]) const {
106  if (i<this->size())
107  dots[0] = this->fastAccessDx(i);
108  else
109  dots[0] = 0.0;
110  }
111 
113  template <int Arg>
115  bool isActive() const { return this->size() > 0; }
116 
119  bool isActive2(int j) const { return this->size() > 0; }
120 
123  bool isLinear() const { return true; }
124 
126  template <int Arg>
128  const T& getTangent(int i) const { return this->fastAccessDx(i); }
129 
132  const value_type* getDx(int j) const { return this->dx(); }
133 
135  int numActiveArgs() const {
136  return this->size() > 0 ? 1 : 0;
137  }
138 
141  void computeActivePartials(const T& bar, value_type *partials) const {
142  if (this->size() > 0)
143  partials[0] = bar;
144  }
145 
146  }; // class Expr<GeneralFad>
147 
148  } // namespace ELRFad
149 
150 } // namespace Sacado
151 
152 #include "Sacado_ELRFad_Ops.hpp"
153 
154 #endif // SACADO_ELRFAD_GENERALFADEXPR_HPP
RemoveConst< T >::type value_type
Typename of values.
expr expr dx(i)
SACADO_INLINE_FUNCTION Expr(const Expr &x)
Copy constructor.
#define SACADO_ENABLE_VALUE_CTOR_DECL
SACADO_INLINE_FUNCTION Expr(const Storage &s)
Constructor with supplied storage s.
SACADO_INLINE_FUNCTION bool isActive2(int j) const
Return whether argument is active.
SACADO_INLINE_FUNCTION bool isLinear() const
Return whether expression is linear.
expr bar
#define SACADO_ENABLE_EXPR_CTOR_DECL
GeneralFad< T, Storage >::scalar_type scalar_type
Typename of scalar&#39;s (which may be different from value_type)
SACADO_INLINE_FUNCTION void computeActivePartials(const T &bar, value_type *partials) const
Return partials w.r.t. arguments.
#define T
Definition: Sacado_rad.hpp:553
BaseExpr< GeneralFad< T, Storage > >::type base_expr_type
Typename of base-expressions.
SACADO_INLINE_FUNCTION void computePartials(const T &bar, value_type partials[]) const
Return partials w.r.t. arguments.
SACADO_INLINE_FUNCTION void getTangents(int i, value_type dots[]) const
Return tangent component i of arguments.
SACADO_INLINE_FUNCTION bool isActive() const
Return whether argument is active.
SACADO_INLINE_FUNCTION const value_type * getDx(int j) const
Get dx array.
SACADO_INLINE_FUNCTION Expr(const S &x, SACADO_ENABLE_VALUE_CTOR_DECL)
Constructor with supplied value x.
SACADO_INLINE_FUNCTION Expr(const int sz, const T &x, const DerivInit zero_out=InitDerivArray)
Constructor with size sz and value x.
SACADO_INLINE_FUNCTION Expr(const int sz, const int i, const T &x)
Constructor with size sz, index i, and value x.
DerivInit
Enum use to signal whether the derivative array should be initialized in AD object constructors...
Forward-mode AD class templated on the storage for the derivative array.
Wrapper for a generic expression template.
expr expr expr fastAccessDx(i)) FAD_UNARYOP_MACRO(exp
Meta-function for determining concrete base expression.
SACADO_INLINE_FUNCTION const T & getTangent(int i) const
Return tangent component i of argument Arg.
SACADO_INLINE_FUNCTION Expr()
Default constructor.
Initialize the derivative array.
SACADO_INLINE_FUNCTION Expr(const Expr< S > &x, SACADO_ENABLE_EXPR_CTOR_DECL)
Copy constructor from any Expression object.
#define SACADO_INLINE_FUNCTION
ScalarType< value_type >::type scalar_type
Typename of scalar&#39;s (which may be different from T)
GeneralFad< T, Storage >::value_type value_type
Typename of values.