39#include "../../tapes/interfaces/reverseTapeInterface.hpp"
40#include "../../traits/expressionTraits.hpp"
41#include "../computeExpression.hpp"
42#include "../constantExpression.hpp"
43#include "../expressionInterface.hpp"
44#include "../static/staticContextActiveType.hpp"
45#include "nodeInterface.hpp"
68 template<
typename T_Rhs,
typename T_Tape,
size_t T_primalValueOffset,
size_t T_constantValueOffset,
typename =
void>
76 CODI_DD(T_primalValueOffset, 0);
78 CODI_DD(T_constantValueOffset, 0);
80 using Real =
typename Tape::Real;
96#ifndef DOXYGEN_DISABLE
98 template<
typename T_Rhs,
typename T_Tape,
size_t T_primalValueOffset,
size_t T_constantValueOffset>
108 using Real =
typename Tape::Real;
109 using Identifier =
typename Tape::Identifier;
121 Real
const primal = primalVector[identifier];
127 template<
typename T_Rhs,
typename T_Tape,
size_t T_primalValueOffset,
size_t T_constantValueOffset>
137 using Real =
typename Rhs::Real;
138 using InnerReal =
typename Tape::Real;
140 using PassiveInnerReal =
typename Tape::PassiveReal;
147 PassiveInnerReal
const*
const constantData) {
150 using ConversionOperator =
typename Rhs::template ConversionOperator<PassiveInnerReal>;
151 using AggregateTraits = RealTraits::AggregatedTypeTraits<Real>;
155 AggregateTraits::template arrayAccess<i.value>(value) =
163 template<
typename T_Real,
template<
typename>
class T_Operation,
typename T_Tape,
size_t T_primalValueOffset,
164 size_t T_constantValueOffset,
typename... T_Args>
166 T_constantValueOffset> {
169 using OpReal = T_Real;
171 using Operation = T_Operation<T>;
175 using Args = std::tuple<T_Args...>;
177 using Real =
typename Tape::Real;
183 template<
typename T,
size_t ArgNum>
184 struct PrimalValueOffsetForArg
185 :
public std::integral_constant<size_t, PrimalValueOffsetForArg<T, ArgNum - 1>::value +
186 ExpressionTraits::NumberOfActiveTypeArguments<
187 typename std::tuple_element<ArgNum - 1, Args>::type>::value> {
192 struct PrimalValueOffsetForArg<T, 0> :
public std::integral_constant<size_t, primalValueOffset> {};
196 template<
typename T,
size_t ArgNum>
197 struct ConstantValueOffsetForArg
198 :
public std::integral_constant<size_t, ConstantValueOffsetForArg<T, ArgNum - 1>::value +
199 ExpressionTraits::NumberOfConstantTypeArguments<
200 typename std::tuple_element<ArgNum - 1, Args>::type>::value> {
205 struct ConstantValueOffsetForArg<T, 0> :
public std::integral_constant<size_t, constantValueOffset> {};
208 template<
size_t ArgNum>
209 using ArgConstructor = ConstructStaticContextLogic<std::tuple_element_t<ArgNum, Args>,
Tape,
210 PrimalValueOffsetForArg<double, ArgNum>::value,
211 ConstantValueOffsetForArg<double, ArgNum>::value>;
214 template<
size_t ArgNum>
215 using ArgMod =
typename ArgConstructor<ArgNum>::ResultType;
218 template<
size_t... Is>
219 static ComputeExpression<OpReal, Operation, ArgMod<Is>...> ResultTypeHelper(std::index_sequence<Is...>);
222 using ResultType =
remove_all<
decltype(ResultTypeHelper(std::index_sequence_for<T_Args...>()))>;
225 template<
size_t... Is>
227 PassiveReal const*
const constantData, std::index_sequence<Is...>) {
228 return ResultType(ArgConstructor<Is>::construct(primalVector, identifiers, constantData)...);
233 return constructHelper(primalVector, identifiers, constantData, std::index_sequence_for<T_Args...>());
#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_T(...)
Abbreviation for CODI_TEMPLATE.
Definition macros.hpp:116
Traits for everything that can be an expression e.g. codi::RealReverse, a + b, etc....
Definition expressionTraits.hpp:65
typename std::enable_if< IsConstantExpression< Expr >::value, T >::type EnableIfConstantExpression
Enable if wrapper for IsConstantExpression.
Definition expressionTraits.hpp:200
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
inlinevoid CODI_UNUSED(Args const &...)
Disable unused warnings for an arbitrary number of arguments.
Definition macros.hpp:54
typename std::remove_cv< typename std::remove_reference< typename std::remove_cv< T >::type >::type >::type remove_all
Removes all reference, constant and volatile modifiers.
Definition removeAll.hpp:47
Represents an operator or function with an arbitrary number of arguments in the expression tree.
Definition computeExpression.hpp:371
Helper class for the construction of an expression in a different context.
Definition constructStaticContext.hpp:69
T_Rhs ResultType
The resulting expression type after all nodes are replaced.
Definition constructStaticContext.hpp:85
static ResultType construct(Real *primalVector, Identifier const *const identifiers, PassiveReal const *const constantData)
Perform the construction.
typename Tape::PassiveReal PassiveReal
Basic computation type.
Definition constructStaticContext.hpp:82
T_Rhs Rhs
See ConstructStaticContextLogic.
Definition constructStaticContext.hpp:72
typename Tape::Real Real
See TapeTypesInterface.
Definition constructStaticContext.hpp:80
static constexpr size_t constantValueOffset
Definition constructStaticContext.hpp:77
typename Tape::Identifier Identifier
See TapeTypesInterface.
Definition constructStaticContext.hpp:81
static constexpr size_t primalValueOffset
Definition constructStaticContext.hpp:75
T_Tape Tape
See ConstructStaticContextLogic.
Definition constructStaticContext.hpp:73
Base class for all CoDiPack expressions.
Definition expressionInterface.hpp:60
Minimum tape interface for a working reverse tape implementation.
Definition reverseTapeInterface.hpp:78
Replacement type of LhsExpressionInterface types in ConstructStaticContext.
Definition staticContextActiveType.hpp:56