CoDiPack  2.2.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-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 "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::ActiveResult;
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}
#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
CoDiPack - Code Differentiation Package.
Definition codi.hpp:90
Represents the base implementation concrete lvalue in the CoDiPack expression tree.
Definition activeTypeBase.hpp:64
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
Impl ActiveResult
Type into which the expression can be converted. Usually also the type from which it is constructed.
Definition activeTypeBase.hpp:148
typename Tape::Gradient Gradient
See LhsExpressionInterface.
Definition activeTypeBase.hpp:79
LhsExpressionInterface< Real, Gradient, T_Tape, T_Impl > Base
Base class abbreviation.
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
ActiveType(ActiveType< Tape > const &v)
Constructor.
Definition activeType.hpp:74
ActiveType & operator=(ActiveType const &v)
See ActiveTypeBase::operator=(ActiveTypeBase const&).
Definition activeType.hpp:86
T_Tape Tape
See ActiveType.
Definition activeType.hpp:55
static Tape & getTape()
Get a reference to the tape which manages this expression.
Definition activeType.hpp:99
~ActiveType()
Destructor.
Definition activeType.hpp:79