COSMOS v7.655  COSMOSv7655
(AirShowerMC)
kcombi.f
Go to the documentation of this file.
1 !c test kcombi
2 ! program test_kcombi
3 ! implicit none
4 ! real*8 m, n, c
5 ! m= 10.
6 ! n= 10.
7 ! call kcombi(n, m, c)
8 ! write(*, *) ' n=',n, ' m=', m, ' c=',c
9 ! end
10 ! **************************************************
11 ! *
12 ! * kcombi: compute n!/(n-m)!/m!
13 ! *
14 ! **************************************************
15 !
16 ! /usage/ call kcombi(n, m, c)
17 ! n: real*8. input.
18 ! m: real*8. input. must be n>=m.
19 ! c: real*8. output. n!/(n-m)!/m!
20 !
21 ! note: n and m may be fractional
22 !
23  subroutine kcombi(n, m, c)
24  implicit none
25  real * 8 n, m, c
26 
27  real*8 big, sq2pi
28  parameter(big = 20., sq2pi =2.5066282746310)
29  real*8 ep, x, z1, z2, z, tmp, kgamma
30 
31 !
32  ep(x)=(1.d0/288./x + 1.d0/12.)/x + 1.
33 !
34  z1=n+1.
35  z2=m+1.
36  z=n-m+1.
37  if(n .gt. big .and. (n-m) .gt. big .and. m .gt. big) then
38  tmp=exp( (n+.5)*log( z1/z) + m*log(z/z2) + 1.
39  * -.5 *log(z2) )
40  c=tmp/sq2pi * ep(z1)/ep(z2)/ep(z)
41  elseif(n .gt. big .and. (n-m) .gt. big) then
42  tmp=exp(m * (log(z)-1.) + (n+.5)*log(z1/z) )
43  c=tmp/kgamma(z2)*ep(z1)/ep(z)
44  elseif(n .gt. big .and. m .gt. big) then
45  tmp=exp( (n+.5)*log(z1) - (m+.5)*log(z2) + m-n)
46  c=tmp*ep(z1)/kgamma(z)/ep(z2)
47  else
48  c=kgamma(z1)/kgamma(z2)/kgamma(z)
49  endif
50  end
integer npitbl real *nx parameter(n=101, npitbl=46, nx=n-1) real *8 uconst
subroutine kcombi(n, m, c)
Definition: kcombi.f:24
block data cblkEvhnp ! currently usable models data RegMdls ad *special data *Cekaon d0
Definition: cblkEvhnp.h:5