/* E01BF_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 << "E01BF_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, *f = 0, *d = 0;
x = new double [n];
f = new double [n];
d = new double [n];
// Read data variables
for (int i=0; i<n; i++) {
cin >> x[i] >> f[i];
}
// Call the passive routine
Integer ifail = 0;
void *ad_handle = 0;
e01be_p0w_f_(ad_handle,n,x,f,d,ifail);
const Integer m = 1;
double px[m], pf[m];
px[0] = 0.5*(x[n/2-1] + x[n/2]);
ifail = 0;
e01bf_p0w_f_(ad_handle,n,x,f,d,m,px,pf,ifail);
cout << "\n Value of interpolant at x = " << px[0];
cout.precision(5);
cout << " is: " << pf[0] << endl;
delete [] x;
delete [] f;
delete [] d;
return exit_status;
}