NAG Library Manual, Mark 27.2
Interfaces:  FL   CL   CPP   AD 

NAG AD Library Introduction
Example description
/* S18DE_P0W_F C++ Header Example Program.
 *
 * Copyright 2021 Numerical Algorithms Group.
 * Mark 27.2, 2021.
 */

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

int main(void)
{
  int exit_status = 0;

  // Input and output variables

  cout << "S18DE_P0W_F C++ Header Example Program Results\n\n";

  Integer ifail     = 0;
  void *  ad_handle = 0;

  cout << "    nu               z             scal         cy[0]\n";
  cout.setf(ios::scientific, ios::floatfield);
  cout.setf(ios::right);
  cout.precision(2);

  const Integer n = 1;
  double        fnu;
  Complex       z, cy[n];
  Integer       nz;
  fnu  = 5.5;
  z.re = -6.1;
  z.im = 9.8;

  // Call NAG AD Routine
  ifail = 0;
  nag::ad::s18de(ad_handle, fnu, z, n, "S", cy, nz, ifail);

  cout.width(10);
  cout << fnu << " (";
  cout.width(9);
  cout << z.re << ",";
  cout.width(10);
  cout << z.im << "   S   (";
  cout.width(9);
  cout << cy[0].re << ",";
  cout.width(10);
  cout << cy[0].im << ")" << endl;

  return exit_status;
}