Blame view

fvn_fnlib/ztan.f 1.48 KB
38581db0c   daniau   git-svn-id: https...
1
2
3
        complex(8) function ztan (z)
        implicit none
  c march 1979 edition.  w. fullerton, c3, los alamos scientific lab.
41811905d   wdaniau   Correction of a b...
4
        complex(8) z
38581db0c   daniau   git-svn-id: https...
5
6
7
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
41
42
43
44
45
46
47
48
49
50
51
        real(8) d1mach,eps, xmax, ylarge, ybig, ymin,sn2x,den
        real(8) x,y,x2,y2
        integer irold,irold2
        external d1mach
        data eps, xmax, ylarge, ybig, ymin / 4*0.0, 1.50 /
  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)))
  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
  c
        call entsrc (irold, 1)
        sn2x = sin(x2)
        call erroff
        den = cos(x2) + cosh(y2)
        call erroff
        call entsrc (irold2, irold)
  c
        if (den.lt.x*x2*eps*eps) call seteru ( 72hztan    tan is nearly si
       1ngular, x is near pi/2 or 3*pi/2 and y is near 0, 72, 3, 2)
        if (den.lt.x*x2*eps) call seteru (74hztan    answer lt half precis
       1ion, x is near pi/2 or 3*pi/2 and y is near 0, 74, 1, 1)
  c
        ztan = dcmplx (sn2x/den, sinh(y2)/den)
        return
  c
   20   if (abs(y).lt.ymin) call seteru (75hztan    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 (69hztan    answer lt half precisi
       1on, abs(x) is very big and abs(y) small, 69, 2, 1)
  c
        ztan = dcmplx (0.0, tanh(y2))
        return
  c
   30   ztan = dcmplx (0.0, -sign(1.0d0, y))
        return
  c
        end