202 SUBROUTINE cstedc( COMPZ, N, D, E, Z, LDZ, WORK, LWORK, RWORK,
203 $ LRWORK, IWORK, LIWORK, INFO )
211 INTEGER INFO, LDZ, LIWORK, LRWORK, LWORK, N
215 REAL D( * ), E( * ), RWORK( * )
216 COMPLEX WORK( * ), Z( LDZ, * )
223 parameter( zero = 0.0e0, one = 1.0e0, two = 2.0e0 )
227 INTEGER FINISH, I, ICOMPZ, II, J, K, LGN, LIWMIN, LL,
228 $ lrwmin, lwmin, m, smlsiz, start
229 REAL EPS, ORGNRM, P, TINY
234 REAL SLAMCH, SLANST, SROUNDUP_LWORK
235 EXTERNAL ilaenv, lsame, slamch, slanst,
244 INTRINSIC abs, int, log, max, mod, real, sqrt
251 lquery = ( lwork.EQ.-1 .OR. lrwork.EQ.-1 .OR. liwork.EQ.-1 )
253 IF( lsame( compz,
'N' ) )
THEN
255 ELSE IF( lsame( compz,
'V' ) )
THEN
257 ELSE IF( lsame( compz,
'I' ) )
THEN
262 IF( icompz.LT.0 )
THEN
264 ELSE IF( n.LT.0 )
THEN
266 ELSE IF( ( ldz.LT.1 ) .OR.
267 $ ( icompz.GT.0 .AND. ldz.LT.max( 1, n ) ) )
THEN
275 smlsiz = ilaenv( 9,
'CSTEDC',
' ', 0, 0, 0, 0 )
276 IF( n.LE.1 .OR. icompz.EQ.0 )
THEN
280 ELSE IF( n.LE.smlsiz )
THEN
284 ELSE IF( icompz.EQ.1 )
THEN
285 lgn = int( log( real( n ) ) / log( two ) )
291 lrwmin = 1 + 3*n + 2*n*lgn + 4*n**2
292 liwmin = 6 + 6*n + 5*n*lgn
293 ELSE IF( icompz.EQ.2 )
THEN
295 lrwmin = 1 + 4*n + 2*n**2
298 work( 1 ) = sroundup_lwork(lwmin)
299 rwork( 1 ) = real( lrwmin )
302 IF( lwork.LT.lwmin .AND. .NOT.lquery )
THEN
304 ELSE IF( lrwork.LT.lrwmin .AND. .NOT.lquery )
THEN
306 ELSE IF( liwork.LT.liwmin .AND. .NOT.lquery )
THEN
312 CALL xerbla(
'CSTEDC', -info )
314 ELSE IF( lquery )
THEN
339 IF( icompz.EQ.0 )
THEN
340 CALL ssterf( n, d, e, info )
347 IF( n.LE.smlsiz )
THEN
349 CALL csteqr( compz, n, d, e, z, ldz, rwork, info )
355 IF( icompz.EQ.2 )
THEN
356 CALL slaset(
'Full', n, n, zero, one, rwork, n )
358 CALL sstedc(
'I', n, d, e, rwork, n,
359 $ rwork( ll ), lrwork-ll+1, iwork, liwork, info )
362 z( i, j ) = rwork( ( j-1 )*n+i )
373 orgnrm = slanst(
'M', n, d, e )
377 eps = slamch(
'Epsilon' )
384 IF( start.LE.n )
THEN
394 IF( finish.LT.n )
THEN
395 tiny = eps*sqrt( abs( d( finish ) ) )*
396 $ sqrt( abs( d( finish+1 ) ) )
397 IF( abs( e( finish ) ).GT.tiny )
THEN
405 m = finish - start + 1
406 IF( m.GT.smlsiz )
THEN
410 orgnrm = slanst(
'M', m, d( start ), e( start ) )
411 CALL slascl(
'G', 0, 0, orgnrm, one, m, 1, d( start ),
414 CALL slascl(
'G', 0, 0, orgnrm, one, m-1, 1,
418 CALL claed0( n, m, d( start ), e( start ), z( 1,
420 $ ldz, work, n, rwork, iwork, info )
422 info = ( info / ( m+1 )+start-1 )*( n+1 ) +
423 $ mod( info, ( m+1 ) ) + start - 1
429 CALL slascl(
'G', 0, 0, one, orgnrm, m, 1, d( start ),
434 CALL ssteqr(
'I', m, d( start ), e( start ), rwork, m,
435 $ rwork( m*m+1 ), info )
436 CALL clacrm( n, m, z( 1, start ), ldz, rwork, m, work,
439 CALL clacpy(
'A', n, m, work, n, z( 1, start ), ldz )
441 info = start*( n+1 ) + finish
460 IF( d( j ).LT.p )
THEN
468 CALL cswap( n, z( 1, i ), 1, z( 1, k ), 1 )
474 work( 1 ) = sroundup_lwork(lwmin)
475 rwork( 1 ) = real( lrwmin )