3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
9 *> Download SSYEQUB + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/ssyequb.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/ssyequb.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/ssyequb.f">
21 * SUBROUTINE SSYEQUB( UPLO, N, A, LDA, S, SCOND, AMAX, WORK, INFO )
23 * .. Scalar Arguments ..
24 * INTEGER INFO, LDA, N
28 * .. Array Arguments ..
29 * REAL A( LDA, * ), S( * ), WORK( * )
38 *> SSYEQUB computes row and column scalings intended to equilibrate a
39 *> symmetric matrix A (with respect to the Euclidean norm) and reduce
40 *> its condition number. The scale factors S are computed by the BIN
41 *> algorithm (see references) so that the scaled matrix B with elements
42 *> B(i,j) = S(i)*A(i,j)*S(j) has a condition number within a factor N of
43 *> the smallest possible condition number over all possible diagonal
52 *> UPLO is CHARACTER*1
53 *> = 'U': Upper triangle of A is stored;
54 *> = 'L': Lower triangle of A is stored.
60 *> The order of the matrix A. N >= 0.
65 *> A is REAL array, dimension (LDA,N)
66 *> The N-by-N symmetric matrix whose scaling factors are to be
73 *> The leading dimension of the array A. LDA >= max(1,N).
78 *> S is REAL array, dimension (N)
79 *> If INFO = 0, S contains the scale factors for A.
85 *> If INFO = 0, S contains the ratio of the smallest S(i) to
86 *> the largest S(i). If SCOND >= 0.1 and AMAX is neither too
87 *> large nor too small, it is not worth scaling by S.
93 *> Largest absolute value of any matrix element. If AMAX is
94 *> very close to overflow or very close to underflow, the
95 *> matrix should be scaled.
100 *> WORK is REAL array, dimension (2*N)
106 *> = 0: successful exit
107 *> < 0: if INFO = -i, the i-th argument had an illegal value
108 *> > 0: if INFO = i, the i-th diagonal element is nonpositive.
114 *> \author Univ. of Tennessee
115 *> \author Univ. of California Berkeley
116 *> \author Univ. of Colorado Denver
119 *> \date November 2011
121 *> \ingroup realSYcomputational
126 *> Livne, O.E. and Golub, G.H., "Scaling by Binormalization", \n
127 *> Numerical Algorithms, vol. 35, no. 1, pp. 97-120, January 2004. \n
128 *> DOI 10.1023/B:NUMA.0000016606.32820.69 \n
129 *> Tech report version: http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.3.1679
131 * =====================================================================
132 SUBROUTINE SSYEQUB( UPLO, N, A, LDA, S, SCOND, AMAX, WORK, INFO )
134 * -- LAPACK computational routine (version 3.4.0) --
135 * -- LAPACK is a software package provided by Univ. of Tennessee, --
136 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
139 * .. Scalar Arguments ..
144 * .. Array Arguments ..
145 REAL A( LDA, * ), S( * ), WORK( * )
148 * =====================================================================
152 PARAMETER ( ONE = 1.0E0, ZERO = 0.0E0 )
154 PARAMETER ( MAX_ITER = 100 )
156 * .. Local Scalars ..
158 REAL AVG, STD, TOL, C0, C1, C2, T, U, SI, D, BASE,
159 $ SMIN, SMAX, SMLNUM, BIGNUM, SCALE, SUMSQ
162 * .. External Functions ..
165 EXTERNAL LSAME, SLAMCH
167 * .. External Subroutines ..
170 * .. Intrinsic Functions ..
171 INTRINSIC ABS, INT, LOG, MAX, MIN, SQRT
173 * .. Executable Statements ..
175 * Test the input parameters.
178 IF ( .NOT. ( LSAME( UPLO, 'U' ) .OR. LSAME( UPLO, 'L' ) ) ) THEN
180 ELSE IF ( N .LT. 0 ) THEN
182 ELSE IF ( LDA .LT. MAX( 1, N ) ) THEN
185 IF ( INFO .NE. 0 ) THEN
186 CALL XERBLA( 'SSYEQUB', -INFO )
190 UP = LSAME( UPLO, 'U' )
193 * Quick return if possible.
208 S( I ) = MAX( S( I ), ABS( A( I, J ) ) )
209 S( J ) = MAX( S( J ), ABS( A( I, J ) ) )
210 AMAX = MAX( AMAX, ABS( A( I, J ) ) )
212 S( J ) = MAX( S( J ), ABS( A( J, J ) ) )
213 AMAX = MAX( AMAX, ABS( A( J, J ) ) )
217 S( J ) = MAX( S( J ), ABS( A( J, J ) ) )
218 AMAX = MAX( AMAX, ABS( A( J, J ) ) )
220 S( I ) = MAX( S( I ), ABS( A( I, J ) ) )
221 S( J ) = MAX( S( J ), ABS( A( I, J ) ) )
222 AMAX = MAX( AMAX, ABS( A( I, J ) ) )
227 S( J ) = 1.0E0 / S( J )
230 TOL = ONE / SQRT( 2.0E0 * N )
232 DO ITER = 1, MAX_ITER
242 WORK( I ) = WORK( I ) + ABS( A( I, J ) ) * S( J )
243 WORK( J ) = WORK( J ) + ABS( A( I, J ) ) * S( I )
245 WORK( J ) = WORK( J ) + ABS( A( J, J ) ) * S( J )
249 WORK( J ) = WORK( J ) + ABS( A( J, J ) ) * S( J )
251 WORK( I ) = WORK( I ) + ABS( A( I, J ) ) * S( J )
252 WORK( J ) = WORK( J ) + ABS( A( I, J ) ) * S( I )
260 AVG = AVG + S( I )*WORK( I )
266 WORK( I ) = S( I-N ) * WORK( I-N ) - AVG
268 CALL SLASSQ( N, WORK( N+1 ), 1, SCALE, SUMSQ )
269 STD = SCALE * SQRT( SUMSQ / N )
271 IF ( STD .LT. TOL * AVG ) GOTO 999
277 C1 = ( N-2 ) * ( WORK( I ) - T*SI )
278 C0 = -(T*SI)*SI + 2*WORK( I )*SI - N*AVG
285 SI = -2*C0 / ( C1 + SQRT( D ) )
293 WORK( J ) = WORK( J ) + D*T
298 WORK( J ) = WORK( J ) + D*T
304 WORK( J ) = WORK( J ) + D*T
309 WORK( J ) = WORK( J ) + D*T
313 AVG = AVG + ( U + WORK( I ) ) * D / N
320 SMLNUM = SLAMCH( 'SAFEMIN' )
321 BIGNUM = ONE / SMLNUM
324 T = ONE / SQRT( AVG )
326 U = ONE / LOG( BASE )
328 S( I ) = BASE ** INT( U * LOG( S( I ) * T ) )
329 SMIN = MIN( SMIN, S( I ) )
330 SMAX = MAX( SMAX, S( I ) )
332 SCOND = MAX( SMIN, SMLNUM ) / MIN( SMAX, BIGNUM )