CoDiPack  3.0.0
A Code Differentiation Package
SciComp TU Kaiserslautern
Loading...
Searching...
No Matches
staticContextActiveType.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 "../../config.h"
38#include "../../misc/macros.hpp"
39#include "../../tapes/interfaces/gradientAccessTapeInterface.hpp"
40#include "../../tapes/interfaces/internalStatementRecordingTapeInterface.hpp"
41#include "../../traits/realTraits.hpp"
42#include "../expressionInterface.hpp"
43
45namespace codi {
46
55 template<typename T_Tape>
56 struct StaticContextActiveType : public ExpressionInterface<typename T_Tape::Real, StaticContextActiveType<T_Tape>> {
57 public:
58
59 using Tape = CODI_DD(
62
63 using Real = CODI_DD(typename Tape::Real, double);
64 using Identifier = typename Tape::Identifier;
65
67
68 private:
69
70 Real const primal;
71 Identifier const identifier;
72
73 public:
74
76 CODI_INLINE StaticContextActiveType(Real const& primal, Identifier const& identifier)
77 : primal(primal), identifier(identifier) {}
78
81 : Base(static_cast<Base const&>(other)), primal(other.primal), identifier(other.identifier) {}
82
84 CODI_INLINE StaticContextActiveType() : primal(), identifier() {}
85
86 /*******************************************************************************/
89
92 return identifier;
93 }
94
96 /*******************************************************************************/
99
101 using ADLogic = Tape;
102
104 CODI_INLINE Real const getValue() const {
105 return primal;
106 }
107
109 /*******************************************************************************/
112
113 static size_t constexpr LinkCount = 0;
114
116
117 private:
118 StaticContextActiveType& operator=(StaticContextActiveType const&) = delete;
119 };
120
122 template<typename T_Real, typename T_Tape>
123 struct ExpressionTraits::ActiveResultImpl<T_Real, T_Tape, true> {
124 public:
125
126 using Real = CODI_DD(T_Real, CODI_ANY);
127 using Tape = CODI_DD(T_Tape, CODI_ANY);
128
131 };
132}
#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_ANY
Used in default declarations of expression templates.
Definition macros.hpp:100
#define CODI_T(...)
Abbreviation for CODI_TEMPLATE.
Definition macros.hpp:116
CoDiPack - Code Differentiation Package.
Definition codi.hpp:94
T_Real Real
See ExpressionTraits::ActiveResultImpl.
Definition staticContextActiveType.hpp:126
T_Tape Tape
See ExpressionTraits::ActiveResultImpl.
Definition staticContextActiveType.hpp:127
StaticContextActiveType< Tape > ActiveResult
The resulting active type of an expression.
Definition staticContextActiveType.hpp:130
Definition expressionTraits.hpp:127
Allow for a direct access to the gradient information computed by the tape.
Definition gradientAccessTapeInterface.hpp:67
Internal tape interface that is used by active types to trigger the storing of an expression.
Definition internalStatementRecordingTapeInterface.hpp:65
Replacement type of LhsExpressionInterface types in ConstructStaticContext.
Definition staticContextActiveType.hpp:56
typename Tape::Identifier Identifier
See TapeTypesInterface.
Definition staticContextActiveType.hpp:64
typename Tape::Real Real
See TapeTypesInterface.
Definition staticContextActiveType.hpp:63
static size_t constexpr LinkCount
Definition staticContextActiveType.hpp:113
T_Tape Tape
See StaticContextActiveType.
Definition staticContextActiveType.hpp:59
StaticContextActiveType StoreAs
Defines how this expression is stored in an expression tree.
Definition staticContextActiveType.hpp:100
inlineIdentifier const & getIdentifier() const
Definition staticContextActiveType.hpp:91
ExpressionInterface< Real, StaticContextActiveType > Base
Base class abbreviation.
Definition staticContextActiveType.hpp:66
Tape ADLogic
AD logic that governs the expression. Needs to be the same for all inputs of the expression.
Definition staticContextActiveType.hpp:101
inlineReal const getValue() const
Compute the primal value that is usually evaluated by the statement/expression.
Definition staticContextActiveType.hpp:104