ADOL-C: Automatic Differentiation in C/C++ 2.7.3
Loading...
Searching...
No Matches
tape_interface.h
Go to the documentation of this file.
1#ifndef ADOLC_TAPE_INTERFACE_H
2#define ADOLC_TAPE_INTERFACE_H
3
4#include <adolc/adolcerror.h>
5#include <adolc/adolcexport.h>
7#include <cassert>
8#include <cstddef>
9#include <vector>
10
25ADOLC_API int trace_on(short tapeId, int keepTaylors = 0);
26
46ADOLC_API int trace_on(short tapeId, int keepTaylors, size_t obs, size_t lbs,
47 size_t vbs, size_t tbs, int skipFileCleanup);
48
62ADOLC_API void trace_off(int flag = 0);
63
72ADOLC_API void cachedTraceTags(std::vector<short> &result);
73
87ADOLC_API inline void nestedReverseEval(short tapeId, bool flag) {
88 findTape(tapeId).nestedReverseEval(flag);
89}
90
101ADOLC_API inline bool nestedReverseEval(short tapeId) {
102 return findTape(tapeId).nestedReverseEval();
103}
104
114ADOLC_API inline std::array<size_t, TapeInfos::STAT_SIZE>
115tapestats(short tapeId) {
116 ValueTape &tape = findTape(tapeId);
117 std::array<size_t, TapeInfos::STAT_SIZE> stats;
118 tape.tapestats(stats.data());
119 return stats;
120}
121
130ADOLC_API void printTapeStats(short tapeId);
131
141ADOLC_API inline size_t get_num_param(short tapeId) {
142 return findTape(tapeId).get_num_param();
143}
144
156ADOLC_API inline size_t get_num_switches(short tapeId) {
157 const auto &tape = findTape(tapeId);
158 if (!tape.tapestats(TapeInfos::NO_MIN_MAX))
160 ADOLCError::FailInfo{.info1 = tapeId});
161 return tape.tapestats(TapeInfos::NUM_SWITCHES);
162}
163
164#ifdef ADOLC_SPARSE
165namespace ADOLC::Sparse {
175ADOLC_API inline void setTapeInfoJacSparse(short tapeId,
176 SparseJacInfos &&sJInfos) {
177 findTape(tapeId).setTapeInfoJacSparse(std::move(sJInfos));
178}
179
189ADOLC_API inline void setTapeInfoHessSparse(short tapeId,
190 SparseHessInfos &&sHInfos) {
191 findTape(tapeId).setTapeInfoHessSparse(std::move(sHInfos));
192}
193
223ADOLC_API inline void setHP(short tapeId, int indep,
224 std::vector<uint *> &&HPIn) {
225 SparseHessInfos sHinfos;
226 sHinfos.setHP(indep, std::move(HPIn));
227 findTape(tapeId).setTapeInfoHessSparse(std::move(sHinfos));
228}
229
255ADOLC_API inline std::vector<uint *> getHP(short tapeId) {
256 return findTape(tapeId).sHInfos().getHP();
257}
258
259} // namespace ADOLC::Sparse
260#endif // ADOLC_SPARSE
261
262#endif // ADOLC_TAPE_INTERFACE_H
#define CURRENT_LOCATION
Definition adolcerror.h:26
#define ADOLC_API
Definition adolcexport.h:16
Owns one recorded function and the state required to evaluate it.
Definition valuetape.h:79
void nestedReverseEval(bool flag)
Definition valuetape.h:427
void tapestats(std::array< size_t, TapeInfos::STAT_SIZE > stats)
Definition valuetape.h:325
size_t get_num_param()
Definition valuetape.h:424
void ADOLC_API fail(ErrorType error, const source_location LocInfo, const FailInfo &failinfo=FailInfo())
Definition adtl_indo.h:46
Additional typed fields used when formatting an ADOL-C failure.
Definition adolcerror.h:225
short info1
Definition adolcerror.h:226
@ NUM_SWITCHES
Definition tapeinfos.h:44
@ NO_MIN_MAX
Definition tapeinfos.h:43
ADOLC_API std::array< size_t, TapeInfos::STAT_SIZE > tapestats(short tapeId)
Writes the tapestats of the tape into an array.
Definition tape_interface.h:115
ADOLC_API void cachedTraceTags(std::vector< short > &result)
Writes the tapeIds of the tapes stored in the thread-local tapeBuffer in result
ADOLC_API void nestedReverseEval(short tapeId, bool flag)
Marks whether reverse evaluation of this tape is nested inside an outer tape evaluation.
Definition tape_interface.h:87
ADOLC_API int trace_on(short tapeId, int keepTaylors=0)
Initializes taping for the given tapeId.
ADOLC_API void trace_off(int flag=0)
Stops the current tracing session and handles the tape.
ADOLC_API size_t get_num_switches(short tapeId)
Returns the number of switching variables recorded on tape.
Definition tape_interface.h:156
ADOLC_API void printTapeStats(short tapeId)
Prints the stats of the tape.
ADOLC_API size_t get_num_param(short tapeId)
Returns the number of parameters recorded on tape.
Definition tape_interface.h:141
ADOLC_API ValueTape & findTape(short tapeId)
Returns a reference to a ValueTape by tapeId, or throws an error if not found.