44#include "../expressions/lhsExpressionInterface.hpp"
45#include "../expressions/logic/compileTimeTraversalLogic.hpp"
46#include "../expressions/logic/constructStaticContext.hpp"
47#include "../expressions/logic/helpers/forEachLeafLogic.hpp"
48#include "../expressions/logic/helpers/jacobianComputationLogic.hpp"
49#include "../expressions/logic/traversalLogic.hpp"
51#include "../misc/mathUtility.hpp"
52#include "../misc/memberStore.hpp"
53#include "../traits/expressionTraits.hpp"
54#include "commonTapeImplementation.hpp"
55#include "data/chunk.hpp"
56#include "data/chunkedData.hpp"
57#include "indices/indexManagerInterface.hpp"
58#include "misc/primalAdjointVectorAccess.hpp"
59#include "statementEvaluators/statementEvaluatorInterface.hpp"
60#include "statementEvaluators/statementEvaluatorTapeInterface.hpp"
75 template<
typename T_Real,
typename T_Gradient,
typename T_IndexManager,
template<
typename>
class T_StatementEvaluator,
76 template<
typename,
typename>
class T_Data>
85 template<
typename Chunk,
typename Nested>
94 IndexManager::NeedsStaticStorage;
101 typename std::conditional<IsLinearIndexHandler, Chunk2<Config::ArgumentSize, EvalHandle>,
133 template<
typename T_TapeTypes,
typename T_Impl>
149 using Real =
typename TapeTypes::Real;
167 template<
typename Adjo
int>
174 TapeTypes::IsLinearIndexHandler;
176 !TapeTypes::IsLinearIndexHandler;
195 return static_cast<Impl const&
>(*this);
199 return static_cast<Impl&
>(*this);
209 template<
typename... Args>
213 template<
typename... Args>
217 template<
typename... Args>
243 checkPrimalSize(
true);
271 checkAdjointSize(identifier);
299 template<
typename Real>
303 identifier = IndexManager::InactiveIndex;
307 template<
typename Real>
323 template<
typename Node>
336 template<
typename Node>
354 template<
typename Node>
377 template<
typename Node,
typename Jacobian>
381 jacobians[pos] = ComputationTraits::adjointConversion<Real>(
jacobianExpr);
391 template<
typename Lhs,
typename Rhs>
403 size_t activeArguments = 0;
404 countActiveArguments.
eval(rhs.
cast(), activeArguments);
412 size_t passiveArguments = 0;
415 bool generatedNewIndex =
indexManager.
get().template assignIndex<Impl>(lhs.
cast().getIdentifier());
416 checkPrimalSize(generatedNewIndex);
419 cast().pushStmtData(lhs.
cast().getIdentifier(), passiveArguments, primalEntry,
420 StatementEvaluator::template createHandle<Impl, Impl, Rhs>());
422 primalEntry = rhs.
cast().getValue();
426 std::array<Identifier, MaxActiveArgs> rhsIdentifiers;
427 std::array<Real, MaxActiveArgs> jacobians;
428 getRhsIdentifiersAndJacobians.
eval(rhs.
cast(),
Real(1.0), rhsIdentifiers.data(), jacobians.data());
431 rhs.
cast().getValue(), MaxActiveArgs,
432 rhsIdentifiers.data(), jacobians.data());
441 lhs.
cast().value() = rhs.
cast().getValue();
446 template<
typename Lhs,
typename Rhs>
460 lhs.
cast().value() = rhs.
cast().getValue();
465 template<
typename Lhs>
469 lhs.
cast().value() = rhs;
480 template<
typename Lhs>
483 if (TapeTypes::IsLinearIndexHandler) {
487 bool generatedNewIndex;
489 generatedNewIndex =
indexManager.
get().template assignUnusedIndex<Impl>(value.
cast().getIdentifier());
491 generatedNewIndex =
indexManager.
get().template assignIndex<Impl>(value.
cast().getIdentifier());
493 checkPrimalSize(generatedNewIndex);
496 if (TapeTypes::IsLinearIndexHandler) {
498 StatementEvaluator::template createHandle<Impl, Impl, Lhs>());
501 Real oldValue = primalEntry;
502 primalEntry = value.
cast().value();
513 template<
typename Lhs>
550 if (TapeTypes::IsLinearIndexHandler) {
551 name =
"CoDi Tape Statistics ( PrimalValueLinearTape )";
553 name =
"CoDi Tape Statistics ( PrimalValueReuseTape )";
558 double memoryAdjoints =
static_cast<double>(nAdjoints) *
static_cast<double>(
sizeof(
Gradient));
561 double memoryPrimals =
static_cast<double>(nPrimals) *
static_cast<double>(
sizeof(
Real));
565 values.
addDoubleEntry(
"Memory allocated", memoryAdjoints,
true,
true);
569 values.
addDoubleEntry(
"Memory allocated", memoryPrimals,
true,
true);
591 template<
typename Adjo
int>
595#if CODI_VariableAdjointInterfaceInPrimalTapes
599 "Please enable 'CODI_VariableAdjointInterfaceInPrimalTapes' in order"
600 " to use custom adjoint vectors in the primal value tapes.");
611 template<
typename Node>
617#if CODI_VariableAdjointInterfaceInPrimalTapes
618 adjointVector->updateTangentWithLhs(
node.getIdentifier(), jacobian);
630 template<
bool copyPrimal,
typename Adjo
int>
645 cast(), start, end, &vectorAccess, EventHints::EvaluationKind::Forward, EventHints::Endpoint::Begin);
648 Base::llfByteData.evaluateForward(start, end, evalFunc, cast(), primalData, dataVector);
651 EventHints::EvaluationKind::Forward, EventHints::Endpoint::End);
659 template<
typename Node>
665#if CODI_VariableAdjointInterfaceInPrimalTapes
666 adjointVector->updateAdjointWithLhs(
node.getIdentifier(), jacobian);
678 template<
bool copyPrimal,
typename Adjo
int>
692 cast(), start, end, &vectorAccess, EventHints::EvaluationKind::Reverse, EventHints::Endpoint::Begin);
695 Base::llfByteData.evaluateReverse(start, end, evalFunc, cast(), primalData, dataVector);
698 EventHints::EvaluationKind::Reverse, EventHints::Endpoint::End);
709 template<
typename Adjo
int>
711 internalEvaluateReverse<!TapeTypes::IsLinearIndexHandler>(start, end, data);
715 template<
typename Adjo
int>
717 internalEvaluateForward<!TapeTypes::IsLinearIndexHandler>(start, end, data);
730 std::swap(
adjoints, other.adjoints);
731 std::swap(
primals, other.primals);
736 checkPrimalSize(
true);
737 other.checkPrimalSize(
true);
797 CODI_EXCEPTION(
"Tried to set a get only option.");
822 template<
typename Adjo
int>
838 template<
typename Lhs>
861 cast().evaluateForward(start, end,
adjoints.data());
873 template<
size_t T_size>
877 static size_t constexpr size = T_size;
884 template<
typename Expr,
typename... Args>
887 CODI_EXCEPTION(
"Forward evaluation of jacobian statement not possible.");
891 template<
typename Expr,
typename... Args>
894 CODI_EXCEPTION(
"Primal evaluation of jacobian statement not possible.");
898 template<
typename Expr>
901 size_t& curConstantPos,
PassiveReal const*
const constantValues,
902 size_t& curPassivePos,
Real const*
const passiveValues,
903 size_t& curRhsIdentifiersPos,
Identifier const*
const rhsIdentifiers) {
904 CODI_UNUSED(primalVector, curConstantPos, constantValues);
906 size_t endPos = curRhsIdentifiersPos - numberOfPassiveArguments;
908 bool const lhsZero = evalJacobianReverse(adjointVector, lhsAdjoint, curPassivePos, passiveValues,
909 curRhsIdentifiersPos, rhsIdentifiers, endPos);
912 curPassivePos -= numberOfPassiveArguments;
913 curRhsIdentifiersPos -= numberOfPassiveArguments;
923 template<
typename Expr,
typename... Args>
926 CODI_EXCEPTION(
"Forward evaluation of jacobian statement not possible.");
932 template<
typename Expr,
typename... Args>
935 CODI_EXCEPTION(
"Primal evaluation of jacobian statement not possible.");
941 template<
typename Expr>
943 Gradient lhsAdjoint,
size_t& curConstantPos,
945 size_t& curRhsIdentifiersPos,
947 CODI_UNUSED(primalVector, curConstantPos, constantValues);
949 size_t passivePos =
size;
950 size_t rhsPos = curRhsIdentifiersPos +
size;
951 size_t endPos = curRhsIdentifiersPos;
953 evalJacobianReverse(adjointVector, lhsAdjoint, passivePos, primalVector, rhsPos, rhsIdentifiers, endPos);
961 size_t& curPassivePos,
Real const*
const passiveValues,
962 size_t& curRhsIdentifiersPos,
Identifier const*
const rhsIdentifiers,
963 size_t endRhsIdentifiersPos) {
964#if CODI_VariableAdjointInterfaceInPrimalTapes
966 bool const lhsZero = adjointVector->isLhsZero();
972 while (curRhsIdentifiersPos > endRhsIdentifiersPos) {
974 curRhsIdentifiersPos -= 1;
976 Real const& jacobian = passiveValues[curPassivePos];
977#if CODI_VariableAdjointInterfaceInPrimalTapes
978 adjointVector->updateAdjointWithLhs(rhsIdentifiers[curRhsIdentifiersPos], jacobian);
980 adjointVector[rhsIdentifiers[curRhsIdentifiersPos]] += jacobian * lhsAdjoint;
999 cast().incrementManualPushCounter();
1016 rhsIdentifiers, jacobians);
1035 primalEntry = lhsValue;
1037 cast().initializeManualPushData(lhsValue, lhsIndex, size);
1082 cast().internalResetPrimalValues(pos);
1103 internalEvaluateReverse<false>(start, end,
adjoints.data());
1105 if (!TapeTypes::IsLinearIndexHandler) {
1121 if (!TapeTypes::IsLinearIndexHandler) {
1122 cast().internalResetPrimalValues(end);
1125 internalEvaluateForward<false>(start, end,
adjoints.data());
1152 EventHints::EvaluationKind::Primal, EventHints::Endpoint::Begin);
1158 EventHints::EvaluationKind::Primal, EventHints::Endpoint::End);
1177 template<
typename Rhs>
1179 Gradient& lhsTangent,
size_t& curConstantPos,
1180 PassiveReal const*
const constantValues,
size_t& curRhsIdentifiersPos,
1183 using StaticRhs =
typename Constructor::ResultType;
1185 StaticRhs staticsRhs = Constructor::construct(primalVector, &rhsIdentifiers[curRhsIdentifiersPos],
1186 &constantValues[curConstantPos]);
1190 incrementForward.
eval(staticsRhs,
Real(1.0), lhsTangent, adjointVector);
1191 return staticsRhs.getValue();
1195 template<
typename Func>
1197 size_t const& maxConstantArgs,
Real* primalVector,
1200 PassiveReal const*
const constantValues,
size_t& curPassivePos,
1201 Real const*
const passiveValues,
size_t& curRhsIdentifiersPos,
1204 primalVector[curPos] = passiveValues[curPassivePos + curPos];
1207 Real ret = evalInner(primalVector, adjointVector, lhsTangent, curConstantPos, constantValues,
1208 curRhsIdentifiersPos, rhsIdentifiers);
1211 curConstantPos += maxConstantArgs;
1212 curPassivePos += numberOfPassiveArguments;
1213 curRhsIdentifiersPos += maxActiveArgs;
1219 template<
typename Rhs>
1221 PassiveReal const*
const constantValues,
size_t& curRhsIdentifiersPos,
1224 using StaticRhs =
typename Constructor::ResultType;
1226 StaticRhs staticsRhs = Constructor::construct(primalVector, &rhsIdentifiers[curRhsIdentifiersPos],
1227 &constantValues[curConstantPos]);
1229 return staticsRhs.getValue();
1233 template<
typename Func>
1235 size_t const& maxConstantArgs,
Real* primalVector,
1237 PassiveReal const*
const constantValues,
size_t& curPassivePos,
1238 Real const*
const passiveValues,
size_t& curRhsIdentifiersPos,
1241 primalVector[curPos] = passiveValues[curPassivePos + curPos];
1244 Real ret = evalInner(primalVector, curConstantPos, constantValues, curRhsIdentifiersPos, rhsIdentifiers);
1247 curConstantPos += maxConstantArgs;
1248 curPassivePos += numberOfPassiveArguments;
1249 curRhsIdentifiersPos += maxActiveArgs;
1255 template<
typename Rhs>
1257 Gradient lhsAdjoint,
size_t& curConstantPos,
1259 size_t& curRhsIdentifiersPos,
1262 using StaticRhs =
typename Constructor::ResultType;
1264 StaticRhs staticsRhs = Constructor::construct(primalVector, &rhsIdentifiers[curRhsIdentifiersPos],
1265 &constantValues[curConstantPos]);
1269 incrementReverse.
eval(staticsRhs,
Real(1.0),
const_cast<Gradient const&
>(lhsAdjoint), adjointVector);
1273 template<
typename Func>
1275 Func
const& evalInner,
size_t const& maxActiveArgs,
size_t const& maxConstantArgs,
Real* primalVector,
1277 size_t& curConstantPos,
PassiveReal const*
const constantValues,
size_t& curPassivePos,
1278 Real const*
const passiveValues,
size_t& curRhsIdentifiersPos,
Identifier const*
const rhsIdentifiers) {
1280 curConstantPos -= maxConstantArgs;
1281 curPassivePos -= numberOfPassiveArguments;
1282 curRhsIdentifiersPos -= maxActiveArgs;
1284#if CODI_VariableAdjointInterfaceInPrimalTapes
1290 primalVector[curPos] = passiveValues[curPassivePos + curPos];
1293 evalInner(primalVector, adjointVector, lhsAdjoint, curConstantPos, constantValues, curRhsIdentifiersPos,
1304 template<
typename Rhs>
1307 PassiveReal const*
const constantValues,
size_t& curPassivePos,
1308 Real const*
const passiveValues,
size_t& curRhsIdentifiersPos,
1314 primalVector, adjointVector, lhsTangent, numberOfPassiveArguments,
1315 curConstantPos, constantValues, curPassivePos, passiveValues,
1316 curRhsIdentifiersPos, rhsIdentifiers);
1320 template<
typename Rhs>
1322 size_t& curConstantPos,
PassiveReal const*
const constantValues,
1323 size_t& curPassivePos,
Real const*
const passiveValues,
1324 size_t& curRhsIdentifiersPos,
Identifier const*
const rhsIdentifiers) {
1329 primalVector, numberOfPassiveArguments, curConstantPos, constantValues,
1330 curPassivePos, passiveValues, curRhsIdentifiersPos, rhsIdentifiers);
1334 template<
typename Rhs>
1338 size_t& curConstantPos,
PassiveReal const*
const constantValues,
1339 size_t& curPassivePos,
Real const*
const passiveValues,
1340 size_t& curRhsIdentifiersPos,
1345 adjointVector, lhsAdjoint, numberOfPassiveArguments, curConstantPos,
1346 constantValues, curPassivePos, passiveValues, curRhsIdentifiersPos,
1352 CODI_INLINE void checkAdjointSize(Identifier
const& identifier) {
1353 if (identifier >= (Identifier)
adjoints.size()) {
1354 resizeAdjointsVector();
1358 CODI_INLINE void checkPrimalSize(
bool generatedNewIndex) {
1360 resizePrimalVector();
1376 template<
size_t size>
1380 template<
size_t size>
1382 static size_t constexpr value = size;
1386 template<
size_t size>
1388 static size_t constexpr value = 0;
1391#define CREATE_EXPRESSION(size) \
1392 TapeTypes::StatementEvaluator::template createHandle<Impl, typename Impl::template JacobianStatementGenerator<size>, \
1393 JacobianExpression<size>>()
1396 template<
typename TapeTypes,
typename Impl>
1397 const CODI_DD(
typename TapeTypes::EvalHandle,
1399 CREATE_EXPRESSION(0), CREATE_EXPRESSION(1), CREATE_EXPRESSION(2), CREATE_EXPRESSION(3),
1400 CREATE_EXPRESSION(4), CREATE_EXPRESSION(5), CREATE_EXPRESSION(6), CREATE_EXPRESSION(7),
1401 CREATE_EXPRESSION(8), CREATE_EXPRESSION(9), CREATE_EXPRESSION(10), CREATE_EXPRESSION(11),
1402 CREATE_EXPRESSION(12), CREATE_EXPRESSION(13), CREATE_EXPRESSION(14), CREATE_EXPRESSION(15),
1403 CREATE_EXPRESSION(16), CREATE_EXPRESSION(17), CREATE_EXPRESSION(18), CREATE_EXPRESSION(19),
1404 CREATE_EXPRESSION(20), CREATE_EXPRESSION(21), CREATE_EXPRESSION(22), CREATE_EXPRESSION(23),
1405 CREATE_EXPRESSION(24), CREATE_EXPRESSION(25), CREATE_EXPRESSION(26), CREATE_EXPRESSION(27),
1406 CREATE_EXPRESSION(28), CREATE_EXPRESSION(29), CREATE_EXPRESSION(30), CREATE_EXPRESSION(31),
1407 CREATE_EXPRESSION(32), CREATE_EXPRESSION(33), CREATE_EXPRESSION(34), CREATE_EXPRESSION(35),
1408 CREATE_EXPRESSION(36), CREATE_EXPRESSION(37), CREATE_EXPRESSION(38), CREATE_EXPRESSION(39),
1409 CREATE_EXPRESSION(40), CREATE_EXPRESSION(41), CREATE_EXPRESSION(42), CREATE_EXPRESSION(43),
1410 CREATE_EXPRESSION(44), CREATE_EXPRESSION(45), CREATE_EXPRESSION(46), CREATE_EXPRESSION(47),
1411 CREATE_EXPRESSION(48), CREATE_EXPRESSION(49), CREATE_EXPRESSION(50), CREATE_EXPRESSION(51),
1412 CREATE_EXPRESSION(52), CREATE_EXPRESSION(53), CREATE_EXPRESSION(54), CREATE_EXPRESSION(55),
1413 CREATE_EXPRESSION(56), CREATE_EXPRESSION(57), CREATE_EXPRESSION(58), CREATE_EXPRESSION(59),
1414 CREATE_EXPRESSION(60), CREATE_EXPRESSION(61), CREATE_EXPRESSION(62), CREATE_EXPRESSION(63),
1415 CREATE_EXPRESSION(64), CREATE_EXPRESSION(65), CREATE_EXPRESSION(66), CREATE_EXPRESSION(67),
1416 CREATE_EXPRESSION(68), CREATE_EXPRESSION(69), CREATE_EXPRESSION(70), CREATE_EXPRESSION(71),
1417 CREATE_EXPRESSION(72), CREATE_EXPRESSION(73), CREATE_EXPRESSION(74), CREATE_EXPRESSION(75),
1418 CREATE_EXPRESSION(76), CREATE_EXPRESSION(77), CREATE_EXPRESSION(78), CREATE_EXPRESSION(79),
1419 CREATE_EXPRESSION(80), CREATE_EXPRESSION(81), CREATE_EXPRESSION(82), CREATE_EXPRESSION(83),
1420 CREATE_EXPRESSION(84), CREATE_EXPRESSION(85), CREATE_EXPRESSION(86), CREATE_EXPRESSION(87),
1421 CREATE_EXPRESSION(88), CREATE_EXPRESSION(89), CREATE_EXPRESSION(90), CREATE_EXPRESSION(91),
1422 CREATE_EXPRESSION(92), CREATE_EXPRESSION(93), CREATE_EXPRESSION(94), CREATE_EXPRESSION(95),
1423 CREATE_EXPRESSION(96), CREATE_EXPRESSION(97), CREATE_EXPRESSION(98), CREATE_EXPRESSION(99),
1424 CREATE_EXPRESSION(100), CREATE_EXPRESSION(101), CREATE_EXPRESSION(102), CREATE_EXPRESSION(103),
1425 CREATE_EXPRESSION(104), CREATE_EXPRESSION(105), CREATE_EXPRESSION(106), CREATE_EXPRESSION(107),
1426 CREATE_EXPRESSION(108), CREATE_EXPRESSION(109), CREATE_EXPRESSION(110), CREATE_EXPRESSION(111),
1427 CREATE_EXPRESSION(112), CREATE_EXPRESSION(113), CREATE_EXPRESSION(114), CREATE_EXPRESSION(115),
1428 CREATE_EXPRESSION(116), CREATE_EXPRESSION(117), CREATE_EXPRESSION(118), CREATE_EXPRESSION(119),
1429 CREATE_EXPRESSION(120), CREATE_EXPRESSION(121), CREATE_EXPRESSION(122), CREATE_EXPRESSION(123),
1430 CREATE_EXPRESSION(124), CREATE_EXPRESSION(125), CREATE_EXPRESSION(126), CREATE_EXPRESSION(127),
1431 CREATE_EXPRESSION(128), CREATE_EXPRESSION(129), CREATE_EXPRESSION(130), CREATE_EXPRESSION(131),
1432 CREATE_EXPRESSION(132), CREATE_EXPRESSION(133), CREATE_EXPRESSION(134), CREATE_EXPRESSION(135),
1433 CREATE_EXPRESSION(136), CREATE_EXPRESSION(137), CREATE_EXPRESSION(138), CREATE_EXPRESSION(139),
1434 CREATE_EXPRESSION(140), CREATE_EXPRESSION(141), CREATE_EXPRESSION(142), CREATE_EXPRESSION(143),
1435 CREATE_EXPRESSION(144), CREATE_EXPRESSION(145), CREATE_EXPRESSION(146), CREATE_EXPRESSION(147),
1436 CREATE_EXPRESSION(148), CREATE_EXPRESSION(149), CREATE_EXPRESSION(150), CREATE_EXPRESSION(151),
1437 CREATE_EXPRESSION(152), CREATE_EXPRESSION(153), CREATE_EXPRESSION(154), CREATE_EXPRESSION(155),
1438 CREATE_EXPRESSION(156), CREATE_EXPRESSION(157), CREATE_EXPRESSION(158), CREATE_EXPRESSION(159),
1439 CREATE_EXPRESSION(160), CREATE_EXPRESSION(161), CREATE_EXPRESSION(162), CREATE_EXPRESSION(163),
1440 CREATE_EXPRESSION(164), CREATE_EXPRESSION(165), CREATE_EXPRESSION(166), CREATE_EXPRESSION(167),
1441 CREATE_EXPRESSION(168), CREATE_EXPRESSION(169), CREATE_EXPRESSION(170), CREATE_EXPRESSION(171),
1442 CREATE_EXPRESSION(172), CREATE_EXPRESSION(173), CREATE_EXPRESSION(174), CREATE_EXPRESSION(175),
1443 CREATE_EXPRESSION(176), CREATE_EXPRESSION(177), CREATE_EXPRESSION(178), CREATE_EXPRESSION(179),
1444 CREATE_EXPRESSION(180), CREATE_EXPRESSION(181), CREATE_EXPRESSION(182), CREATE_EXPRESSION(183),
1445 CREATE_EXPRESSION(184), CREATE_EXPRESSION(185), CREATE_EXPRESSION(186), CREATE_EXPRESSION(187),
1446 CREATE_EXPRESSION(188), CREATE_EXPRESSION(189), CREATE_EXPRESSION(190), CREATE_EXPRESSION(191),
1447 CREATE_EXPRESSION(192), CREATE_EXPRESSION(193), CREATE_EXPRESSION(194), CREATE_EXPRESSION(195),
1448 CREATE_EXPRESSION(196), CREATE_EXPRESSION(197), CREATE_EXPRESSION(198), CREATE_EXPRESSION(199),
1449 CREATE_EXPRESSION(200), CREATE_EXPRESSION(201), CREATE_EXPRESSION(202), CREATE_EXPRESSION(203),
1450 CREATE_EXPRESSION(204), CREATE_EXPRESSION(205), CREATE_EXPRESSION(206), CREATE_EXPRESSION(207),
1451 CREATE_EXPRESSION(208), CREATE_EXPRESSION(209), CREATE_EXPRESSION(210), CREATE_EXPRESSION(211),
1452 CREATE_EXPRESSION(212), CREATE_EXPRESSION(213), CREATE_EXPRESSION(214), CREATE_EXPRESSION(215),
1453 CREATE_EXPRESSION(216), CREATE_EXPRESSION(217), CREATE_EXPRESSION(218), CREATE_EXPRESSION(219),
1454 CREATE_EXPRESSION(220), CREATE_EXPRESSION(221), CREATE_EXPRESSION(222), CREATE_EXPRESSION(223),
1455 CREATE_EXPRESSION(224), CREATE_EXPRESSION(225), CREATE_EXPRESSION(226), CREATE_EXPRESSION(227),
1456 CREATE_EXPRESSION(228), CREATE_EXPRESSION(229), CREATE_EXPRESSION(230), CREATE_EXPRESSION(231),
1457 CREATE_EXPRESSION(232), CREATE_EXPRESSION(233), CREATE_EXPRESSION(234), CREATE_EXPRESSION(235),
1458 CREATE_EXPRESSION(236), CREATE_EXPRESSION(237), CREATE_EXPRESSION(238), CREATE_EXPRESSION(239),
1459 CREATE_EXPRESSION(240), CREATE_EXPRESSION(241), CREATE_EXPRESSION(242), CREATE_EXPRESSION(243),
1460 CREATE_EXPRESSION(244), CREATE_EXPRESSION(245), CREATE_EXPRESSION(246), CREATE_EXPRESSION(247),
1461 CREATE_EXPRESSION(248), CREATE_EXPRESSION(249), CREATE_EXPRESSION(250), CREATE_EXPRESSION(251),
1462 CREATE_EXPRESSION(252)};
1464#undef CREATE_EXPRESSION
#define CODI_NO_INLINE
See codi::Config::AvoidedInlines.
Definition config.h:417
#define CODI_INLINE
See codi::Config::ForcedInlines.
Definition config.h:457
#define ADJOINT_VECTOR_TYPE
See codi::Config::VariableAdjointInterfaceInPrimalTapes.
Definition config.h:277
#define CODI_Likely
Declare likely evaluation of an execution path.
Definition config.h:397
#define codiAssert(x)
See codi::Config::EnableAssert.
Definition config.h:432
#define CODI_DD(Type, Default)
Abbreviation for CODI_DECLARE_DEFAULT.
Definition macros.hpp:94
#define CODI_ENABLE_CHECK(option, condition)
Definition macros.hpp:53
#define CODI_WRAP_FUNCTION(NAME, FUNC)
Wrap a function in a function object. Used for performance optimizations.
Definition macros.hpp:156
#define CODI_ANY
Used in default declarations of expression templates.
Definition macros.hpp:98
#define CODI_STATIC_ASSERT(cond, message)
Static assert in CoDiPack.
Definition macros.hpp:123
#define CODI_T(...)
Abbreviation for CODI_TEMPLATE.
Definition macros.hpp:111
uint16_t LowLevelFunctionToken
Token type for low level functions in the tapes.
Definition config.h:108
const bool CheckEmptyStatements
Tapes push statements only if at least one Jacobian was pushed.
Definition config.h:154
size_t constexpr ChunkSize
Default size of chunks (ChunkBase) used in ChunkedData in reverse tape implementations.
Definition config.h:94
bool constexpr CheckZeroIndex
Ignore active types that are not dependent on any input value in Jacobian tapes.
Definition config.h:178
bool constexpr IgnoreInvalidJacobians
Ignore invalid Jacobians like NaN or Inf.
Definition config.h:240
bool constexpr CheckTapeActivity
Makes it possible to ignore certain code parts. If turned of everything will be recorded.
Definition config.h:170
size_t constexpr StatementLowLevelFunctionTag
Statement tag for low level functions.
Definition config.h:126
size_t constexpr MaxArgumentSize
Maximum number of arguments in a statement.
Definition config.h:120
bool constexpr StatementEvents
Enable statement events. Disabled by default.
Definition config.h:319
bool constexpr CopyOptimization
Do not store copy statements like a = b; if the identity handler allows it.
Definition config.h:186
uint8_t ArgumentSize
Type for the number of arguments in statements.
Definition config.h:117
size_t constexpr StatementInputTag
Tag for statements that are inputs. Used in linear index management context.
Definition config.h:123
bool constexpr SkipZeroAdjointEvaluation
Do not perform a reverse evaluation of a statement if the seeding adjoint is zero.
Definition config.h:256
bool isTotalFinite(Type const &v)
Function for checking if all values of the type are finite.
Definition realTraits.hpp:133
typename TraitsImplementation< Type >::PassiveReal PassiveReal
The original computation type, that was used in the application.
Definition realTraits.hpp:117
bool isTotalZero(Type const &v)
Function for checking if the value of the type is completely zero.
Definition realTraits.hpp:139
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
IntegralType getNextMultiple(IntegralType const &targetSize, IntegralType const &chunkSize)
Helper function for overallocation in multiples of a given chunk size.
Definition mathUtility.hpp:49
TapeParameters
Configuration options for a tape.
Definition tapeParameters.hpp:52
@ PassiveValuesSize
[A: RW] Allocated number of entries in the passive value vector in primal value tapes.
@ LargestIdentifier
[A: R] Largest identifier distributed by the index manger.
@ PrimalSize
[A: RW] Number of primal vector entries in primal value tapes.
@ StatementSize
[A: RW] Allocated number of entries in the statement vector in all tapes.
AdjointsManagement
Policies for management of the tape's interal adjoints.
Definition tapeParameters.hpp:98
@ Automatic
Manage internal adjoints automatically, including locking, bounds checking, and resizing.
Definition byteDataView.hpp:51
Data is stored chunk-wise in this DataInterface implementation. If a chunk runs out of space,...
Definition chunkedData.hpp:64
Implementation of all common tape functionality.
Definition commonTapeImplementation.hpp:130
Real manualPushLhsValue
For storeManual, remember the value assigned to the lhs.
Definition commonTapeImplementation.hpp:157
void setParameter(TapeParameters parameter, size_t value)
See Parameters functions.
Definition commonTapeImplementation.hpp:458
void evaluateForward(AdjointsManagement adjointsManagement=AdjointsManagement::Automatic)
Perform a forward evaluation of a part of the tape. It has to hold start <= end.
Definition commonTapeImplementation.hpp:591
size_t manualPushCounter
Count the pushes after storeManual, to identify the last push.
Definition commonTapeImplementation.hpp:160
Identifier manualPushLhsIdentifier
For storeManual, remember the identifier assigned to the lhs.
Definition commonTapeImplementation.hpp:158
bool isActive() const
Check if the tape is recording.
Definition commonTapeImplementation.hpp:319
size_t manualPushGoal
Store the number of expected pushes after a storeManual call.
Definition commonTapeImplementation.hpp:159
void init(typename ImplTapeTypes::NestedData *nested)
Initialize the base class.
Definition commonTapeImplementation.hpp:715
void reset(bool resetAdjoints=true, AdjointsManagement adjointsManagement=AdjointsManagement::Automatic)
Reset the tape to the initial state for a fresh recording.
Definition commonTapeImplementation.hpp:354
std::set< TapeParameters > options
All options.
Definition commonTapeImplementation.hpp:152
void evaluate(AdjointsManagement adjointsManagement=AdjointsManagement::Automatic)
Perform a full reverse evaluation of the tape.
Definition commonTapeImplementation.hpp:292
void swap(Impl &other)
Swap all data with an other tape.
Definition commonTapeImplementation.hpp:367
typename CommonTapeTypes< ImplTapeTypes >::Position Position
See TapeTypesInterface.
Definition commonTapeImplementation.hpp:144
LowLevelFunctionByteData llfByteData
Byte data for low level functions.
Definition commonTapeImplementation.hpp:155
void resetTo(Position const &pos, bool resetAdjoints=true, AdjointsManagement adjointsManagement=AdjointsManagement::Automatic)
Reset the tape to the provided position.
Definition commonTapeImplementation.hpp:668
size_t getParameter(TapeParameters parameter) const
See Parameters functions.
Definition commonTapeImplementation.hpp:430
void evaluatePrimal()
Perform a full (forward) reevaluation of the primals in the tape.
Definition commonTapeImplementation.hpp:690
void internalStoreLowLevelFunction(Config::LowLevelFunctionToken token, size_t size, ByteDataView &dataView)
Called by the implementing tapes to store a low level function. The size is reserved and allocated....
Definition commonTapeImplementation.hpp:493
Helper class for the construction of an expression in a different context.
Definition constructStaticContext.hpp:70
Data stream interface for tape data. Encapsulates data that is written e.g. for each statement or arg...
Definition dataInterface.hpp:149
static void notifyStatementStoreOnTapeListeners(Tape &tape, Identifier const &lhsIdentifier, Real const &newValue, size_t numActiveVariables, Identifier const *rhsIdentifiers, Real const *jacobians)
Invoke callbacks for StatementStoreOnTape events.
Definition eventSystem.hpp:676
static void notifyTapeEvaluateListeners(Tape &tape, Position const &start, Position const &end, VectorAccess *adjoint, EventHints::EvaluationKind evalKind, EventHints::Endpoint endpoint)
Invoke callbacks for TapeEvaluate events.
Definition eventSystem.hpp:486
static void notifyTapeRegisterInputListeners(Tape &tape, Real &value, Identifier &identifier)
Invoke callbacks for TapeRegisterInput events.
Definition eventSystem.hpp:424
Base class for all CoDiPack expressions.
Definition expressionInterface.hpp:59
Impl const & cast() const
Cast to the implementation.
Definition expressionInterface.hpp:75
Counts the number of nodes that inherit from LhsExpressionInterface in the expression.
Definition expressionTraits.hpp:184
Counts the number of types that inherit from ConstantExpression in the expression.
Definition expressionTraits.hpp:210
Implement logic for leaf nodes only.
Definition forEachLeafLogic.hpp:60
Indices enable the mapping of primal values to their adjoint counterparts.
Definition indexManagerInterface.hpp:78
Definition jacobianComputationLogic.hpp:53
void link(Child const &child, Root const &root, Jacobian const &jacobian, Args &&... args)
Definition jacobianComputationLogic.hpp:84
Specialized for NumberOfActiveTypeArguments and NumberOfConstantTypeArguments.
Definition primalValueBaseTape.hpp:1377
Default implementation of the Jacobian interface.
Definition jacobian.hpp:60
Base class for all CoDiPack lvalue expression.
Definition lhsExpressionInterface.hpp:63
Impl & cast()
Cast to the implementation.
Definition lhsExpressionInterface.hpp:99
Defines a member that can either be static or local to the struct.
Definition memberStore.hpp:56
Type & get()
Get a reference to the actual member.
Definition memberStore.hpp:76
Implementation of VectorAccessInterface for adjoint and primal vectors.
Definition primalAdjointVectorAccess.hpp:58
Count all arguments that have non-zero index.
Definition primalValueBaseTape.hpp:319
void handleActive(Node const &node, size_t &numberOfActiveArguments)
Called for leaf nodes which implement LhsExpressionInterface.
Definition primalValueBaseTape.hpp:324
Perform the adjoint update based on the configuration in codi::Config::VariableAdjointInterfaceInPrim...
Definition primalValueBaseTape.hpp:607
void handleJacobianOnActive(Node const &node, Real jacobian, Gradient &lhsTangent, Gradient *adjointVector)
Called for leaf nodes which implement LhsExpressionInterface.
Definition primalValueBaseTape.hpp:612
Perform the adjoint update based on the configuration in codi::Config::VariableAdjointInterfaceInPrim...
Definition primalValueBaseTape.hpp:655
void handleJacobianOnActive(Node const &node, Real jacobian, Gradient const &lhsAdjoint, Gradient *adjointVector)
See IncrementReversalLogic.
Definition primalValueBaseTape.hpp:660
Definition primalValueBaseTape.hpp:874
static Real statementEvaluatePrimalInner(Args &&... args)
Throws exception.
Definition primalValueBaseTape.hpp:933
static Real statementEvaluateForwardInner(Args &&... args)
Throws exception.
Definition primalValueBaseTape.hpp:924
static Real statementEvaluateForward(Args &&... args)
Throws exception.
Definition primalValueBaseTape.hpp:885
static void statementEvaluateReverseInner(Real *primalVector, Gradient *adjointVector, Gradient lhsAdjoint, size_t &curConstantPos, PassiveReal const *const constantValues, size_t &curRhsIdentifiersPos, Identifier const *const rhsIdentifiers)
Evaluate expression in a reverse mode.
Definition primalValueBaseTape.hpp:942
static size_t constexpr size
See JacobianStatementGenerator.
Definition primalValueBaseTape.hpp:877
static void statementEvaluateReverse(Real *primalVector, Gradient *adjointVector, Gradient lhsAdjoint, Config::ArgumentSize numberOfPassiveArguments, size_t &curConstantPos, PassiveReal const *const constantValues, size_t &curPassivePos, Real const *const passiveValues, size_t &curRhsIdentifiersPos, Identifier const *const rhsIdentifiers)
Evaluate expression in a reverse mode.
Definition primalValueBaseTape.hpp:899
static Real statementEvaluatePrimal(Args &&... args)
Throws exception.
Definition primalValueBaseTape.hpp:892
Push all data for each argument.
Definition primalValueBaseTape.hpp:332
void handleActive(Node const &node, RhsIdentifierData &rhsIdentiferData, PassiveValueData &passiveValueData, ConstantValueData &constantValueData, size_t &curPassiveArgument)
Called for leaf nodes which implement LhsExpressionInterface.
Definition primalValueBaseTape.hpp:337
void handleConstant(Node const &node, RhsIdentifierData &rhsIdentiferData, PassiveValueData &passiveValueData, ConstantValueData &constantValueData, size_t &curPassiveArgument)
Called for leaf nodes which implement ConstantExpression.
Definition primalValueBaseTape.hpp:355
Additional wrapper that triggers compiler optimizations.
Definition primalValueBaseTape.hpp:627
Wrapper helper for improved compiler optimizations.
Definition primalValueBaseTape.hpp:1135
Additional wrapper that triggers compiler optimizations.
Definition primalValueBaseTape.hpp:675
Base class for all standard Primal value tape implementations.
Definition primalValueBaseTape.hpp:136
MemberStore< IndexManager, Impl, TapeTypes::IsStaticIndexHandler > indexManager
Index manager.
Definition primalValueBaseTape.hpp:182
typename ConstantValueData::Position NestedPosition
See PrimalValueTapeTypes.
Definition primalValueBaseTape.hpp:164
std::vector< Real > primalsCopy
Copy of primal values for AD evaluations.
Definition primalValueBaseTape.hpp:190
VectorAccess< Adjoint > * createVectorAccessCustomAdjoints(Adjoint *data)
See Adjoint vector access.
Definition primalValueBaseTape.hpp:823
typename TapeTypes::EvalHandle EvalHandle
See PrimalValueTapeTypes.
Definition primalValueBaseTape.hpp:155
static bool constexpr RequiresPrimalRestore
See PrimalEvaluationTapeInterface.
Definition primalValueBaseTape.hpp:175
void beginUseAdjointVector()
Declare that the adjoint vector is being used. See Adjoint vector management.
Definition primalValueBaseTape.hpp:752
static Real statementEvaluateForwardFull(Func const &evalInner, size_t const &maxActiveArgs, size_t const &maxConstantArgs, Real *primalVector, Gradient *adjointVector, Gradient &lhsTangent, Config::ArgumentSize numberOfPassiveArguments, size_t &curConstantPos, PassiveReal const *const constantValues, size_t &curPassivePos, Real const *const passiveValues, size_t &curRhsIdentifiersPos, Identifier const *const rhsIdentifiers)
Load the expression data and evaluate the expression in a forward mode.
Definition primalValueBaseTape.hpp:1196
void resetTo(Position const &pos, bool resetAdjoints=true, AdjointsManagement adjointsManagement=AdjointsManagement::Automatic)
Reset the tape to the provided position.
Definition primalValueBaseTape.hpp:1080
PrimalValueBaseTape()
Constructor.
Definition primalValueBaseTape.hpp:232
static void statementEvaluateReverseFull(Func const &evalInner, size_t const &maxActiveArgs, size_t const &maxConstantArgs, Real *primalVector, Gradient *adjointVector, Gradient lhsAdjoint, Config::ArgumentSize numberOfPassiveArguments, size_t &curConstantPos, PassiveReal const *const constantValues, size_t &curPassivePos, Real const *const passiveValues, size_t &curRhsIdentifiersPos, Identifier const *const rhsIdentifiers)
Load the expression data and evaluate the expression in a reverse mode.
Definition primalValueBaseTape.hpp:1274
PassiveValueData passiveValueData
Data stream for passive argument value data.
Definition primalValueBaseTape.hpp:185
T_Impl Impl
See PrimalValueBaseTape.
Definition primalValueBaseTape.hpp:144
static void statementEvaluateReverseInner(Real *primalVector, Gradient *adjointVector, Gradient lhsAdjoint, size_t &curConstantPos, PassiveReal const *const constantValues, size_t &curRhsIdentifiersPos, Identifier const *const rhsIdentifiers)
Evaluate expression in a reverse mode.
Definition primalValueBaseTape.hpp:1256
void registerInput(LhsExpressionInterface< Real, Gradient, Impl, Lhs > &value)
Definition primalValueBaseTape.hpp:514
void deleteAdjointVector()
Delete the adjoint vector. See Adjoint vector management.
Definition primalValueBaseTape.hpp:741
Real registerExternalFunctionOutput(LhsExpressionInterface< Real, Gradient, Impl, Lhs > &value)
Definition primalValueBaseTape.hpp:839
Real const & primal(Identifier const &identifier) const
Read only reference to primal value.
Definition primalValueBaseTape.hpp:1167
static bool constexpr HasPrimalValues
See PrimalEvaluationTapeInterface.
Definition primalValueBaseTape.hpp:172
typename TapeTypes::StatementEvaluator StatementEvaluator
See PrimalValueTapeTypes.
Definition primalValueBaseTape.hpp:152
static Real statementEvaluatePrimalInner(Real *primalVector, size_t &curConstantPos, PassiveReal const *const constantValues, size_t &curRhsIdentifiersPos, Identifier const *const rhsIdentifiers)
Evaluate expression in a primal setting.
Definition primalValueBaseTape.hpp:1220
typename TapeTypes::PassiveValueData PassiveValueData
See PrimalValueTapeTypes.
Definition primalValueBaseTape.hpp:159
std::vector< Real > primals
Current state of primal values in the program.
Definition primalValueBaseTape.hpp:189
typename TapeTypes::Real Real
See TapeTypesInterface.
Definition primalValueBaseTape.hpp:149
Gradient * selectAdjointVector(VectorAccess< Adjoint > *vectorAccess, Adjoint *data)
Select the configured adjoint vector, see codi::Config::VariableAdjointInterfaceInPrimalTapes.
Definition primalValueBaseTape.hpp:592
static void internalEvaluateReverse_EvalStatements(Args &&... args)
Perform a reverse evaluation of the tape. Arguments are from the recursive eval methods of the DataIn...
std::vector< Gradient > adjoints
Evaluation vector for AD.
Definition primalValueBaseTape.hpp:188
void evaluateForwardKeepState(Position const &start, Position const &end, AdjointsManagement adjointsManagement=AdjointsManagement::Automatic)
Perform a tape evaluation but restore the state afterwards such that it is the same as when the evalu...
Definition primalValueBaseTape.hpp:1113
void internalEvaluateForward(Position const &start, Position const &end, Adjoint *data)
Internal method for the forward evaluation of the whole tape.
Definition primalValueBaseTape.hpp:631
void evaluate(Position const &start, Position const &end, Adjoint *data)
Perform a reverse evaluation for a part of the tape. It hast to hold start >= end.
Definition primalValueBaseTape.hpp:710
void evaluate(Position const &start, Position const &end, AdjointsManagement adjointsManagement=AdjointsManagement::Automatic)
Perform a reverse evaluation for a part of the tape. It hast to hold start >= end.
Definition primalValueBaseTape.hpp:1066
static Real statementEvaluateForwardInner(Real *primalVector, Gradient *adjointVector, Gradient &lhsTangent, size_t &curConstantPos, PassiveReal const *const constantValues, size_t &curRhsIdentifiersPos, Identifier const *const rhsIdentifiers)
Evaluate expression in a forward mode.
Definition primalValueBaseTape.hpp:1178
typename TapeTypes::Identifier Identifier
See PrimalValueTapeTypes.
Definition primalValueBaseTape.hpp:153
RhsIdentifierData rhsIdentiferData
Data stream for argument identifier data.
Definition primalValueBaseTape.hpp:184
void evaluateForward(Position const &start, Position const &end, Adjoint *data)
Perform a forward evaluation of a part of the tape. It has to hold start <= end.
Definition primalValueBaseTape.hpp:716
T_TapeTypes TapeTypes
See PrimalValueBaseTape.
Definition primalValueBaseTape.hpp:140
void pushStmtData(Identifier const &index, Config::ArgumentSize const &numberOfPassiveArguments, Real const &oldPrimalValue, EvalHandle evalHandle)
Add statement specific data to the data streams.
static bool constexpr AllowJacobianOptimization
See InternalStatementRecordingTapeInterface.
Definition primalValueBaseTape.hpp:171
static void statementEvaluateReverse(Real *primalVector, Gradient *adjointVector, Gradient lhsAdjoint, Config::ArgumentSize numberOfPassiveArguments, size_t &curConstantPos, PassiveReal const *const constantValues, size_t &curPassivePos, Real const *const passiveValues, size_t &curRhsIdentifiersPos, Identifier const *const rhsIdentifiers)
Evaluate expression in a reverse mode.
Definition primalValueBaseTape.hpp:1335
typename TapeTypes::RhsIdentifierData RhsIdentifierData
See PrimalValueTapeTypes.
Definition primalValueBaseTape.hpp:158
Gradient const & gradient(Identifier const &identifier, AdjointsManagement adjointsManagement=AdjointsManagement::Automatic) const
Constant reference access to gradient.
Definition primalValueBaseTape.hpp:282
void evaluateKeepState(Position const &start, Position const &end, AdjointsManagement adjointsManagement=AdjointsManagement::Automatic)
Perform a tape evaluation but restore the state afterwards such that it is the same as when the evalu...
Definition primalValueBaseTape.hpp:1095
TapeValues internalGetTapeValues() const
Definition primalValueBaseTape.hpp:548
void evaluateForward(Position const &start, Position const &end, AdjointsManagement adjointsManagement=AdjointsManagement::Automatic)
Perform a forward evaluation of a part of the tape. It has to hold start <= end.
Definition primalValueBaseTape.hpp:853
void initIdentifier(Real &value, Identifier &identifier)
Definition primalValueBaseTape.hpp:300
void deleteVectorAccess(VectorAccessInterface< Real, Identifier > *access)
See Adjoint vector access.
Definition primalValueBaseTape.hpp:828
void evaluatePrimal(Position const &start, Position const &end)
Perform a full (forward) reevaluation of the primals in the tape.
Definition primalValueBaseTape.hpp:1147
void reset(bool resetAdjoints=true, AdjointsManagement adjointsManagement=AdjointsManagement::Automatic)
Reset the tape to the initial state for a fresh recording.
Definition primalValueBaseTape.hpp:533
void store(LhsExpressionInterface< Real, Gradient, Impl, Lhs > &lhs, Real const &rhs)
Has to be called by an AD variable every time it is assigned.
Definition primalValueBaseTape.hpp:466
static void internalEvaluatePrimal_EvalStatements(Args &&... args)
Perform a primal evaluation of the tape. Arguments are from the recursive eval methods of the DataInt...
void setParameter(TapeParameters parameter, size_t value)
See Parameters functions.
Definition primalValueBaseTape.hpp:788
Real & primal(Identifier const &identifier)
Writable reference to primal value.
Definition primalValueBaseTape.hpp:1162
static void internalEvaluateForward_EvalStatements(Args &&... args)
Perform a forward evaluation of the tape. Arguments are from the recursive eval methods of the DataIn...
static bool constexpr LinearIndexHandling
See IdentifierInformationTapeInterface.
Definition primalValueBaseTape.hpp:173
void internalResetPrimalValues(Position const &pos)
Reset the primal values to the given position.
void swap(Impl &other)
Swap all data with an other tape.
Definition primalValueBaseTape.hpp:726
void store(LhsExpressionInterface< Real, Gradient, Impl, Lhs > &lhs, LhsExpressionInterface< Real, Gradient, Impl, Rhs > const &rhs)
Has to be called by an AD variable every time it is assigned.
Definition primalValueBaseTape.hpp:447
RealTraits::PassiveReal< Real > PassiveReal
Basic computation type.
Definition primalValueBaseTape.hpp:162
typename Base::Position Position
See TapeTypesInterface.
Definition primalValueBaseTape.hpp:165
typename TapeTypes::Gradient Gradient
See TapeTypesInterface.
Definition primalValueBaseTape.hpp:150
void store(LhsExpressionInterface< Real, Gradient, Impl, Lhs > &lhs, ExpressionInterface< Real, Rhs > const &rhs)
Has to be called by an AD variable every time it is assigned.
Definition primalValueBaseTape.hpp:392
void internalEvaluateReverse(Position const &start, Position const &end, Adjoint *data)
Internal method for the reverse evaluation of the whole tape.
Definition primalValueBaseTape.hpp:679
void resizeAdjointVector()
Explicitly trigger resizing of the adjoint vector. See Adjoint vector management.
Definition primalValueBaseTape.hpp:746
typename TapeTypes::StatementData StatementData
See PrimalValueTapeTypes.
Definition primalValueBaseTape.hpp:157
void endUseAdjointVector()
Declare that the adjoint vector is no longer used. See Adjoint vector management.
Definition primalValueBaseTape.hpp:756
void destroyIdentifier(Real &value, Identifier &identifier)
Has to be called for each identifier, before it is deallocated.
Definition primalValueBaseTape.hpp:308
static Real statementEvaluateForward(Real *primalVector, Gradient *adjointVector, Gradient &lhsTangent, Config::ArgumentSize numberOfPassiveArguments, size_t &curConstantPos, PassiveReal const *const constantValues, size_t &curPassivePos, Real const *const passiveValues, size_t &curRhsIdentifiersPos, Identifier const *const rhsIdentifiers)
Evaluate expression in a forward mode.
Definition primalValueBaseTape.hpp:1305
VectorAccess< Gradient > * createVectorAccess()
See Adjoint vector access.
Definition primalValueBaseTape.hpp:817
void clearAdjoints(AdjointsManagement adjointsManagement=AdjointsManagement::Automatic)
Clear all adjoint values, that is, set them to zero.
Definition primalValueBaseTape.hpp:522
static EvalHandle const jacobianExpressions[Config::MaxArgumentSize]
Expressions for manual statement pushes.
Definition primalValueBaseTape.hpp:180
Gradient & gradient(Identifier const &identifier, AdjointsManagement adjointsManagement=AdjointsManagement::Automatic)
Reference access to gradient.
Definition primalValueBaseTape.hpp:268
Real internalRegisterInput(LhsExpressionInterface< Real, Gradient, Impl, Lhs > &value, bool unusedIndex)
Add a new input to the tape and update the primal value vector.
Definition primalValueBaseTape.hpp:481
void storeManual(Real const &lhsValue, Identifier &lhsIndex, Config::ArgumentSize const &size)
Definition primalValueBaseTape.hpp:1022
void pushJacobianManual(Real const &jacobian, Real const &value, Identifier const &index)
Definition primalValueBaseTape.hpp:996
StatementData statementData
Data stream for statement specific data.
Definition primalValueBaseTape.hpp:183
static Real statementEvaluatePrimal(Real *primalVector, Config::ArgumentSize numberOfPassiveArguments, size_t &curConstantPos, PassiveReal const *const constantValues, size_t &curPassivePos, Real const *const passiveValues, size_t &curRhsIdentifiersPos, Identifier const *const rhsIdentifiers)
Evaluate primal expression.
Definition primalValueBaseTape.hpp:1321
void pushLowLevelFunction(Config::LowLevelFunctionToken token, size_t size, ByteDataView &data)
Push a low level function to the tape.
Definition primalValueBaseTape.hpp:1046
typename TapeTypes::ConstantValueData ConstantValueData
See PrimalValueTapeTypes.
Definition primalValueBaseTape.hpp:160
friend Base
Allow the base class to call protected and private methods.
Definition primalValueBaseTape.hpp:147
size_t getParameter(TapeParameters parameter) const
See Parameters functions.
Definition primalValueBaseTape.hpp:759
static Real statementEvaluatePrimalFull(Func const &evalInner, size_t const &maxActiveArgs, size_t const &maxConstantArgs, Real *primalVector, Config::ArgumentSize numberOfPassiveArguments, size_t &curConstantPos, PassiveReal const *const constantValues, size_t &curPassivePos, Real const *const passiveValues, size_t &curRhsIdentifiersPos, Identifier const *const rhsIdentifiers)
Load the expression data and evaluate the expression in a primal setting.
Definition primalValueBaseTape.hpp:1234
typename TapeTypes::IndexManager IndexManager
See TapeTypesInterface.
Definition primalValueBaseTape.hpp:151
ConstantValueData constantValueData
Data stream for constant argument data.
Definition primalValueBaseTape.hpp:186
Type definitions for the primal value tapes.
Definition primalValueBaseTape.hpp:77
T_Gradient Gradient
See PrimalValueTapeTypes.
Definition primalValueBaseTape.hpp:81
typename IndexManager::Index Identifier
See IndexManagerInterface.
Definition primalValueBaseTape.hpp:89
Data< PassiveValueChunk, RhsIdentifierData > PassiveValueData
Passive values data vector.
Definition primalValueBaseTape.hpp:109
typename std::conditional< IsLinearIndexHandler, Chunk2< Config::ArgumentSize, EvalHandle >, Chunk4< Identifier, Config::ArgumentSize, Real, EvalHandle > >::type StatementChunk
Definition primalValueBaseTape.hpp:100
T_Data< Chunk, Nested > Data
See PrimalValueTapeTypes.
Definition primalValueBaseTape.hpp:86
static constexpr bool IsLinearIndexHandler
True if the index manager is linear.
Definition primalValueBaseTape.hpp:92
RealTraits::PassiveReal< Real > PassiveReal
Basic computation type.
Definition primalValueBaseTape.hpp:90
T_Real Real
See PrimalValueTapeTypes.
Definition primalValueBaseTape.hpp:80
Data< IdentifierChunk, StatementData > RhsIdentifierData
Rhs identifiers data vector.
Definition primalValueBaseTape.hpp:106
Data< StatementChunk, IndexManager > StatementData
Statement data vector.
Definition primalValueBaseTape.hpp:103
ConstantValueData NestedData
See TapeTypesInterface.
Definition primalValueBaseTape.hpp:114
T_IndexManager IndexManager
See PrimalValueTapeTypes.
Definition primalValueBaseTape.hpp:82
Data< ConstantValueChunk, PassiveValueData > ConstantValueData
Constant values data vector.
Definition primalValueBaseTape.hpp:112
static constexpr bool IsStaticIndexHandler
True if the index manager must be stored statically in the tape.
Definition primalValueBaseTape.hpp:93
typename StatementEvaluator::Handle EvalHandle
Handle type returned by the statement generator.
Definition primalValueBaseTape.hpp:96
T_StatementEvaluator< Real > StatementEvaluator
See PrimalValueTapeTypes.
Definition primalValueBaseTape.hpp:83
Tape side interface for StatementEvaluatorInterface.
Definition statementEvaluatorTapeInterface.hpp:91
Creation of handles for the evaluation of expressions in a context where the expression type is not a...
Definition statementEvaluatorInterface.hpp:103
Tape side interface for StatementEvaluatorInterface.
Definition statementEvaluatorTapeInterface.hpp:55
Interface for the definition of tape types.
Definition commonTapeImplementation.hpp:63
Tape information that can be printed in a pretty print format or a table format.
Definition tapeValues.hpp:73
void addDoubleEntry(std::string const &name, double const &value, bool usedMem=false, bool allocatedMem=false)
Add double entry. If it is a memory entry, it should be in bytes.
Definition tapeValues.hpp:126
void addUnsignedLongEntry(std::string const &name, unsigned long const &value)
Add unsigned long entry.
Definition tapeValues.hpp:150
void addSection(std::string const &name)
Add section. All further entries are added under this section.
Definition tapeValues.hpp:145
void eval(NodeInterface< Node > const &node, Args &&... args)
Start the evaluation of the logic on the given expression.
Definition traversalLogic.hpp:70
void node(Node const &node, Args &&... args)
Called for each node in the expression.
Definition traversalLogic.hpp:86
void link(Child const &child, Root const &root, Args &&... args)
Called for all links in the expression.
Definition traversalLogic.hpp:110
Unified access to the adjoint vector and primal vector in a tape evaluation.
Definition vectorAccessInterface.hpp:91