CMS 3D CMS Logo

Functions
GammaContinuedFraction.h File Reference

Go to the source code of this file.

Functions

float GammaContinuedFraction (float a, float x)
 

Function Documentation

float GammaContinuedFraction ( float  a,
float  x 
)

Returns the continued fraction summation of the (complement of the) incomplete gamma function P(a,x) evaluated by its continued fraction representation. source: Numerical Recipes

Definition at line 10 of file GammaContinuedFraction.cc.

References a, b, EnergyCorrector::c, MessageLogger_cfi::cerr, edmIntegrityCheck::d, EPS, FPMIN, h, mps_fire::i, and ITMAX.

Referenced by IncompleteGammaComplement::ln(), and IncompleteGammaComplement::value().

11 {
12  int i;
13  float an,del;
14 
15  /* Set up for evaluating continued fraction by modified Lentz's method (par.5.2
16  in Numerical Recipes in C) with b_0 = 0 */
17  double b = x+1.0-a;
18  double c = 1.0/FPMIN;
19  double d = 1.0/b;
20  double h = d;
21  for (i=1;i<=ITMAX;i++) {
22  an = -i*(i-a);
23  b += 2.0;
24  d=an*d+b;
25  if (fabs(d) < FPMIN) d=FPMIN;
26  c=b+an/c;
27  if (fabs(c) < FPMIN) c=FPMIN;
28  d=1.0/d;
29  del=d*c;
30  h *= del;
31  if (fabs(del-1.0) < EPS) break;
32  }
33  if( i > ITMAX ) std::cerr << "GammaContinuedFraction::a too large, "
34  << "ITMAX too small" << std::endl;
35  return h;
36 }
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
#define EPS
T x() const
Cartesian x coordinate.
#define FPMIN
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
#define ITMAX