Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
nf_gammaFunctions.cc File Reference

Go to the source code of this file.

Macros

#define MAXGAM   171.624376956302725
 
#define MAXSTIR   143.01608
 
#define MAXLGM   2.556348e305
 

Functions

double nf_gammaFunction (double x, nfu_status *status)
 
double nf_logGammaFunction (double x, nfu_status *status)
 

Macro Definition Documentation

◆ MAXGAM

#define MAXGAM   171.624376956302725

Definition at line 93 of file nf_gammaFunctions.cc.

◆ MAXLGM

#define MAXLGM   2.556348e305

Definition at line 201 of file nf_gammaFunctions.cc.

◆ MAXSTIR

#define MAXSTIR   143.01608

Definition at line 99 of file nf_gammaFunctions.cc.

Function Documentation

◆ nf_gammaFunction()

double nf_gammaFunction ( double x,
nfu_status * status )

Definition at line 126 of file nf_gammaFunctions.cc.

126 {
127
128 double p, q, z;
129 int i, sgngam = 1;
130
131 *status = nfu_badInput;
132 if( !isfinite( x ) ) return( x );
133 *status = nfu_Okay;
134
135 q = fabs( x );
136
137 if( q > 33.0 ) {
138 if( x < 0.0 ) {
139 p = floor( q );
140 if( p == q ) goto goverf;
141 i = (int) p;
142 if( ( i & 1 ) == 0 ) sgngam = -1;
143 z = q - p;
144 if( z > 0.5 ) {
145 p += 1.0;
146 z = q - p;
147 }
148 z = q * sin( M_PI * z );
149 if( z == 0.0 ) goto goverf;
150 z = M_PI / ( fabs( z ) * stirf( q, status ) );
151 }
152 else {
153 z = stirf( x, status );
154 }
155 return( sgngam * z );
156 }
157
158 z = 1.0;
159 while( x >= 3.0 ) {
160 x -= 1.0;
161 z *= x;
162 } // Loop checking, 11.06.2015, T. Koi
163
164 while( x < 0.0 ) {
165 if( x > -1.E-9 ) goto small;
166 z /= x;
167 x += 1.0;
168 } // Loop checking, 11.06.2015, T. Koi
169
170 while( x < 2.0 ) {
171 if( x < 1.e-9 ) goto small;
172 z /= x;
173 x += 1.0;
174 } // Loop checking, 11.06.2015, T. Koi
175
176 if( x == 2.0 ) return( z );
177
178 x -= 2.0;
179 p = nf_polevl( x, P, 6 );
180 q = nf_polevl( x, Q, 7 );
181 return( z * p / q );
182
183small:
184 if( x == 0.0 ) goto goverf;
185 return( z / ( ( 1.0 + 0.5772156649015329 * x ) * x ) );
186
187goverf:
188 return( sgngam * DBL_MAX );
189}
#define M_PI
Definition SbMath.h:33
double nf_polevl(double x, double coef[], int N)
Definition nf_polevl.cc:46
@ nfu_Okay
@ nfu_badInput
#define DBL_MAX
Definition templates.hh:62

Referenced by nf_incompleteGammaFunction(), and nf_incompleteGammaFunctionComplementary().

◆ nf_logGammaFunction()

double nf_logGammaFunction ( double x,
nfu_status * status )

Definition at line 206 of file nf_gammaFunctions.cc.

206 {
207/* Logarithm of gamma function */
208
209 int sgngam;
210
211 *status = nfu_badInput;
212 if( !isfinite( x ) ) return( x );
213 *status = nfu_Okay;
214 return( lgam( x, &sgngam, status ) );
215}