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

#include <nag.h>
#include <dco_light.hpp>
#include <nagad.h>
#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 << "E02DE_P0W_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
  double *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);
  x      = new double [mx];
  y      = new double [my];
  lamda  = new double [mx+4];
  mu     = new double [my+4];
  f      = new double [my*mx];
  c      = new double [my*mx];
  wrk    = new double [lwrk];
  dx     = new double [mx];
  dy     = new double [my];
  df     = new double [my*mx];
  iwrk   = new Integer[lwrk];


  // Read data 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;
    }
  }
    
  // Call the passive routine
  Integer px, py;
  Integer ifail = 0;
  void    *ad_handle = 0;
  e01da_p0w_f_(ad_handle,mx,my,x,y,f,px,py,lamda,mu,c,wrk,ifail);

  const Integer m = 1;
  double        tx[m], ty[m], ff[m];
  tx[0] = 1.4;
  ty[0] = 0.5;

  ifail = 0;
  e02de_p0w_f_(ad_handle,m,px,py,tx,ty,lamda,mu,c,ff,wrk,iwrk,ifail);

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

  delete [] x;
  delete [] y;
  delete [] lamda;
  delete [] mu;
  delete [] f;
  delete [] c;
  delete [] wrk;
  delete [] dx;
  delete [] dy;
  delete [] df;
  delete [] iwrk;
  return exit_status;
}