129 SUBROUTINE csyequb( UPLO, N, A, LDA, S, SCOND, AMAX, WORK,
142 COMPLEX A( LDA, * ), WORK( * )
150 parameter( one = 1.0e0, zero = 0.0e0 )
152 parameter( max_iter = 100 )
156 REAL AVG, STD, TOL, C0, C1, C2, T, U, SI, D, BASE,
157 $ smin, smax, smlnum, bignum, scale, sumsq
164 EXTERNAL lsame, slamch
170 INTRINSIC abs, aimag, int, log, max, min, real, sqrt
176 cabs1( zdum ) = abs( real( zdum ) ) + abs( aimag( zdum ) )
183 IF ( .NOT. ( lsame( uplo,
'U' ) .OR.
184 $ lsame( uplo,
'L' ) ) )
THEN
186 ELSE IF ( n .LT. 0 )
THEN
188 ELSE IF ( lda .LT. max( 1, n ) )
THEN
191 IF ( info .NE. 0 )
THEN
192 CALL xerbla(
'CSYEQUB', -info )
196 up = lsame( uplo,
'U' )
214 s( i ) = max( s( i ), cabs1( a( i, j ) ) )
215 s( j ) = max( s( j ), cabs1( a( i, j ) ) )
216 amax = max( amax, cabs1( a( i, j ) ) )
218 s( j ) = max( s( j ), cabs1( a( j, j ) ) )
219 amax = max( amax, cabs1( a( j, j ) ) )
223 s( j ) = max( s( j ), cabs1( a( j, j ) ) )
224 amax = max( amax, cabs1( a( j, j ) ) )
226 s( i ) = max( s( i ), cabs1( a( i, j ) ) )
227 s( j ) = max( s( j ), cabs1( a( i, j ) ) )
228 amax = max( amax, cabs1( a( i, j ) ) )
233 s( j ) = 1.0 / s( j )
236 tol = one / sqrt( 2.0e0 * real( n ) )
238 DO iter = 1, max_iter
248 work( i ) = work( i ) + cabs1( a( i, j ) ) * s( j )
249 work( j ) = work( j ) + cabs1( a( i, j ) ) * s( i )
251 work( j ) = work( j ) + cabs1( a( j, j ) ) * s( j )
255 work( j ) = work( j ) + cabs1( a( j, j ) ) * s( j )
257 work( i ) = work( i ) + cabs1( a( i, j ) ) * s( j )
258 work( j ) = work( j ) + cabs1( a( i, j ) ) * s( i )
266 avg = avg + real( s( i )*work( i ) )
268 avg = avg / real( n )
272 work( i ) = s( i-n ) * work( i-n ) - avg
274 CALL classq( n, work( n+1 ), 1, scale, sumsq )
275 std = scale * sqrt( sumsq / real( n ) )
277 IF ( std .LT. tol * avg )
GOTO 999
280 t = cabs1( a( i, i ) )
283 c1 = real( n-2 ) * ( real( work( i ) ) - t*si )
284 c0 = -(t*si)*si + 2 * real( work( i ) ) * si - real( n )*avg
291 si = -2*c0 / ( c1 + sqrt( d ) )
297 t = cabs1( a( j, i ) )
299 work( j ) = work( j ) + d*t
302 t = cabs1( a( i, j ) )
304 work( j ) = work( j ) + d*t
308 t = cabs1( a( i, j ) )
310 work( j ) = work( j ) + d*t
313 t = cabs1( a( j, i ) )
315 work( j ) = work( j ) + d*t
319 avg = avg + ( u + real( work( i ) ) ) * d / real( n )
326 smlnum = slamch(
'SAFEMIN' )
327 bignum = one / smlnum
330 t = one / sqrt( avg )
332 u = one / log( base )
334 s( i ) = base ** int( u * log( s( i ) * t ) )
335 smin = min( smin, s( i ) )
336 smax = max( smax, s( i ) )
338 scond = max( smin, smlnum ) / min( smax, bignum )