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

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

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

cout << "E01DA_T1W_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_t1w_w_rtype *x = 0,  *lamda = 0, *y = 0, *mu = 0, *f = 0, *c = 0,
*wrk = 0;
Integer           *iwrk = 0;
Integer           lwrk = (my+6)*(mx+6);
iwrk   = new Integer           [lwrk];

// 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] = xr;
}
for (int i=0; i<my; i++) {
double yr;
cin >> yr;
y[i] = yr;
}
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] = fr;
}
}

Integer px, py;
ifail = 0;

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

double inc = 1.0, zero =0.0;
ifail = 0;

ifail = 0;

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

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

cout << "\n Derivatives of fitted value w.r.t. fit point:\n\n";
cout << "   dfit/dx = " << dx << endl;
cout << "   dfit/dy = " << dy << endl;

// Remove computational data object