CoDiPack  3.0.0
A Code Differentiation Package
SciComp TU Kaiserslautern
Loading...
Searching...
No Matches
activeType.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 "activeTypeBase.hpp"
38
40namespace codi {
41
51 template<typename T_Tape>
52 struct ActiveType : public ActiveTypeBase<T_Tape, ActiveType<T_Tape>> {
53 public:
54
55 using Tape = CODI_DD(T_Tape, CODI_DEFAULT_TAPE);
56
58
59 using typename Base::Gradient;
60 using typename Base::Identifier;
61 using typename Base::PassiveReal;
62 using typename Base::Real;
63
64 using typename Base::ADLogic;
65 using typename Base::StoreAs;
66
67 private:
68
69 static Tape tape;
70
71 public:
72
74 CODI_INLINE ActiveType(ActiveType<Tape> const& v) : Base(static_cast<Base const&>(v)) {}
75
76 using Base::Base; // Use constructors from base class.
77
80
81 /*******************************************************************************/
84
87 static_cast<Base&>(*this) = static_cast<Base const&>(v);
88 return *this;
89 }
90
91 using Base::operator=;
92
94 /*******************************************************************************/
97
100 return tape;
101 }
102
104 };
105
106 // clang-format off
107 template<typename Tape>
108 CODI_DD(Tape, CODI_DEFAULT_TAPE) ActiveType<Tape>::tape{};
109 // clang-format on
110
112 template<typename T_Real, typename T_Tape>
113 struct ExpressionTraits::ActiveResultImpl<T_Real, T_Tape, false> {
114 public:
115
116 using Real = CODI_DD(T_Real, CODI_ANY);
117 using Tape = CODI_DD(T_Tape, CODI_ANY);
118
121 };
122}
#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
CoDiPack - Code Differentiation Package.
Definition codi.hpp:94
Represents the base implementation concrete lvalue in the CoDiPack expression tree.
Definition activeTypeBase.hpp:64
Tape ADLogic
AD logic that governs the expression. Needs to be the same for all inputs of the expression.
Definition activeTypeBase.hpp:148
Impl const & StoreAs
Defines how this expression is stored in an expression tree.
Definition activeTypeBase.hpp:147
RealTraits::PassiveReal< Real > PassiveReal
Basic computation type.
Definition activeTypeBase.hpp:77
typename Tape::Identifier Identifier
See LhsExpressionInterface.
Definition activeTypeBase.hpp:78
typename Tape::Gradient Gradient
See LhsExpressionInterface.
Definition activeTypeBase.hpp:79
LhsExpressionInterface< Real, Gradient, T_Tape, ActiveType > Base
Definition activeTypeBase.hpp:81
typename Tape::Real Real
See LhsExpressionInterface.
Definition activeTypeBase.hpp:76
Represents a concrete lvalue in the CoDiPack expression tree.
Definition activeType.hpp:52
static inlineTape & getTape()
Definition activeType.hpp:99
inline ~ActiveType()
Definition activeType.hpp:79
ForwardEvaluation< Real, Gradient > Tape
Definition activeType.hpp:55
ActiveTypeBase< ForwardEvaluation< Real, Gradient >, ActiveType > Base
Definition activeType.hpp:57
inlineActiveType & operator=(ActiveType const &v)
Definition activeType.hpp:86
ActiveType< Tape > ActiveResult
The resulting active type of an expression.
Definition activeType.hpp:120
T_Tape Tape
See ExpressionTraits::ActiveResultImpl.
Definition activeType.hpp:117
T_Real Real
See ExpressionTraits::ActiveResultImpl.
Definition activeType.hpp:116
Definition expressionTraits.hpp:127