3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
9 *> Download SGEEQU + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/sgeequ.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/sgeequ.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/sgeequ.f">
21 * SUBROUTINE SGEEQU( M, N, A, LDA, R, C, ROWCND, COLCND, AMAX,
24 * .. Scalar Arguments ..
25 * INTEGER INFO, LDA, M, N
26 * REAL AMAX, COLCND, ROWCND
28 * .. Array Arguments ..
29 * REAL A( LDA, * ), C( * ), R( * )
38 *> SGEEQU 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.
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.
56 *> The number of rows of the matrix A. M >= 0.
62 *> The number of columns of the matrix A. N >= 0.
67 *> A is REAL array, dimension (LDA,N)
68 *> The M-by-N matrix whose equilibration factors are
75 *> The leading dimension of the array A. LDA >= max(1,M).
80 *> R is REAL array, dimension (M)
81 *> If INFO = 0 or INFO > M, R contains the row scale factors
87 *> C is REAL array, dimension (N)
88 *> If INFO = 0, C contains the column scale factors for A.
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
100 *> \param[out] COLCND
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.
111 *> Absolute value of largest matrix element. If AMAX is very
112 *> close to overflow or very close to underflow, the matrix
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
129 *> \author Univ. of Tennessee
130 *> \author Univ. of California Berkeley
131 *> \author Univ. of Colorado Denver
134 *> \date November 2011
136 *> \ingroup realGEcomputational
138 * =====================================================================
139 SUBROUTINE SGEEQU( M, N, A, LDA, R, C, ROWCND, COLCND, AMAX,
142 * -- LAPACK computational routine (version 3.4.0) --
143 * -- LAPACK is a software package provided by Univ. of Tennessee, --
144 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
147 * .. Scalar Arguments ..
148 INTEGER INFO, LDA, M, N
149 REAL AMAX, COLCND, ROWCND
151 * .. Array Arguments ..
152 REAL A( LDA, * ), C( * ), R( * )
155 * =====================================================================
159 PARAMETER ( ONE = 1.0E+0, ZERO = 0.0E+0 )
161 * .. Local Scalars ..
163 REAL BIGNUM, RCMAX, RCMIN, SMLNUM
165 * .. External Functions ..
169 * .. External Subroutines ..
172 * .. Intrinsic Functions ..
173 INTRINSIC ABS, MAX, MIN
175 * .. Executable Statements ..
177 * Test the input parameters.
182 ELSE IF( N.LT.0 ) THEN
184 ELSE IF( LDA.LT.MAX( 1, M ) ) THEN
188 CALL XERBLA( 'SGEEQU', -INFO )
192 * Quick return if possible
194 IF( M.EQ.0 .OR. N.EQ.0 ) THEN
201 * Get machine constants.
203 SMLNUM = SLAMCH( 'S' )
204 BIGNUM = ONE / SMLNUM
206 * Compute row scale factors.
212 * Find the maximum element in each row.
216 R( I ) = MAX( R( I ), ABS( A( I, J ) ) )
220 * Find the maximum and minimum scale factors.
225 RCMAX = MAX( RCMAX, R( I ) )
226 RCMIN = MIN( RCMIN, R( I ) )
230 IF( RCMIN.EQ.ZERO ) THEN
232 * Find the first zero scale factor and return an error code.
235 IF( R( I ).EQ.ZERO ) THEN
242 * Invert the scale factors.
245 R( I ) = ONE / MIN( MAX( R( I ), SMLNUM ), BIGNUM )
248 * Compute ROWCND = min(R(I)) / max(R(I))
250 ROWCND = MAX( RCMIN, SMLNUM ) / MIN( RCMAX, BIGNUM )
253 * Compute column scale factors
259 * Find the maximum element in each column,
260 * assuming the row scaling computed above.
264 C( J ) = MAX( C( J ), ABS( A( I, J ) )*R( I ) )
268 * Find the maximum and minimum scale factors.
273 RCMIN = MIN( RCMIN, C( J ) )
274 RCMAX = MAX( RCMAX, C( J ) )
277 IF( RCMIN.EQ.ZERO ) THEN
279 * Find the first zero scale factor and return an error code.
282 IF( C( J ).EQ.ZERO ) THEN
289 * Invert the scale factors.
292 C( J ) = ONE / MIN( MAX( C( J ), SMLNUM ), BIGNUM )
295 * Compute COLCND = min(C(J)) / max(C(J))
297 COLCND = MAX( RCMIN, SMLNUM ) / MIN( RCMAX, BIGNUM )