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);
194 template<
typename Logic,
typename... Args>
200 template<
typename Logic,
typename... Args>
202 return Logic::NeutralElement;
227 template<
typename Expr>
229 typename Expr::Real temp;
237#ifndef DOXYGEN_DISABLE
240 template<
typename T_Type>
241 struct RealTraits::DataExtraction<T_Type, ExpressionTraits::EnableIfLhsExpression<T_Type>> {
243 using Type =
CODI_DD(T_Type, CODI_DEFAULT_LHS_EXPRESSION);
245 using Real =
typename Type::Real;
246 using Identifier =
typename Type::Identifier;
255 return v.getIdentifier();
265 template<
typename T_Type>
267 using Type =
CODI_DD(T_Type, CODI_DEFAULT_LHS_EXPRESSION);
273 Type::getTape().registerInput(v);
278 Type::getTape().registerOutput(v);
283 return Type::getTape().registerExternalFunctionOutput(v);
#define CODI_INLINE
See codi::Config::ForcedInlines.
Definition config.h:457
#define CODI_DD(Type, Default)
Abbreviation for CODI_DECLARE_DEFAULT.
Definition macros.hpp:94
#define CODI_UNUSED_ARG(arg)
Used in a constexpr context, where using CODI_UNUSED spoils the constexpr.
Definition macros.hpp:49
Statement
Classify statements.
Definition eventSystem.hpp:65
typename std::enable_if< IsLhsExpression< Expr >::value, T >::type EnableIfLhsExpression
Enable if wrapper for IsLhsExpression.
Definition expressionTraits.hpp:137
typename TraitsImplementation< Type >::PassiveReal PassiveReal
The original computation type, that was used in the application.
Definition realTraits.hpp:117
CoDiPack - Code Differentiation Package.
Definition codi.hpp:90
void CODI_UNUSED(Args const &...)
Disable unused warnings for an arbitrary number of arguments.
Definition macros.hpp:46
ExpressionTraits::EnableIfLhsExpression< Expr, std::istream > & operator>>(std::istream &stream, Expr &v)
Read the primal value from a stream.
Definition lhsExpressionInterface.hpp:228
T const toConst(T &&v)
Constant cast function that works with CUDA.
Definition toConst.hpp:47
Represents a concrete lvalue in the CoDiPack expression tree.
Definition activeType.hpp:52
static void notifyStatementPrimalListeners(Tape &tape, Real const &lhsValue, Identifier const &lhsIdentifier, Real const &newValue, EventHints::Statement statement)
Invoke callbacks for StatementPrimal events.
Definition eventSystem.hpp:264
Base class for all CoDiPack expressions.
Definition expressionInterface.hpp:59
Impl const & cast() const
Cast to the implementation.
Definition expressionInterface.hpp:75
Base class for all CoDiPack lvalue expression.
Definition lhsExpressionInterface.hpp:63
Identifier & getIdentifier()
static Logic::ResultType constexpr forEachLinkConstExpr(Args &&...)
Definition lhsExpressionInterface.hpp:201
Real & value()
Get a reference to the lvalue represented by the expression.
LhsExpressionInterface(LhsExpressionInterface const &other)=default
Constructor.
Real const & value() const
Get a constant reference to the lvalue represented by the expression.
Impl & operator=(LhsExpressionInterface< Real, Gradient, Tape, Rhs > const &rhs)
Assignment operator for lhs expressions. Calls store on the InternalStatementRecordingTapeInterface.
Definition lhsExpressionInterface.hpp:179
Impl & operator=(ExpressionInterface< Real, Rhs > const &rhs)
Assignment operator for expressions. Calls store on the InternalStatementRecordingTapeInterface.
Definition lhsExpressionInterface.hpp:153
RealTraits::PassiveReal< Real > PassiveReal
Basic computation type.
Definition lhsExpressionInterface.hpp:74
void setValue(Real const &v)
Set the primal value of this lvalue.
Definition lhsExpressionInterface.hpp:130
typename Tape::Identifier Identifier
See GradientAccessTapeInterface.
Definition lhsExpressionInterface.hpp:73
void setGradient(Gradient const &g)
Set the gradient of this lvalue in the tape.
Definition lhsExpressionInterface.hpp:120
Gradient const & gradient() const
Get the gradient of this lvalue from the tape.
Definition lhsExpressionInterface.hpp:110
Gradient & gradient()
Get the gradient of this lvalue from the tape.
Definition lhsExpressionInterface.hpp:105
T_Real Real
See LhsExpressionInterface.
Definition lhsExpressionInterface.hpp:66
Impl & operator=(PassiveReal const &rhs)
Assignment operator for passive values. Calls store on the InternalStatementRecordingTapeInterface.
Definition lhsExpressionInterface.hpp:144
static bool constexpr EndPoint
If this expression is handled as a leaf in the tree.
Definition lhsExpressionInterface.hpp:191
LhsExpressionInterface()=default
Constructor.
Impl & operator=(LhsExpressionInterface const &rhs)
Assignment operator for lhs expressions. Calls store on the InternalStatementRecordingTapeInterface.
Definition lhsExpressionInterface.hpp:170
T_Tape Tape
See LhsExpressionInterface.
Definition lhsExpressionInterface.hpp:68
Real const & getValue() const
Get the primal value of this lvalue.
Definition lhsExpressionInterface.hpp:125
Gradient getGradient() const
Get the gradient of this lvalue from the tape.
Definition lhsExpressionInterface.hpp:115
void destroy()
Definition lhsExpressionInterface.hpp:219
Identifier const & getIdentifier() const
void forEachLink(TraversalLogic< Logic > &logic, Args &&... args) const
Definition lhsExpressionInterface.hpp:195
T_Gradient Gradient
See LhsExpressionInterface.
Definition lhsExpressionInterface.hpp:67
static Tape & getTape()
Get a reference to the tape which manages this expression.
Impl & cast()
Cast to the implementation.
Definition lhsExpressionInterface.hpp:99
Impl & operator=(Real const &rhs)
Assignment operator for passive values. Calls store on the InternalStatementRecordingTapeInterface.
Definition lhsExpressionInterface.hpp:135
T_Impl Impl
See LhsExpressionInterface.
Definition lhsExpressionInterface.hpp:69
void init(Real const &newValue, EventHints::Statement statementType)
Definition lhsExpressionInterface.hpp:210
Impl & operator=(ExpressionInterface< typename U::Real, Rhs > const &rhs)
Assignment operator for expressions. Calls store on the InternalStatementRecordingTapeInterface.
Definition lhsExpressionInterface.hpp:162
static Real registerExternalFunctionOutput(Type &v)
Register all active types of a aggregated type as external function outputs.
T_Type Type
See TapeRegistration.
Definition realTraits.hpp:194
static void registerOutput(Type &v)
Register all active types of a aggregated type as tape output.
static void registerInput(Type &v)
Register all active types of a aggregated type as tape input.
Traversal of CoDiPack expressions.
Definition traversalLogic.hpp:56