CMS 3D CMS Logo

GammaContinuedFraction.cc
Go to the documentation of this file.
2 #include <cmath>
3 #include <iostream>
4 
5 #define ITMAX 100 // maximum allowed number of iterations
6 #define EPS 3.0e-7 // relative accuracy
7 #define FPMIN 1.0e-30 // number near the smallest representable floating-point number
8 
9 float
10 GammaContinuedFraction( float a, float x )
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 }
37 #undef ITMAX
38 #undef EPS
39 #undef FPMIN
40 /* (C) Copr. 1986-92 Numerical Recipes Software B2.. */
int i
Definition: DBlmapReader.cc:9
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
float GammaContinuedFraction(float a, float x)
double a
Definition: hdecay.h:121
#define ITMAX