# include <cmath>
# include <f2cad/dbskes.hpp>
test_result dbskes(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 bke[2];
integer nin = 2;
f2cad::dbskes_(&xnu, x+0, &nin, bke);
// dependent variables
integer m = 1; // number of dependent variables
doublereal f[1]; // vector of dependent variables
f[0] = bke[1]; // value f[0] = K_(nu+1) (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 term = 1. / sqrt( 2. * x0 / pi );
double check = term * (1. + 1. / x0 );
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 = - (1. + 1. / x0) * term * term * term / pi;
check += - term / (x0 * x0);
ok &= f2cad::near_equal(p, check, 1e-10, 1e-10);
if( ok )
return test_pass;
return test_fail;
}