ADOL-C: Automatic Differentiation in C/C++ 2.7.3
Loading...
Searching...
No Matches
sparse_fo_rev.h
Go to the documentation of this file.
1/*----------------------------------------------------------------------------
2 ADOL-C -- Automatic Differentiation by Overloading in C++
3 File: sparse/sparse_fo_rev.h
4 Revision: $Id$
5 Contents: This file contains some "Easy To Use" interfaces of the sparse
6package.
7
8
9 Copyright (c) Andrea Walther, Christo Mitev
10
11 This file is part of ADOL-C. This software is provided as open source.
12 Any use, reproduction, or distribution of the software constitutes
13 recipient's acceptance of the terms of the accompanying license file.
14
15----------------------------------------------------------------------------*/
16#ifndef ADOLC_SPARSE_FO_REV_H
17#define ADOLC_SPARSE_FO_REV_H
18#include <adolc/adolcerror.h>
19#include <adolc/adolcexport.h>
20#include <adolc/dvlparms.h>
21#include <adolc/interfaces.h>
25#include <vector>
26
27namespace ADOLC::Sparse {
72template <ControlFlowMode CFM>
73ADOLC_API int forward(short tag, int m, int n, int p, double *x,
74 std::vector<bitword_t *> &X, double *y,
75 std::vector<bitword_t *> &Y) {
76 if constexpr (CFM == ControlFlowMode::Tight) {
77 if (x != nullptr)
78 return int_forward_tight(tag, m, n, p, x, X.data(), y, Y.data());
79 else
81
82 } else if constexpr (CFM == ControlFlowMode::Safe)
83 return int_forward_safe(tag, m, n, p, X.data(), Y.data());
84 else
85 static_assert(is_dependent_v<CFM>,
86 "Mode must be either 'safe' or 'tight'!");
87}
88
118template <ControlFlowMode CFM>
119ADOLC_API int forward(short tag, int m, int n, int p,
120 std::vector<bitword_t *> &X,
121 std::vector<bitword_t *> &Y) {
122 if constexpr (CFM == ControlFlowMode::Safe)
123 return int_forward_safe(tag, m, n, p, X.data(), Y.data());
124 else
125 static_assert(is_dependent_v<CFM>, "Mode has to be 'safe'!");
126}
127
162template <ControlFlowMode CFM>
163ADOLC_API int reverse(short tag, int m, int n, int q,
164 std::vector<bitword_t *> &U,
165 std::vector<bitword_t *> &Z) {
166 if constexpr (CFM == ControlFlowMode::Safe)
167 return int_reverse_safe(tag, m, n, q, U.data(), Z.data());
168 else if constexpr (CFM == ControlFlowMode::Tight)
169 return int_reverse_tight(tag, m, n, q, U.data(), Z.data());
170 else
171 static_assert(is_dependent_v<CFM>,
172 "Mode must be either 'safe' or 'tight'!");
173}
174
220ADOLC_API int forward(short tag, int m, int n, int p, double *x, bitword_t **X,
221 double *y, bitword_t **Y, char mode);
222
252ADOLC_API int forward(short tag, int m, int n, int p, bitword_t **X,
253 bitword_t **Y, char mode);
254
293ADOLC_API int reverse(short tag, int m, int n, int q, bitword_t **U,
294 bitword_t **Z, char mode);
295} // namespace ADOLC::Sparse
296#endif // ADOLC_SPARSE_FO_REV_H
#define CURRENT_LOCATION
Definition adolcerror.h:26
#define ADOLC_API
Definition adolcexport.h:16
uint32_t bitword_t
Definition common.h:37
ADOLC_API int int_forward_tight(short, int, int, int, const double *, const bitword_t *const *, double *, bitword_t **)
ADOLC_API int int_reverse_safe(short, int, int, int, const bitword_t *const *, bitword_t **)
ADOLC_API int int_reverse_tight(short, int, int, int, const bitword_t *const *, bitword_t **)
ADOLC_API int int_forward_safe(short, int, int, int, const bitword_t *const *, bitword_t **)
void ADOLC_API fail(ErrorType error, const source_location LocInfo, const FailInfo &failinfo=FailInfo())
Definition adtl_indo.h:46
@ Tight
Tight (basepoint-dependent) control-flow handling.
@ Safe
Safe (conservative) control-flow handling.
ADOLC_API int reverse(short tag, int m, int n, int q, std::vector< bitword_t * > &U, std::vector< bitword_t * > &Z)
Reverse-mode bit-pattern propagation (safe or tight control-flow).
Definition sparse_fo_rev.h:163
ADOLC_API int forward(short tag, int m, int n, int p, double *x, std::vector< bitword_t * > &X, double *y, std::vector< bitword_t * > &Y)
Forward-mode bit-pattern propagation (safe or tight control-flow).
Definition sparse_fo_rev.h:73