CoDiPack  3.0.0
A Code Differentiation Package
SciComp TU Kaiserslautern
Loading...
Searching...
No Matches
immutableActiveType.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/fullTapeInterface.hpp"
40#include "../traits/realTraits.hpp"
41#include "activeType.hpp"
42#include "assignmentOperators.hpp"
43#include "incrementOperators.hpp"
44#include "lhsExpressionInterface.hpp"
45
47namespace codi {
48
60 template<typename T_ActiveType>
62 : public LhsExpressionInterface<typename T_ActiveType::Real, typename T_ActiveType::Gradient,
63 typename T_ActiveType::Tape, ImmutableActiveType<T_ActiveType>>,
64 public AssignmentOperators<typename T_ActiveType::Tape::Real, T_ActiveType::Tape::AllowJacobianOptimization,
65 ImmutableActiveType<T_ActiveType>>,
66 public IncrementOperators<typename T_ActiveType::Tape, ImmutableActiveType<T_ActiveType>> {
67 public:
68
70 using Tape = typename ActiveType::Tape;
71
72 using Real = typename Tape::Real;
74 using Identifier = typename Tape::Identifier;
75 using Gradient = typename Tape::Gradient;
76
78
79 private:
80
81 Real const primalValue;
82 Identifier const identifier;
83
84 public:
85
89 : primalValue(value), identifier(identifier) {
90 // deliberately left empty
91 }
92
96 : primalValue(value.getValue()), identifier(value.getIdentifier()) {
97 // deliberately left empty
98 }
99
103 // deliberately left empty
104 }
105
108
109 /*******************************************************************************/
112
114 using ADLogic = Tape;
115
117 /*******************************************************************************/
123
126 return identifier;
127 }
128
130 CODI_INLINE Real const& value() const {
131 return primalValue;
132 }
133
136 return ActiveType::getTape();
137 }
138
140 };
141} // end of namespace codi
#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
typename TraitsImplementation< Type >::PassiveReal PassiveReal
The original computation type that was used in the application.
Definition realTraits.hpp:123
CoDiPack - Code Differentiation Package.
Definition codi.hpp:94
JacobianLinearTape< JacobianTapeTypes< Real, Gradient, LinearIndexManager< Index >, DefaultChunkedData > > Tape
Definition activeType.hpp:55
Provides assignment operators for LhsExpressionInterface implementations.
Definition assignmentOperators.hpp:120
Creates a pseudo active type from a data value. Can be used to overlay existing data with immutable a...
Definition immutableActiveType.hpp:66
typename ActiveType::Tape Tape
See ActiveType.
Definition immutableActiveType.hpp:70
typename Tape::Identifier Identifier
See LhsExpressionInterface.
Definition immutableActiveType.hpp:74
typename Tape::Real Real
See LhsExpressionInterface.
Definition immutableActiveType.hpp:72
static inlineTape & getTape()
Get a reference to the tape which manages this expression.
Definition immutableActiveType.hpp:135
typename Tape::Gradient Gradient
See LhsExpressionInterface.
Definition immutableActiveType.hpp:75
inlineIdentifier const & getIdentifier() const
Definition immutableActiveType.hpp:125
inline ~ImmutableActiveType()
Definition immutableActiveType.hpp:102
inlineImmutableActiveType< ActiveType > & operator=(ImmutableActiveType< ActiveType > const &v)=delete
This class is immutable, delete all assignment operators.
ImmutableActiveType const & StoreAs
Defines how this expression is stored in an expression tree.
Definition immutableActiveType.hpp:113
LhsExpressionInterface< Real, Gradient, Tape, ImmutableActiveType > Base
Base class abbreviation.
Definition immutableActiveType.hpp:77
Tape ADLogic
AD logic that governs the expression. Needs to be the same for all inputs of the expression.
Definition immutableActiveType.hpp:114
inlineReal const & value() const
Get a constant reference to the lvalue represented by the expression.
Definition immutableActiveType.hpp:130
T_ActiveType ActiveType
See ImmutableActiveType.
Definition immutableActiveType.hpp:69
RealTraits::PassiveReal< Real > PassiveReal
Basic computation type.
Definition immutableActiveType.hpp:73
Implementation of increment operators for LhsExpressionInterface implementations.
Definition incrementOperators.hpp:54