1
subroutine wwdiv(ar,ai,br,bi,cr,ci,ierr)
4
c This subroutine wwdiv computes c=a/b where a and b are complex numbers
8
c subroutine wwdiv(ar,ai,br,bi,cr,ci,ierr)
10
c ar, ai: double precision, a real and complex parts.
12
c br, bi: double precision, b real and complex parts.
14
c cr, ci: double precision, c real and complex parts.
22
double precision ar,ai,br,bi,cr,ci
24
double precision s,d,ars,ais,brs,bis
30
elseif(br.eq.0.0d0) then
1
subroutine wwdiv(ar, ai, br, bi, cr, ci, ierr)
4
* complex division algorithm : compute c := a / b
11
* inputs : ar, ai, br, bi (double precision)
12
* outputs : cr, ci (double precision)
13
* ierr (integer) ierr = 1 if b = 0 (else 0)
15
* IMPLEMENTATION NOTES
16
* 1/ Use scaling with ||b||_oo; the original wwdiv.f used a scaling
17
* with ||b||_1. It results fewer operations. From the famous
18
* Golberg paper. This is known as Smith's method.
19
* 2/ Currently set c = NaN + i NaN in case of a division by 0 ;
20
* is that the good choice ?
23
* Bruno Pincon <Bruno.Pincon@iecn.u-nancy.fr>
28
double precision ar, ai, br, bi, cr, ci
48
elseif (br .eq. 0d0) then
35
if (s .eq. 0.0d+0) then
52
* Generic division algorithm
53
if (abs(br) .ge. abs(bi)) then
46
cr = (ars*brs + ais*bis)/d
47
ci = (ais*brs - ars*bis)/d