COSMOS v7.655  COSMOSv7655
(AirShowerMC)
kgamma.f
Go to the documentation of this file.
1 ! test kgamma
2 ! real*8 kgamma, y, x
3 ! do x=-0.01d0, -6.d0,-0.001d0
4 ! y=kgamma(x)
5 ! write(*,*) sngl(x), sngl(y)
6 ! enddo
7 ! end
8 ! *************************************************************
9 ! * *
10 ! * kgamma: gamma function in real domain.
11 ! * although real*8 must be specified, this gives
12 ! * single precision accuracy.
13 ! * *
14 ! *************************************************************
15 !
16 ! Usage: y=kgamma(x). x
17 !
18 ! Computes gamma(x) with 6 significant digit. gamma(x)=factorial of
19 ! (x-1). gamma(1)=gamma(2)=1 .........................................
20 !
21 !
22 !
23 !
24  real*8 function kgamma(x)
25 !
26  implicit none
27  real*8 x
28 !
29  real*8 pi, z, f, t
30 !
31 !
32  parameter(pi=3.141592653)
33 !
34  if(abs(x).gt.15.d0) then
35  z=x
36  if(z .le. 0.d0) then
37  f=pi/sin(pi*z)
38  z=1.d0-z
39  endif
40  kgamma=2.506628274d0*exp(-z)*z**(z-0.5d0)*
41  * ((3.47222222222d-3/z+8.3333333133d-2)/z+1.d0)
42  if(x .lt. 0.d0) then
43  kgamma=f/kgamma
44  endif
45  else
46  f=1.
47  z=x
48  do while (z .gt. 3.0)
49  z=z-1.
50  f=f*z
51  enddo
52  do while (z .lt. 2.0)
53  f=f*z
54  z=z+1.
55  enddo
56  z=z-2.0
57  t = (((((1.08298598d-2*z - 3.42705226d-3)*z + 7.7549276d-2)*z
58  * + 8.01782477d-2)*z + 4.12102903d-1)*z +4.22766368d-1)* z +
59  * 1.0000002d0
60  if(x .lt. 2.0d0) f=1.0d0/f
61  kgamma=t*f
62  endif
63  end
integer npitbl real *nx parameter(n=101, npitbl=46, nx=n-1) real *8 uconst
real *8 function kgamma(x)
Definition: kgamma.f:25
block data cblkEvhnp ! currently usable models data RegMdls ad *special data *Cekaon d0
Definition: cblkEvhnp.h:5
dE dx *! Nuc Int sampling table d
Definition: cblkMuInt.h:130