01:       SUBROUTINE SLADIV( A, B, C, D, P, Q )
02: *
03: *  -- LAPACK auxiliary routine (version 3.2) --
04: *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
05: *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
06: *     November 2006
07: *
08: *     .. Scalar Arguments ..
09:       REAL               A, B, C, D, P, Q
10: *     ..
11: *
12: *  Purpose
13: *  =======
14: *
15: *  SLADIV performs complex division in  real arithmetic
16: *
17: *                        a + i*b
18: *             p + i*q = ---------
19: *                        c + i*d
20: *
21: *  The algorithm is due to Robert L. Smith and can be found
22: *  in D. Knuth, The art of Computer Programming, Vol.2, p.195
23: *
24: *  Arguments
25: *  =========
26: *
27: *  A       (input) REAL
28: *  B       (input) REAL
29: *  C       (input) REAL
30: *  D       (input) REAL
31: *          The scalars a, b, c, and d in the above expression.
32: *
33: *  P       (output) REAL
34: *  Q       (output) REAL
35: *          The scalars p and q in the above expression.
36: *
37: *  =====================================================================
38: *
39: *     .. Local Scalars ..
40:       REAL               E, F
41: *     ..
42: *     .. Intrinsic Functions ..
43:       INTRINSIC          ABS
44: *     ..
45: *     .. Executable Statements ..
46: *
47:       IF( ABS( D ).LT.ABS( C ) ) THEN
48:          E = D / C
49:          F = C + D*E
50:          P = ( A+B*E ) / F
51:          Q = ( B-A*E ) / F
52:       ELSE
53:          E = C / D
54:          F = D + C*E
55:          P = ( B+A*E ) / F
56:          Q = ( -A+B*E ) / F
57:       END IF
58: *
59:       RETURN
60: *
61: *     End of SLADIV
62: *
63:       END
64: