C ALGORITHM 404 COLLECTED ALGORITHMS FROM ACM. C ALGORITHM APPEARED IN COMM. ACM, VOL. 14, NO. 01, C P. 048. FUNCTION CGAMMA(Z) COMPLEX Z,ZM,T,TT,SUM,TERM,DEN,CGAMMA,PI,A DIMENSION C(12) LOGICAL REFLEK C SET IOUT FOR PROPER OUTPUT CHANNEL OF COMPUTER SYSTEM FOR C ERROR MESSAGES IOUT = 3 PI = (3.141593,0.0) X = REAL(Z) Y = AIMAG(Z) C TOL = LIMIT OF PRECISION OF COMPUTER SYSTEM IN SINGLE PRECISI TOL = 1.0E-7 REFLEK = .TRUE. C DETERMINE WHETHER Z IS TOO CLOSE TO A POLE C CHECK WHETHER TOO CLOSE TO ORIGIN IF(X.GE.TOL) GO TO 20 C FIND THE NEAREST POLE AND COMPUTE DISTANCE TO IT XDIST = X-INT(X-.5) ZM = CMPLX(XDIST,Y) IF(CABS(ZM).GE.TOL) GO TO 10 C IF Z IS TOO CLOSE TO A POLE, PRINT ERROR MESSAGE AND RETURN C WITH CGAMMA = (1.E7,0.0E0) WRITE(IOUT,900) Z CGAMMA = (1.E7,0.E0) RETURN C FOR REAL(Z) NEGATIVE EMPLOY THE REFLECTION FORMULA C GAMMA(Z) = PI/(SIN(PI*Z)*GAMMA(1-Z)) C AND COMPUTE GAMMA(1-Z). NOTE REFLEK IS A TAG TO INDICATE THA C THIS RELATION MUST BE USED LATER. 10 IF(X.GE.0.0) GO TO 20 REFLEK = .FALSE. Z = (1.0,0.0)-Z X = 1.0-X Y = -Y C IF Z IS NOT TOO CLOSE TO A POLE, MAKE REAL(Z)>10 AND ARG(Z)