# include <f2cad/ddot.hpp>
test_result ddot(void)
{ bool ok = true;
integer n = 4;
doublereal x[4];
x[0] = 1.;
x[1] = 2.;
x[2] = 3.;
x[3] = 4.;
// declare independent variables
f2cad::Independent(n, x);
// set f = x[0] * x[2] + x[1] * x[3]
integer m = 1;
doublereal f[1];
integer incx = 1;
integer n2 = n / 2;
f[0] = f2cad::ddot_ (&n2, x, &incx, x+n2, &incx);
// declare dependent variables
f2cad::Dependent(m, f);
double p;
p = f2cad::Partial<doublereal>(0, 0);
ok &= f2cad::near_equal(p, f2cad::Value(x[2]), 1e-10, 1e-10);
p = f2cad::Partial<doublereal>(0, 1);
ok &= f2cad::near_equal(p, f2cad::Value(x[3]), 1e-10, 1e-10);
p = f2cad::Partial<doublereal>(0, 2);
ok &= f2cad::near_equal(p, f2cad::Value(x[0]), 1e-10, 1e-10);
p = f2cad::Partial<doublereal>(0, 3);
ok &= f2cad::near_equal(p, f2cad::Value(x[1]), 1e-10, 1e-10);
if( ok )
return test_pass;
return test_fail;
}