3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
9 *> Download SGBEQUB + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/sgbequb.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/sgbequb.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/sgbequb.f">
21 * SUBROUTINE SGBEQUB( M, N, KL, KU, AB, LDAB, R, C, ROWCND, COLCND,
24 * .. Scalar Arguments ..
25 * INTEGER INFO, KL, KU, LDAB, M, N
26 * REAL AMAX, COLCND, ROWCND
28 * .. Array Arguments ..
29 * REAL AB( LDAB, * ), C( * ), R( * )
38 *> SGBEQUB 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 an absolute value of at most
45 *> R(i) and C(j) are restricted to be a power of the radix between
46 *> SMLNUM = smallest safe number and BIGNUM = largest safe number. Use
47 *> of these scaling factors is not guaranteed to reduce the condition
48 *> number of A but works well in practice.
50 *> This routine differs from SGEEQU by restricting the scaling factors
51 *> to a power of the radix. Barring over- and underflow, scaling by
52 *> these factors introduces no additional rounding errors. However, the
53 *> scaled entries' magnitudes are no longer approximately 1 but lie
54 *> between sqrt(radix) and 1/sqrt(radix).
63 *> The number of rows of the matrix A. M >= 0.
69 *> The number of columns of the matrix A. N >= 0.
75 *> The number of subdiagonals within the band of A. KL >= 0.
81 *> The number of superdiagonals within the band of A. KU >= 0.
86 *> AB is REAL array, dimension (LDAB,N)
87 *> On entry, the matrix A in band storage, in rows 1 to KL+KU+1.
88 *> The j-th column of A is stored in the j-th column of the
89 *> array AB as follows:
90 *> AB(KU+1+i-j,j) = A(i,j) for max(1,j-KU)<=i<=min(N,j+kl)
96 *> The leading dimension of the array A. LDAB >= max(1,M).
101 *> R is REAL array, dimension (M)
102 *> If INFO = 0 or INFO > M, R contains the row scale factors
108 *> C is REAL array, dimension (N)
109 *> If INFO = 0, C contains the column scale factors for A.
112 *> \param[out] ROWCND
115 *> If INFO = 0 or INFO > M, ROWCND contains the ratio of the
116 *> smallest R(i) to the largest R(i). If ROWCND >= 0.1 and
117 *> AMAX is neither too large nor too small, it is not worth
121 *> \param[out] COLCND
124 *> If INFO = 0, COLCND contains the ratio of the smallest
125 *> C(i) to the largest C(i). If COLCND >= 0.1, it is not
126 *> worth scaling by C.
132 *> Absolute value of largest matrix element. If AMAX is very
133 *> close to overflow or very close to underflow, the matrix
140 *> = 0: successful exit
141 *> < 0: if INFO = -i, the i-th argument had an illegal value
142 *> > 0: if INFO = i, and i is
143 *> <= M: the i-th row of A is exactly zero
144 *> > M: the (i-M)-th column of A is exactly zero
150 *> \author Univ. of Tennessee
151 *> \author Univ. of California Berkeley
152 *> \author Univ. of Colorado Denver
157 *> \ingroup realGBcomputational
159 * =====================================================================
160 SUBROUTINE SGBEQUB( M, N, KL, KU, AB, LDAB, R, C, ROWCND, COLCND,
163 * -- LAPACK computational routine (version 3.6.1) --
164 * -- LAPACK is a software package provided by Univ. of Tennessee, --
165 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
168 * .. Scalar Arguments ..
169 INTEGER INFO, KL, KU, LDAB, M, N
170 REAL AMAX, COLCND, ROWCND
172 * .. Array Arguments ..
173 REAL AB( LDAB, * ), C( * ), R( * )
176 * =====================================================================
180 PARAMETER ( ONE = 1.0E+0, ZERO = 0.0E+0 )
182 * .. Local Scalars ..
184 REAL BIGNUM, RCMAX, RCMIN, SMLNUM, RADIX, LOGRDX
186 * .. External Functions ..
190 * .. External Subroutines ..
193 * .. Intrinsic Functions ..
194 INTRINSIC ABS, MAX, MIN, LOG
196 * .. Executable Statements ..
198 * Test the input parameters.
203 ELSE IF( N.LT.0 ) THEN
205 ELSE IF( KL.LT.0 ) THEN
207 ELSE IF( KU.LT.0 ) THEN
209 ELSE IF( LDAB.LT.KL+KU+1 ) THEN
213 CALL XERBLA( 'SGBEQUB', -INFO )
217 * Quick return if possible.
219 IF( M.EQ.0 .OR. N.EQ.0 ) THEN
226 * Get machine constants. Assume SMLNUM is a power of the radix.
228 SMLNUM = SLAMCH( 'S' )
229 BIGNUM = ONE / SMLNUM
230 RADIX = SLAMCH( 'B' )
233 * Compute row scale factors.
239 * Find the maximum element in each row.
243 DO 20 I = MAX( J-KU, 1 ), MIN( J+KL, M )
244 R( I ) = MAX( R( I ), ABS( AB( KD+I-J, J ) ) )
248 IF( R( I ).GT.ZERO ) THEN
249 R( I ) = RADIX**INT( LOG( R( I ) ) / LOGRDX )
253 * Find the maximum and minimum scale factors.
258 RCMAX = MAX( RCMAX, R( I ) )
259 RCMIN = MIN( RCMIN, R( I ) )
263 IF( RCMIN.EQ.ZERO ) THEN
265 * Find the first zero scale factor and return an error code.
268 IF( R( I ).EQ.ZERO ) THEN
275 * Invert the scale factors.
278 R( I ) = ONE / MIN( MAX( R( I ), SMLNUM ), BIGNUM )
281 * Compute ROWCND = min(R(I)) / max(R(I)).
283 ROWCND = MAX( RCMIN, SMLNUM ) / MIN( RCMAX, BIGNUM )
286 * Compute column scale factors.
292 * Find the maximum element in each column,
293 * assuming the row scaling computed above.
296 DO 80 I = MAX( J-KU, 1 ), MIN( J+KL, M )
297 C( J ) = MAX( C( J ), ABS( AB( KD+I-J, J ) )*R( I ) )
299 IF( C( J ).GT.ZERO ) THEN
300 C( J ) = RADIX**INT( LOG( C( J ) ) / LOGRDX )
304 * Find the maximum and minimum scale factors.
309 RCMIN = MIN( RCMIN, C( J ) )
310 RCMAX = MAX( RCMAX, C( J ) )
313 IF( RCMIN.EQ.ZERO ) THEN
315 * Find the first zero scale factor and return an error code.
318 IF( C( J ).EQ.ZERO ) THEN
325 * Invert the scale factors.
328 C( J ) = ONE / MIN( MAX( C( J ), SMLNUM ), BIGNUM )
331 * Compute COLCND = min(C(J)) / max(C(J)).
333 COLCND = MAX( RCMIN, SMLNUM ) / MIN( RCMAX, BIGNUM )