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

#include <nag.h>
#include <nagx04.h>
#include <nagad.h>
#include <math.h>
#include <stdio.h>
#include <string>
#include <iostream>
using namespace std;
extern "C"
{
  static void (NAG_CALL f)(void* &ad_handle,
			   Integer &iflag,
			   const Integer &n,
                           const double x[],
                           double fx[],
                           Integer iuser[],
                           double ruser[]);
}
int main(void)
{
  int       exit_status = 0;
  void      *ad_handle = 0;
  Integer   ifail = 0;

  cout << "F01EF_P0W_F C++ Header Example Program Results\n\n";
  // Skip heading in data file
  string mystr;
  getline (cin, mystr);

  // Read problem size and number of right-hand-sides 
  Integer n;
  cin >> n;

  // Allocate arrays containing A and its factorized form, B
  // and the solution X.
  double *a=0;
  a    =  new double [n*n];  
  
  // Read the matrix A, register and copy
  for (int i = 0; i<n; ++i) {
    for (int j = i; j<n; ++j) {
      Integer k = i + j*n;
      cin >> a[k];
    }
  }
  // Find f(A)
  Integer iflag, iuser[1];
  double  ruser[1];

  ifail = 0;
  f01ef_p0w_f_(ad_handle,"U",n,a,n,f,iuser,ruser,iflag,ifail,1);

  // Print f(A)
  cout << endl;
  NagError  fail;
  INIT_FAIL(fail);
  x04cac(Nag_ColMajor,Nag_UpperMatrix,Nag_NonUnitDiag,n,n,a,n,
         "  f(A)",0,&fail);

  delete [] a;

  return exit_status;
}
static void (NAG_CALL f)(void* &ad_handle,
			 Integer &iflag,
			 const Integer &n,
			 const double x[],
			 double fx[],
			 Integer iuser[],
			 double ruser[])
{
  for (int i=0; i<n; ++i) {
    fx[i] = cos(x[i]);
  }
}