32 {
33
34
35
36 int i1;
37 double estimate = 0., y1, integral_, coarse;
40
41 *integral = 0.;
42 *evaluations = 0;
44
47
48 for( i1 = 0; i1 < numberOfInitialPoints; i1++ ) {
49 if( ( status = integrandFunction( x1 + ( x2 - x1 ) * initialPoints[i1], &y1, argList ) ) !=
nfu_Okay )
return( status );
50 estimate += y1;
51 }
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;
56
57 if( ( status = quadratureFunction( integrandFunction, argList, x1, x2, &coarse ) ) !=
nfu_Okay )
return( status );
58 integral_ = nf_GnG_adaptiveQuadrature2( &adaptiveQuadrature_info, coarse, x1, x2, 0 );
59
60 for( i1 = 0; i1 < 2; i1++ ) {
61 if( integral_ == 0. ) break;
62 y1 = integral_ / estimate;
63 if( ( y1 > 0.1 ) && ( y1 < 10. ) ) break;
64
65 estimate = integral_;
67 *evaluations += adaptiveQuadrature_info.
evaluations;
69 integral_ = nf_GnG_adaptiveQuadrature2( &adaptiveQuadrature_info, integral_, x1, x2, 0 );
70 }
71
72 *evaluations += adaptiveQuadrature_info.
evaluations;
73 if( adaptiveQuadrature_info.
status ==
nfu_Okay ) *integral = integral_;
74 return( adaptiveQuadrature_info.
status );
75}
#define nf_GnG_adaptiveQuadrature_MaxMaxDepth
enum nfu_status_e nfu_status