00001 00015 #include "Integrator.h" 00016 00017 ClassImp(Integrator) 00018 00019 //____________________________________________________________________________ 00020 Integrator * Integrator::Instance() 00021 { 00022 if(fInstance == 0) fInstance = new Integrator(); 00023 return fInstance; 00024 } 00025 //____________________________________________________________________________ 00026 Integrator * Integrator::fInstance = 0; 00027 //____________________________________________________________________________ 00028 Integrator::Integrator() 00029 { 00030 fInstance = 0; 00031 } 00032 //____________________________________________________________________________ 00033 Integrator::Integrator(const Integrator & intg) : 00034 TObject(intg) 00035 { 00036 00037 } 00038 //____________________________________________________________________________ 00039 Integrator::~Integrator() 00040 { 00041 fInstance = 0; 00042 } 00043 //____________________________________________________________________________ 00044 double Integrator::Simpson(const double * f, const int n, const double dx) const 00045 { 00046 //-- apply Simpson rule for integration 00047 00048 double integral = (f[0] + f[n-1]) / 2.; 00049 00050 for(int i = 0; i < n-1; i++) integral += ( f[i] * (i%2 + 1) ); 00051 00052 integral *= (2.*dx/3.); 00053 00054 return integral; 00055 } 00056 //____________________________________________________________________________
1.3.9.1