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

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

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

int main()
{
  int exit_status = 0;

  // Input and output variables

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

  Integer           ifail = 0;
  nag::ad::handle_t ad_handle;

  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;
}