3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
9 *> Download CGBEQU + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cgbequ.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cgbequ.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cgbequ.f">
21 * SUBROUTINE CGBEQU( 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 ..
30 * COMPLEX AB( LDAB, * )
39 *> CGBEQU computes row and column scalings intended to equilibrate an
40 *> M-by-N band matrix A and reduce its condition number. R returns the
41 *> row scale factors and C the column scale factors, chosen to try to
42 *> make the largest element in each row and column of the matrix B with
43 *> elements B(i,j)=R(i)*A(i,j)*C(j) have absolute value 1.
45 *> R(i) and C(j) are restricted to be between SMLNUM = smallest safe
46 *> number and BIGNUM = largest safe number. Use of these scaling
47 *> factors is not guaranteed to reduce the condition number of A but
48 *> works well in practice.
57 *> The number of rows of the matrix A. M >= 0.
63 *> The number of columns of the matrix A. N >= 0.
69 *> The number of subdiagonals within the band of A. KL >= 0.
75 *> The number of superdiagonals within the band of A. KU >= 0.
80 *> AB is COMPLEX array, dimension (LDAB,N)
81 *> The band matrix A, stored in rows 1 to KL+KU+1. The j-th
82 *> column of A is stored in the j-th column of the array AB as
84 *> AB(ku+1+i-j,j) = A(i,j) for max(1,j-ku)<=i<=min(m,j+kl).
90 *> The leading dimension of the array AB. LDAB >= KL+KU+1.
95 *> R is REAL array, dimension (M)
96 *> If INFO = 0, or INFO > M, R contains the row scale factors
102 *> C is REAL array, dimension (N)
103 *> If INFO = 0, C contains the column scale factors for A.
106 *> \param[out] ROWCND
109 *> If INFO = 0 or INFO > M, ROWCND contains the ratio of the
110 *> smallest R(i) to the largest R(i). If ROWCND >= 0.1 and
111 *> AMAX is neither too large nor too small, it is not worth
115 *> \param[out] COLCND
118 *> If INFO = 0, COLCND contains the ratio of the smallest
119 *> C(i) to the largest C(i). If COLCND >= 0.1, it is not
120 *> worth scaling by C.
126 *> Absolute value of largest matrix element. If AMAX is very
127 *> close to overflow or very close to underflow, the matrix
134 *> = 0: successful exit
135 *> < 0: if INFO = -i, the i-th argument had an illegal value
136 *> > 0: if INFO = i, and i is
137 *> <= M: the i-th row of A is exactly zero
138 *> > M: the (i-M)-th column of A is exactly zero
144 *> \author Univ. of Tennessee
145 *> \author Univ. of California Berkeley
146 *> \author Univ. of Colorado Denver
149 *> \date November 2011
151 *> \ingroup complexGBcomputational
153 * =====================================================================
154 SUBROUTINE CGBEQU( M, N, KL, KU, AB, LDAB, R, C, ROWCND, COLCND,
157 * -- LAPACK computational routine (version 3.4.0) --
158 * -- LAPACK is a software package provided by Univ. of Tennessee, --
159 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
162 * .. Scalar Arguments ..
163 INTEGER INFO, KL, KU, LDAB, M, N
164 REAL AMAX, COLCND, ROWCND
166 * .. Array Arguments ..
168 COMPLEX AB( LDAB, * )
171 * =====================================================================
175 PARAMETER ( ONE = 1.0E+0, ZERO = 0.0E+0 )
177 * .. Local Scalars ..
179 REAL BIGNUM, RCMAX, RCMIN, SMLNUM
182 * .. External Functions ..
186 * .. External Subroutines ..
189 * .. Intrinsic Functions ..
190 INTRINSIC ABS, AIMAG, MAX, MIN, REAL
192 * .. Statement Functions ..
195 * .. Statement Function definitions ..
196 CABS1( ZDUM ) = ABS( REAL( ZDUM ) ) + ABS( AIMAG( ZDUM ) )
198 * .. Executable Statements ..
200 * Test the input parameters
205 ELSE IF( N.LT.0 ) THEN
207 ELSE IF( KL.LT.0 ) THEN
209 ELSE IF( KU.LT.0 ) THEN
211 ELSE IF( LDAB.LT.KL+KU+1 ) THEN
215 CALL XERBLA( 'CGBEQU', -INFO )
219 * Quick return if possible
221 IF( M.EQ.0 .OR. N.EQ.0 ) THEN
228 * Get machine constants.
230 SMLNUM = SLAMCH( 'S' )
231 BIGNUM = ONE / SMLNUM
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 ), CABS1( AB( KD+I-J, J ) ) )
248 * Find the maximum and minimum scale factors.
253 RCMAX = MAX( RCMAX, R( I ) )
254 RCMIN = MIN( RCMIN, R( I ) )
258 IF( RCMIN.EQ.ZERO ) THEN
260 * Find the first zero scale factor and return an error code.
263 IF( R( I ).EQ.ZERO ) THEN
270 * Invert the scale factors.
273 R( I ) = ONE / MIN( MAX( R( I ), SMLNUM ), BIGNUM )
276 * Compute ROWCND = min(R(I)) / max(R(I))
278 ROWCND = MAX( RCMIN, SMLNUM ) / MIN( RCMAX, BIGNUM )
281 * Compute column scale factors
287 * Find the maximum element in each column,
288 * assuming the row scaling computed above.
292 DO 80 I = MAX( J-KU, 1 ), MIN( J+KL, M )
293 C( J ) = MAX( C( J ), CABS1( AB( KD+I-J, J ) )*R( I ) )
297 * Find the maximum and minimum scale factors.
302 RCMIN = MIN( RCMIN, C( J ) )
303 RCMAX = MAX( RCMAX, C( J ) )
306 IF( RCMIN.EQ.ZERO ) THEN
308 * Find the first zero scale factor and return an error code.
311 IF( C( J ).EQ.ZERO ) THEN
318 * Invert the scale factors.
321 C( J ) = ONE / MIN( MAX( C( J ), SMLNUM ), BIGNUM )
324 * Compute COLCND = min(C(J)) / max(C(J))
326 COLCND = MAX( RCMIN, SMLNUM ) / MIN( RCMAX, BIGNUM )