11 double b,
double acury)
20 double a,
double b,
double eps,
21 int level,
int level_max)
23 double c, d, e, h, result;
24 double one_simpson, two_simpson;
25 double left_simpson, right_simpson;
29 one_simpson = h*(f(&a)+4.0*f(&c)+f(&b))/6.0;
32 two_simpson = h*(f(&a)+4.0*f(&d)+2.0*f(&c)+4.0*f(&e)+f(&b))/12.0;
34 if (level+1 >= level_max) {
36 std::cerr<<
"Maximum level reached\n";
40 if (std::fabs(two_simpson-one_simpson) < 15.0*eps)
41 result = two_simpson + (two_simpson-one_simpson)/15.0;
46 result = left_simpson + right_simpson;
static vnl_integrant_fnct * pfnct_
virtual double f_(double)=0
static double int_fnct_(double *x)
used to wrap the function class to an ordinary function.
int depth_
maximum recursion depth.
double integral(vnl_integrant_fnct *f, double a, double b, double accuracy)
a and b are integral limits respectively.
double adaptivesimpson(double(*f)(double *), double a, double b, double eps, int level, int level_max)
real computation.