CoDiPack  2.2.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/jacobianBaseTape.hpp"
42#include "../tapes/primalValueBaseTape.hpp"
43
45namespace codi {
46
47 template<typename T_Real, typename T_Gradient>
48 struct ForwardEvaluation;
49
50 template<typename T_Real, typename T_Tag>
51 struct TagTapeForward;
52
53 template<typename T_Real, typename T_Tag>
54 struct TagTapeReverse;
55
58 namespace TapeTraits {
59
60 /*******************************************************************************/
63
65 template<typename Tape, typename = void>
66 struct IsForwardTape : std::false_type {};
67
68#ifndef DOXYGEN_DISABLE
69 template<typename Tape>
70 struct IsForwardTape<
71 Tape, typename enable_if_base_of<ForwardEvaluation<typename Tape::Real, typename Tape::Gradient>, Tape>::type>
72 : std::true_type {};
73
74 template<typename Tape>
75 struct IsForwardTape<
76 Tape, typename enable_if_base_of<TagTapeForward<typename Tape::Real, typename Tape::Tag>, Tape>::type>
77 : std::true_type {};
78#endif
79
80#if CODI_IS_CPP14
82 template<typename Tape>
83 bool constexpr isForwardTape = IsForwardTape<Tape>::value;
84#endif
85
87 template<typename Tape>
88 using EnableIfForwardTape = typename std::enable_if<IsForwardTape<Tape>::value>::type;
89
91 template<typename Tape, typename = void>
92 struct IsPrimalValueTape : std::false_type {};
93
94#ifndef DOXYGEN_DISABLE
95 template<typename Tape>
96 struct IsPrimalValueTape<
97 Tape, typename enable_if_base_of<PrimalValueBaseTape<typename Tape::TapeTypes, Tape>, Tape>::type>
98 : std::true_type {};
99#endif
100
101#if CODI_IS_CPP14
103 template<typename Tape>
104 bool constexpr isPrimalValueTape = IsPrimalValueTape<Tape>::value;
105#endif
106
108 template<typename Tape>
109 using EnableIfPrimalValueTape = typename std::enable_if<IsPrimalValueTape<Tape>::value>::type;
110
112 template<typename Tape, typename = void>
113 struct IsJacobianTape : std::false_type {};
114
115#ifndef DOXYGEN_DISABLE
116 template<typename Tape>
117 struct IsJacobianTape<Tape,
118 typename enable_if_base_of<JacobianBaseTape<typename Tape::TapeTypes, Tape>, Tape>::type>
119 : std::true_type {};
120#endif
121
122#if CODI_IS_CPP14
124 template<typename Tape>
125 bool constexpr isJacobianTape = IsJacobianTape<Tape>::value;
126#endif
127
129 template<typename Tape>
130 using EnableIfJacobianTape = typename std::enable_if<IsJacobianTape<Tape>::value>::type;
131
132 template<typename Tape, typename = void>
133 struct IsReverseTape : std::false_type {};
134
135#ifndef DOXYGEN_DISABLE
137 template<typename Tape>
138 struct IsReverseTape<Tape,
139 typename std::enable_if<IsJacobianTape<Tape>::value || IsPrimalValueTape<Tape>::value>::type>
140 : std::true_type {};
141
142 template<typename Tape>
143 struct IsReverseTape<
144 Tape, typename enable_if_base_of<TagTapeReverse<typename Tape::Real, typename Tape::Tag>, Tape>::type>
145 : std::true_type {};
146#endif
147
148#if CODI_IS_CPP14
150 template<typename Tape>
151 bool constexpr isReverseTape = IsReverseTape<Tape>::value;
152#endif
153
155 template<typename Tape>
156 using EnableIfReverseTape = typename std::enable_if<IsReverseTape<Tape>::value>::type;
157
159 }
160}
typename std::enable_if< IsJacobianTape< Tape >::value >::type EnableIfJacobianTape
Enable if wrapper for IsJacobianTape.
Definition tapeTraits.hpp:130
typename std::enable_if< IsPrimalValueTape< Tape >::value >::type EnableIfPrimalValueTape
Enable if wrapper for IsPrimalValueTape.
Definition tapeTraits.hpp:109
typename std::enable_if< IsForwardTape< Tape >::value >::type EnableIfForwardTape
Enable if wrapper for IsForwardTape.
Definition tapeTraits.hpp:88
typename std::enable_if< IsReverseTape< Tape >::value >::type EnableIfReverseTape
Enable if wrapper for IsReverseTape.
Definition tapeTraits.hpp:156
CoDiPack - Code Differentiation Package.
Definition codi.hpp:90
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
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:125
Base class for all standard Primal value tape implementations.
Definition primalValueBaseTape.hpp:136
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:66
If the tape inherits from JacobianBaseTape.
Definition tapeTraits.hpp:113
If the tape inherits from PrimalValueBaseTape.
Definition tapeTraits.hpp:92
Definition tapeTraits.hpp:133