38#include "../expressions/aggregate/aggregatedActiveType.hpp"
39#include "../expressions/aggregate/arrayAccessExpression.hpp"
40#include "../expressions/lhsExpressionInterface.hpp"
41#include "../expressions/logic/helpers/jacobianComputationLogic.hpp"
43#include "../traits/expressionTraits.hpp"
44#include "../traits/realTraits.hpp"
45#include "../traits/tapeTraits.hpp"
46#include "interfaces/gradientAccessTapeInterface.hpp"
47#include "interfaces/internalStatementRecordingTapeInterface.hpp"
72 template<
typename T_Real,
typename T_Gradient>
90 template<
typename Real>
97 template<
typename Real>
108 template<
typename Node>
109 CODI_INLINE void handleJacobianOnActive(Node
const&
node, Real jacobian, Gradient& lhsGradient) {
111 lhsGradient +=
node.gradient() * jacobian;
121 template<
typename Lhs,
typename Rhs>
124 LocalReverseLogic reversal;
127 reversal.eval(rhs.
cast(), 1.0, newGradient);
129 lhs.
cast().value() = rhs.
cast().getValue();
130 lhs.
cast().gradient() = newGradient;
135 template<
typename Aggregated,
typename Type,
typename Lhs,
typename Rhs>
139 int constexpr Elements = AggregatedTraits::Elements;
140 LocalReverseLogic reversal;
142 Gradient newGradient[Elements] = {};
147 Aggregated newValue = rhs.
cast().getValue();
149 lhs.
values[i.value].value() = AggregatedTraits::template arrayAccess<i.value>(newValue);
150 lhs.
values[i.value].gradient() = newGradient[i.value];
156 template<
typename Lhs,
typename Rhs>
159 lhs.
cast().value() = rhs.
cast().getValue();
160 lhs.
cast().gradient() = rhs.
cast().getGradient();
165 template<
typename Lhs>
167 lhs.
cast().value() = rhs;
229 template<
typename T_Type>
246 template<
typename T_Type>
253 using Real =
typename Type::Real;
258 return Real() == v.getValue() &&
typename Type::Gradient() == v.getGradient();
#define CODI_LAMBDA_INLINE
See codi::Config::ForcedInlines.
Definition config.h:473
#define CODI_INLINE
See codi::Config::ForcedInlines.
Definition config.h:469
#define CODI_DD(Type, Default)
Abbreviation for CODI_DECLARE_DEFAULT.
Definition macros.hpp:96
#define CODI_ENABLE_CHECK(option, condition)
Definition macros.hpp:61
#define CODI_T(...)
Abbreviation for CODI_TEMPLATE.
Definition macros.hpp:116
bool constexpr IgnoreInvalidJacobians
Ignore invalid Jacobians like NaN or Inf.
Definition config.h:240
inlinebool isTotalFinite(Type const &v)
Function for checking if all values of the type are finite.
Definition realTraits.hpp:139
typename TraitsImplementation< Type >::Real Real
Inner type of the real value.
Definition realTraits.hpp:119
typename TraitsImplementation< Type >::PassiveReal PassiveReal
The original computation type that was used in the application.
Definition realTraits.hpp:123
Definition tapeTraits.hpp:63
CoDiPack - Code Differentiation Package.
Definition codi.hpp:94
inlinevoid static_for(F func, Args &&... args)
Static for with i = 0 .. (N - 1). See CompileTimeLoop for details.
Definition compileTimeLoop.hpp:110
typename ArrayAccessExpressionImpl< Aggregated, element >::template Expression< Arg > ArrayAccessExpression
Expression that performs a[element] in a compile time context.
Definition arrayAccessExpression.hpp:98
inlinevoid CODI_UNUSED(Args const &...)
Disable unused warnings for an arbitrary number of arguments.
Definition macros.hpp:54
AdjointsManagement
Policies for management of the tape's interal adjoints.
Definition tapeParameters.hpp:100
@ Automatic
Manage internal adjoints automatically, including locking, bounds checking, and resizing.
Definition tapeParameters.hpp:102
InnerActiveType values[Elements]
Array representation.
Definition aggregatedActiveType.hpp:75
Represents a concrete aggregated lvalue int the CoDiPack expression tree.
Definition aggregatedActiveType.hpp:164
Base class for all CoDiPack expressions.
Definition expressionInterface.hpp:60
inlineImpl const & cast() const
Cast to the implementation.
Definition expressionInterface.hpp:76
Implementation of a tape-free forward AD mode through the internal expression interfaces.
Definition forwardEvaluation.hpp:74
T_Gradient Gradient
See ForwardEvaluation.
Definition forwardEvaluation.hpp:78
inlinevoid setGradient(Identifier &identifier, Gradient const &gradient, AdjointsManagement adjointsManagement=AdjointsManagement::Automatic)
Set the gradient.
Definition forwardEvaluation.hpp:179
RealTraits::PassiveReal< Real > PassiveReal
Basic computation type.
Definition forwardEvaluation.hpp:80
inlineGradient const & getGradient(Identifier const &identifier, AdjointsManagement adjointsManagement=AdjointsManagement::Automatic) const
Set the gradient.
Definition forwardEvaluation.hpp:188
inlinevoid store(AggregatedActiveType< Aggregated, Type, Lhs > &lhs, ExpressionInterface< Aggregated, Rhs > const &rhs)
Has to be called by an AD variable every time it is assigned.
Definition forwardEvaluation.hpp:136
inlinevoid store(LhsExpressionInterface< Real, Gradient, ForwardEvaluation, Lhs > &lhs, ExpressionInterface< Real, Rhs > const &rhs)
Has to be called by an AD variable every time it is assigned.
Definition forwardEvaluation.hpp:122
T_Real Real
See ForwardEvaluation.
Definition forwardEvaluation.hpp:77
inlinevoid initIdentifier(Real &value, Identifier &identifier)
Definition forwardEvaluation.hpp:91
inlineGradient & gradient(Identifier &identifier, AdjointsManagement adjointsManagement=AdjointsManagement::Automatic)
Reference access to gradient.
Definition forwardEvaluation.hpp:197
static bool constexpr AllowJacobianOptimization
See InternalStatementRecordingTapeInterface.
Definition forwardEvaluation.hpp:87
inlinevoid destroyIdentifier(Real &value, Identifier &identifier)
Has to be called for each identifier, before it is deallocated.
Definition forwardEvaluation.hpp:98
inlinevoid store(LhsExpressionInterface< Real, Gradient, ForwardEvaluation, Lhs > &lhs, Real const &rhs)
Has to be called by an AD variable every time it is assigned.
Definition forwardEvaluation.hpp:166
inlineGradient const & gradient(Identifier const &identifier, AdjointsManagement adjointsManagement=AdjointsManagement::Automatic) const
Constant reference access to gradient.
Definition forwardEvaluation.hpp:206
Gradient Identifier
Same as the gradient type. Tangent data is stored in the active types.
Definition forwardEvaluation.hpp:81
inlinevoid store(LhsExpressionInterface< Real, Gradient, ForwardEvaluation, Lhs > &lhs, LhsExpressionInterface< Real, Gradient, ForwardEvaluation, Rhs > const &rhs)
Has to be called by an AD variable every time it is assigned.
Definition forwardEvaluation.hpp:157
Allow for a direct access to the gradient information computed by the tape.
Definition gradientAccessTapeInterface.hpp:67
Internal tape interface that is used by active types to trigger the storing of an expression.
Definition internalStatementRecordingTapeInterface.hpp:65
Definition jacobianComputationLogic.hpp:54
Base class for all CoDiPack lvalue expression.
Definition lhsExpressionInterface.hpp:63
inlineImpl & cast()
Cast to the implementation.
Definition lhsExpressionInterface.hpp:99
Methods that access inner values of aggregated types that contain CoDiPack active types.
Definition realTraits.hpp:226
T_Type Type
See RealTraits::IsTotalFinite.
Definition forwardEvaluation.hpp:233
static inlinebool isTotalFinite(Type const &v)
Checks if the values are all finite.
Definition forwardEvaluation.hpp:238
Function for checking if all values of the type are finite.
Definition realTraits.hpp:88
static inlinebool isTotalZero(Type const &v)
Checks if the values are completely zero.
Definition forwardEvaluation.hpp:257
T_Type Type
See RealTraits::IsTotalZero.
Definition forwardEvaluation.hpp:250
typename Type::Real Real
Definition forwardEvaluation.hpp:253
Function for checking if the value of the type is completely zero.
Definition realTraits.hpp:106
inlinevoid node(Node const &node, Args &&... args)
Definition traversalLogic.hpp:87