Sacado Package Browser (Single Doxygen Collection) Version of the Day
Loading...
Searching...
No Matches
Sacado_ELRCacheFad_GeneralFadExpr.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_ELRCACHEFAD_GENERALFADEXPR_HPP
31#define SACADO_ELRCACHEFAD_GENERALFADEXPR_HPP
32
34
35namespace Sacado {
36
37 namespace ELRCacheFad {
38
40
46 template <typename T, typename Storage>
47 class Expr< GeneralFad<T,Storage> > : public GeneralFad<T,Storage> {
48
49 public:
50
53
56
58 static const int num_args = 1;
59
61 static const bool is_linear = true;
62
65 Expr() :
66 GeneralFad<T,Storage>() {}
67
69
72 template <typename S>
75 GeneralFad<T,Storage>(x) {}
76
78
82 Expr(const int sz, const T & x, const DerivInit zero_out = InitDerivArray) :
83 GeneralFad<T,Storage>(sz,x,zero_out) {}
84
86
92 Expr(const int sz, const int i, const T & x) :
93 GeneralFad<T,Storage>(sz,i,x) {}
94
97 Expr(const Storage& s) :
98 GeneralFad<T,Storage>(s) {}
99
102 Expr(const Expr& x) :
103 GeneralFad<T,Storage>(static_cast<const GeneralFad<T,Storage>&>(x)) {}
104
106 template <typename S>
109 GeneralFad<T,Storage>(x) {}
110
113 ~Expr() {}
114
117 void computePartials(const T& bar, value_type partials[]) const {
118 partials[0] = bar;
119 }
120
123 void getTangents(int i, value_type dots[]) const {
124 if (i<this->size())
125 dots[0] = this->fastAccessDx(i);
126 else
127 dots[0] = 0.0;
128 }
129
131 template <int Arg>
133 bool isActive() const { return this->size() > 0; }
134
137 bool isLinear() const { return true; }
138
140 template <int Arg>
142 T getTangent(int i) const { return this->fastAccessDx(i); }
143
146 const value_type* getDx(int j) const { return this->dx(); }
147
148 }; // class Expr<GeneralFad>
149
150 } // namespace ELRCacheFad
151
152} // namespace Sacado
153
155
156#endif // SACADO_ELRCACHEFAD_GENERALFADEXPR_HPP
#define SACADO_INLINE_FUNCTION
expr expr dx(i)
expr expr expr fastAccessDx(i)) FAD_UNARYOP_MACRO(exp
#define SACADO_ENABLE_VALUE_CTOR_DECL
#define SACADO_ENABLE_EXPR_CTOR_DECL
SACADO_INLINE_FUNCTION Expr(const Expr< S > &x, SACADO_ENABLE_EXPR_CTOR_DECL)
Copy constructor from any Expression object.
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.
SACADO_INLINE_FUNCTION Expr(const S &x, SACADO_ENABLE_VALUE_CTOR_DECL)
Constructor with supplied value x.
BaseExpr< GeneralFad< T, Storage > >::type base_expr_type
Typename of base-expressions.
SACADO_INLINE_FUNCTION const value_type * getDx(int j) const
Get dx array.
SACADO_INLINE_FUNCTION void computePartials(const T &bar, value_type partials[]) const
Return partials w.r.t. arguments.
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 T getTangent(int i) const
Return tangent component i of argument Arg.
SACADO_INLINE_FUNCTION void getTangents(int i, value_type dots[]) const
Return tangent component i of arguments.
SACADO_INLINE_FUNCTION bool isLinear() const
Return whether expression is linear.
SACADO_INLINE_FUNCTION Expr(const Storage &s)
Constructor with supplied storage s.
Wrapper for a generic expression template.
Forward-mode AD class templated on the storage for the derivative array.
ScalarType< value_type >::type scalar_type
Typename of scalar's (which may be different from T)
RemoveConst< T >::type value_type
Typename of values.
DerivInit
Enum use to signal whether the derivative array should be initialized in AD object constructors.
@ InitDerivArray
Initialize the derivative array.
Meta-function for determining concrete base expression.