3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
9 *> Download ZGEEQUB + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zgeequb.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zgeequb.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zgeequb.f">
21 * SUBROUTINE ZGEEQUB( M, N, A, LDA, R, C, ROWCND, COLCND, AMAX,
24 * .. Scalar Arguments ..
25 * INTEGER INFO, LDA, M, N
26 * DOUBLE PRECISION AMAX, COLCND, ROWCND
28 * .. Array Arguments ..
29 * DOUBLE PRECISION C( * ), R( * )
30 * COMPLEX*16 A( LDA, * )
39 *> ZGEEQUB computes row and column scalings intended to equilibrate an
40 *> M-by-N matrix A and reduce its condition number. R returns the row
41 *> scale factors and C the column scale factors, chosen to try to make
42 *> 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 an absolute value of at most
46 *> R(i) and C(j) are restricted to be a power of the radix between
47 *> SMLNUM = smallest safe number and BIGNUM = largest safe number. Use
48 *> of these scaling factors is not guaranteed to reduce the condition
49 *> number of A but works well in practice.
51 *> This routine differs from ZGEEQU by restricting the scaling factors
52 *> to a power of the radix. Baring over- and underflow, scaling by
53 *> these factors introduces no additional rounding errors. However, the
54 *> scaled entries' magnitured are no longer approximately 1 but lie
55 *> between sqrt(radix) and 1/sqrt(radix).
64 *> The number of rows of the matrix A. M >= 0.
70 *> The number of columns of the matrix A. N >= 0.
75 *> A is COMPLEX*16 array, dimension (LDA,N)
76 *> The M-by-N matrix whose equilibration factors are
83 *> The leading dimension of the array A. LDA >= max(1,M).
88 *> R is DOUBLE PRECISION array, dimension (M)
89 *> If INFO = 0 or INFO > M, R contains the row scale factors
95 *> C is DOUBLE PRECISION array, dimension (N)
96 *> If INFO = 0, C contains the column scale factors for A.
101 *> ROWCND is DOUBLE PRECISION
102 *> If INFO = 0 or INFO > M, ROWCND contains the ratio of the
103 *> smallest R(i) to the largest R(i). If ROWCND >= 0.1 and
104 *> AMAX is neither too large nor too small, it is not worth
108 *> \param[out] COLCND
110 *> COLCND is DOUBLE PRECISION
111 *> If INFO = 0, COLCND contains the ratio of the smallest
112 *> C(i) to the largest C(i). If COLCND >= 0.1, it is not
113 *> worth scaling by C.
118 *> AMAX is DOUBLE PRECISION
119 *> Absolute value of largest matrix element. If AMAX is very
120 *> close to overflow or very close to underflow, the matrix
127 *> = 0: successful exit
128 *> < 0: if INFO = -i, the i-th argument had an illegal value
129 *> > 0: if INFO = i, and i is
130 *> <= M: the i-th row of A is exactly zero
131 *> > M: the (i-M)-th column of A is exactly zero
137 *> \author Univ. of Tennessee
138 *> \author Univ. of California Berkeley
139 *> \author Univ. of Colorado Denver
142 *> \date November 2011
144 *> \ingroup complex16GEcomputational
146 * =====================================================================
147 SUBROUTINE ZGEEQUB( M, N, A, LDA, R, C, ROWCND, COLCND, AMAX,
150 * -- LAPACK computational routine (version 3.4.0) --
151 * -- LAPACK is a software package provided by Univ. of Tennessee, --
152 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
155 * .. Scalar Arguments ..
156 INTEGER INFO, LDA, M, N
157 DOUBLE PRECISION AMAX, COLCND, ROWCND
159 * .. Array Arguments ..
160 DOUBLE PRECISION C( * ), R( * )
161 COMPLEX*16 A( LDA, * )
164 * =====================================================================
167 DOUBLE PRECISION ONE, ZERO
168 PARAMETER ( ONE = 1.0D+0, ZERO = 0.0D+0 )
170 * .. Local Scalars ..
172 DOUBLE PRECISION BIGNUM, RCMAX, RCMIN, SMLNUM, RADIX, LOGRDX
175 * .. External Functions ..
176 DOUBLE PRECISION DLAMCH
179 * .. External Subroutines ..
182 * .. Intrinsic Functions ..
183 INTRINSIC ABS, MAX, MIN, LOG, DBLE, DIMAG
185 * .. Statement Functions ..
186 DOUBLE PRECISION CABS1
188 * .. Statement Function definitions ..
189 CABS1( ZDUM ) = ABS( DBLE( ZDUM ) ) + ABS( DIMAG( ZDUM ) )
191 * .. Executable Statements ..
193 * Test the input parameters.
198 ELSE IF( N.LT.0 ) THEN
200 ELSE IF( LDA.LT.MAX( 1, M ) ) THEN
204 CALL XERBLA( 'ZGEEQUB', -INFO )
208 * Quick return if possible.
210 IF( M.EQ.0 .OR. N.EQ.0 ) THEN
217 * Get machine constants. Assume SMLNUM is a power of the radix.
219 SMLNUM = DLAMCH( 'S' )
220 BIGNUM = ONE / SMLNUM
221 RADIX = DLAMCH( 'B' )
222 LOGRDX = LOG( RADIX )
224 * Compute row scale factors.
230 * Find the maximum element in each row.
234 R( I ) = MAX( R( I ), CABS1( A( I, J ) ) )
238 IF( R( I ).GT.ZERO ) THEN
239 R( I ) = RADIX**INT( LOG(R( I ) ) / LOGRDX )
243 * Find the maximum and minimum scale factors.
248 RCMAX = MAX( RCMAX, R( I ) )
249 RCMIN = MIN( RCMIN, R( I ) )
253 IF( RCMIN.EQ.ZERO ) THEN
255 * Find the first zero scale factor and return an error code.
258 IF( R( I ).EQ.ZERO ) THEN
265 * Invert the scale factors.
268 R( I ) = ONE / MIN( MAX( R( I ), SMLNUM ), BIGNUM )
271 * Compute ROWCND = min(R(I)) / max(R(I)).
273 ROWCND = MAX( RCMIN, SMLNUM ) / MIN( RCMAX, BIGNUM )
276 * Compute column scale factors.
282 * Find the maximum element in each column,
283 * assuming the row scaling computed above.
287 C( J ) = MAX( C( J ), CABS1( A( I, J ) )*R( I ) )
289 IF( C( J ).GT.ZERO ) THEN
290 C( J ) = RADIX**INT( LOG( C( J ) ) / LOGRDX )
294 * Find the maximum and minimum scale factors.
299 RCMIN = MIN( RCMIN, C( J ) )
300 RCMAX = MAX( RCMAX, C( J ) )
303 IF( RCMIN.EQ.ZERO ) THEN
305 * Find the first zero scale factor and return an error code.
308 IF( C( J ).EQ.ZERO ) THEN
315 * Invert the scale factors.
318 C( J ) = ONE / MIN( MAX( C( J ), SMLNUM ), BIGNUM )
321 * Compute COLCND = min(C(J)) / max(C(J)).
323 COLCND = MAX( RCMIN, SMLNUM ) / MIN( RCMAX, BIGNUM )