CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
NumericalIntegration.cc
Go to the documentation of this file.
3 #include <cmath>
4 
6  samples_(samples) {
7  if (samples <= 0)
9  << "gauss_legendre_integral: number of samples must be positive\n";
10  if(epsilon <= 0)
12  << "gauss_legendre_integral: numerical precision must be positive\n";
13 
14  x.resize(samples);
15  w.resize(samples);
16  const unsigned int m = (samples + 1)/2;
17 
18  double z, zSqr, pp, p1, p2, p3;
19 
20  for (unsigned int i = 0; i < m; ++i) {
21  z = std::cos(3.14159265358979323846 * (i + 0.75)/(samples + 0.5));
22  zSqr = z*z;
23  do {
24  p1 = 1.0;
25  p2 = 0.0;
26  for (unsigned int j = 0; j < samples; ++j) {
27  p3 = p2;
28  p2 = p1;
29  p1 = ((2.0*j + 1.0)*z*p2 - j*p3)/(j + 1.0);
30  }
31  pp = samples*(z*p1 - p2)/(zSqr - 1.0);
32  z -= p1/pp;
33  } while (std::fabs(p1/pp) > epsilon);
34 
35  x[i] = -z;
36  x[samples - i - 1] = z;
37  w[i] = 2.0/((1.0 - zSqr)*pp*pp);
38  w[samples - i -1] = w[i];
39  }
40 }
41 
42 
43 const double funct::GaussIntegrator::x[12] = {
44  0.96028985649753623, 0.79666647741362674,
45  0.52553240991632899, 0.18343464249564980,
46  0.98940093499164993, 0.94457502307323258,
47  0.86563120238783174, 0.75540440835500303,
48  0.61787624440264375, 0.45801677765722739,
49  0.28160355077925891, 0.09501250983763744 };
50 
51 const double funct::GaussIntegrator::w[12] = {
52  0.10122853629037626, 0.22238103445337447,
53  0.31370664587788729, 0.36268378337836198,
54  0.02715245941175409, 0.06225352393864789,
55  0.09515851168249278, 0.12462897125553387,
56  0.14959598881657673, 0.16915651939500254,
57  0.18260341504492359, 0.18945061045506850 };
58 
59 const double funct::GaussIntegrator::kHF = 0.5;
60 const double funct::GaussIntegrator::kCST = 5./1000;
tuple pp
Definition: createTree.py:15
double double double z
static const double kCST
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
int j
Definition: DBlmapReader.cc:9
double p2[4]
Definition: TauolaWrapper.h:90
static const double w[12]
double p1[4]
Definition: TauolaWrapper.h:89
const double epsilon
static const double x[12]
double p3[4]
Definition: TauolaWrapper.h:91