CoDiPack  3.0.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-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 "../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
73 protected:
74
76
77 public:
78
79 // TODO: Implement const variant
80
82 mutable Real jacobian;
83
86
89
95 using LhsExpressionInterface<Real, Gradient, Tape, ReferenceActiveType>::operator=;
96
97 /*******************************************************************************/
100
102 using ADLogic = Tape;
103
106 return reference.getIdentifier();
107 }
108
111 return reference.getIdentifier();
112 }
113
116 return reference.value();
117 }
118
120 CODI_INLINE Real const& value() const {
121 return reference.value();
122 }
123
125 static CODI_INLINE decltype(Type::getTape()) getTape() {
126 return Type::getTape();
127 }
128 };
129}
#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
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
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:102
Real jacobian
Used by Jacobian tapes to optimize for reoccurring arguments.
Definition referenceActiveType.hpp:82
Type & reference
Reference to the underlying active type.
Definition referenceActiveType.hpp:75
typename Tape::Real Real
See LhsExpressionInterface.
Definition referenceActiveType.hpp:68
ReferenceActiveType const & StoreAs
Defines how this expression is stored in an expression tree.
Definition referenceActiveType.hpp:101
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:115
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:120
typename Type::Tape Tape
See LhsExpressionInterface.
Definition referenceActiveType.hpp:66
T_Type Type
See ReferenceActiveType.
Definition referenceActiveType.hpp:65
inlineIdentifier & getIdentifier()
Definition referenceActiveType.hpp:105
typename Tape::Identifier Identifier
See LhsExpressionInterface.
Definition referenceActiveType.hpp:70
inlineReferenceActiveType & operator=(ReferenceActiveType const &v)
See LhsExpressionInterface::operator=(ExpressionInterface const&).
Definition referenceActiveType.hpp:91
inlineIdentifier const & getIdentifier() const
Definition referenceActiveType.hpp:110