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

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

int main(void)
{
  int exit_status = 0;

  // Input and output variables

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

  // Create AD configuration data object
  Integer ifail = 0;
  void    *ad_handle = 0;
  x10aa_t1w_f_(ad_handle,ifail);

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

  const Integer     n = 1;
  nagad_t1w_w_rtype fnu, x, zr, zi;
  nagad_t1w_w_ctype z, cy[n];
  Integer           nz;
  fnu =  5.5;
  zr  = -6.1;
  zi  =  9.8;
  z.real(zr);
  z.imag(zi);
  
  // Call NAG AD Routine
  double inc = 1.0;
  nagad_t1w_inc_derivative(&fnu,inc);
  ifail = 0;
  s18de_t1w_f_(ad_handle,fnu,z,n,"S",cy,nz,ifail,1);

  nagad_t1w_w_rtype cyr;
  cyr = real(cy[0]);
  double dyrdnu = nagad_t1w_get_derivative(cyr);

  nagad_t1w_w_rtype cyi;
  cyi = imag(cy[0]);
  double dyidnu = nagad_t1w_get_derivative(cyi);

  cout.width(10);  cout << nagad_t1w_get_value(fnu) << " (";
  cout.width(9);  cout << nagad_t1w_get_value(real(z)) << ",";
  cout.width(10);  cout << nagad_t1w_get_value(imag(z)) << ")   S   (";
  cout.width(9);  cout << nagad_t1w_get_value(cyr) << ",";
  cout.width(10);  cout << nagad_t1w_get_value(cyi) << ")    (";
  cout.width(9);  cout << dyrdnu << ",";
  cout.width(10);  cout << dyidnu << ")" << endl;

  // Remove computational data object and tape
  x10ab_t1w_f_(ad_handle,ifail);

  return exit_status;
}