Skip to content

Commit

Permalink
add interface for forward and reverse drivers
Browse files Browse the repository at this point in the history
  • Loading branch information
TimSiebert1 committed Sep 27, 2024
1 parent ab6c401 commit 2671898
Show file tree
Hide file tree
Showing 2 changed files with 326 additions and 0 deletions.
168 changes: 168 additions & 0 deletions ADOL-C/c_interface/driver_interface.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
#include <adolc/adolc.h>
#include "driver_interface.h"
/*
This file generates an interface to the overloaded forward and reverse mode calls.
*/

int forward1(short tag,
int m,
int n,
int d,
int keep,
double **X,
double **Y)
{
return forward(tag, m, n, d, keep, X, Y);
}
int forward2(short tag,
int m,
int n,
int d,
int keep,
double **X,
double *Y)
{
return forward(tag, m, n, d, keep, X, Y);
}
int forward3(short tag,
int m,
int n,
int d,
int keep,
double *X,
double *Y)
{
return forward(tag, m, n, d, keep, X, Y);
}
int forward4(short tag,
int m,
int n,
int keep,
double *X,
double *Y)
{
return forward(tag, m, n, keep, X, Y);
}
int forward5(short tag,
int m,
int n,
int d,
int p,
double *x,
double ***X,
double *y,
double ***Y)
{
return forward(tag, m, n, d, p, x, X, y, Y);
}

int forward6(short tag,
int m,
int n,
int p,
double *x,
double **X,
double *y,
double **Y)
{
return forward(tag, m, n, p, x, X, y, Y);
}
int reverse1(short tag,
int m,
int n,
int d,
double *u,
double **Z)
{
return reverse(tag, m, n, d, u, Z);
}
int reverse2(short tag,
int m,
int n,
int d,
double u,
double **Z)
{
return reverse(tag, m, n, d, u, Z);
}
int reverse3(short tag,
int m,
int n,
int d,
double *u,
double *Z)
{
return reverse(tag, m, n, d, u, Z);
}
int reverse4(short tag,
int m,
int n,
int d,
double u,
double *Z)
{
return reverse(tag, m, n, d, u, Z);
}
int reverse5(short tag,
int m,
int n,
int d,
int q,
double **U,
double ***Z,
short **nz)
{
return reverse(tag, m, n, d, q, U, Z, nz);
}
int reverse6(short tag,
int m,
int n,
int d,
int q,
double *U,
double ***Z,
short **nz)
{
return reverse(tag, m, n, d, q, U, Z, nz);
}

int reverse7(short tag,
int m,
int n,
int d,
int q,
double **U,
double **Z)
{
return reverse(tag, m, n, d, q, U, Z);
}

int reverse8(short tag,
int m,
int n,
int q,
double **U,
double **Z)
{
return reverse(tag, m, n, q, U, Z);
}
int reverse9(short tag,
int m,
int n,
int d,
int q,
double *U,
double **Z)
{
return reverse(tag, m, n, d, q, U, Z);
}

int reverse10(short tag,
int m,
int n,
int d,
double ***Z,
short **nz)
{
return reverse(tag, m, n, d, Z, nz);
}
158 changes: 158 additions & 0 deletions ADOL-C/c_interface/driver_interface.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
/*
This file generates an interface to the overloaded forward and reverse mode calls.
*/

#ifndef DRIVER_INTERFACE_H
#define DRIVER_INTERFACE_H

#ifdef __cplusplus
extern "C"
{
#endif
/* forward(tag, m, n, d, keep, X[n][d+1], Y[m][d+1]) */
int forward1(short tag,
int m,
int n,
int d,
int keep,
double **X,
double **Y);

/* forward(tag, m, n, d, keep, X[n][d+1], Y[d+1]) : hos || fos || zos */
int forward2(short tag,
int m,
int n,
int d,
int keep,
double **X,
double *Y);

/* forward(tag, m, n, d, keep, X[n], Y[m]) : zos */
int forward3(short tag,
int m,
int n,
int d,
int keep,
double *X,
double *Y);

/* forward(tag, m, n, keep, X[n], Y[m]) : zos */
int forward4(short tag,
int m,
int n,
int keep,
double *X,
double *Y);

/* forward(tag, m, n, d, p, x[n], X[n][p][d], y[m], Y[m][p][d]) : hov */
int forward5(short tag,
int m,
int n,
int d,
int p,
double *x,
double ***X,
double *y,
double ***Y);

/* forward(tag, m, n, p, x[n], X[n][p], y[m], Y[m][p]) : fov */
int forward6(short tag,
int m,
int n,
int p,
double *x,
double **X,
double *y,
double **Y);

/* reverse(tag, m, n, d, u[m], Z[n][d + 1]) */
int reverse1(short tag,
int m,
int n,
int d,
double *u,
double **Z);

/* reverse(tag, 1, n, 0, u, Z[n][d+1]), m=1 => u scalar */
int reverse2(short tag,
int m,
int n,
int d,
double u,
double **Z);

/* reverse(tag, m, n, 0, u[m], Z[n]), d=0 */
int reverse3(short tag,
int m,
int n,
int d,
double *u,
double *Z);

/* reverse(tag, 1, n, 0, u, Z[n]), m=1 and d=0 => u and Z scalars */
int reverse4(short tag,
int m,
int n,
int d,
double u,
double *Z);

/* reverse(tag, m, n, d, q, U[q][m], Z[q][n][d+1], nz[q][n]) */
int reverse5(short tag,
int m,
int n,
int d,
int q,
double **U,
double ***Z,
short **nz);

/* reverse(tag, m, n, d, q, U[q], Z[q][n][d+1], nz[q][n]) : hov */
int reverse6(short tag,
int m,
int n,
int d,
int q,
double *U,
double ***Z,
short **nz);

/* reverse(tag, 1, n, d, q, U[q], Z[q][n][d+1], nz[q][n]), m=1 => u vector */
int reverse7(short tag,
int m,
int n,
int d,
int q,
double **U,
double **Z);

/* reverse(tag, m, n, q, U[q][m], Z[q][n]) */
int reverse8(short tag,
int m,
int n,
int q,
double **U,
double **Z);

/* reverse(tag, m, n, d, q, U[q], Z[q][n]) */
int reverse9(short tag,
int m,
int n,
int d,
int q,
double *U,
double **Z);

/* reverse(tag, m, n, d, Z[q][n][d+1], nz[q][n]) : hov */
int reverse10(short tag,
int m,
int n,
int d,
double ***Z,
short **nz);

#ifdef __cplusplus
}
#endif

#endif // DRIVER_INTERFACE_H

0 comments on commit 2671898

Please sign in to comment.