3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
9 *> Download ZSYEQUB + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zsyequb.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zsyequb.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zsyequb.f">
21 * SUBROUTINE ZSYEQUB( 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 *> ZSYEQUB computes row and column scalings intended to equilibrate a
40 *> symmetric matrix A (with respect to the Euclidean norm) and reduce
41 *> its condition number. The scale factors S are computed by the BIN
42 *> algorithm (see references) so that the scaled matrix B with elements
43 *> B(i,j) = S(i)*A(i,j)*S(j) has a condition number within a factor N of
44 *> the smallest possible condition number over all possible diagonal
53 *> UPLO is CHARACTER*1
54 *> = 'U': Upper triangle of A is stored;
55 *> = 'L': Lower triangle of A is stored.
61 *> The order of the matrix A. N >= 0.
66 *> A is COMPLEX*16 array, dimension (LDA,N)
67 *> The N-by-N symmetric matrix whose scaling factors are to be
74 *> The leading dimension of the array A. LDA >= max(1,N).
79 *> S is DOUBLE PRECISION array, dimension (N)
80 *> If INFO = 0, S contains the scale factors for A.
85 *> SCOND is DOUBLE PRECISION
86 *> If INFO = 0, S contains the ratio of the smallest S(i) to
87 *> the largest S(i). If SCOND >= 0.1 and AMAX is neither too
88 *> large nor too small, it is not worth scaling by S.
93 *> AMAX is DOUBLE PRECISION
94 *> Largest absolute value of any matrix element. If AMAX is
95 *> very close to overflow or very close to underflow, the
96 *> matrix should be scaled.
101 *> WORK is COMPLEX*16 array, dimension (2*N)
107 *> = 0: successful exit
108 *> < 0: if INFO = -i, the i-th argument had an illegal value
109 *> > 0: if INFO = i, the i-th diagonal element is nonpositive.
115 *> \author Univ. of Tennessee
116 *> \author Univ. of California Berkeley
117 *> \author Univ. of Colorado Denver
120 *> \date November 2011
122 *> \ingroup complex16SYcomputational
127 *> Livne, O.E. and Golub, G.H., "Scaling by Binormalization", \n
128 *> Numerical Algorithms, vol. 35, no. 1, pp. 97-120, January 2004. \n
129 *> DOI 10.1023/B:NUMA.0000016606.32820.69 \n
130 *> Tech report version: http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.3.1679
132 * =====================================================================
133 SUBROUTINE ZSYEQUB( UPLO, N, A, LDA, S, SCOND, AMAX, WORK, INFO )
135 * -- LAPACK computational routine (version 3.4.0) --
136 * -- LAPACK is a software package provided by Univ. of Tennessee, --
137 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
140 * .. Scalar Arguments ..
142 DOUBLE PRECISION AMAX, SCOND
145 * .. Array Arguments ..
146 COMPLEX*16 A( LDA, * ), WORK( * )
147 DOUBLE PRECISION S( * )
150 * =====================================================================
153 DOUBLE PRECISION ONE, ZERO
154 PARAMETER ( ONE = 1.0D0, ZERO = 0.0D0 )
156 PARAMETER ( MAX_ITER = 100 )
158 * .. Local Scalars ..
160 DOUBLE PRECISION AVG, STD, TOL, C0, C1, C2, T, U, SI, D, BASE,
161 $ SMIN, SMAX, SMLNUM, BIGNUM, SCALE, SUMSQ
165 * .. External Functions ..
166 DOUBLE PRECISION DLAMCH
168 EXTERNAL DLAMCH, LSAME
170 * .. External Subroutines ..
173 * .. Intrinsic Functions ..
174 INTRINSIC ABS, DBLE, DIMAG, INT, LOG, MAX, MIN, SQRT
176 * .. Statement Functions ..
177 DOUBLE PRECISION CABS1
179 * .. Statement Function Definitions ..
180 CABS1( ZDUM ) = ABS( DBLE( ZDUM ) ) + ABS( DIMAG( ZDUM ) )
182 * .. Executable Statements ..
184 * Test the input parameters.
187 IF ( .NOT. ( LSAME( UPLO, 'U' ) .OR. LSAME( UPLO, 'L' ) ) ) THEN
189 ELSE IF ( N .LT. 0 ) THEN
191 ELSE IF ( LDA .LT. MAX( 1, N ) ) THEN
194 IF ( INFO .NE. 0 ) THEN
195 CALL XERBLA( 'ZSYEQUB', -INFO )
199 UP = LSAME( UPLO, 'U' )
202 * Quick return if possible.
217 S( I ) = MAX( S( I ), CABS1( A( I, J ) ) )
218 S( J ) = MAX( S( J ), CABS1( A( I, J ) ) )
219 AMAX = MAX( AMAX, CABS1( A( I, J ) ) )
221 S( J ) = MAX( S( J ), CABS1( A( J, J ) ) )
222 AMAX = MAX( AMAX, CABS1( A( J, J ) ) )
226 S( J ) = MAX( S( J ), CABS1( A( J, J ) ) )
227 AMAX = MAX( AMAX, CABS1( A( J, J ) ) )
229 S( I ) = MAX( S( I ), CABS1( A( I, J ) ) )
230 S( J ) = MAX( S( J ), CABS1( A( I, J ) ) )
231 AMAX = MAX( AMAX, CABS1( A( I, J ) ) )
236 S( J ) = 1.0D0 / S( J )
239 TOL = ONE / SQRT( 2.0D0 * N )
241 DO ITER = 1, MAX_ITER
251 WORK( I ) = WORK( I ) + CABS1( A( I, J ) ) * S( J )
252 WORK( J ) = WORK( J ) + CABS1( A( I, J ) ) * S( I )
254 WORK( J ) = WORK( J ) + CABS1( A( J, J ) ) * S( J )
258 WORK( J ) = WORK( J ) + CABS1( A( J, J ) ) * S( J )
260 WORK( I ) = WORK( I ) + CABS1( A( I, J ) ) * S( J )
261 WORK( J ) = WORK( J ) + CABS1( A( I, J ) ) * S( I )
269 AVG = AVG + S( I )*WORK( I )
275 WORK( I ) = S( I-N ) * WORK( I-N ) - AVG
277 CALL ZLASSQ( N, WORK( N+1 ), 1, SCALE, SUMSQ )
278 STD = SCALE * SQRT( SUMSQ / N )
280 IF ( STD .LT. TOL * AVG ) GOTO 999
283 T = CABS1( A( I, I ) )
286 C1 = ( N-2 ) * ( WORK( I ) - T*SI )
287 C0 = -(T*SI)*SI + 2*WORK( I )*SI - N*AVG
294 SI = -2*C0 / ( C1 + SQRT( D ) )
300 T = CABS1( A( J, I ) )
302 WORK( J ) = WORK( J ) + D*T
305 T = CABS1( A( I, J ) )
307 WORK( J ) = WORK( J ) + D*T
311 T = CABS1( A( I, J ) )
313 WORK( J ) = WORK( J ) + D*T
316 T = CABS1( A( J, I ) )
318 WORK( J ) = WORK( J ) + D*T
322 AVG = AVG + ( U + WORK( I ) ) * D / N
329 SMLNUM = DLAMCH( 'SAFEMIN' )
330 BIGNUM = ONE / SMLNUM
333 T = ONE / SQRT( AVG )
335 U = ONE / LOG( BASE )
337 S( I ) = BASE ** INT( U * LOG( S( I ) * T ) )
338 SMIN = MIN( SMIN, S( I ) )
339 SMAX = MAX( SMAX, S( I ) )
341 SCOND = MAX( SMIN, SMLNUM ) / MIN( SMAX, BIGNUM )