CoDiPack  3.0.0
A Code Differentiation Package
SciComp TU Kaiserslautern
Loading...
Searching...
No Matches
innerStatementEvaluator.hpp
1/*
2 * CoDiPack, a Code Differentiation Package
3 *
4 * Copyright (C) 2015-2025 Chair for Scientific Computing (SciComp), University of Kaiserslautern-Landau
5 * Homepage: http://scicomp.rptu.de
6 * Contact: Prof. Nicolas R. Gauger (codi@scicomp.uni-kl.de)
7 *
8 * Lead developers: Max Sagebaum, Johannes Blühdorn (SciComp, University of Kaiserslautern-Landau)
9 *
10 * This file is part of CoDiPack (http://scicomp.rptu.de/software/codi).
11 *
12 * CoDiPack is free software: you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, either version 3 of the
15 * License, or (at your option) any later version.
16 *
17 * CoDiPack is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty
19 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20 *
21 * See the GNU General Public License for more details.
22 * You should have received a copy of the GNU
23 * General Public License along with CoDiPack.
24 * If not, see <http://www.gnu.org/licenses/>.
25 *
26 * For other licensing options please contact us.
27 *
28 * Authors:
29 * - SciComp, University of Kaiserslautern-Landau:
30 * - Max Sagebaum
31 * - Johannes Blühdorn
32 * - Former members:
33 * - Tim Albring
34 */
35#pragma once
36
37#include <algorithm>
38#include <functional>
39#include <type_traits>
40
41#include "../../expressions/activeType.hpp"
42#include "../../misc/macros.hpp"
43#include "../../traits/expressionTraits.hpp"
44#include "../misc/assignStatement.hpp"
45#include "../misc/statementSizes.hpp"
46#include "directStatementEvaluator.hpp"
47#include "statementEvaluatorInterface.hpp"
48
50namespace codi {
51
67
70 template<typename Generator, typename Stmt>
72 public:
73
77
79 template<StatementCall... types>
81 using Handle = typename PrimalTapeStatementFunctions::Handle;
82
85 ((Handle)Generator::template StatementCallGenerator<types, Stmt>::evaluateInner)...),
87 }
88 };
89
90 template<typename Generator, typename Stmt>
93
105 public:
106
107 /*******************************************************************************/
110
112
114 template<StatementCall type, typename Tape, typename... Args>
115 static void call(Handle const& h, Args&&... args) {
117 using CallGen = typename Tape::template StatementCallGenerator<type, Stmt>;
118
119 using Function = decltype(&CallGen::evaluateInner);
120
121 CallGen::evaluateFull(((Function)h->functions.funcs[(size_t)type]), h->stmtSizes.outputArgs,
122 h->stmtSizes.inputArgs, h->stmtSizes.constantArgs, std::forward<Args>(args)...);
123 }
124
126 template<typename Tape, typename Generator, typename Stmt>
130
132 };
133}
CoDiPack - Code Differentiation Package.
Definition codi.hpp:94
StatementCall
Defines all the operations which can be evaluated on a statement by a tape.
Definition statementEvaluatorTapeInterface.hpp:45
Represents a concrete lvalue in the CoDiPack expression tree.
Definition activeType.hpp:52
Definition assignStatement.hpp:50
Additional data required by an InnerStatementEvaluator.
Definition innerStatementEvaluator.hpp:55
InnerPrimalTapeStatementData(PrimalTapeStatementFunctions functions, StatementSizes stmtSizes)
Constructor.
Definition innerStatementEvaluator.hpp:64
PrimalTapeStatementFunctions Base
Base class abbreviation.
Definition innerStatementEvaluator.hpp:58
PrimalTapeStatementFunctions functions
Functions stored for the handle.
Definition innerStatementEvaluator.hpp:60
StatementSizes stmtSizes
Statement sizes stored for the handle.
Definition innerStatementEvaluator.hpp:61
Definition innerStatementEvaluator.hpp:71
static InnerPrimalTapeStatementData gen()
Generates the data for the static store.
Definition innerStatementEvaluator.hpp:80
static InnerPrimalTapeStatementData const staticStore
Static storage.
Definition innerStatementEvaluator.hpp:76
Expression evaluation in the inner function. Data loading in the compilation context of the tape....
Definition innerStatementEvaluator.hpp:104
static Handle createHandle()
Definition innerStatementEvaluator.hpp:127
static void call(Handle const &h, Args &&... args)
Definition innerStatementEvaluator.hpp:115
InnerPrimalTapeStatementData const * Handle
Pointer to static storage location.
Definition innerStatementEvaluator.hpp:111
Data required for all possible handle calls.
Definition directStatementEvaluator.hpp:52
void * Handle
Function pointer.
Definition directStatementEvaluator.hpp:55
Creation of handles for the evaluation of expressions in a context where the expression type is not a...
Definition statementEvaluatorInterface.hpp:103
Define all static sizes of an Expression.
Definition statementSizes.hpp:45
static StatementSizes create()
Creation function from AssignStatement.
Definition statementSizes.hpp:56