Sacado Package Browser (Single Doxygen Collection) Version of the Day
Loading...
Searching...
No Matches
Sacado_ELRFad_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_ELRFAD_GENERALFADEXPR_HPP
31#define SACADO_ELRFAD_GENERALFADEXPR_HPP
32
34
35namespace Sacado {
36
37 namespace ELRFad {
38
40
45 template <typename T, typename Storage>
46 class Expr< GeneralFad<T,Storage> > : public GeneralFad<T,Storage> {
47
48 public:
49
52
55
58
60 static const int num_args = 1;
61
63 static const bool is_linear = true;
64
67 Expr() :
68 GeneralFad<T,Storage>() {}
69
71
74 template <typename S>
77 GeneralFad<T,Storage>(x) {}
78
80
84 Expr(const int sz, const T & x, const DerivInit zero_out = InitDerivArray) :
85 GeneralFad<T,Storage>(sz,x,zero_out) {}
86
88
94 Expr(const int sz, const int i, const T & x) :
95 GeneralFad<T,Storage>(sz,i,x) {}
96
99 Expr(const Storage& s) :
100 GeneralFad<T,Storage>(s) {}
101
104 Expr(const Expr& x) :
105 GeneralFad<T,Storage>(static_cast<const GeneralFad<T,Storage>&>(x)) {}
106
108 template <typename S>
111 GeneralFad<T,Storage>(x) {}
112
115 ~Expr() {}
116
119 void computePartials(const T& bar, value_type partials[]) const {
120 partials[0] = bar;
121 }
122
125 void getTangents(int i, value_type dots[]) const {
126 if (i<this->size())
127 dots[0] = this->fastAccessDx(i);
128 else
129 dots[0] = 0.0;
130 }
131
133 template <int Arg>
135 bool isActive() const { return this->size() > 0; }
136
139 bool isActive2(int j) const { return this->size() > 0; }
140
143 bool isLinear() const { return true; }
144
146 template <int Arg>
148 const T& getTangent(int i) const { return this->fastAccessDx(i); }
149
152 const value_type* getDx(int j) const { return this->dx(); }
153
155 int numActiveArgs() const {
156 return this->size() > 0 ? 1 : 0;
157 }
158
161 void computeActivePartials(const T& bar, value_type *partials) const {
162 if (this->size() > 0)
163 partials[0] = bar;
164 }
165
166 }; // class Expr<GeneralFad>
167
168 } // namespace ELRFad
169
170} // namespace Sacado
171
172#include "Sacado_ELRFad_Ops.hpp"
173
174#endif // SACADO_ELRFAD_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
BaseExpr< GeneralFad< T, Storage > >::type base_expr_type
Typename of base-expressions.
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.
GeneralFad< T, Storage >::scalar_type scalar_type
Typename of scalar's (which may be different from value_type)
GeneralFad< T, Storage >::value_type value_type
Typename of values.
SACADO_INLINE_FUNCTION bool isActive2(int j) const
Return whether argument is active.
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 Storage &s)
Constructor with supplied storage s.
SACADO_INLINE_FUNCTION Expr()
Default constructor.
SACADO_INLINE_FUNCTION const T & getTangent(int i) const
Return tangent component i of argument Arg.
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 Expr< S > &x, SACADO_ENABLE_EXPR_CTOR_DECL)
Copy constructor from any Expression object.
SACADO_INLINE_FUNCTION void computeActivePartials(const T &bar, value_type *partials) const
Return partials w.r.t. arguments.
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.
SACADO_INLINE_FUNCTION Expr(const Expr &x)
Copy constructor.
SACADO_INLINE_FUNCTION Expr(const int sz, const T &x, const DerivInit zero_out=InitDerivArray)
Constructor with size sz and value x.
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.