CoDiPack  3.0.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-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 "../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 struct FullTapeInterface;
48
49 template<typename T_Tape>
50 struct ActiveType;
51
53 template<typename... Args>
54 CODI_INLINE void CODI_UNUSED(Args const&...) {}
55
57#define CODI_UNUSED_ARG(arg) /* arg */
58
61#define CODI_ENABLE_CHECK(option, condition) (!(option) || (condition))
62
64#define CODI_TO_STRING2(expression) #expression
65
67#define CODI_TO_STRING(expression) CODI_TO_STRING2(expression)
68
69/*******************************************************************************/
78
85#if CODI_IDE
86 #define CODI_DECLARE_DEFAULT(Type, Default) Default
87#else
88 #define CODI_DECLARE_DEFAULT(Type, Default) Type
89#endif
90
92// Does not work in QT if CODI_DECLARE_DEFAULT is used
93#if CODI_IDE
94 #define CODI_DD(Type, Default) Default
95#else
96 #define CODI_DD(Type, Default) Type
97#endif
98
100#define CODI_ANY int
101
103#define CODI_ANY_T(Type) Type
104
105#ifndef DOXYGEN_DISABLE
107 struct ImplProxy {};
108#endif
110#define CODI_IMPLEMENTATION ImplProxy
111
113#define CODI_TEMPLATE(...) __VA_ARGS__
114
116#define CODI_T(...) CODI_TEMPLATE(__VA_ARGS__)
117
119#define CODI_UNDEFINED char
120
122#define CODI_UNDEFINED_VALUE false
123
125#if CODI_IDE
126 #define CODI_STATIC_ASSERT(cond, message) /* Do not check in IDE mode */
127#else
129 #define CODI_STATIC_ASSERT(cond, message) static_assert(cond, message)
130#endif
131
132#if CODI_IDE
134 struct ActiveTypeProxy {
135 using Real = double;
136 using Identifier = int;
137 };
138
140 #define CODI_DEFAULT_TAPE FullTapeInterface<double, double, int, EmptyPosition>
141
143 #define CODI_DEFAULT_PARALLEL_TAPE CODI_UNION<CODI_DEFAULT_TAPE, EditingTapeInterface<EmptyPosition>>
144
146 #define CODI_DEFAULT_LHS_EXPRESSION LhsExpressionInterface<double, double, CODI_DEFAULT_TAPE, CODI_ANY>
147
149 #define CODI_DEFAULT_ACTIVE_TYPE ActiveType<CODI_DEFAULT_TAPE>
150#endif
151
152#ifndef DOXYGEN_DISABLE
154 template<typename First, typename... Tail>
155 struct CODI_UNION : public First, public CODI_UNION<Tail...> {};
156#endif
157
159 template<typename First>
160 struct CODI_UNION<First> : public First {};
161
163
165#define CODI_WRAP_FUNCTION(NAME, FUNC) \
166 struct NAME { \
167 public: \
168 \
169 template<typename... Args> \
170 void operator()(Args&&... args) const { \
171 FUNC(std::forward<Args>(args)...); \
172 } \
173 }
174
176#define CODI_WRAP_FUNCTION_TEMPLATE(NAME, FUNC) \
177 template<typename... TT> \
178 struct NAME { \
179 public: \
180 \
181 template<typename... Args> \
182 void operator()(Args&&... args) const { \
183 FUNC<TT...>(std::forward<Args>(args)...); \
184 } \
185 }
186}
#define CODI_INLINE
See codi::Config::ForcedInlines.
Definition config.h:469
CoDiPack - Code Differentiation Package.
Definition codi.hpp:94
inlinevoid CODI_UNUSED(Args const &...)
Disable unused warnings for an arbitrary number of arguments.
Definition macros.hpp:54
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:84