CoDiPack  2.2.0
A Code Differentiation Package
SciComp TU Kaiserslautern
Loading...
Searching...
No Matches
emptyData.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 <vector>
38
39#include "../../config.h"
40#include "../../misc/macros.hpp"
41#include "chunk.hpp"
42#include "dataInterface.hpp"
43#include "position.hpp"
44
46namespace codi {
47
54 struct EmptyData : public DataInterface<> {
55 public:
56
57 using NestedData = void;
58
60 using InternalPosHandle = size_t;
61
62 /*******************************************************************************/
64
67
70
72 CODI_INLINE void addDataSize(size_t size) {
73 CODI_UNUSED(size);
74 }
75
78 CODI_UNUSED(items);
79
80 return 0;
81 }
82
83 /*******************************************************************************/
85
87 void resize(size_t const& totalSize) {
88 CODI_UNUSED(totalSize);
89 }
90
92 void reset() {}
93
95 void resetHard() {}
96
98 void resetTo(Position const& pos) {
99 CODI_UNUSED(pos);
100 }
101
103 void erase(Position const& start, Position const& end, bool recursive = true) {
104 CODI_UNUSED(start, end, recursive);
105 }
106
107 /*******************************************************************************/
109
111 CODI_INLINE size_t getDataSize() const {
112 return 0;
113 }
114
117 return Position();
118 }
119
122 CODI_UNUSED(startPos);
123
124 return 0;
125 }
126
129 return Position();
130 }
131
132 /*******************************************************************************/
134
136 void addToTapeValues(TapeValues& values) const {
137 CODI_UNUSED(values);
138 }
139
141 template<typename = void>
143 return pos;
144 }
145
149 CODI_UNUSED(v);
150 }
151
153 void swap(DataInterface& other) {
154 CODI_UNUSED(other);
155 }
156
157 /*******************************************************************************/
159
163 template<int selectedDepth = -1, typename FunctionObject, typename... Args>
164 CODI_INLINE void evaluateForward(Position const& start, Position const& end, FunctionObject function,
165 Args&&... args) {
166 CODI_UNUSED(start, end);
167 function(std::forward<Args>(args)...);
168 }
169
173 template<int selectedDepth = -1, typename FunctionObject, typename... Args>
174 CODI_INLINE void evaluateReverse(Position const& start, Position const& end, FunctionObject function,
175 Args&&... args) {
176 CODI_UNUSED(start, end);
177 function(std::forward<Args>(args)...);
178 }
179
181 template<typename FunctionObject, typename... Args>
182 CODI_INLINE void forEachChunk(FunctionObject& function, bool recursive, Args&&... args) {
183 CODI_UNUSED(function, recursive, args...);
184 }
185
187 template<typename FunctionObject, typename... Args>
188 CODI_INLINE void forEachForward(Position const& start, Position const& end, FunctionObject function,
189 Args&&... args) {
190 CODI_UNUSED(start, end, function, args...);
191 }
192
194 template<typename FunctionObject, typename... Args>
195 CODI_INLINE void forEachReverse(Position const& start, Position const& end, FunctionObject function,
196 Args&&... args) {
197 CODI_UNUSED(start, end, function, args...);
198 }
199 };
200}
#define CODI_INLINE
See codi::Config::ForcedInlines.
Definition config.h:457
CoDiPack - Code Differentiation Package.
Definition codi.hpp:90
void CODI_UNUSED(Args const &...)
Disable unused warnings for an arbitrary number of arguments.
Definition macros.hpp:46
Data stream interface for tape data. Encapsulates data that is written e.g. for each statement or arg...
Definition dataInterface.hpp:149
No data is stored in this DataInterface implementation. It is used to terminate the recursive nature ...
Definition emptyData.hpp:54
void reset()
Definition emptyData.hpp:92
void setNested(NestedData *v)
Definition emptyData.hpp:148
void addDataSize(size_t size)
Add this many items to the data stream, after the data has been manipulated via pointers obtained fro...
Definition emptyData.hpp:72
void forEachChunk(FunctionObject &function, bool recursive, Args &&... args)
Calls the function object for each continuous segment of data.
Definition emptyData.hpp:182
void getDataPointers()
Get pointers to the data from the storage implementation. The method can only be called after a call ...
Definition emptyData.hpp:69
void forEachForward(Position const &start, Position const &end, FunctionObject function, Args &&... args)
Calls the function object for each item in the data stream. This call is not recursive.
Definition emptyData.hpp:188
InternalPosHandle reserveItems(size_t const &items)
Reserve this many items on the data stream. See pushData for details.
Definition emptyData.hpp:77
void resetHard()
Definition emptyData.hpp:95
void forEachReverse(Position const &start, Position const &end, FunctionObject function, Args &&... args)
Calls the function object for each item in the data stream. This call is not recursive.
Definition emptyData.hpp:195
void evaluateReverse(Position const &start, Position const &end, FunctionObject function, Args &&... args)
Evaluates the function object with segments of continuous and valid data for all nested DataInterface...
Definition emptyData.hpp:174
Position getZeroPosition() const
Definition emptyData.hpp:128
size_t getPushedDataCount(InternalPosHandle const &startPos)
Definition emptyData.hpp:121
void pushData()
Add data to the storage allocated by the implementation. The method can only be called after a call t...
Definition emptyData.hpp:66
void NestedData
No nested data.
Definition emptyData.hpp:57
void evaluateForward(Position const &start, Position const &end, FunctionObject function, Args &&... args)
Evaluates the function object with segments of continuous and valid data for all nested DataInterface...
Definition emptyData.hpp:164
EmptyPosition Position
No positional data.
Definition emptyData.hpp:59
size_t getDataSize() const
Definition emptyData.hpp:111
Position getPosition() const
Definition emptyData.hpp:116
size_t InternalPosHandle
Will always be zero.
Definition emptyData.hpp:60
void erase(Position const &start, Position const &end, bool recursive=true)
Definition emptyData.hpp:103
void swap(DataInterface &other)
Definition emptyData.hpp:153
void resize(size_t const &totalSize)
Definition emptyData.hpp:87
void addToTapeValues(TapeValues &values) const
Add amount of stored data to the TapeValues object. Not called on the nested vector.
Definition emptyData.hpp:136
void resetTo(Position const &pos)
Definition emptyData.hpp:98
Position extractPosition(Position const &pos) const
Extract the position of a nested DataInterface from the global position object provide by this interf...
Definition emptyData.hpp:142
Empty Position with no nested data.
Definition position.hpp:47
Tape information that can be printed in a pretty print format or a table format.
Definition tapeValues.hpp:73