00001 #ifndef __CROMBERG_INTEGRATOR_H
00002 #define __CROMBERG_INTEGRATOR_H
00003
00011
00012 #define EPS 1.0e-6 //fractional accuracy desired
00013 #define JMAX 20 // max number of steps
00014 #define K 5 // number of polints used in extrapolation
00015
00016 enum RI_CallMethod{RI_a_function,RI_a_class};
00017
00018 class CRombergIntegrator
00019 {
00020 public:
00021 CRombergIntegrator();
00022 CRombergIntegrator(double(*function)(double));
00023 CRombergIntegrator(double eps, int jmax, int k, double(*function)(double));
00024 CRombergIntegrator(void*,double(*function)(void*,double));
00025 CRombergIntegrator(double eps, int jmax, int k, void*,double(*function)(void*,double));
00026 ~CRombergIntegrator();
00027
00028 double compute(double a, double b);
00029
00030 protected:
00031
00032 double (*function_class)(void*,double);
00033 void* callingClass;
00034 double (*function_fun)(double);
00035 RI_CallMethod mCallMethod;
00036
00037 double function(double);
00038 double *s;
00039 double *h;
00040 int jmax;
00041 int k;
00042 double eps;
00043 void polint(double xa[], double ya[], int n, double x, double *y, double *dy);
00044 double trapzd(double a, double b, int n);
00045 };
00046
00047 #endif