ADOL-C: Automatic Differentiation in C/C++ 2.7.3
Loading...
Searching...
No Matches
externfcts.h
Go to the documentation of this file.
1/*----------------------------------------------------------------------------
2 ADOL-C -- Automatic Differentiation by Overloading in C++
3 File: externfcts.h
4 Revision: $Id$
5 Contents: public functions and data types for extern (differentiated)
6 functions.
7
8 Copyright (c) Andreas Kowarz, Jean Utke
9
10 This file is part of ADOL-C. This software is provided as open source.
11 Any use, reproduction, or distribution of the software constitutes
12 recipient's acceptance of the terms of the accompanying license file.
13
14----------------------------------------------------------------------------*/
15
16#ifndef ADOLC_EXTERNFCTS_H
17#define ADOLC_EXTERNFCTS_H
18
19#include <adolc/adolcexport.h>
21#include <functional>
22
23// ignore missing dll-interface of stl for the moment
24// would require a bigger refactor
25#ifdef _MSC_VER
26#pragma warning(push)
27#pragma warning(disable : 4251) // STL members in exported classes
28#endif
29
30class adouble;
31
33 std::function<int(short tapeId, int m, int n, double *x, double *y)>;
34using ADOLC_ext_fct_zos_forward = std::function<int(
35 short tapeId, int m, int n, int keep, double *x, double *y)>;
37 std::function<int(short tapeId, int m, int n, int keep, double *x,
38 double *X, double *y, double *Y)>;
40 std::function<int(short tapeId, int m, int n, int p, double *x, double **Xp,
41 double *y, double **Yp)>;
43 std::function<int(short tapeId, int m, int n, int d, int keep, double *x,
44 double **Xd, double *y, double **Yd)>;
46 std::function<int(short tapeId, int m, int n, int d, int p, double *x,
47 double ***Xpd, double *y, double ***Ypd)>;
48using ADOLC_ext_fct_fos_reverse = std::function<int(
49 short tapeId, int m, int n, double *u, double *z, double *x, double *y)>;
51 std::function<int(short tapeId, int m, int n, int q, double **Uq,
52 double **Zq, double *x, double *y)>;
54 std::function<int(short tapeId, int m, int n, int d, double *u, double **Zd,
55 double **Xd, double **Yd)>;
57 std::function<int(short tapeId, int m, int n, int d, double **Ud,
58 double **Zd, double **Xd, double **Yd)>;
60 std::function<int(short tapeId, int m, int n, int d, int q, double **Uq,
61 double ***Zqd, short **nz, double **Xd, double **Yd)>;
62
68 std::function<int(short tapeId, size_t iArrLength, size_t *iArr, int m,
69 int n, double *x, double *y)>;
71 std::function<int(short tapeId, size_t iArrLength, size_t *iArr, int m,
72 int n, int keep, double *x, double *y)>;
73using ADOLC_ext_fct_iArr_fos_forward = std::function<int(
74 short tapeId, size_t iArrLength, size_t *iArr, int m, int n, int keep,
75 double *x, double *X, double *y, double *Y)>;
76using ADOLC_ext_fct_iArr_fov_forward = std::function<int(
77 short tapeId, size_t iArrLength, size_t *iArr, int m, int n, int p,
78 double *x, double **Xp, double *y, double **Yp)>;
79using ADOLC_ext_fct_iArr_hos_forward = std::function<int(
80 short tapeId, size_t iArrLength, size_t *iArr, int m, int n, int d,
81 int keep, double *x, double **Xd, double *y, double **Yd)>;
82using ADOLC_ext_fct_iArr_hov_forward = std::function<int(
83 short tapeId, size_t iArrLength, size_t *iArr, int m, int n, int d, int p,
84 double *x, double ***Xpd, double *y, double ***Ypd)>;
86 std::function<int(short tapeId, size_t iArrLength, size_t *iArr, int m,
87 int n, double *u, double *z, double *x, double *y)>;
88using ADOLC_ext_fct_iArr_fov_reverse = std::function<int(
89 short tapeId, size_t iArrLength, size_t *iArr, int m, int n, int q,
90 double **Uq, double **Zq, double *x, double *y)>;
91using ADOLC_ext_fct_iArr_hos_reverse = std::function<int(
92 short tapeId, size_t iArrLength, size_t *iArr, int m, int n, int d,
93 double *u, double **Zd, double **Xd, double **Yd)>;
94using ADOLC_ext_fct_iArr_hov_reverse = std::function<int(
95 short tapeId, size_t iArrLength, size_t *iArr, int m, int n, int d, int q,
96 double **Uq, double ***Zqd, short **nz, double **Xd, double **Yd)>;
97
107 // This is the id of the outer tape that calls the external differentiated
108 // function later
109 short tapeId{0};
110
111 // tape that stores the external differentiated function.
112 short extTapeId{0};
113
114 // storage for the adouble locations to select the right locations to read and
115 // write for the taylor buffer later on! note: We can not just use the
116 // location of adp_y[0] etc. later, because the location might change while
117 // evaluation of the ext function
118 size_t firstDepLocation{0};
119 size_t firstIndLocation{0};
120
122 int p{0};
123
125 int q{0};
126
129 ADOLC_ext_fct_iArr function_iArr{nullptr};
130
132 size_t index{0};
133
134 size_t cp_index{0};
135
138 ADOLC_ext_fct_iArr_zos_forward zos_forward_iArr{nullptr};
139
142 ADOLC_ext_fct_iArr_fos_forward fos_forward_iArr{nullptr};
143
146 ADOLC_ext_fct_iArr_fov_forward fov_forward_iArr{nullptr};
149 ADOLC_ext_fct_iArr_hos_forward hos_forward_iArr{nullptr};
152 ADOLC_ext_fct_iArr_hov_forward hov_forward_iArr{nullptr};
155 ADOLC_ext_fct_iArr_fos_reverse fos_reverse_iArr{nullptr};
158 ADOLC_ext_fct_iArr_fov_reverse fov_reverse_iArr{nullptr};
161 ADOLC_ext_fct_iArr_hos_reverse hos_reverse_iArr{nullptr};
162
164
167 ADOLC_ext_fct_iArr_hov_reverse hov_reverse_iArr{nullptr};
168
171 char nestedAdolc{1};
172
175 char dp_x_changes{1};
176
178 char dp_y_priorRequired{1};
179
181 char *allmem{nullptr};
182
184 void *obj{nullptr};
185};
186
187/****************************************************************************/
188/* This is all C++ */
189
190ADOLC_API ext_diff_fct *reg_ext_fct(short tapeId, short extTapeId,
191 ADOLC_ext_fct ext_fct);
192ADOLC_API ext_diff_fct *reg_ext_fct(short tapeId, short extTapeId,
193 ADOLC_ext_fct_iArr ext_fct);
194
195ADOLC_API ext_diff_fct *get_ext_diff_fct(short tapeId, size_t index);
196
197ADOLC_API int call_ext_fct(ext_diff_fct *edfct, int n, adouble *xa, int m,
198 adouble *ya);
199ADOLC_API int call_ext_fct(ext_diff_fct *edfct, size_t iArrLength, size_t *iArr,
200 int n, adouble *xa, int m, adouble *ya);
201
202/****************************************************************************/
203#endif // ADOLC_EXTERNFCTS_H
#define ADOLC_API
Definition adolcexport.h:16
Taped active scalar for reusable forward and reverse differentiation.
Definition adtb_types.h:211
BEGIN_C_DECLS ADOLC_API int function(short, int, int, const double *, double *)
std::function< int(short tapeId, size_t iArrLength, size_t *iArr, int m, int n, double *u, double *z, double *x, double *y)> ADOLC_ext_fct_iArr_fos_reverse
Definition externfcts.h:87
std::function< int(short tapeId, size_t iArrLength, size_t *iArr, int m, int n, int d, int q, double **Uq, double ***Zqd, short **nz, double **Xd, double **Yd)> ADOLC_ext_fct_iArr_hov_reverse
Definition externfcts.h:96
ADOLC_API ext_diff_fct * get_ext_diff_fct(short tapeId, size_t index)
std::function< int(short tapeId, size_t iArrLength, size_t *iArr, int m, int n, int keep, double *x, double *y)> ADOLC_ext_fct_iArr_zos_forward
Definition externfcts.h:72
std::function< int(short tapeId, int m, int n, int d, int p, double *x, double ***Xpd, double *y, double ***Ypd)> ADOLC_ext_fct_hov_forward
Definition externfcts.h:47
ADOLC_API ext_diff_fct * reg_ext_fct(short tapeId, short extTapeId, ADOLC_ext_fct ext_fct)
std::function< int(short tapeId, int m, int n, int keep, double *x, double *X, double *y, double *Y)> ADOLC_ext_fct_fos_forward
Definition externfcts.h:38
std::function< int(short tapeId, size_t iArrLength, size_t *iArr, int m, int n, int q, double **Uq, double **Zq, double *x, double *y)> ADOLC_ext_fct_iArr_fov_reverse
Definition externfcts.h:90
std::function< int(short tapeId, size_t iArrLength, size_t *iArr, int m, int n, int d, int p, double *x, double ***Xpd, double *y, double ***Ypd)> ADOLC_ext_fct_iArr_hov_forward
Definition externfcts.h:84
std::function< int(short tapeId, size_t iArrLength, size_t *iArr, int m, int n, int d, double *u, double **Zd, double **Xd, double **Yd)> ADOLC_ext_fct_iArr_hos_reverse
Definition externfcts.h:93
std::function< int(short tapeId, size_t iArrLength, size_t *iArr, int m, int n, double *x, double *y)> ADOLC_ext_fct_iArr
Definition externfcts.h:69
std::function< int(short tapeId, int m, int n, int d, int q, double **Uq, double ***Zqd, short **nz, double **Xd, double **Yd)> ADOLC_ext_fct_hov_reverse
Definition externfcts.h:61
std::function< int(short tapeId, int m, int n, double *u, double *z, double *x, double *y)> ADOLC_ext_fct_fos_reverse
Definition externfcts.h:49
std::function< int(short tapeId, size_t iArrLength, size_t *iArr, int m, int n, int keep, double *x, double *X, double *y, double *Y)> ADOLC_ext_fct_iArr_fos_forward
Definition externfcts.h:75
std::function< int(short tapeId, int m, int n, int keep, double *x, double *y)> ADOLC_ext_fct_zos_forward
Definition externfcts.h:35
ADOLC_API int call_ext_fct(ext_diff_fct *edfct, int n, adouble *xa, int m, adouble *ya)
std::function< int(short tapeId, size_t iArrLength, size_t *iArr, int m, int n, int p, double *x, double **Xp, double *y, double **Yp)> ADOLC_ext_fct_iArr_fov_forward
Definition externfcts.h:78
std::function< int(short tapeId, int m, int n, double *x, double *y)> ADOLC_ext_fct
Definition externfcts.h:33
std::function< int(short tapeId, size_t iArrLength, size_t *iArr, int m, int n, int d, int keep, double *x, double **Xd, double *y, double **Yd)> ADOLC_ext_fct_iArr_hos_forward
Definition externfcts.h:81
std::function< int(short tapeId, int m, int n, int p, double *x, double **Xp, double *y, double **Yp)> ADOLC_ext_fct_fov_forward
Definition externfcts.h:41
std::function< int(short tapeId, int m, int n, int q, double **Uq, double **Zq, double *x, double *y)> ADOLC_ext_fct_fov_reverse
Definition externfcts.h:52
std::function< int(short tapeId, int m, int n, int d, int keep, double *x, double **Xd, double *y, double **Yd)> ADOLC_ext_fct_hos_forward
Definition externfcts.h:44
std::function< int(short tapeId, int m, int n, int d, double *u, double **Zd, double **Xd, double **Yd)> ADOLC_ext_fct_hos_reverse
Definition externfcts.h:55
std::function< int(short tapeId, int m, int n, int d, double **Ud, double **Zd, double **Xd, double **Yd)> ADOLC_ext_fct_hos_ti_reverse
Definition externfcts.h:58
ADOLC_API int fos_forward(short, int, int, int, const double *, const double *, double *, double *)
ADOLC_API int hov_forward(short, int, int, int, int, const double *, const double *const *const *, double *, double ***)
ADOLC_API int fos_reverse(short, int, int, const double *, double *)
ADOLC_API int fov_forward(short, int, int, int, const double *, const double *const *, double *, double **)
ADOLC_API int hos_forward(short, int, int, int, int, const double *, const double *const *, double *, double **)
ADOLC_API int hos_reverse(short, int, int, int, const double *, double **)
ADOLC_API int fov_reverse(short, int, int, int, const double *const *, double **)
BEGIN_C_DECLS ADOLC_API int zos_forward(short, int, int, int, const double *, double *)
ADOLC_API int hov_reverse(short, int, int, int, int, const double *const *, double ***, short **)
ADOLC_API int hos_ti_reverse(short, int, int, int, const double *const *, double **)
Callback descriptor for an externally differentiated function.
Definition externfcts.h:106