214 SUBROUTINE sgees( JOBVS, SORT, SELECT, N, A, LDA, SDIM, WR, WI,
215 $ VS, LDVS, WORK, LWORK, BWORK, INFO )
222 CHARACTER JOBVS, SORT
223 INTEGER INFO, LDA, LDVS, LWORK, N, SDIM
227 REAL A( LDA, * ), VS( LDVS, * ), WI( * ), WORK( * ),
239 parameter( zero = 0.0e0, one = 1.0e0 )
242 LOGICAL CURSL, LASTSL, LQUERY, LST2SL, SCALEA, WANTST,
244 INTEGER HSWORK, I, I1, I2, IBAL, ICOND, IERR, IEVAL,
245 $ ihi, ilo, inxt, ip, itau, iwrk, maxwrk, minwrk
246 REAL ANRM, BIGNUM, CSCALE, EPS, S, SEP, SMLNUM
259 REAL SLAMCH, SLANGE, SROUNDUP_LWORK
260 EXTERNAL lsame, ilaenv, slamch, slange, sroundup_lwork
270 lquery = ( lwork.EQ.-1 )
271 wantvs = lsame( jobvs,
'V' )
272 wantst = lsame( sort,
'S' )
273 IF( ( .NOT.wantvs ) .AND. ( .NOT.lsame( jobvs,
'N' ) ) )
THEN
275 ELSE IF( ( .NOT.wantst ) .AND. ( .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,
'SGEHRD',
' ', n, 1, n, 0 )
303 CALL shseqr(
'S', jobvs, n, 1, n, a, lda, wr, wi, vs, ldvs,
305 hswork = int( work( 1 ) )
307 IF( .NOT.wantvs )
THEN
308 maxwrk = max( maxwrk, n + hswork )
310 maxwrk = max( maxwrk, 2*n + ( n - 1 )*ilaenv( 1,
311 $
'SORGHR',
' ', n, 1, n, -1 ) )
312 maxwrk = max( maxwrk, n + hswork )
315 work( 1 ) = sroundup_lwork(maxwrk)
317 IF( lwork.LT.minwrk .AND. .NOT.lquery )
THEN
323 CALL xerbla(
'SGEES ', -info )
325 ELSE IF( lquery )
THEN
339 smlnum = slamch(
'S' )
340 bignum = one / smlnum
341 smlnum = sqrt( smlnum ) / eps
342 bignum = one / smlnum
346 anrm = slange(
'M', n, n, a, lda, dum )
348 IF( anrm.GT.zero .AND. anrm.LT.smlnum )
THEN
351 ELSE IF( anrm.GT.bignum )
THEN
356 $
CALL slascl(
'G', 0, 0, anrm, cscale, n, n, a, lda, ierr )
362 CALL sgebal(
'P', n, a, lda, ilo, ihi, work( ibal ), ierr )
369 CALL sgehrd( n, ilo, ihi, a, lda, work( itau ), work( iwrk ),
370 $ lwork-iwrk+1, ierr )
376 CALL slacpy(
'L', n, n, a, lda, vs, ldvs )
381 CALL sorghr( n, ilo, ihi, vs, ldvs, work( itau ), work( iwrk ),
382 $ lwork-iwrk+1, ierr )
391 CALL shseqr(
'S', jobvs, n, ilo, ihi, a, lda, wr, wi, vs, ldvs,
392 $ work( iwrk ), lwork-iwrk+1, ieval )
398 IF( wantst .AND. info.EQ.0 )
THEN
400 CALL slascl(
'G', 0, 0, cscale, anrm, n, 1, wr, n, ierr )
401 CALL slascl(
'G', 0, 0, cscale, anrm, n, 1, wi, n, ierr )
404 bwork( i ) =
SELECT( wr( i ), wi( i ) )
410 CALL strsen(
'N', jobvs, bwork, n, a, lda, vs, ldvs, wr, wi,
411 $ sdim, s, sep, work( iwrk ), lwork-iwrk+1, idum, 1,
422 CALL sgebak(
'P',
'R', n, ilo, ihi, work( ibal ), n, vs, ldvs,
430 CALL slascl(
'H', 0, 0, cscale, anrm, n, n, a, lda, ierr )
431 CALL scopy( n, a, lda+1, wr, 1 )
432 IF( cscale.EQ.smlnum )
THEN
438 IF( ieval.GT.0 )
THEN
441 CALL slascl(
'G', 0, 0, cscale, anrm, ilo-1, 1, wi,
442 $ max( ilo-1, 1 ), ierr )
443 ELSE IF( wantst )
THEN
454 IF( wi( i ).EQ.zero )
THEN
457 IF( a( i+1, i ).EQ.zero )
THEN
460 ELSE IF( a( i+1, i ).NE.zero .AND. a( i, i+1 ).EQ.
465 $
CALL sswap( i-1, a( 1, i ), 1, a( 1, i+1 ), 1 )
467 $
CALL sswap( n-i-1, a( i, i+2 ), lda,
468 $ a( i+1, i+2 ), lda )
470 CALL sswap( n, vs( 1, i ), 1, vs( 1, i+1 ), 1 )
472 a( i, i+1 ) = a( i+1, i )
482 CALL slascl(
'G', 0, 0, cscale, anrm, n-ieval, 1,
483 $ wi( ieval+1 ), max( n-ieval, 1 ), ierr )
486 IF( wantst .AND. info.EQ.0 )
THEN
495 cursl =
SELECT( wr( i ), wi( i ) )
496 IF( wi( i ).EQ.zero )
THEN
500 IF( cursl .AND. .NOT.lastsl )
507 cursl = cursl .OR. lastsl
512 IF( cursl .AND. .NOT.lst2sl )
526 work( 1 ) = sroundup_lwork(maxwrk)
subroutine xerbla(srname, info)
subroutine scopy(n, sx, incx, sy, incy)
SCOPY
subroutine sgebak(job, side, n, ilo, ihi, scale, m, v, ldv, info)
SGEBAK
subroutine sgebal(job, n, a, lda, ilo, ihi, scale, info)
SGEBAL
subroutine sgees(jobvs, sort, select, n, a, lda, sdim, wr, wi, vs, ldvs, work, lwork, bwork, info)
SGEES computes the eigenvalues, the Schur form, and, optionally, the matrix of Schur vectors for GE m...
subroutine sgehrd(n, ilo, ihi, a, lda, tau, work, lwork, info)
SGEHRD
subroutine shseqr(job, compz, n, ilo, ihi, h, ldh, wr, wi, z, ldz, work, lwork, info)
SHSEQR
subroutine slacpy(uplo, m, n, a, lda, b, ldb)
SLACPY copies all or part of one two-dimensional array to another.
subroutine slascl(type, kl, ku, cfrom, cto, m, n, a, lda, info)
SLASCL multiplies a general rectangular matrix by a real scalar defined as cto/cfrom.
subroutine sswap(n, sx, incx, sy, incy)
SSWAP
subroutine strsen(job, compq, select, n, t, ldt, q, ldq, wr, wi, m, s, sep, work, lwork, iwork, liwork, info)
STRSEN
subroutine sorghr(n, ilo, ihi, a, lda, tau, work, lwork, info)
SORGHR