00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef O2SCL_CERN_GAUSS56_H
00024 #define O2SCL_CERN_GAUSS56_H
00025
00026 #include <o2scl/inte.h>
00027
00028 #ifndef DOXYGENP
00029 namespace o2scl {
00030 #endif
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 template<class param_t, class func_t> class cern_gauss56 :
00042 public inte<param_t,func_t> {
00043
00044 public:
00045
00046 cern_gauss56() {
00047 x5[0]=4.6910077030668004e-02;
00048 w5[0]=1.1846344252809454e-01;
00049 x5[1]=2.3076534494715846e-01;
00050 w5[1]=2.3931433524968324e-01;
00051 x5[2]=5.0000000000000000e-01;
00052 w5[2]=2.8444444444444444e-01;
00053 x5[3]=7.6923465505284154e-01;
00054 w5[3]=2.3931433524968324e-01;
00055 x5[4]=9.5308992296933200e-01;
00056 w5[4]=1.1846344252809454e-01;
00057
00058 x6[0]=3.3765242898423989e-02;
00059 w6[0]=8.5662246189585178e-02;
00060 x6[1]=1.6939530676686775e-01;
00061 w6[1]=1.8038078652406930e-01;
00062 x6[2]=3.8069040695840155e-01;
00063 w6[2]=2.3395696728634552e-01;
00064 x6[3]=6.1930959304159845e-01;
00065 w6[3]=2.3395696728634552e-01;
00066 x6[4]=8.3060469323313225e-01;
00067 w6[4]=1.8038078652406930e-01;
00068 x6[5]=9.6623475710157601e-01;
00069 w6[5]=8.5662246189585178e-02;
00070 }
00071
00072
00073
00074 virtual double integ(func_t &func, double a, double b, param_t &pa) {
00075 double res, err;
00076 integ_err(func,a,b,pa,res,err);
00077 return res;
00078 }
00079
00080
00081
00082
00083
00084 virtual int integ_err(func_t &func, double a, double b, param_t &pa,
00085 double &res, double &err) {
00086
00087 double rang=b-a, e5=0.0, e6=0.0, ytmp;
00088
00089 for(int i=0;i<5;i++) {
00090 func(a+rang*x5[i],ytmp,pa);
00091 e5+=w5[i]*ytmp;
00092 func(a+rang*x6[i],ytmp,pa);
00093 e6+=w6[i]*ytmp;
00094 }
00095 func(a+rang*x6[5],ytmp,pa);
00096 e6+=w6[5]*ytmp;
00097 res=(e6+e5)*rang/2.0;
00098 err=fabs((e6-e5)*rang);
00099
00100 return 0;
00101 }
00102
00103 protected:
00104
00105 #ifndef DOXYGEN_INTERNAL
00106
00107
00108
00109
00110 double x5[5], w5[5];
00111 double x6[6], w6[6];
00112
00113
00114 #endif
00115
00116 };
00117
00118 #ifndef DOXYGENP
00119 }
00120 #endif
00121
00122 #endif