c Andrew M. O'Reilly 11/15/2001 c c***************************************************** c Gamma Function, approximation from: c Press, W.H., Flannery, B.P., Teukolsky, S.A., and c Vetterling, W.T., 1989, Numerical recipes -- c The art of scientific computing (FORTRAN version): c Cambridge University Press, 702 p. c c The error of this numerical approximation is reported c to be less than 2e-10 for xx>=1, and for 00 and uses the reflection c formula for 0 0' endif c tmp=x+fpf tmp=(x+half)*log(tmp)-tmp ser=one do 10 j=1,6 x=x+one ser=ser+cof(j)/x 10 continue gammln=tmp+log(stp*ser) c if (irefl.eq.1) then gammln=log(pi*(one-xx))-gammln-log(sin(pi*(one-xx))) endif c return end