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

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

int main(void)
{
  // Scalars
  int     exit_status = 0;
  
  cout << "E01EB_P0W_F C++ Header Example Program Results\n\n";

  // Skip first line of data file
  string  mystr;
  getline (cin, mystr);
  // Read number of data points
  Integer n;
  cin >> n;

  // Allocate arrays for data and interpolant
  double  *x = 0, *y = 0, *f = 0;
  Integer *triang = 0;
  x      = new double  [n];
  y      = new double  [n];
  f      = new double  [n];
  triang = new Integer [7*n];

  // Read data variables
  for (int i=0; i<n; i++) {
    double xr, yr, fr;
    cin >> xr >> yr >> fr;
    x[i] = xr;
    y[i] = yr;
    f[i] = fr;
  }
    
  Integer ifail = 0;
  void    *ad_handle = 0;
  e01ea_p0w_f_(n,x,y,triang,ifail);

  double  px[1], py[1], pf[1];
  double  xint, yint;
  xint = 0.5*(x[n/2-1] + x[n/2]);
  yint = 0.5*(y[n/2-1] + y[n/2]);
  px[0] = xint;
  py[0] = yint;
    
  // Call the passive routine
  Integer m = 1;
  ifail = 0;
  e01eb_p0w_f_(ad_handle,m,n,x,y,f,triang,px,py,pf,ifail);

  cout << "\n Interpolant point: x = " << xint << " y = " << yint << endl;
  cout.precision(5);
  cout << " Interpolated value = " << pf[0] << endl;

  delete [] x;
  delete [] y;
  delete [] f;
  delete [] triang;
  return exit_status;
}