LAPACK 3.12.0
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
dgeequ.f
Go to the documentation of this file.
1*> \brief \b DGEEQU
2*
3* =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6* http://www.netlib.org/lapack/explore-html/
7*
8*> \htmlonly
9*> Download DGEEQU + dependencies
10*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dgeequ.f">
11*> [TGZ]</a>
12*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dgeequ.f">
13*> [ZIP]</a>
14*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dgeequ.f">
15*> [TXT]</a>
16*> \endhtmlonly
17*
18* Definition:
19* ===========
20*
21* SUBROUTINE DGEEQU( M, N, A, LDA, R, C, ROWCND, COLCND, AMAX,
22* INFO )
23*
24* .. Scalar Arguments ..
25* INTEGER INFO, LDA, M, N
26* DOUBLE PRECISION AMAX, COLCND, ROWCND
27* ..
28* .. Array Arguments ..
29* DOUBLE PRECISION A( LDA, * ), C( * ), R( * )
30* ..
31*
32*
33*> \par Purpose:
34* =============
35*>
36*> \verbatim
37*>
38*> DGEEQU computes row and column scalings intended to equilibrate an
39*> M-by-N matrix A and reduce its condition number. R returns the row
40*> scale factors and C the column scale factors, chosen to try to make
41*> the largest element in each row and column of the matrix B with
42*> elements B(i,j)=R(i)*A(i,j)*C(j) have absolute value 1.
43*>
44*> R(i) and C(j) are restricted to be between SMLNUM = smallest safe
45*> number and BIGNUM = largest safe number. Use of these scaling
46*> factors is not guaranteed to reduce the condition number of A but
47*> works well in practice.
48*> \endverbatim
49*
50* Arguments:
51* ==========
52*
53*> \param[in] M
54*> \verbatim
55*> M is INTEGER
56*> The number of rows of the matrix A. M >= 0.
57*> \endverbatim
58*>
59*> \param[in] N
60*> \verbatim
61*> N is INTEGER
62*> The number of columns of the matrix A. N >= 0.
63*> \endverbatim
64*>
65*> \param[in] A
66*> \verbatim
67*> A is DOUBLE PRECISION array, dimension (LDA,N)
68*> The M-by-N matrix whose equilibration factors are
69*> to be computed.
70*> \endverbatim
71*>
72*> \param[in] LDA
73*> \verbatim
74*> LDA is INTEGER
75*> The leading dimension of the array A. LDA >= max(1,M).
76*> \endverbatim
77*>
78*> \param[out] R
79*> \verbatim
80*> R is DOUBLE PRECISION array, dimension (M)
81*> If INFO = 0 or INFO > M, R contains the row scale factors
82*> for A.
83*> \endverbatim
84*>
85*> \param[out] C
86*> \verbatim
87*> C is DOUBLE PRECISION array, dimension (N)
88*> If INFO = 0, C contains the column scale factors for A.
89*> \endverbatim
90*>
91*> \param[out] ROWCND
92*> \verbatim
93*> ROWCND is DOUBLE PRECISION
94*> If INFO = 0 or INFO > M, ROWCND contains the ratio of the
95*> smallest R(i) to the largest R(i). If ROWCND >= 0.1 and
96*> AMAX is neither too large nor too small, it is not worth
97*> scaling by R.
98*> \endverbatim
99*>
100*> \param[out] COLCND
101*> \verbatim
102*> COLCND is DOUBLE PRECISION
103*> If INFO = 0, COLCND contains the ratio of the smallest
104*> C(i) to the largest C(i). If COLCND >= 0.1, it is not
105*> worth scaling by C.
106*> \endverbatim
107*>
108*> \param[out] AMAX
109*> \verbatim
110*> AMAX is DOUBLE PRECISION
111*> Absolute value of largest matrix element. If AMAX is very
112*> close to overflow or very close to underflow, the matrix
113*> should be scaled.
114*> \endverbatim
115*>
116*> \param[out] INFO
117*> \verbatim
118*> INFO is INTEGER
119*> = 0: successful exit
120*> < 0: if INFO = -i, the i-th argument had an illegal value
121*> > 0: if INFO = i, and i is
122*> <= M: the i-th row of A is exactly zero
123*> > M: the (i-M)-th column of A is exactly zero
124*> \endverbatim
125*
126* Authors:
127* ========
128*
129*> \author Univ. of Tennessee
130*> \author Univ. of California Berkeley
131*> \author Univ. of Colorado Denver
132*> \author NAG Ltd.
133*
134*> \ingroup geequ
135*
136* =====================================================================
137 SUBROUTINE dgeequ( M, N, A, LDA, R, C, ROWCND, COLCND, AMAX,
138 $ INFO )
139*
140* -- LAPACK computational routine --
141* -- LAPACK is a software package provided by Univ. of Tennessee, --
142* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
143*
144* .. Scalar Arguments ..
145 INTEGER INFO, LDA, M, N
146 DOUBLE PRECISION AMAX, COLCND, ROWCND
147* ..
148* .. Array Arguments ..
149 DOUBLE PRECISION A( LDA, * ), C( * ), R( * )
150* ..
151*
152* =====================================================================
153*
154* .. Parameters ..
155 DOUBLE PRECISION ONE, ZERO
156 parameter( one = 1.0d+0, zero = 0.0d+0 )
157* ..
158* .. Local Scalars ..
159 INTEGER I, J
160 DOUBLE PRECISION BIGNUM, RCMAX, RCMIN, SMLNUM
161* ..
162* .. External Functions ..
163 DOUBLE PRECISION DLAMCH
164 EXTERNAL dlamch
165* ..
166* .. External Subroutines ..
167 EXTERNAL xerbla
168* ..
169* .. Intrinsic Functions ..
170 INTRINSIC abs, max, min
171* ..
172* .. Executable Statements ..
173*
174* Test the input parameters.
175*
176 info = 0
177 IF( m.LT.0 ) THEN
178 info = -1
179 ELSE IF( n.LT.0 ) THEN
180 info = -2
181 ELSE IF( lda.LT.max( 1, m ) ) THEN
182 info = -4
183 END IF
184 IF( info.NE.0 ) THEN
185 CALL xerbla( 'DGEEQU', -info )
186 RETURN
187 END IF
188*
189* Quick return if possible
190*
191 IF( m.EQ.0 .OR. n.EQ.0 ) THEN
192 rowcnd = one
193 colcnd = one
194 amax = zero
195 RETURN
196 END IF
197*
198* Get machine constants.
199*
200 smlnum = dlamch( 'S' )
201 bignum = one / smlnum
202*
203* Compute row scale factors.
204*
205 DO 10 i = 1, m
206 r( i ) = zero
207 10 CONTINUE
208*
209* Find the maximum element in each row.
210*
211 DO 30 j = 1, n
212 DO 20 i = 1, m
213 r( i ) = max( r( i ), abs( a( i, j ) ) )
214 20 CONTINUE
215 30 CONTINUE
216*
217* Find the maximum and minimum scale factors.
218*
219 rcmin = bignum
220 rcmax = zero
221 DO 40 i = 1, m
222 rcmax = max( rcmax, r( i ) )
223 rcmin = min( rcmin, r( i ) )
224 40 CONTINUE
225 amax = rcmax
226*
227 IF( rcmin.EQ.zero ) THEN
228*
229* Find the first zero scale factor and return an error code.
230*
231 DO 50 i = 1, m
232 IF( r( i ).EQ.zero ) THEN
233 info = i
234 RETURN
235 END IF
236 50 CONTINUE
237 ELSE
238*
239* Invert the scale factors.
240*
241 DO 60 i = 1, m
242 r( i ) = one / min( max( r( i ), smlnum ), bignum )
243 60 CONTINUE
244*
245* Compute ROWCND = min(R(I)) / max(R(I))
246*
247 rowcnd = max( rcmin, smlnum ) / min( rcmax, bignum )
248 END IF
249*
250* Compute column scale factors
251*
252 DO 70 j = 1, n
253 c( j ) = zero
254 70 CONTINUE
255*
256* Find the maximum element in each column,
257* assuming the row scaling computed above.
258*
259 DO 90 j = 1, n
260 DO 80 i = 1, m
261 c( j ) = max( c( j ), abs( a( i, j ) )*r( i ) )
262 80 CONTINUE
263 90 CONTINUE
264*
265* Find the maximum and minimum scale factors.
266*
267 rcmin = bignum
268 rcmax = zero
269 DO 100 j = 1, n
270 rcmin = min( rcmin, c( j ) )
271 rcmax = max( rcmax, c( j ) )
272 100 CONTINUE
273*
274 IF( rcmin.EQ.zero ) THEN
275*
276* Find the first zero scale factor and return an error code.
277*
278 DO 110 j = 1, n
279 IF( c( j ).EQ.zero ) THEN
280 info = m + j
281 RETURN
282 END IF
283 110 CONTINUE
284 ELSE
285*
286* Invert the scale factors.
287*
288 DO 120 j = 1, n
289 c( j ) = one / min( max( c( j ), smlnum ), bignum )
290 120 CONTINUE
291*
292* Compute COLCND = min(C(J)) / max(C(J))
293*
294 colcnd = max( rcmin, smlnum ) / min( rcmax, bignum )
295 END IF
296*
297 RETURN
298*
299* End of DGEEQU
300*
301 END
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine dgeequ(m, n, a, lda, r, c, rowcnd, colcnd, amax, info)
DGEEQU
Definition dgeequ.f:139