212 SUBROUTINE dgees( JOBVS, SORT, SELECT, N, A, LDA, SDIM, WR, WI,
213 $ VS, LDVS, WORK, LWORK, BWORK, INFO )
220 CHARACTER JOBVS, SORT
221 INTEGER INFO, LDA, LDVS, LWORK, N, SDIM
225 DOUBLE PRECISION A( LDA, * ), VS( LDVS, * ), WI( * ), WORK( * ),
236 DOUBLE PRECISION ZERO, ONE
237 parameter( zero = 0.0d0, one = 1.0d0 )
240 LOGICAL CURSL, LASTSL, LQUERY, LST2SL, SCALEA, WANTST,
242 INTEGER HSWORK, I, I1, I2, IBAL, ICOND, IERR, IEVAL,
243 $ ihi, ilo, inxt, ip, itau, iwrk, maxwrk, minwrk
244 DOUBLE PRECISION ANRM, BIGNUM, CSCALE, EPS, S, SEP, SMLNUM
248 DOUBLE PRECISION DUM( 1 )
258 DOUBLE PRECISION DLAMCH, DLANGE
259 EXTERNAL lsame, ilaenv, dlamch, dlange
269 lquery = ( lwork.EQ.-1 )
270 wantvs = lsame( jobvs,
'V' )
271 wantst = lsame( sort,
'S' )
272 IF( ( .NOT.wantvs ) .AND. ( .NOT.lsame( jobvs,
'N' ) ) )
THEN
274 ELSE IF( ( .NOT.wantst ) .AND.
275 $ ( .NOT.lsame( sort,
'N' ) ) )
THEN
277 ELSE IF( n.LT.0 )
THEN
279 ELSE IF( lda.LT.max( 1, n ) )
THEN
281 ELSE IF( ldvs.LT.1 .OR. ( wantvs .AND. ldvs.LT.n ) )
THEN
300 maxwrk = 2*n + n*ilaenv( 1,
'DGEHRD',
' ', n, 1, n, 0 )
303 CALL dhseqr(
'S', jobvs, n, 1, n, a, lda, wr, wi, vs,
306 hswork = int( work( 1 ) )
308 IF( .NOT.wantvs )
THEN
309 maxwrk = max( maxwrk, n + hswork )
311 maxwrk = max( maxwrk, 2*n + ( n - 1 )*ilaenv( 1,
312 $
'DORGHR',
' ', n, 1, n, -1 ) )
313 maxwrk = max( maxwrk, n + hswork )
318 IF( lwork.LT.minwrk .AND. .NOT.lquery )
THEN
324 CALL xerbla(
'DGEES ', -info )
326 ELSE IF( lquery )
THEN
340 smlnum = dlamch(
'S' )
341 bignum = one / smlnum
342 smlnum = sqrt( smlnum ) / eps
343 bignum = one / smlnum
347 anrm = dlange(
'M', n, n, a, lda, dum )
349 IF( anrm.GT.zero .AND. anrm.LT.smlnum )
THEN
352 ELSE IF( anrm.GT.bignum )
THEN
357 $
CALL dlascl(
'G', 0, 0, anrm, cscale, n, n, a, lda, ierr )
363 CALL dgebal(
'P', n, a, lda, ilo, ihi, work( ibal ), ierr )
370 CALL dgehrd( n, ilo, ihi, a, lda, work( itau ), work( iwrk ),
371 $ lwork-iwrk+1, ierr )
377 CALL dlacpy(
'L', n, n, a, lda, vs, ldvs )
382 CALL dorghr( n, ilo, ihi, vs, ldvs, work( itau ),
384 $ lwork-iwrk+1, ierr )
393 CALL dhseqr(
'S', jobvs, n, ilo, ihi, a, lda, wr, wi, vs, ldvs,
394 $ work( iwrk ), lwork-iwrk+1, ieval )
400 IF( wantst .AND. info.EQ.0 )
THEN
402 CALL dlascl(
'G', 0, 0, cscale, anrm, n, 1, wr, n, ierr )
403 CALL dlascl(
'G', 0, 0, cscale, anrm, n, 1, wi, n, ierr )
406 bwork( i ) =
SELECT( wr( i ), wi( i ) )
412 CALL dtrsen(
'N', jobvs, bwork, n, a, lda, vs, ldvs, wr, wi,
413 $ sdim, s, sep, work( iwrk ), lwork-iwrk+1, idum, 1,
424 CALL dgebak(
'P',
'R', n, ilo, ihi, work( ibal ), n, vs,
433 CALL dlascl(
'H', 0, 0, cscale, anrm, n, n, a, lda, ierr )
434 CALL dcopy( n, a, lda+1, wr, 1 )
435 IF( cscale.EQ.smlnum )
THEN
441 IF( ieval.GT.0 )
THEN
444 CALL dlascl(
'G', 0, 0, cscale, anrm, ilo-1, 1, wi,
445 $ max( ilo-1, 1 ), ierr )
446 ELSE IF( wantst )
THEN
457 IF( wi( i ).EQ.zero )
THEN
460 IF( a( i+1, i ).EQ.zero )
THEN
463 ELSE IF( a( i+1, i ).NE.zero .AND. a( i, i+1 ).EQ.
468 $
CALL dswap( i-1, a( 1, i ), 1, a( 1, i+1 ),
471 $
CALL dswap( n-i-1, a( i, i+2 ), lda,
472 $ a( i+1, i+2 ), lda )
474 CALL dswap( n, vs( 1, i ), 1, vs( 1, i+1 ),
477 a( i, i+1 ) = a( i+1, i )
487 CALL dlascl(
'G', 0, 0, cscale, anrm, n-ieval, 1,
488 $ wi( ieval+1 ), max( n-ieval, 1 ), ierr )
491 IF( wantst .AND. info.EQ.0 )
THEN
500 cursl =
SELECT( wr( i ), wi( i ) )
501 IF( wi( i ).EQ.zero )
THEN
505 IF( cursl .AND. .NOT.lastsl )
512 cursl = cursl .OR. lastsl
517 IF( cursl .AND. .NOT.lst2sl )