CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Private Attributes
funct::GaussLegendreIntegrator Class Reference

#include <NumericalIntegration.h>

Public Member Functions

 GaussLegendreIntegrator ()
 
 GaussLegendreIntegrator (unsigned int samples, double epsilon)
 
template<typename F >
double operator() (const F &f, double min, double max) const
 

Private Attributes

double a0
 
double b0
 
unsigned int i
 
double result
 
unsigned int samples_
 
std::vector< double > w
 
std::vector< double > x
 

Detailed Description

Definition at line 42 of file NumericalIntegration.h.

Constructor & Destructor Documentation

funct::GaussLegendreIntegrator::GaussLegendreIntegrator ( )
inline

Definition at line 44 of file NumericalIntegration.h.

funct::GaussLegendreIntegrator::GaussLegendreIntegrator ( unsigned int  samples,
double  epsilon 
)

Definition at line 5 of file NumericalIntegration.cc.

References edm::errors::Configuration, funct::cos(), Exception, i, dqmiolumiharvest::j, funct::m, fireworks::p1, fireworks::p2, createTree::pp, w, and x.

5  : samples_(samples) {
6  if (samples <= 0)
7  throw edm::Exception(edm::errors::Configuration) << "gauss_legendre_integral: number of samples must be positive\n";
8  if (epsilon <= 0)
10  << "gauss_legendre_integral: numerical precision must be positive\n";
11 
12  x.resize(samples);
13  w.resize(samples);
14  const unsigned int m = (samples + 1) / 2;
15 
16  double z, zSqr, pp, p1, p2, p3;
17 
18  for (unsigned int i = 0; i < m; ++i) {
19  z = std::cos(3.14159265358979323846 * (i + 0.75) / (samples + 0.5));
20  zSqr = z * z;
21  do {
22  p1 = 1.0;
23  p2 = 0.0;
24  for (unsigned int j = 0; j < samples; ++j) {
25  p3 = p2;
26  p2 = p1;
27  p1 = ((2.0 * j + 1.0) * z * p2 - j * p3) / (j + 1.0);
28  }
29  pp = samples * (z * p1 - p2) / (zSqr - 1.0);
30  z -= p1 / pp;
31  } while (std::fabs(p1 / pp) > epsilon);
32 
33  x[i] = -z;
34  x[samples - i - 1] = z;
35  w[i] = 2.0 / ((1.0 - zSqr) * pp * pp);
36  w[samples - i - 1] = w[i];
37  }
38 }
tuple pp
Definition: createTree.py:17
const TString p2
Definition: fwPaths.cc:13
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
const TString p1
Definition: fwPaths.cc:12

Member Function Documentation

template<typename F >
double funct::GaussLegendreIntegrator::operator() ( const F f,
double  min,
double  max 
) const
inline

Definition at line 47 of file NumericalIntegration.h.

References a0, b0, validate-o2o-wbm::f, i, SiStripPI::min, result, samples_, w, and x.

Member Data Documentation

double funct::GaussLegendreIntegrator::a0
mutableprivate

Definition at line 61 of file NumericalIntegration.h.

Referenced by operator()().

double funct::GaussLegendreIntegrator::b0
mutableprivate

Definition at line 61 of file NumericalIntegration.h.

Referenced by operator()().

unsigned int funct::GaussLegendreIntegrator::i
mutableprivate

Definition at line 62 of file NumericalIntegration.h.

Referenced by GaussLegendreIntegrator(), and operator()().

double funct::GaussLegendreIntegrator::result
mutableprivate

Definition at line 61 of file NumericalIntegration.h.

Referenced by operator()().

unsigned int funct::GaussLegendreIntegrator::samples_
private

Definition at line 59 of file NumericalIntegration.h.

Referenced by operator()().

std::vector<double> funct::GaussLegendreIntegrator::w
private

Definition at line 60 of file NumericalIntegration.h.

Referenced by GaussLegendreIntegrator(), and operator()().

std::vector<double> funct::GaussLegendreIntegrator::x
private