```/* E01DA_A1W_F C++ Header Example Program.
*
* Copyright 2019 Numerical Algorithms Group.
* Mark 27, 2019.
*/

#include <nag.h>
#include <stdio.h>
#include <math.h>
#include <nag_stdlib.h>
#include <nagx04.h>
#include <string>
#include <iostream>
using namespace std;

int main(void)
{
// Scalars
int               exit_status = 0;

cout << "E01DA_A1W_F C++ Header Example Program Results\n\n";

// Skip first line of data file
string mystr;
getline (cin, mystr);
// Read number of x and y data points
Integer mx, my;
cin >> mx;
cin >> my;

// Allocate arrays for data and interpolant
nagad_a1w_w_rtype *x = 0,  *lamda = 0, *y = 0, *mu = 0, *f = 0, *c = 0,
*wrk = 0;
double            *dx = 0, *dy = 0, *df = 0;
Integer           *iwrk = 0;
Integer           lwrk = (my+6)*(mx+6);
if (!(x      = NAG_ALLOC(mx,    nagad_a1w_w_rtype)) ||
!(dx     = NAG_ALLOC(mx,    double)) ||
!(dy     = NAG_ALLOC(my,    double)) ||
!(df     = NAG_ALLOC(my*mx, double)) ||
!(iwrk   = NAG_ALLOC(lwrk,  Integer))) {
printf("Allocation failure\n");
exit_status = -2;
}
if (exit_status==0) {

// Create AD configuration data object
Integer ifail = 0;

// Read data and register variables
for (int i=0; i<mx; i++) {
double xr;
cin >> xr;
x[i].value = xr;
x[i].id = 0;
}
for (int i=0; i<my; i++) {
double yr;
cin >> yr;
y[i].value = yr;
y[i].id = 0;
}
for (int i=0; i<my; i++) {
double fr;
for (int j=0; j<mx; j++) {
Integer k = j*my + i;
cin >> fr;
f[k].value = fr;
f[k].id = 0;
}
}

Integer px, py;
ifail = 0;

// Evaluate interpolant and derivatives at an internal point
const Integer     m = 1;
tx[0].value = 1.4;
tx[0].id = 0;
ty[0].value = 0.5;
ty[0].id = 0;

ifail = 0;

cout << "\n Interpolant evaluatyed at x = " << nagad_a1w_get_value(tx[0]);
cout << " and y = " << nagad_a1w_get_value(ty[0]);
cout.precision(5);
cout << "\n Value of interpolant        = ";

// Setup evaluation of derivatives via adjoints.
double inc = 1.0;

ifail = 0;

cout << "\n Derivatives calculated: First order adjoints\n";
cout << " Computational mode    : algorithmic\n";

// Get derivatives
cout << "\n Derivatives of fitted value w.r.t. data points:\n\n";
for (int j=0; j < mx; j++) {
}
for (int j=0; j < my; j++) {
}
for (int j=0; j < my*mx; j++) {
}
cout << endl;
NagError  fail;
INIT_FAIL(fail);
x04cac(Nag_ColMajor,Nag_GeneralMatrix,Nag_NonUnitDiag,1,mx,dx,1,
"     d/dx",0,&fail);
cout << endl;
x04cac(Nag_ColMajor,Nag_GeneralMatrix,Nag_NonUnitDiag,1,my,dy,1,
"     d/dy",0,&fail);
cout << endl;
x04cac(Nag_ColMajor,Nag_GeneralMatrix,Nag_NonUnitDiag,my,mx,df,my,
"     d/df",0,&fail);

// Remove computational data object and tape
}
NAG_FREE(x);
NAG_FREE(y);
NAG_FREE(lamda);
NAG_FREE(mu);
NAG_FREE(f);
NAG_FREE(c);
NAG_FREE(wrk);
NAG_FREE(dx);
NAG_FREE(dy);
NAG_FREE(df);
NAG_FREE(iwrk);

return exit_status;
}
```