10 #if defined __cplusplus
24 static double initialPoints[] = { 0.2311, 0.4860, 0.6068, 0.8913, 0.9501 };
32 void *argList,
double x1,
double x2,
int maxDepth,
double tolerance,
double *integral,
long *evaluations ) {
37 double estimate = 0.,
y1, integral_, coarse;
49 if( ( status = integrandFunction( x1 + ( x2 - x1 ) *
initialPoints[i1], &
y1, argList ) ) !=
nfu_Okay )
return( status );
52 if( ( status = quadratureFunction( integrandFunction, argList, x1, x2, &integral_ ) ) !=
nfu_Okay )
return( status );
53 estimate = 0.5 * ( estimate * ( x2 -
x1 ) / numberOfInitialPoints + integral_ );
54 if( estimate == 0. ) estimate = x2 -
x1;
57 if( ( status = quadratureFunction( integrandFunction, argList, x1, x2, &coarse ) ) !=
nfu_Okay )
return( status );
60 for( i1 = 0; i1 < 2; i1++ ) {
61 if( integral_ == 0. )
break;
62 y1 = integral_ / estimate;
63 if( (
y1 > 0.1 ) && (
y1 < 10. ) )
break;
67 *evaluations += adaptiveQuadrature_info.
evaluations;
72 *evaluations += adaptiveQuadrature_info.
evaluations;
73 if( adaptiveQuadrature_info.
status ==
nfu_Okay ) *integral = integral_;
74 return( adaptiveQuadrature_info.
status );
81 double xm, intregral1, intregral2, fine, extrapolate;
84 if( x1 == x2 )
return( 0. );
90 xm = 0.5 * ( x1 +
x2 );
92 adaptiveQuadrature_info->
argList, x1, xm, &intregral1 ) ) !=
nfu_Okay )
return( 0. );
94 adaptiveQuadrature_info->
argList, xm, x2, &intregral2 ) ) !=
nfu_Okay )
return( 0. );
95 fine = intregral1 + intregral2;
96 extrapolate = ( 16. * fine - coarse ) / 15.;
97 if( extrapolate != 0 ) {
98 if( adaptiveQuadrature_info->
estimate + ( extrapolate - fine ) == adaptiveQuadrature_info->
estimate )
return( fine );
100 if( depth > adaptiveQuadrature_info->
maxDepth )
return( fine );
105 #if defined __cplusplus