#include <EvtItgSimpsonIntegrator.hh>
Inheritance diagram for EvtItgSimpsonIntegrator:
Public Member Functions | |
double | evaluate (double lower, double upper) const |
EvtItgSimpsonIntegrator (const EvtItgAbsFunction &, double precision=1.0e-5, int maxLoop=20) | |
double | normalisation () const |
virtual | ~EvtItgSimpsonIntegrator () |
Protected Member Functions | |
virtual double | evaluateIt (double, double) const |
double | myFunction (double x) const |
double | trapezoid (double lower, double higher, int n, double &result) const |
Private Member Functions | |
EvtItgSimpsonIntegrator (const EvtItgSimpsonIntegrator &) | |
EvtItgSimpsonIntegrator () | |
EvtItgSimpsonIntegrator & | operator= (const EvtItgSimpsonIntegrator &) |
Private Attributes | |
double | _maxLoop |
double | _precision |
|
00049 : 00050 EvtItgAbsIntegrator(theFunction), 00051 _precision(precision), 00052 _maxLoop(maxLoop) 00053 {}
|
|
00061 {}
|
|
|
|
|
|
00052 { 00053 00054 double newLower(lower), newUpper(upper); 00055 00056 boundsCheck(newLower, newUpper); 00057 00058 return evaluateIt(newLower, newUpper); 00059 }
|
|
Implements EvtItgAbsIntegrator. 00064 { 00065 00066 // report(INFO,"EvtGen")<<"in evaluate"<<endl; 00067 int j; 00068 double result(0.0); 00069 double s, st, ost(0.0); 00070 for (j=1;j<4;j++) { 00071 st = trapezoid(lower, higher, j, result); 00072 s = (4.0 * st - ost)/3.0; 00073 ost=st; 00074 } 00075 00076 double olds(s); 00077 st = trapezoid(lower, higher, j, result); 00078 s = (4.0 * st - ost)/3.0; 00079 00080 if (fabs(s - olds) < _precision*fabs(olds) || (s==0.0 && olds==0.0)) return s; 00081 00082 ost=st; 00083 00084 for (j=5;j<_maxLoop;j++){ 00085 00086 st = trapezoid(lower, higher, j, result); 00087 s = (4.0 * st - ost)/3.0; 00088 00089 if (fabs(s - olds) < _precision*fabs(olds) || (s==0.0 && olds==0.0)) return s; 00090 olds=s; 00091 ost=st; 00092 } 00093 00094 report(ERROR,"EvtGen") << "Severe error in EvtItgSimpsonIntegrator. Failed to converge after loop with 2**" 00095 << _maxLoop << " calls to the integrand in." << endl; 00096 00097 return 0.0; 00098 00099 }
|
|
00049 {return _myFunction(x);}
|
|
00047 { 00048 return evaluateIt(_myFunction.lowerRange(), _myFunction.upperRange()); 00049 }
|
|
|
|
00062 { 00063 00064 if (n==1) return 0.5*(higher-lower)*(_myFunction(lower) + _myFunction(higher)); 00065 00066 int it, j; 00067 00068 for (it=1, j=1;j<n-1;j++) it <<=1; 00069 00070 double itDouble(it); 00071 00072 double sum(0.0); 00073 00074 double deltaX((higher - lower)/itDouble); 00075 00076 double x(lower + 0.5* deltaX); 00077 00078 for (j=1;j<=it;j++){ 00079 sum+=_myFunction(x); 00080 x+=deltaX; 00081 } 00082 00083 result = 0.5*(result+(higher - lower)*sum/itDouble); 00084 00085 return result; 00086 }
|
|
|
|
|