LAPACK  3.6.1
LAPACK: Linear Algebra PACKage
subroutine sladiv ( real  A,
real  B,
real  C,
real  D,
real  P,
real  Q 
)

SLADIV performs complex division in real arithmetic, avoiding unnecessary overflow.

Download SLADIV + dependencies [TGZ] [ZIP] [TXT]

Purpose:
 SLADIV performs complex division in  real arithmetic

                       a + i*b
            p + i*q = ---------
                       c + i*d

 The algorithm is due to Michael Baudin and Robert L. Smith
 and can be found in the paper
 "A Robust Complex Division in Scilab"
Parameters
[in]A
          A is REAL
[in]B
          B is REAL
[in]C
          C is REAL
[in]D
          D is REAL
          The scalars a, b, c, and d in the above expression.
[out]P
          P is REAL
[out]Q
          Q is REAL
          The scalars p and q in the above expression.
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
Date
January 2013

Definition at line 93 of file sladiv.f.

93 *
94 * -- LAPACK auxiliary routine (version 3.5.0) --
95 * -- LAPACK is a software package provided by Univ. of Tennessee, --
96 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
97 * January 2013
98 *
99 * .. Scalar Arguments ..
100  REAL a, b, c, d, p, q
101 * ..
102 *
103 * =====================================================================
104 *
105 * .. Parameters ..
106  REAL bs
107  parameter ( bs = 2.0e0 )
108  REAL half
109  parameter ( half = 0.5e0 )
110  REAL two
111  parameter ( two = 2.0e0 )
112 *
113 * .. Local Scalars ..
114  REAL aa, bb, cc, dd, ab, cd, s, ov, un, be, eps
115 * ..
116 * .. External Functions ..
117  REAL slamch
118  EXTERNAL slamch
119 * ..
120 * .. External Subroutines ..
121  EXTERNAL sladiv1
122 * ..
123 * .. Intrinsic Functions ..
124  INTRINSIC abs, max
125 * ..
126 * .. Executable Statements ..
127 *
128  aa = a
129  bb = b
130  cc = c
131  dd = d
132  ab = max( abs(a), abs(b) )
133  cd = max( abs(c), abs(d) )
134  s = 1.0e0
135 
136  ov = slamch( 'Overflow threshold' )
137  un = slamch( 'Safe minimum' )
138  eps = slamch( 'Epsilon' )
139  be = bs / (eps*eps)
140 
141  IF( ab >= half*ov ) THEN
142  aa = half * aa
143  bb = half * bb
144  s = two * s
145  END IF
146  IF( cd >= half*ov ) THEN
147  cc = half * cc
148  dd = half * dd
149  s = half * s
150  END IF
151  IF( ab <= un*bs/eps ) THEN
152  aa = aa * be
153  bb = bb * be
154  s = s / be
155  END IF
156  IF( cd <= un*bs/eps ) THEN
157  cc = cc * be
158  dd = dd * be
159  s = s * be
160  END IF
161  IF( abs( d ).LE.abs( c ) ) THEN
162  CALL sladiv1(aa, bb, cc, dd, p, q)
163  ELSE
164  CALL sladiv1(bb, aa, dd, cc, p, q)
165  q = -q
166  END IF
167  p = p * s
168  q = q * s
169 *
170  RETURN
171 *
172 * End of SLADIV
173 *
subroutine sladiv1(A, B, C, D, P, Q)
Definition: sladiv.f:179
real function slamch(CMACH)
SLAMCH
Definition: slamch.f:69

Here is the call graph for this function:

Here is the caller graph for this function: