202 SUBROUTINE zstedc( COMPZ, N, D, E, Z, LDZ, WORK, LWORK, RWORK,
203 $ LRWORK, IWORK, LIWORK, INFO )
211 INTEGER INFO, LDZ, LIWORK, LRWORK, LWORK, N
215 DOUBLE PRECISION D( * ), E( * ), RWORK( * )
216 COMPLEX*16 WORK( * ), Z( LDZ, * )
222 DOUBLE PRECISION ZERO, ONE, TWO
223 parameter( zero = 0.0d0, one = 1.0d0, two = 2.0d0 )
227 INTEGER FINISH, I, ICOMPZ, II, J, K, LGN, LIWMIN, LL,
228 $ lrwmin, lwmin, m, smlsiz, start
229 DOUBLE PRECISION EPS, ORGNRM, P, TINY
234 DOUBLE PRECISION DLAMCH, DLANST
235 EXTERNAL lsame, ilaenv, dlamch, dlanst
243 INTRINSIC abs, dble, int, log, max, mod, sqrt
250 lquery = ( lwork.EQ.-1 .OR. lrwork.EQ.-1 .OR. liwork.EQ.-1 )
252 IF( lsame( compz,
'N' ) )
THEN
254 ELSE IF( lsame( compz,
'V' ) )
THEN
256 ELSE IF( lsame( compz,
'I' ) )
THEN
261 IF( icompz.LT.0 )
THEN
263 ELSE IF( n.LT.0 )
THEN
265 ELSE IF( ( ldz.LT.1 ) .OR.
266 $ ( icompz.GT.0 .AND. ldz.LT.max( 1, n ) ) )
THEN
274 smlsiz = ilaenv( 9,
'ZSTEDC',
' ', 0, 0, 0, 0 )
275 IF( n.LE.1 .OR. icompz.EQ.0 )
THEN
279 ELSE IF( n.LE.smlsiz )
THEN
283 ELSE IF( icompz.EQ.1 )
THEN
284 lgn = int( log( dble( n ) ) / log( two ) )
290 lrwmin = 1 + 3*n + 2*n*lgn + 4*n**2
291 liwmin = 6 + 6*n + 5*n*lgn
292 ELSE IF( icompz.EQ.2 )
THEN
294 lrwmin = 1 + 4*n + 2*n**2
298 rwork( 1 ) = real( lrwmin )
301 IF( lwork.LT.lwmin .AND. .NOT.lquery )
THEN
303 ELSE IF( lrwork.LT.lrwmin .AND. .NOT.lquery )
THEN
305 ELSE IF( liwork.LT.liwmin .AND. .NOT.lquery )
THEN
311 CALL xerbla(
'ZSTEDC', -info )
313 ELSE IF( lquery )
THEN
338 IF( icompz.EQ.0 )
THEN
339 CALL dsterf( n, d, e, info )
346 IF( n.LE.smlsiz )
THEN
348 CALL zsteqr( compz, n, d, e, z, ldz, rwork, info )
354 IF( icompz.EQ.2 )
THEN
355 CALL dlaset(
'Full', n, n, zero, one, rwork, n )
357 CALL dstedc(
'I', n, d, e, rwork, n,
358 $ rwork( ll ), lrwork-ll+1, iwork, liwork, info )
361 z( i, j ) = rwork( ( j-1 )*n+i )
372 orgnrm = dlanst(
'M', n, d, e )
376 eps = dlamch(
'Epsilon' )
383 IF( start.LE.n )
THEN
393 IF( finish.LT.n )
THEN
394 tiny = eps*sqrt( abs( d( finish ) ) )*
395 $ sqrt( abs( d( finish+1 ) ) )
396 IF( abs( e( finish ) ).GT.tiny )
THEN
404 m = finish - start + 1
405 IF( m.GT.smlsiz )
THEN
409 orgnrm = dlanst(
'M', m, d( start ), e( start ) )
410 CALL dlascl(
'G', 0, 0, orgnrm, one, m, 1, d( start ),
413 CALL dlascl(
'G', 0, 0, orgnrm, one, m-1, 1,
417 CALL zlaed0( n, m, d( start ), e( start ), z( 1,
419 $ ldz, work, n, rwork, iwork, info )
421 info = ( info / ( m+1 )+start-1 )*( n+1 ) +
422 $ mod( info, ( m+1 ) ) + start - 1
428 CALL dlascl(
'G', 0, 0, one, orgnrm, m, 1, d( start ),
433 CALL dsteqr(
'I', m, d( start ), e( start ), rwork, m,
434 $ rwork( m*m+1 ), info )
435 CALL zlacrm( n, m, z( 1, start ), ldz, rwork, m, work,
438 CALL zlacpy(
'A', n, m, work, n, z( 1, start ), ldz )
440 info = start*( n+1 ) + finish
459 IF( d( j ).LT.p )
THEN
467 CALL zswap( n, z( 1, i ), 1, z( 1, k ), 1 )
474 rwork( 1 ) = real( lrwmin )