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>
91 template<
typename Real>
98 template<
typename Real>
109 template<
typename Node>
110 CODI_INLINE void handleJacobianOnActive(Node
const&
node, Real jacobian, Gradient& lhsGradient) {
112 lhsGradient +=
node.gradient() * jacobian;
122 template<
typename Lhs,
typename Rhs>
125 LocalReverseLogic reversal;
128 reversal.eval(rhs.
cast(), 1.0, newGradient);
130 lhs.
cast().value() = rhs.
cast().getValue();
131 lhs.
cast().gradient() = newGradient;
136 template<
typename Aggregated,
typename Type,
typename Lhs,
typename Rhs>
140 int constexpr Elements = AggregatedTraits::Elements;
141 LocalReverseLogic reversal;
143 Gradient newGradient[Elements] = {};
148 Aggregated newValue = rhs.
cast().getValue();
150 lhs.
values[i.value].value() = AggregatedTraits::template arrayAccess<i.value>(newValue);
151 lhs.
values[i.value].gradient() = newGradient[i.value];
157 template<
typename Lhs,
typename Rhs>
160 lhs.
cast().value() = rhs.
cast().getValue();
161 lhs.
cast().gradient() = rhs.
cast().getGradient();
166 template<
typename Lhs>
168 lhs.
cast().value() = rhs;
244 template<
typename T_Type>
261 template<
typename T_Type>
268 using Real =
typename Type::Real;
273 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:97
#define CODI_ENABLE_CHECK(option, condition)
Definition macros.hpp:62
#define CODI_T(...)
Abbreviation for CODI_TEMPLATE.
Definition macros.hpp:117
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:97
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:55
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:180
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:189
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:137
inlineIdentifier & getIdentifier(ActiveTypeTapeData &data)
Definition forwardEvaluation.hpp:223
inlinevoid destroyTapeData(Real &value, ActiveTypeTapeData &data)
Has to be called for each tape data, before it is deallocated.
Definition forwardEvaluation.hpp:99
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:123
T_Real Real
See ForwardEvaluation.
Definition forwardEvaluation.hpp:77
inlineGradient & gradient(Identifier &identifier, AdjointsManagement adjointsManagement=AdjointsManagement::Automatic)
Reference access to gradient.
Definition forwardEvaluation.hpp:198
static bool constexpr AllowJacobianOptimization
See InternalStatementRecordingTapeInterface.
Definition forwardEvaluation.hpp:88
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:167
Gradient ActiveTypeTapeData
Same as the gradient type. Tangent data is stored in the active types.
Definition forwardEvaluation.hpp:82
inlineGradient const & gradient(Identifier const &identifier, AdjointsManagement adjointsManagement=AdjointsManagement::Automatic) const
Constant reference access to gradient.
Definition forwardEvaluation.hpp:207
Gradient Identifier
Same as the gradient type. Tangent data is stored in the active types.
Definition forwardEvaluation.hpp:81
inlineIdentifier const & getIdentifier(ActiveTypeTapeData const &data)
Definition forwardEvaluation.hpp:218
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:158
inlinevoid initTapeData(Real &value, ActiveTypeTapeData &data)
< Has to be called for each tape data, after it is allocated.
Definition forwardEvaluation.hpp:92
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:66
Definition jacobianComputationLogic.hpp:54
Base class for all CoDiPack lvalue expression.
Definition lhsExpressionInterface.hpp:63
inlineImpl & cast()
Cast to the implementation.
Definition lhsExpressionInterface.hpp:103
Methods that access inner values of aggregated types that contain CoDiPack active types.
Definition realTraits.hpp:233
T_Type Type
See RealTraits::IsTotalFinite.
Definition forwardEvaluation.hpp:248
static inlinebool isTotalFinite(Type const &v)
Checks if the values are all finite.
Definition forwardEvaluation.hpp:253
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:272
T_Type Type
See RealTraits::IsTotalZero.
Definition forwardEvaluation.hpp:265
typename Type::Real Real
Definition forwardEvaluation.hpp:268
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