# include <cmath>
# include <f2cad/d9knus.hpp>
test_result d9knus(void)
{ bool ok = true;
// independent variable
integer n = 1; // number of independent variables
doublereal x[1]; // vector of independent variables
x[0] = .75; // value of independent variable
f2cad::Independent(n, x); // declare x as independent variable vector
// call the routine
doublereal xnu = .5;
doublereal bknu, bknu1;
integer iswtch;
f2cad::d9knus_(&xnu, x+0, &bknu, &bknu1, &iswtch);
// dependent variables
integer m = 1; // number of dependent variables
doublereal f[1]; // vector of dependent variables
f[0] = bknu; // value f[0] = K_nu (x[0]) * exp( x[0] )
f2cad::Dependent(m, f); // declare f as dependent variable vector
// check function value
double x0 = f2cad::Value( x[0] );
double f0 = f2cad::Value( f[0] );
double pi = 4. * std::atan(1.);
double check = 1. / sqrt( 2. * x0 / pi );
ok &= f2cad::near_equal(f0, check, 1e-10, 1e-10);
// Evaluate the derivative of f[0] w.r.t x[0]
double p = f2cad::Partial<doublereal>(0, 0);
check = - check * check * check / pi;
ok &= f2cad::near_equal(p, check, 1e-10, 1e-10);
if( ok )
return test_pass;
return test_fail;
}