CoDiPack  2.2.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-2024 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>
56 struct ReferenceActiveType : public LhsExpressionInterface<typename T_Type::Real, typename T_Type::Gradient,
57 typename T_Type::Tape, ReferenceActiveType<T_Type>>,
58 public AssignmentOperators<T_Type, ReferenceActiveType<T_Type>>,
59 public IncrementOperators<T_Type, ReferenceActiveType<T_Type>> {
60 public:
61
63 using Type = CODI_DD(T_Type, CODI_DEFAULT_LHS_EXPRESSION);
64 using Tape = typename Type::Tape;
65
66 using Real = typename Tape::Real;
68 using Identifier = typename Tape::Identifier;
69 using Gradient = typename Tape::Gradient;
70
71 private:
72
73 Type& reference;
74
75 public:
76
77 // TODO: Implement const variant
78
80 mutable Real jacobian;
81
84
91
92 /*******************************************************************************/
95
97 using ActiveResult = typename Type::ActiveResult;
98
101 return reference.getIdentifier();
102 }
103
106 return reference.getIdentifier();
107 }
108
111 return reference.value();
112 }
113
115 CODI_INLINE Real const& value() const {
116 return reference.value();
117 }
118
120 static CODI_INLINE decltype(Type::getTape()) getTape() {
121 return Type::getTape();
122 }
123 };
124}
#define CODI_INLINE
See codi::Config::ForcedInlines.
Definition config.h:457
#define CODI_DD(Type, Default)
Abbreviation for CODI_DECLARE_DEFAULT.
Definition macros.hpp:94
typename TraitsImplementation< Type >::PassiveReal PassiveReal
The original computation type, that was used in the application.
Definition realTraits.hpp:117
CoDiPack - Code Differentiation Package.
Definition codi.hpp:90
Implementation of assignment operators for LhsExpressionInterface implementations.
Definition assignmentOperators.hpp:54
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:59
Real jacobian
Used by Jacobian tapes to optimize for reoccurring arguments.
Definition referenceActiveType.hpp:80
Real & value()
Get a reference to the lvalue represented by the expression.
Definition referenceActiveType.hpp:110
Identifier & getIdentifier()
Definition referenceActiveType.hpp:100
Real const & value() const
Get a constant reference to the lvalue represented by the expression.
Definition referenceActiveType.hpp:115
Identifier const & getIdentifier() const
Definition referenceActiveType.hpp:105
static decltype(Type::getTape()) getTape()
Get a reference to the tape which manages this expression.
Definition referenceActiveType.hpp:120
typename Tape::Real Real
See LhsExpressionInterface.
Definition referenceActiveType.hpp:66
ReferenceActiveType const & StoreAs
Defines how this expression is stored in an expression tree.
Definition referenceActiveType.hpp:96
ReferenceActiveType(Type &v)
Constructor.
Definition referenceActiveType.hpp:83
typename Tape::Gradient Gradient
See LhsExpressionInterface.
Definition referenceActiveType.hpp:69
RealTraits::PassiveReal< Real > PassiveReal
Basic computation type.
Definition referenceActiveType.hpp:67
typename Type::Tape Tape
See LhsExpressionInterface.
Definition referenceActiveType.hpp:64
T_Type Type
See ReferenceActiveType.
Definition referenceActiveType.hpp:63
typename Type::ActiveResult ActiveResult
Type into which the expression can be converted. Usually also the type from which it is constructed.
Definition referenceActiveType.hpp:97
typename Tape::Identifier Identifier
See LhsExpressionInterface.
Definition referenceActiveType.hpp:68
ReferenceActiveType< Tape > & operator=(ReferenceActiveType< Tape > const &v)
See LhsExpressionInterface::operator=(ExpressionInterface const&).
Definition referenceActiveType.hpp:86