3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
9 *> Download ZHEEQUB + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zheequb.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zheequb.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zheequb.f">
21 * SUBROUTINE ZHEEQUB( UPLO, N, A, LDA, S, SCOND, AMAX, WORK, INFO )
23 * .. Scalar Arguments ..
24 * INTEGER INFO, LDA, N
25 * DOUBLE PRECISION AMAX, SCOND
28 * .. Array Arguments ..
29 * COMPLEX*16 A( LDA, * ), WORK( * )
30 * DOUBLE PRECISION S( * )
39 *> ZHEEQUB computes row and column scalings intended to equilibrate a
40 *> Hermitian matrix A and reduce its condition number
41 *> (with respect to the two-norm). S contains the scale factors,
42 *> S(i) = 1/sqrt(A(i,i)), chosen so that the scaled matrix B with
43 *> elements B(i,j) = S(i)*A(i,j)*S(j) has ones on the diagonal. This
44 *> choice of S puts the condition number of B within a factor N of the
45 *> smallest possible condition number over all possible diagonal
54 *> UPLO is CHARACTER*1
55 *> = 'U': Upper triangles of A and B are stored;
56 *> = 'L': Lower triangles of A and B are stored.
62 *> The order of the matrix A. N >= 0.
67 *> A is COMPLEX*16 array, dimension (LDA,N)
68 *> The N-by-N Hermitian matrix whose scaling
69 *> factors are to be computed. Only the diagonal elements of A
76 *> The leading dimension of the array A. LDA >= max(1,N).
81 *> S is DOUBLE PRECISION array, dimension (N)
82 *> If INFO = 0, S contains the scale factors for A.
87 *> SCOND is DOUBLE PRECISION
88 *> If INFO = 0, S contains the ratio of the smallest S(i) to
89 *> the largest S(i). If SCOND >= 0.1 and AMAX is neither too
90 *> large nor too small, it is not worth scaling by S.
95 *> AMAX is DOUBLE PRECISION
96 *> Absolute value of largest matrix element. If AMAX is very
97 *> close to overflow or very close to underflow, the matrix
103 *> WORK is COMPLEX*16 array, dimension (3*N)
109 *> = 0: successful exit
110 *> < 0: if INFO = -i, the i-th argument had an illegal value
111 *> > 0: if INFO = i, the i-th diagonal element is nonpositive.
117 *> \author Univ. of Tennessee
118 *> \author Univ. of California Berkeley
119 *> \author Univ. of Colorado Denver
124 *> \ingroup complex16HEcomputational
126 * =====================================================================
127 SUBROUTINE ZHEEQUB( UPLO, N, A, LDA, S, SCOND, AMAX, WORK, INFO )
129 * -- LAPACK computational routine (version 3.4.1) --
130 * -- LAPACK is a software package provided by Univ. of Tennessee, --
131 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
134 * .. Scalar Arguments ..
136 DOUBLE PRECISION AMAX, SCOND
139 * .. Array Arguments ..
140 COMPLEX*16 A( LDA, * ), WORK( * )
141 DOUBLE PRECISION S( * )
144 * =====================================================================
147 DOUBLE PRECISION ONE, ZERO
148 PARAMETER ( ONE = 1.0D+0, ZERO = 0.0D+0 )
150 PARAMETER ( MAX_ITER = 100 )
152 * .. Local Scalars ..
154 DOUBLE PRECISION AVG, STD, TOL, C0, C1, C2, T, U, SI, D,
155 $ BASE, SMIN, SMAX, SMLNUM, BIGNUM, SCALE, SUMSQ
159 * .. External Functions ..
160 DOUBLE PRECISION DLAMCH
162 EXTERNAL DLAMCH, LSAME
164 * .. External Subroutines ..
167 * .. Intrinsic Functions ..
168 INTRINSIC ABS, DBLE, DIMAG, INT, LOG, MAX, MIN, SQRT
170 * .. Statement Functions ..
171 DOUBLE PRECISION CABS1
173 * .. Statement Function Definitions ..
174 CABS1( ZDUM ) = ABS( DBLE( ZDUM ) ) + ABS( DIMAG( ZDUM ) )
176 * Test input parameters.
179 IF (.NOT. ( LSAME( UPLO, 'U' ) .OR. LSAME( UPLO, 'L' ) ) ) THEN
181 ELSE IF ( N .LT. 0 ) THEN
183 ELSE IF ( LDA .LT. MAX( 1, N ) ) THEN
186 IF ( INFO .NE. 0 ) THEN
187 CALL XERBLA( 'ZHEEQUB', -INFO )
191 UP = LSAME( UPLO, 'U' )
194 * Quick return if possible.
209 S( I ) = MAX( S( I ), CABS1( A( I, J ) ) )
210 S( J ) = MAX( S( J ), CABS1( A( I, J ) ) )
211 AMAX = MAX( AMAX, CABS1( A( I, J ) ) )
213 S( J ) = MAX( S( J ), CABS1( A( J, J ) ) )
214 AMAX = MAX( AMAX, CABS1( A( J, J ) ) )
218 S( J ) = MAX( S( J ), CABS1( A( J, J ) ) )
219 AMAX = MAX( AMAX, CABS1( A( J, J ) ) )
221 S( I ) = MAX( S( I ), CABS1( A( I, J ) ) )
222 S( J ) = MAX( S( J ), CABS1( A( I, J ) ) )
223 AMAX = MAX( AMAX, CABS1( A(I, J ) ) )
228 S( J ) = 1.0D+0 / S( J )
231 TOL = ONE / SQRT( 2.0D0 * N )
233 DO ITER = 1, MAX_ITER
243 T = CABS1( A( I, J ) )
244 WORK( I ) = WORK( I ) + CABS1( A( I, J ) ) * S( J )
245 WORK( J ) = WORK( J ) + CABS1( A( I, J ) ) * S( I )
247 WORK( J ) = WORK( J ) + CABS1( A( J, J ) ) * S( J )
251 WORK( J ) = WORK( J ) + CABS1( A( J, J ) ) * S( J )
253 T = CABS1( A( I, J ) )
254 WORK( I ) = WORK( I ) + CABS1( A( I, J ) ) * S( J )
255 WORK( J ) = WORK( J ) + CABS1( A( I, J ) ) * S( I )
263 AVG = AVG + S( I )*WORK( I )
269 WORK( I ) = S( I-2*N ) * WORK( I-2*N ) - AVG
271 CALL ZLASSQ( N, WORK( 2*N+1 ), 1, SCALE, SUMSQ )
272 STD = SCALE * SQRT( SUMSQ / N )
274 IF ( STD .LT. TOL * AVG ) GOTO 999
277 T = CABS1( A( I, I ) )
280 C1 = ( N-2 ) * ( WORK( I ) - T*SI )
281 C0 = -(T*SI)*SI + 2*WORK( I )*SI - N*AVG
288 SI = -2*C0 / ( C1 + SQRT( D ) )
294 T = CABS1( A( J, I ) )
296 WORK( J ) = WORK( J ) + D*T
299 T = CABS1( A( I, J ) )
301 WORK( J ) = WORK( J ) + D*T
305 T = CABS1( A( I, J ) )
307 WORK( J ) = WORK( J ) + D*T
310 T = CABS1( A( J, I ) )
312 WORK( J ) = WORK( J ) + D*T
315 AVG = AVG + ( U + WORK( I ) ) * D / N
323 SMLNUM = DLAMCH( 'SAFEMIN' )
324 BIGNUM = ONE / SMLNUM
327 T = ONE / SQRT( AVG )
329 U = ONE / LOG( BASE )
331 S( I ) = BASE ** INT( U * LOG( S( I ) * T ) )
332 SMIN = MIN( SMIN, S( I ) )
333 SMAX = MAX( SMAX, S( I ) )
335 SCOND = MAX( SMIN, SMLNUM ) / MIN( SMAX, BIGNUM )