/* S18DE_T1W_F C++ Header Example Program.
*
* Copyright 2022 Numerical Algorithms Group.
* Mark 28.6, 2022.
*/
#include <dco.hpp>
#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_T1W_F C++ Header Example Program Results\n\n";
// Create AD configuration data object
Integer ifail = 0;
nag::ad::handle_t ad_handle;
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;
dco::derivative(fnu) = inc;
ifail = 0;
nag::ad::s18de(ad_handle, fnu, z, n, "S", cy, nz, ifail);
nagad_t1w_w_rtype cyr;
cyr = real(cy[0]);
double dyrdnu = dco::derivative(cyr);
nagad_t1w_w_rtype cyi;
cyi = imag(cy[0]);
double dyidnu = dco::derivative(cyi);
cout.width(10);
cout << dco::value(fnu) << " (";
cout.width(9);
cout << dco::value(real(z)) << ",";
cout.width(10);
cout << dco::value(imag(z)) << ") S (";
cout.width(9);
cout << dco::value(cyr) << ",";
cout.width(10);
cout << dco::value(cyi) << ") (";
cout.width(9);
cout << dyrdnu << ",";
cout.width(10);
cout << dyidnu << ")" << endl;
return exit_status;
}