CoDiPack  2.3.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-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 <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>
47 struct PrimalValueBaseTape;
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
85#if CODI_IS_CPP14
87 template<typename Tape>
88 bool constexpr isForwardTape = IsForwardTape<Tape>::value;
89#endif
90
92 template<typename Tape>
93 using EnableIfForwardTape = typename std::enable_if<IsForwardTape<Tape>::value>::type;
94
96 template<typename Tape, typename = void>
97 struct IsPrimalValueTape : std::false_type {};
98
99#ifndef DOXYGEN_DISABLE
100 template<typename Tape>
101 struct IsPrimalValueTape<
102 Tape, typename enable_if_base_of<PrimalValueBaseTape<typename Tape::TapeTypes, Tape>, Tape>::type>
103 : std::true_type {};
104#endif
105
106#if CODI_IS_CPP14
108 template<typename Tape>
109 bool constexpr isPrimalValueTape = IsPrimalValueTape<Tape>::value;
110#endif
111
113 template<typename Tape>
114 using EnableIfPrimalValueTape = typename std::enable_if<IsPrimalValueTape<Tape>::value>::type;
115
117 template<typename Tape, typename = void>
118 struct IsJacobianTape : std::false_type {};
119
120#ifndef DOXYGEN_DISABLE
121 template<typename Tape>
122 struct IsJacobianTape<Tape,
123 typename enable_if_base_of<JacobianBaseTape<typename Tape::TapeTypes, Tape>, Tape>::type>
124 : std::true_type {};
125#endif
126
127#if CODI_IS_CPP14
129 template<typename Tape>
130 bool constexpr isJacobianTape = IsJacobianTape<Tape>::value;
131#endif
132
134 template<typename Tape>
135 using EnableIfJacobianTape = typename std::enable_if<IsJacobianTape<Tape>::value>::type;
136
137 template<typename Tape, typename = void>
138 struct IsReverseTape : std::false_type {};
139
140#ifndef DOXYGEN_DISABLE
142 template<typename Tape>
143 struct IsReverseTape<Tape,
144 typename std::enable_if<IsJacobianTape<Tape>::value || IsPrimalValueTape<Tape>::value>::type>
145 : std::true_type {};
146
147 template<typename Tape>
148 struct IsReverseTape<
149 Tape, typename enable_if_base_of<TagTapeReverse<typename Tape::Real, typename Tape::Tag>, Tape>::type>
150 : std::true_type {};
151#endif
152
153#if CODI_IS_CPP14
155 template<typename Tape>
156 bool constexpr isReverseTape = IsReverseTape<Tape>::value;
157#endif
158
160 template<typename Tape>
161 using EnableIfReverseTape = typename std::enable_if<IsReverseTape<Tape>::value>::type;
162
163 template<typename Tape, typename = void>
164 struct SupportsEditing : std::false_type {};
165
166#ifndef DOXYGEN_DISABLE
167 template<typename Tape>
168 struct SupportsEditing<Tape, typename enable_if_base_of<EditingTapeInterface<typename Tape::Position>, Tape>::type>
169 : std::true_type {};
170#endif
171
172#if CODI_IS_CPP14
174 template<typename Tape>
175 bool constexpr supportsEditing = SupportsEditing<Tape>::value;
176#endif
177
179 template<typename Tape>
180 using EnableIfSupportsEditing = typename std::enable_if<SupportsEditing<Tape>::value>::type;
181
183 template<typename Tape>
184 using EnableIfNoEditing = typename std::enable_if<!SupportsEditing<Tape>::value>::type;
185
187 }
188}
typename std::enable_if< SupportsEditing< Tape >::value >::type EnableIfSupportsEditing
Enable if wrapper for SupportsEditing.
Definition tapeTraits.hpp:180
typename std::enable_if< IsJacobianTape< Tape >::value >::type EnableIfJacobianTape
Enable if wrapper for IsJacobianTape.
Definition tapeTraits.hpp:135
typename std::enable_if< IsPrimalValueTape< Tape >::value >::type EnableIfPrimalValueTape
Enable if wrapper for IsPrimalValueTape.
Definition tapeTraits.hpp:114
typename std::enable_if< IsForwardTape< Tape >::value >::type EnableIfForwardTape
Enable if wrapper for IsForwardTape.
Definition tapeTraits.hpp:93
typename std::enable_if<!SupportsEditing< Tape >::value >::type EnableIfNoEditing
Enable if wrapper for SupportsEditing.
Definition tapeTraits.hpp:184
typename std::enable_if< IsReverseTape< Tape >::value >::type EnableIfReverseTape
Enable if wrapper for IsReverseTape.
Definition tapeTraits.hpp:161
CoDiPack - Code Differentiation Package.
Definition codi.hpp:91
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
Represents a concrete lvalue in the CoDiPack expression tree.
Definition activeType.hpp:52
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:72
Base class for all standard Jacobian tape implementations.
Definition jacobianBaseTape.hpp:128
Base class for all standard Primal value tape implementations.
Definition primalValueBaseTape.hpp:137
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:118
If the tape inherits from PrimalValueBaseTape.
Definition tapeTraits.hpp:97
Definition tapeTraits.hpp:138
Definition tapeTraits.hpp:164