3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
9 *> Download DSYEQUB + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dsyequb.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dsyequb.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dsyequb.f">
21 * SUBROUTINE DSYEQUB( 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 * DOUBLE PRECISION A( LDA, * ), S( * ), WORK( * )
38 *> DSYEQUB computes row and column scalings intended to equilibrate a
39 *> symmetric matrix A and reduce its condition number
40 *> (with respect to the two-norm). S contains the scale factors,
41 *> S(i) = 1/sqrt(A(i,i)), chosen so that the scaled matrix B with
42 *> elements B(i,j) = S(i)*A(i,j)*S(j) has ones on the diagonal. This
43 *> choice of S puts the condition number of B within a factor N of the
44 *> smallest possible condition number over all possible diagonal
53 *> UPLO is CHARACTER*1
54 *> Specifies whether the details of the factorization are stored
55 *> as an upper or lower triangular matrix.
56 *> = 'U': Upper triangular, form is A = U*D*U**T;
57 *> = 'L': Lower triangular, form is A = L*D*L**T.
63 *> The order of the matrix A. N >= 0.
68 *> A is DOUBLE PRECISION array, dimension (LDA,N)
69 *> The N-by-N symmetric matrix whose scaling
70 *> factors are to be computed. Only the diagonal elements of A
77 *> The leading dimension of the array A. LDA >= max(1,N).
82 *> S is DOUBLE PRECISION array, dimension (N)
83 *> If INFO = 0, S contains the scale factors for A.
88 *> SCOND is DOUBLE PRECISION
89 *> If INFO = 0, S contains the ratio of the smallest S(i) to
90 *> the largest S(i). If SCOND >= 0.1 and AMAX is neither too
91 *> large nor too small, it is not worth scaling by S.
96 *> AMAX is DOUBLE PRECISION
97 *> Absolute value of largest matrix element. If AMAX is very
98 *> close to overflow or very close to underflow, the matrix
104 *> WORK is DOUBLE PRECISION array, dimension (3*N)
110 *> = 0: successful exit
111 *> < 0: if INFO = -i, the i-th argument had an illegal value
112 *> > 0: if INFO = i, the i-th diagonal element is nonpositive.
118 *> \author Univ. of Tennessee
119 *> \author Univ. of California Berkeley
120 *> \author Univ. of Colorado Denver
123 *> \date November 2011
125 *> \ingroup doubleSYcomputational
130 *> Livne, O.E. and Golub, G.H., "Scaling by Binormalization", \n
131 *> Numerical Algorithms, vol. 35, no. 1, pp. 97-120, January 2004. \n
132 *> DOI 10.1023/B:NUMA.0000016606.32820.69 \n
133 *> Tech report version: http://ruready.utah.edu/archive/papers/bin.pdf
135 * =====================================================================
136 SUBROUTINE DSYEQUB( UPLO, N, A, LDA, S, SCOND, AMAX, WORK, INFO )
138 * -- LAPACK computational routine (version 3.4.0) --
139 * -- LAPACK is a software package provided by Univ. of Tennessee, --
140 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
143 * .. Scalar Arguments ..
145 DOUBLE PRECISION AMAX, SCOND
148 * .. Array Arguments ..
149 DOUBLE PRECISION A( LDA, * ), S( * ), WORK( * )
152 * =====================================================================
155 DOUBLE PRECISION ONE, ZERO
156 PARAMETER ( ONE = 1.0D+0, ZERO = 0.0D+0 )
158 PARAMETER ( MAX_ITER = 100 )
160 * .. Local Scalars ..
162 DOUBLE PRECISION AVG, STD, TOL, C0, C1, C2, T, U, SI, D, BASE,
163 $ SMIN, SMAX, SMLNUM, BIGNUM, SCALE, SUMSQ
166 * .. External Functions ..
167 DOUBLE PRECISION DLAMCH
169 EXTERNAL DLAMCH, LSAME
171 * .. External Subroutines ..
174 * .. Intrinsic Functions ..
175 INTRINSIC ABS, INT, LOG, MAX, MIN, SQRT
177 * .. Executable Statements ..
179 * Test input parameters.
182 IF ( .NOT. ( LSAME( UPLO, 'U' ) .OR. LSAME( UPLO, 'L' ) ) ) THEN
184 ELSE IF ( N .LT. 0 ) THEN
186 ELSE IF ( LDA .LT. MAX( 1, N ) ) THEN
189 IF ( INFO .NE. 0 ) THEN
190 CALL XERBLA( 'DSYEQUB', -INFO )
194 UP = LSAME( UPLO, 'U' )
197 * Quick return if possible.
212 S( I ) = MAX( S( I ), ABS( A( I, J ) ) )
213 S( J ) = MAX( S( J ), ABS( A( I, J ) ) )
214 AMAX = MAX( AMAX, ABS( A(I, J) ) )
216 S( J ) = MAX( S( J ), ABS( A( J, J ) ) )
217 AMAX = MAX( AMAX, ABS( A( J, J ) ) )
221 S( J ) = MAX( S( J ), ABS( A( J, J ) ) )
222 AMAX = MAX( AMAX, ABS( A( J, J ) ) )
224 S( I ) = MAX( S( I ), ABS( A( I, J ) ) )
225 S( J ) = MAX( S( J ), ABS( A( I, J ) ) )
226 AMAX = MAX( AMAX, ABS( A( I, J ) ) )
231 S( J ) = 1.0D+0 / S( J )
234 TOL = ONE / SQRT(2.0D0 * N)
236 DO ITER = 1, MAX_ITER
247 WORK( I ) = WORK( I ) + ABS( A( I, J ) ) * S( J )
248 WORK( J ) = WORK( J ) + ABS( A( I, J ) ) * S( I )
250 WORK( J ) = WORK( J ) + ABS( A( J, J ) ) * S( J )
254 WORK( J ) = WORK( J ) + ABS( A( J, J ) ) * S( J )
257 WORK( I ) = WORK( I ) + ABS( A( I, J ) ) * S( J )
258 WORK( J ) = WORK( J ) + ABS( A( I, J ) ) * S( I )
266 AVG = AVG + S( I )*WORK( I )
272 WORK( I ) = S( I-2*N ) * WORK( I-2*N ) - AVG
274 CALL DLASSQ( N, WORK( 2*N+1 ), 1, SCALE, SUMSQ )
275 STD = SCALE * SQRT( SUMSQ / N )
277 IF ( STD .LT. TOL * AVG ) GOTO 999
283 C1 = ( N-2 ) * ( WORK( I ) - T*SI )
284 C0 = -(T*SI)*SI + 2*WORK( I )*SI - N*AVG
291 SI = -2*C0 / ( C1 + SQRT( D ) )
299 WORK( J ) = WORK( J ) + D*T
304 WORK( J ) = WORK( J ) + D*T
310 WORK( J ) = WORK( J ) + D*T
315 WORK( J ) = WORK( J ) + D*T
319 AVG = AVG + ( U + WORK( I ) ) * D / N
328 SMLNUM = DLAMCH( 'SAFEMIN' )
329 BIGNUM = ONE / SMLNUM
334 U = ONE / LOG( BASE )
336 S( I ) = BASE ** INT( U * LOG( S( I ) * T ) )
337 SMIN = MIN( SMIN, S( I ) )
338 SMAX = MAX( SMAX, S( I ) )
340 SCOND = MAX( SMIN, SMLNUM ) / MIN( SMAX, BIGNUM )