Example description
/* C05AU_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 <iostream>
#include <string>


extern "C"
{
  static void NAG_CALL f(void * &ad_handle,
                         const double &x,
                         double &z,
                         Integer iuser[],
                         double ruser[]);
}

int main(void)
{
  /* Scalars */
  Integer exit_status = 0;
  double  a, b, eps, eta, h, x;
  Integer ifail;
  void    *ad_handle = 0;
  /* Arrays */
  double  ruser[1];
  Integer iuser[1];

  printf("C05AU_P0W_F C++ Header Example Program Results\n");

  ruser[0] = 1.0;
  x = 1.0;
  h = 0.1;
  eps = 1e-05;
  eta = 0.0;

  c05au_p0w_f_(ad_handle, x, h, eps, eta, f, a, b, iuser, ruser, ifail);
  if (ifail == 0) {
    printf("Root is %13.5f\n", x);
    printf("Interval searched is [%8.5f,%8.5f]\n", a, b);
  } else {
    printf("%" NAG_IFMT "\n", ifail);
    if (ifail == 3 || ifail == 4) {
      printf("Final value = %13.5f\n", x);
      exit_status = 1;
    } else {
      exit_status = 2;
      goto END;
    }
  }

 END:
  return exit_status;
}

static void (NAG_CALL f)(void * &ad_handle,
                         const double &x,
                         double &z,
                         Integer iuser[],
                         double ruser[])
{
  z = x - exp(-ruser[0]*x);
}