CoDiPack  3.1.0
A Code Differentiation Package
SciComp TU Kaiserslautern
Loading...
Searching...
No Matches
macros.hpp
Go to the documentation of this file.
1/*
2 * CoDiPack, a Code Differentiation Package
3 *
4 * Copyright (C) 2015-2026 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 "../config.h"
38
40
42namespace codi {
43
44 struct EmptyPosition;
45
46 template<typename T_Real, typename T_Gradient, typename T_Identifier, typename T_Position,
47 typename T_ActiveTypeTapeData>
48 struct FullTapeInterface;
49
50 template<typename T_Tape>
51 struct ActiveType;
52
54 template<typename... Args>
55 CODI_INLINE void CODI_UNUSED(Args const&...) {}
56
58#define CODI_UNUSED_ARG(arg) /* arg */
59
62#define CODI_ENABLE_CHECK(option, condition) (!(option) || (condition))
63
65#define CODI_TO_STRING2(expression) #expression
66
68#define CODI_TO_STRING(expression) CODI_TO_STRING2(expression)
69
70/*******************************************************************************/
79
86#if CODI_IDE
87 #define CODI_DECLARE_DEFAULT(Type, Default) Default
88#else
89 #define CODI_DECLARE_DEFAULT(Type, Default) Type
90#endif
91
93// Does not work in QT if CODI_DECLARE_DEFAULT is used
94#if CODI_IDE
95 #define CODI_DD(Type, Default) Default
96#else
97 #define CODI_DD(Type, Default) Type
98#endif
99
101#define CODI_ANY int
102
104#define CODI_ANY_T(Type) Type
105
106#ifndef DOXYGEN_DISABLE
108 struct ImplProxy {};
109#endif
111#define CODI_IMPLEMENTATION ImplProxy
112
114#define CODI_TEMPLATE(...) __VA_ARGS__
115
117#define CODI_T(...) CODI_TEMPLATE(__VA_ARGS__)
118
120#define CODI_UNDEFINED char
121
123#define CODI_UNDEFINED_VALUE false
124
126#if CODI_IDE
127 #define CODI_STATIC_ASSERT(cond, message) /* Do not check in IDE mode */
128#else
130 #define CODI_STATIC_ASSERT(cond, message) static_assert(cond, message)
131#endif
132
133#if CODI_IDE
135 struct ActiveTypeProxy {
136 using Real = double;
137 using Identifier = int;
138 using TapeData = int;
139 };
140
142 #define CODI_DEFAULT_TAPE FullTapeInterface<double, double, int, EmptyPosition, int>
143
145 #define CODI_DEFAULT_PARALLEL_TAPE CODI_UNION<CODI_DEFAULT_TAPE, EditingTapeInterface<EmptyPosition>>
146
148 #define CODI_DEFAULT_LHS_EXPRESSION LhsExpressionInterface<double, double, CODI_DEFAULT_TAPE, CODI_ANY>
149
151 #define CODI_DEFAULT_ACTIVE_TYPE ActiveType<CODI_DEFAULT_TAPE>
152#endif
153
154#ifndef DOXYGEN_DISABLE
156 template<typename First, typename... Tail>
157 struct CODI_UNION : public First, public CODI_UNION<Tail...> {};
158#endif
159
161 template<typename First>
162 struct CODI_UNION<First> : public First {};
163
165
167#define CODI_WRAP_FUNCTION(NAME, FUNC) \
168 struct NAME { \
169 public: \
170 \
171 template<typename... Args> \
172 void operator()(Args&&... args) const { \
173 FUNC(std::forward<Args>(args)...); \
174 } \
175 }
176
178#define CODI_WRAP_FUNCTION_TEMPLATE(NAME, FUNC) \
179 template<typename... TT> \
180 struct NAME { \
181 public: \
182 \
183 template<typename... Args> \
184 void operator()(Args&&... args) const { \
185 FUNC<TT...>(std::forward<Args>(args)...); \
186 } \
187 }
188}
#define CODI_INLINE
See codi::Config::ForcedInlines.
Definition config.h:469
CoDiPack - Code Differentiation Package.
Definition codi.hpp:97
inlinevoid CODI_UNUSED(Args const &...)
Disable unused warnings for an arbitrary number of arguments.
Definition macros.hpp:55
Represents a concrete lvalue in the CoDiPack expression tree.
Definition activeType.hpp:52
Empty Position with no nested data.
Definition position.hpp:47
Full tape interface that supports all features of CoDiPack.
Definition fullTapeInterface.hpp:89