LAPACK 3.12.0
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches

◆ sladiv()

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.

Definition at line 90 of file sladiv.f.

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