LAPACK
3.12.1
LAPACK: Linear Algebra PACKage
Toggle main menu visibility
Main Page
Related Pages
Routines
Modules
Modules List
Module Members
All
c
d
s
z
Functions/Subroutines
Variables
c
d
s
z
Data Types
Data Types List
Data Type Index
Data Fields
All
Functions/Subroutines
Variables
Files
File List
File Members
All
_
a
b
c
d
f
g
h
i
l
m
p
r
s
t
u
x
z
Functions/Subroutines
_
a
c
d
f
g
h
i
l
m
s
t
x
z
Variables
c
l
r
Typedefs
Enumerations
Enumerator
Macros
a
b
c
f
i
p
t
u
x
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Modules
Pages
Loading...
Searching...
No Matches
sladiv.f
Go to the documentation of this file.
1
*> \brief \b SLADIV performs complex division in real arithmetic, avoiding unnecessary overflow.
2
*
3
* =========== DOCUMENTATION ===========
4
*
5
* Online html documentation available at
6
* http://www.netlib.org/lapack/explore-html/
7
*
8
*> Download SLADIV + dependencies
9
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/sladiv.f">
10
*> [TGZ]</a>
11
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/sladiv.f">
12
*> [ZIP]</a>
13
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/sladiv.f">
14
*> [TXT]</a>
15
*
16
* Definition:
17
* ===========
18
*
19
* SUBROUTINE SLADIV( A, B, C, D, P, Q )
20
*
21
* .. Scalar Arguments ..
22
* REAL A, B, C, D, P, Q
23
* ..
24
*
25
*
26
*> \par Purpose:
27
* =============
28
*>
29
*> \verbatim
30
*>
31
*> SLADIV performs complex division in real arithmetic
32
*>
33
*> a + i*b
34
*> p + i*q = ---------
35
*> c + i*d
36
*>
37
*> The algorithm is due to Michael Baudin and Robert L. Smith
38
*> and can be found in the paper
39
*> "A Robust Complex Division in Scilab"
40
*> \endverbatim
41
*
42
* Arguments:
43
* ==========
44
*
45
*> \param[in] A
46
*> \verbatim
47
*> A is REAL
48
*> \endverbatim
49
*>
50
*> \param[in] B
51
*> \verbatim
52
*> B is REAL
53
*> \endverbatim
54
*>
55
*> \param[in] C
56
*> \verbatim
57
*> C is REAL
58
*> \endverbatim
59
*>
60
*> \param[in] D
61
*> \verbatim
62
*> D is REAL
63
*> The scalars a, b, c, and d in the above expression.
64
*> \endverbatim
65
*>
66
*> \param[out] P
67
*> \verbatim
68
*> P is REAL
69
*> \endverbatim
70
*>
71
*> \param[out] Q
72
*> \verbatim
73
*> Q is REAL
74
*> The scalars p and q in the above expression.
75
*> \endverbatim
76
*
77
* Authors:
78
* ========
79
*
80
*> \author Univ. of Tennessee
81
*> \author Univ. of California Berkeley
82
*> \author Univ. of Colorado Denver
83
*> \author NAG Ltd.
84
*
85
*> \ingroup ladiv
86
*
87
* =====================================================================
88
SUBROUTINE
sladiv
( A, B, C, D, P, Q )
89
*
90
* -- LAPACK auxiliary routine --
91
* -- LAPACK is a software package provided by Univ. of Tennessee, --
92
* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
93
*
94
* .. Scalar Arguments ..
95
REAL
A, B, C, D, P, Q
96
* ..
97
*
98
* =====================================================================
99
*
100
* .. Parameters ..
101
REAL
BS
102
parameter( bs = 2.0e0 )
103
REAL
HALF
104
parameter( half = 0.5e0 )
105
REAL
TWO
106
parameter( two = 2.0e0 )
107
*
108
* .. Local Scalars ..
109
REAL
AA, BB, CC, DD, AB, CD, S, OV, UN, BE, EPS
110
* ..
111
* .. External Functions ..
112
REAL
SLAMCH
113
EXTERNAL
slamch
114
* ..
115
* .. External Subroutines ..
116
EXTERNAL
sladiv1
117
* ..
118
* .. Intrinsic Functions ..
119
INTRINSIC
abs, max
120
* ..
121
* .. Executable Statements ..
122
*
123
aa = a
124
bb = b
125
cc = c
126
dd = d
127
ab = max( abs(a), abs(b) )
128
cd = max( abs(c), abs(d) )
129
s = 1.0e0
130
131
ov = slamch(
'Overflow threshold'
)
132
un = slamch(
'Safe minimum'
)
133
eps = slamch(
'Epsilon'
)
134
be = bs / (eps*eps)
135
136
IF
( ab >= half*ov )
THEN
137
aa = half * aa
138
bb = half * bb
139
s = two * s
140
END IF
141
IF
( cd >= half*ov )
THEN
142
cc = half * cc
143
dd = half * dd
144
s = half * s
145
END IF
146
IF
( ab <= un*bs/eps )
THEN
147
aa = aa * be
148
bb = bb * be
149
s = s / be
150
END IF
151
IF
( cd <= un*bs/eps )
THEN
152
cc = cc * be
153
dd = dd * be
154
s = s * be
155
END IF
156
IF
( abs( d ).LE.abs( c ) )
THEN
157
CALL
sladiv1
(aa, bb, cc, dd, p, q)
158
ELSE
159
CALL
sladiv1
(bb, aa, dd, cc, p, q)
160
q = -q
161
END IF
162
p = p * s
163
q = q * s
164
*
165
RETURN
166
*
167
* End of SLADIV
168
*
88
SUBROUTINE
sladiv
( A, B, C, D, P, Q )
…
169
END
170
171
*> \ingroup ladiv
172
173
174
SUBROUTINE
sladiv1
( A, B, C, D, P, Q )
175
*
176
* -- LAPACK auxiliary routine --
177
* -- LAPACK is a software package provided by Univ. of Tennessee, --
178
* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
179
*
180
* .. Scalar Arguments ..
181
REAL
A, B, C, D, P, Q
182
* ..
183
*
184
* =====================================================================
185
*
186
* .. Parameters ..
187
REAL
ONE
188
parameter( one = 1.0e0 )
189
*
190
* .. Local Scalars ..
191
REAL
R, T
192
* ..
193
* .. External Functions ..
194
REAL
SLADIV2
195
EXTERNAL
sladiv2
196
* ..
197
* .. Executable Statements ..
198
*
199
r = d / c
200
t = one / (c + d * r)
201
p = sladiv2(a, b, c, d, r, t)
202
a = -a
203
q = sladiv2(b, a, c, d, r, t)
204
*
205
RETURN
206
*
207
* End of SLADIV1
208
*
174
SUBROUTINE
sladiv1
( A, B, C, D, P, Q )
…
209
END
210
211
*> \ingroup ladiv
212
213
REAL
function
sladiv2
( a, b, c, d, r, t )
214
*
215
* -- LAPACK auxiliary routine --
216
* -- LAPACK is a software package provided by Univ. of Tennessee, --
217
* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
218
*
219
* .. Scalar Arguments ..
220
REAL
a, b, c, d, r, t
221
* ..
222
*
223
* =====================================================================
224
*
225
* .. Parameters ..
226
REAL
zero
227
parameter( zero = 0.0e0 )
228
*
229
* .. Local Scalars ..
230
REAL
br
231
* ..
232
* .. Executable Statements ..
233
*
234
IF
( r.NE.zero )
THEN
235
br = b * r
236
if
( br.NE.zero )
THEN
237
sladiv2
= (a + br) * t
238
ELSE
239
sladiv2
= a * t + (b * t) * r
240
END IF
241
ELSE
242
sladiv2
= (a + d * (b / c)) * t
243
END IF
244
*
245
RETURN
246
*
247
* End of SLADIV2
248
*
213
REAL
function
sladiv2
( a, b, c, d, r, t )
…
249
END
sladiv2
real function sladiv2(a, b, c, d, r, t)
Definition
sladiv.f:214
sladiv1
subroutine sladiv1(a, b, c, d, p, q)
Definition
sladiv.f:175
sladiv
subroutine sladiv(a, b, c, d, p, q)
SLADIV performs complex division in real arithmetic, avoiding unnecessary overflow.
Definition
sladiv.f:89
SRC
sladiv.f
Generated on Mon Jan 20 2025 17:18:12 for LAPACK by
1.11.0