home *** CD-ROM | disk | FTP | other *** search
- gamma(x,gam)
-
- /* function to find the gamma function for */
- /* any variable x greater than zero. */
-
- float x,*gam;
-
- {
- int n,nd;
- float x1,gam1,gam2;
- static float
- b[9]={.035868343,-.193527818,.482199394,-.756704078,
- .918206857,-.897056937,.988205891,-.577191652,1.00};
-
- n = 0;
- gam1 = x;
- x1 = x;
- if(x <= 0.0)
- {
- *gam = 9999999.9;
- return;
- }
- if(x <= 1.0)
- {
- gam1 = 1.0/x1;
- }
- else
- {
- if(x <= 2.0) n = 1;
- x1 = x1 - 1.0;
- while (x1 >= 2.)
- {
- gam1 = gam1 * x1;
- x1 = x1 -1.0;
- }
- if(x1 > 1.0) x1 = x1 - 1.;
- }
- nd = 8;
- plyevl (b,nd,x1,&gam2);
- *gam = gam2;
- if(n == 1) return;
- *gam = *gam * gam1;
- }
-