CoDiPack  3.1.0
A Code Differentiation Package
SciComp TU Kaiserslautern
Loading...
Searching...
No Matches
referenceActiveType.hpp
1/*
2 * CoDiPack, a Code Differentiation Package
3 *
4 * Copyright (C) 2015-2026 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 "../traits/realTraits.hpp"
41#include "assignmentOperators.hpp"
42#include "incrementOperators.hpp"
43#include "lhsExpressionInterface.hpp"
44
46namespace codi {
47
55 template<typename T_Type>
57 : public LhsExpressionInterface<typename T_Type::Real, typename T_Type::Gradient, typename T_Type::Tape,
58 ReferenceActiveType<T_Type>>,
59 public AssignmentOperators<typename T_Type::Tape::Real, T_Type::Tape::AllowJacobianOptimization,
60 ReferenceActiveType<T_Type>>,
61 public IncrementOperators<typename T_Type::Tape, ReferenceActiveType<T_Type>> {
62 public:
63
65 using Type = CODI_DD(T_Type, CODI_DEFAULT_LHS_EXPRESSION);
66 using Tape = typename Type::Tape;
67
68 using Real = typename Tape::Real;
70 using Identifier = typename Tape::Identifier;
71 using Gradient = typename Tape::Gradient;
72 using TapeData = typename Tape::ActiveTypeTapeData;
73
74 protected:
75
77
78 public:
79
80 // TODO: Implement const variant
81
83 mutable Real jacobian;
84
87
90
96 using LhsExpressionInterface<Real, Gradient, Tape, ReferenceActiveType>::operator=;
97
98 /*******************************************************************************/
101
103 using ADLogic = Tape;
104
107 return reference.getIdentifier();
108 }
109
112 return reference.getIdentifier();
113 }
114
117 return reference.getTapeData();
118 }
119
122 return reference.getTapeData();
123 }
124
127 return reference.value();
128 }
129
131 CODI_INLINE Real const& value() const {
132 return reference.value();
133 }
134
136 static CODI_INLINE decltype(Type::getTape()) getTape() {
137 return Type::getTape();
138 }
139 };
140}
#define CODI_INLINE
See codi::Config::ForcedInlines.
Definition config.h:469
#define CODI_DD(Type, Default)
Abbreviation for CODI_DECLARE_DEFAULT.
Definition macros.hpp:97
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:97
Provides assignment operators for LhsExpressionInterface implementations.
Definition assignmentOperators.hpp:120
Implementation of increment operators for LhsExpressionInterface implementations.
Definition incrementOperators.hpp:54
Base class for all CoDiPack lvalue expression.
Definition lhsExpressionInterface.hpp:63
Holds a reference to an ActiveType for manual optimization of common arguments.
Definition referenceActiveType.hpp:61
Tape ADLogic
AD logic that governs the expression. Needs to be the same for all inputs of the expression.
Definition referenceActiveType.hpp:103
Real jacobian
Used by Jacobian tapes to optimize for reoccurring arguments.
Definition referenceActiveType.hpp:83
Type & reference
Reference to the underlying active type.
Definition referenceActiveType.hpp:76
inlineTapeData const & getTapeData() const
Get the data of the tape stored in this lhs expression.
Definition referenceActiveType.hpp:121
typename Tape::Real Real
See LhsExpressionInterface.
Definition referenceActiveType.hpp:68
typename Tape::ActiveTypeTapeData TapeData
See IdentifierInformationTapeInterface.
Definition referenceActiveType.hpp:72
ReferenceActiveType const & StoreAs
Defines how this expression is stored in an expression tree.
Definition referenceActiveType.hpp:102
typename Tape::Gradient Gradient
See LhsExpressionInterface.
Definition referenceActiveType.hpp:71
inlineReal & value()
Get a reference to the lvalue represented by the expression.
Definition referenceActiveType.hpp:126
RealTraits::PassiveReal< Real > PassiveReal
Basic computation type.
Definition referenceActiveType.hpp:69
inlineReal const & value() const
Get a constant reference to the lvalue represented by the expression.
Definition referenceActiveType.hpp:131
typename Type::Tape Tape
See LhsExpressionInterface.
Definition referenceActiveType.hpp:66
T_Type Type
See ReferenceActiveType.
Definition referenceActiveType.hpp:65
inlineTapeData & getTapeData()
Get the data of the tape stored in this lhs expression.
Definition referenceActiveType.hpp:116
inlineIdentifier & getIdentifier()
Definition referenceActiveType.hpp:106
typename Tape::Identifier Identifier
See LhsExpressionInterface.
Definition referenceActiveType.hpp:70
inlineReferenceActiveType & operator=(ReferenceActiveType const &v)
See LhsExpressionInterface::operator=(ExpressionInterface const&).
Definition referenceActiveType.hpp:92
inlineIdentifier const & getIdentifier() const
Definition referenceActiveType.hpp:111