Blame view
fvn_fnlib/zcot.f
1.78 KB
0c3098aed ChW 02/2010 for t... |
1 |
complex(kind(1.d0)) function zcot (z) |
38581db0c git-svn-id: https... |
2 3 |
implicit none c march 1979 edition. w. fullerton, c3, los alamos scientific lab. |
0c3098aed ChW 02/2010 for t... |
4 5 6 7 |
complex(kind(1.d0)) z real(kind(1.d0)) d1mach real(kind(1.d0)) eps, xmax, ylarge, ybig, rmin, ymin real(kind(1.d0)) x,y,x2,y2,sn2x,den |
38581db0c git-svn-id: https... |
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
integer irold,irold2 external d1mach data eps, xmax, ylarge, ybig, rmin, ymin / 5*0.0, 1.5 / c if (eps.ne.0.0) go to 10 eps = d1mach(4) xmax = 1.0/eps ylarge = -0.5*log(0.5*d1mach(3)) ybig = -0.5*log(0.5*sqrt(d1mach(3))) rmin = exp (max(log(d1mach(1)), -log(d1mach(2))) + 0.01) c 10 x = real (z) y = aimag (z) if (abs(y).gt.ylarge) go to 30 c x2 = 2.0*x y2 = 2.0*y if (abs(x2).gt.xmax) go to 20 if ( abs(z).lt.rmin) call seteru (55hzcot abs(z) is zero or so 1 small that zcot overflows, 55, 5, 2) c call entsrc (irold, 1) sn2x = sin(x2) call erroff den = cosh(y2) - cos(x2) call erroff call entsrc (irold2, irold) c if (den.lt.x*x2*eps*eps) call seteru (74hzcot cot is nearly sin 1gular, x is near a multiple of pi and y is near 0, 74, 3, 2) if (den.lt.x*x2*eps .and. abs(x).gt.0.5) call seteru (65hzcot a 1nswer is lt half precision, x is near pi and y is near 0, 65, 1,1) c |
0c3098aed ChW 02/2010 for t... |
41 |
zcot = cmplx (sn2x/den, -sinh(y2)/den, kind(1.d0)) |
38581db0c git-svn-id: https... |
42 43 44 45 46 47 48 |
return c 20 if (abs(y).lt.ymin) call seteru (75hzcot answer would have no p 1recision, abs(x) is very big and abs(y) small, 75, 4, 2) if (abs(y).lt.ybig) call seteru (69hzcot answer lt half precisi 1on, abs(x) is very big and abs(y) small, 69, 2, 1) c |
0c3098aed ChW 02/2010 for t... |
49 |
zcot = cmplx (0.0, 1.0/tanh(y2), kind(1.d0)) |
38581db0c git-svn-id: https... |
50 51 |
return c |
0c3098aed ChW 02/2010 for t... |
52 |
30 zcot = cmplx (0.0, sign (1.0d0, y), kind(1.d0)) |
38581db0c git-svn-id: https... |
53 54 55 |
return c end |