CoDiPack  3.0.0
A Code Differentiation Package
SciComp TU Kaiserslautern
Loading...
Searching...
No Matches
tapeTraits.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 <type_traits>
38
39#include "../config.h"
40#include "../misc/macros.hpp"
41#include "../tapes/interfaces/editingTapeInterface.hpp"
42#include "misc/enableIfHelpers.hpp"
43
45namespace codi {
46 template<typename Tape, typename Impl>
48
49 template<typename Tape, typename Impl>
50 struct JacobianBaseTape;
51
52 template<typename T_Real, typename T_Gradient>
53 struct ForwardEvaluation;
54
55 template<typename T_Real, typename T_Tag>
56 struct TagTapeForward;
57
58 template<typename T_Real, typename T_Tag>
59 struct TagTapeReverse;
60
63 namespace TapeTraits {
64
65 /*******************************************************************************/
68
70 template<typename Tape, typename = void>
71 struct IsForwardTape : std::false_type {};
72
73#ifndef DOXYGEN_DISABLE
74 template<typename Tape>
75 struct IsForwardTape<
76 Tape, typename enable_if_base_of<ForwardEvaluation<typename Tape::Real, typename Tape::Gradient>, Tape>::type>
77 : std::true_type {};
78
79 template<typename Tape>
80 struct IsForwardTape<
81 Tape, typename enable_if_base_of<TagTapeForward<typename Tape::Real, typename Tape::Tag>, Tape>::type>
82 : std::true_type {};
83#endif
84
86 template<typename Tape>
88
90 template<typename Tape>
91 using EnableIfForwardTape = typename std::enable_if<IsForwardTape<Tape>::value>::type;
92
94 template<typename Tape, typename = void>
95 struct IsPrimalValueTape : std::false_type {};
96
97#ifndef DOXYGEN_DISABLE
98 template<typename Tape>
99 struct IsPrimalValueTape<
100 Tape, typename enable_if_base_of<PrimalValueBaseTape<typename Tape::TapeTypes, Tape>, Tape>::type>
101 : std::true_type {};
102#endif
103
105 template<typename Tape>
107
109 template<typename Tape>
110 using EnableIfPrimalValueTape = typename std::enable_if<IsPrimalValueTape<Tape>::value>::type;
111
113 template<typename Tape, typename = void>
114 struct IsJacobianTape : std::false_type {};
115
116#ifndef DOXYGEN_DISABLE
117 template<typename Tape>
118 struct IsJacobianTape<Tape,
119 typename enable_if_base_of<JacobianBaseTape<typename Tape::TapeTypes, Tape>, Tape>::type>
120 : std::true_type {};
121#endif
122
124 template<typename Tape>
126
128 template<typename Tape>
129 using EnableIfJacobianTape = typename std::enable_if<IsJacobianTape<Tape>::value>::type;
130
131 template<typename Tape, typename = void>
132 struct IsReverseTape : std::false_type {};
133
134#ifndef DOXYGEN_DISABLE
136 template<typename Tape>
137 struct IsReverseTape<Tape,
138 typename std::enable_if<IsJacobianTape<Tape>::value || IsPrimalValueTape<Tape>::value>::type>
139 : std::true_type {};
140
141 template<typename Tape>
142 struct IsReverseTape<
143 Tape, typename enable_if_base_of<TagTapeReverse<typename Tape::Real, typename Tape::Tag>, Tape>::type>
144 : std::true_type {};
145#endif
146
148 template<typename Tape>
150
152 template<typename Tape>
153 using EnableIfReverseTape = typename std::enable_if<IsReverseTape<Tape>::value>::type;
154
155 template<typename Tape, typename = void>
156 struct SupportsEditing : std::false_type {};
157
158#ifndef DOXYGEN_DISABLE
159 template<typename Tape>
160 struct SupportsEditing<Tape, typename enable_if_base_of<EditingTapeInterface<typename Tape::Position>, Tape>::type>
161 : std::true_type {};
162#endif
163
165 template<typename Tape>
167
169 template<typename Tape>
170 using EnableIfSupportsEditing = typename std::enable_if<SupportsEditing<Tape>::value>::type;
171
173 template<typename Tape>
174 using EnableIfNoEditing = typename std::enable_if<!SupportsEditing<Tape>::value>::type;
175
177 template<typename Tape, typename = void>
178 struct IsTagTape : std::false_type {};
179
180#ifndef DOXYGEN_DISABLE
181 template<typename Tape>
182 struct IsTagTape<Tape,
183 typename enable_if_base_of<TagTapeReverse<typename Tape::Real, typename Tape::Tag>, Tape>::type>
184 : std::true_type {};
185
186 template<typename Tape>
187 struct IsTagTape<Tape,
188 typename enable_if_base_of<TagTapeForward<typename Tape::Real, typename Tape::Tag>, Tape>::type>
189 : std::true_type {};
190#endif
191
193 template<typename Tape>
195
197 template<typename Tape>
198 using EnableIfTagTape = typename std::enable_if<IsTagTape<Tape>::value>::type;
199
201 template<typename Tape, typename = void>
202 struct IsTagTapeReverse : std::false_type {};
203
204#ifndef DOXYGEN_DISABLE
205 template<typename Tape>
206 struct IsTagTapeReverse<
207 Tape, typename enable_if_base_of<TagTapeReverse<typename Tape::Real, typename Tape::Tag>, Tape>::type>
208 : std::true_type {};
209#endif
210
212 template<typename Tape>
214
216 template<typename Tape>
217 using EnableIfTagTapeReverse = typename std::enable_if<IsTagTapeReverse<Tape>::value>::type;
218
220 }
221}
Definition tapeTraits.hpp:63
typename std::enable_if< SupportsEditing< Tape >::value >::type EnableIfSupportsEditing
Enable if wrapper for SupportsEditing.
Definition tapeTraits.hpp:170
bool constexpr isReverseTape
Value entry of IsReverseTape.
Definition tapeTraits.hpp:149
bool constexpr isTagTapeReverse
Value entry of IsTagTape.
Definition tapeTraits.hpp:213
bool constexpr supportsEditing
Value entry of SupportsEditing.
Definition tapeTraits.hpp:166
typename std::enable_if< IsTagTapeReverse< Tape >::value >::type EnableIfTagTapeReverse
Enable if wrapper for IsTagTape.
Definition tapeTraits.hpp:217
typename std::enable_if< IsJacobianTape< Tape >::value >::type EnableIfJacobianTape
Enable if wrapper for IsJacobianTape.
Definition tapeTraits.hpp:129
typename std::enable_if< IsPrimalValueTape< Tape >::value >::type EnableIfPrimalValueTape
Enable if wrapper for IsPrimalValueTape.
Definition tapeTraits.hpp:110
typename std::enable_if< IsForwardTape< Tape >::value >::type EnableIfForwardTape
Enable if wrapper for IsForwardTape.
Definition tapeTraits.hpp:91
bool constexpr isPrimalValueTape
Value entry of IsPrimalValueTape.
Definition tapeTraits.hpp:106
bool constexpr isForwardTape
Value entry of IsForwardTape.
Definition tapeTraits.hpp:87
bool constexpr isTagTape
Value entry of IsTagTape.
Definition tapeTraits.hpp:194
bool constexpr isJacobianTape
Value entry of IsJacobianTape.
Definition tapeTraits.hpp:125
typename std::enable_if< IsTagTape< Tape >::value >::type EnableIfTagTape
Enable if wrapper for IsTagTape.
Definition tapeTraits.hpp:198
typename std::enable_if<!SupportsEditing< Tape >::value >::type EnableIfNoEditing
Enable if wrapper for SupportsEditing.
Definition tapeTraits.hpp:174
typename std::enable_if< IsReverseTape< Tape >::value >::type EnableIfReverseTape
Enable if wrapper for IsReverseTape.
Definition tapeTraits.hpp:153
CoDiPack - Code Differentiation Package.
Definition codi.hpp:94
std::enable_if< std::is_base_of< Base, Impl >::value, R > enable_if_base_of
Enable if abbreviation for std::is_base_of.
Definition enableIfHelpers.hpp:47
Edit tapes after they have been recorded.
Definition editingTapeInterface.hpp:65
Implementation of a tape-free forward AD mode through the internal expression interfaces.
Definition forwardEvaluation.hpp:74
Base class for all standard Jacobian tape implementations.
Definition jacobianBaseTape.hpp:130
Base class for all standard Primal value tape implementations.
Definition primalValueBaseTape.hpp:131
Tape for tagging variables and find errors in the AD workflow.
Definition tagTapeForward.hpp:62
Tape for tagging variables and find errors in the AD workflow.
Definition tagTapeReverse.hpp:56
If the tape inherits from ForwardEvaluation.
Definition tapeTraits.hpp:71
If the tape inherits from JacobianBaseTape.
Definition tapeTraits.hpp:114
If the tape inherits from PrimalValueBaseTape.
Definition tapeTraits.hpp:95
Definition tapeTraits.hpp:132
If the tape inherits from TagTapeReverse.
Definition tapeTraits.hpp:202
If the tape inherits from TagTapeBase.
Definition tapeTraits.hpp:178
Definition tapeTraits.hpp:156