38#include "../misc/eventSystem.hpp"
40#include "../misc/toConst.hpp"
41#include "../tapes/interfaces/fullTapeInterface.hpp"
42#include "../traits/expressionTraits.hpp"
43#include "../traits/realTraits.hpp"
44#include "expressionInterface.hpp"
62 template<
typename T_Real,
typename T_Gradient,
typename T_Tape,
typename T_Impl>
100 return static_cast<Impl&
>(*this);
116 return cast().gradient();
121 cast().gradient() = g;
126 return cast().value();
137 rhs, EventHints::Statement::Passive);
138 Impl::getTape().store(
cast(), rhs);
143 template<
typename U = Real,
typename = RealTraits::EnableIfNotPassiveReal<U>>
146 rhs, EventHints::Statement::Passive);
147 Impl::getTape().store(
cast(), rhs);
152 template<
typename Rhs>
155 rhs.
cast().getValue(), EventHints::Statement::Expression);
156 Impl::getTape().store(
cast(), rhs.
cast());
161 template<
typename Rhs,
typename U = Real,
typename = RealTraits::EnableIfNotPassiveReal<U>>
164 rhs.
cast().getValue(), EventHints::Statement::Passive);
165 Impl::getTape().store(
cast(),
Real(rhs));
172 rhs.
cast().getValue(), EventHints::Statement::Copy);
173 Impl::getTape().store(
cast(), rhs);
178 template<
typename Rhs>
181 rhs.
cast().getValue(), EventHints::Statement::Copy);
182 Impl::getTape().store(
cast(), rhs);
215 template<
typename Expr>
217 typename Expr::Real temp;
225#ifndef DOXYGEN_DISABLE
228 template<
typename T_Type>
229 struct RealTraits::DataExtraction<T_Type, ExpressionTraits::EnableIfLhsExpression<T_Type>> {
231 using Type =
CODI_DD(T_Type, CODI_DEFAULT_LHS_EXPRESSION);
233 using Real =
typename Type::Real;
234 using Identifier =
typename Type::Identifier;
243 return v.getIdentifier();
253 v.getIdentifier() = identifier;
258 template<
typename T_Type>
260 using Type =
CODI_DD(T_Type, CODI_DEFAULT_LHS_EXPRESSION);
266 Type::getTape().registerInput(v);
271 Type::getTape().registerOutput(v);
276 return Type::getTape().registerExternalFunctionOutput(v);
281 template<
typename T_Type>
#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
Statement
Classify statements.
Definition eventSystem.hpp:65
Traits for everything that can be an expression e.g. codi::RealReverse, a + b, etc....
Definition expressionTraits.hpp:65
typename std::enable_if< IsLhsExpression< Expr >::value, T >::type EnableIfLhsExpression
Enable if wrapper for IsLhsExpression.
Definition expressionTraits.hpp:183
typename TraitsImplementation< Type >::PassiveReal PassiveReal
The original computation type that was used in the application.
Definition realTraits.hpp:123
CoDiPack - Code Differentiation Package.
Definition codi.hpp:94
ExpressionTraits::EnableIfLhsExpression< Expr, std::istream > & operator>>(std::istream &stream, Expr &v)
Read the primal value from a stream.
Definition lhsExpressionInterface.hpp:216
inlineT const toConst(T &&v)
Constant cast function that works with CUDA.
Definition toConst.hpp:47
static inlinevoid notifyStatementPrimalListeners(Tape &tape, Real const &lhsValue, Identifier const &lhsIdentifier, Real const &newValue, EventHints::Statement statement)
Invoke callbacks for StatementPrimal events.
Definition eventSystem.hpp:264
ExpressionInterface()=default
Constructor.
inlineImpl const & cast() const
Cast to the implementation.
Definition expressionInterface.hpp:76
Identifier & getIdentifier()
Real & value()
Get a reference to the lvalue represented by the expression.
inlineImpl & operator=(Real const &rhs)
Assignment operator for passive values. Calls store on the InternalStatementRecordingTapeInterface.
Definition lhsExpressionInterface.hpp:135
LhsExpressionInterface(LhsExpressionInterface const &other)=default
Constructor.
inlineGradient & gradient()
Get the gradient of this lvalue from the tape.
Definition lhsExpressionInterface.hpp:105
inlinevoid setGradient(Gradient const &g)
Set the gradient of this lvalue in the tape.
Definition lhsExpressionInterface.hpp:120
Real const & value() const
Get a constant reference to the lvalue represented by the expression.
inlineImpl & operator=(LhsExpressionInterface< Real, Gradient, Tape, Rhs > const &rhs)
Assignment operator for lhs expressions. Calls store on the InternalStatementRecordingTapeInterface.
Definition lhsExpressionInterface.hpp:179
static size_t constexpr LinkCount
Definition lhsExpressionInterface.hpp:191
RealTraits::PassiveReal< Real > PassiveReal
Definition lhsExpressionInterface.hpp:74
typename Tape::Identifier Identifier
Definition lhsExpressionInterface.hpp:73
inlineImpl & operator=(LhsExpressionInterface const &rhs)
Assignment operator for lhs expressions. Calls store on the InternalStatementRecordingTapeInterface.
Definition lhsExpressionInterface.hpp:170
Real Real
Definition lhsExpressionInterface.hpp:66
LhsExpressionInterface()=default
Constructor.
T_Tape Tape
Definition lhsExpressionInterface.hpp:68
inlineImpl & operator=(ExpressionInterface< Real, Rhs > const &rhs)
Assignment operator for expressions. Calls store on the InternalStatementRecordingTapeInterface.
Definition lhsExpressionInterface.hpp:153
ExpressionInterface< Real, T_Impl > Base
Definition lhsExpressionInterface.hpp:71
inlineGradient const & gradient() const
Get the gradient of this lvalue from the tape.
Definition lhsExpressionInterface.hpp:110
inlinevoid init(Real const &newValue, EventHints::Statement statementType)
Definition lhsExpressionInterface.hpp:198
Identifier const & getIdentifier() const
inlineImpl & operator=(PassiveReal const &rhs)
Assignment operator for passive values. Calls store on the InternalStatementRecordingTapeInterface.
Definition lhsExpressionInterface.hpp:144
inlineGradient getGradient() const
Get the gradient of this lvalue from the tape.
Definition lhsExpressionInterface.hpp:115
Gradient Gradient
Definition lhsExpressionInterface.hpp:67
static Tape & getTape()
Get a reference to the tape which manages this expression.
inlinevoid setValue(Real const &v)
Set the primal value of this lvalue.
Definition lhsExpressionInterface.hpp:130
inlineReal const & getValue() const
Get the primal value of this lvalue.
Definition lhsExpressionInterface.hpp:125
T_Impl Impl
Definition lhsExpressionInterface.hpp:69
inlineImpl & cast()
Cast to the implementation.
Definition lhsExpressionInterface.hpp:99
inlineImpl & operator=(ExpressionInterface< typename U::Real, Rhs > const &rhs)
Assignment operator for expressions. Calls store on the InternalStatementRecordingTapeInterface.
Definition lhsExpressionInterface.hpp:162
inlinevoid destroy()
Definition lhsExpressionInterface.hpp:207
Methods that access inner values of aggregated types that contain CoDiPack active types.
Definition realTraits.hpp:226
static inlinestd::string getMathRep()
Get the math symbol of the operation. E.g. + for operators and pow() for functions.
Definition realTraits.hpp:291
Base implementation of AggregatedTypeTraits for aggregated types that can be defined as an array.
Definition realTraits.hpp:301
Tape registration methods for aggregated types that contain CoDiPack active types.
Definition realTraits.hpp:197
T_Type Type
See TapeRegistration.
Definition realTraits.hpp:202
inlinestatic void registerInput(Type &v)
Register all active types of an aggregated type as tape inputs.
inlinestatic void registerOutput(Type &v)
Register all active types of an aggregated type as tape outputs.
typename DataExtraction< Type >::Real Real
See DataExtraction::Real.
Definition realTraits.hpp:204
inlinestatic Real registerExternalFunctionOutput(Type &v)
Register all active types of an aggregated type as external function outputs.