home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Geek Gadgets 1
/
ADE-1.bin
/
ade-dist
/
eispack-1.0-src.tgz
/
tar.out
/
contrib
/
eispack
/
csroot.f
< prev
next >
Wrap
Text File
|
1996-09-28
|
504b
|
18 lines
subroutine csroot(xr,xi,yr,yi)
double precision xr,xi,yr,yi
c
c (yr,yi) = complex dsqrt(xr,xi)
c branch chosen so that yr .ge. 0.0 and sign(yi) .eq. sign(xi)
c
double precision s,tr,ti,pythag
tr = xr
ti = xi
s = dsqrt(0.5d0*(pythag(tr,ti) + dabs(tr)))
if (tr .ge. 0.0d0) yr = s
if (ti .lt. 0.0d0) s = -s
if (tr .le. 0.0d0) yi = s
if (tr .lt. 0.0d0) yr = 0.5d0*(ti/yi)
if (tr .gt. 0.0d0) yi = 0.5d0*(ti/yr)
return
end