278 SUBROUTINE sgeesx( JOBVS, SORT, SELECT, SENSE, N, A, LDA, SDIM,
279 $ WR, WI, VS, LDVS, RCONDE, RCONDV, WORK, LWORK,
280 $ IWORK, LIWORK, BWORK, INFO )
287 CHARACTER JOBVS, SENSE, SORT
288 INTEGER INFO, LDA, LDVS, LIWORK, LWORK, N, SDIM
294 REAL A( LDA, * ), VS( LDVS, * ), WI( * ), WORK( * ),
306 PARAMETER ( ZERO = 0.0e0, one = 1.0e0 )
309 LOGICAL CURSL, LASTSL, LQUERY, LST2SL, SCALEA, WANTSB,
310 $ WANTSE, WANTSN, WANTST, WANTSV, WANTVS
311 INTEGER HSWORK, I, I1, I2, IBAL, ICOND, IERR, IEVAL,
312 $ IHI, ILO, INXT, IP, ITAU, IWRK, LWRK, LIWRK,
314 REAL ANRM, BIGNUM, CSCALE, EPS, SMLNUM
326 REAL SLAMCH, SLANGE, SROUNDUP_LWORK
327 EXTERNAL lsame, ilaenv, slamch, slange, sroundup_lwork
337 wantvs = lsame( jobvs,
'V' )
338 wantst = lsame( sort,
'S' )
339 wantsn = lsame( sense,
'N' )
340 wantse = lsame( sense,
'E' )
341 wantsv = lsame( sense,
'V' )
342 wantsb = lsame( sense,
'B' )
343 lquery = ( lwork.EQ.-1 .OR. liwork.EQ.-1 )
345 IF( ( .NOT.wantvs ) .AND. ( .NOT.lsame( jobvs,
'N' ) ) )
THEN
347 ELSE IF( ( .NOT.wantst ) .AND. ( .NOT.lsame( sort,
'N' ) ) )
THEN
349 ELSE IF( .NOT.( wantsn .OR. wantse .OR. wantsv .OR. wantsb ) .OR.
350 $ ( .NOT.wantst .AND. .NOT.wantsn ) )
THEN
352 ELSE IF( n.LT.0 )
THEN
354 ELSE IF( lda.LT.max( 1, n ) )
THEN
356 ELSE IF( ldvs.LT.1 .OR. ( wantvs .AND. ldvs.LT.n ) )
THEN
380 maxwrk = 2*n + n*ilaenv( 1,
'SGEHRD',
' ', n, 1, n, 0 )
383 CALL shseqr(
'S', jobvs, n, 1, n, a, lda, wr, wi, vs, ldvs,
385 hswork = int( work( 1 ) )
387 IF( .NOT.wantvs )
THEN
388 maxwrk = max( maxwrk, n + hswork )
390 maxwrk = max( maxwrk, 2*n + ( n - 1 )*ilaenv( 1,
391 $
'SORGHR',
' ', n, 1, n, -1 ) )
392 maxwrk = max( maxwrk, n + hswork )
396 $ lwrk = max( lwrk, n + ( n*n )/2 )
397 IF( wantsv .OR. wantsb )
401 work( 1 ) = sroundup_lwork(lwrk)
403 IF( lwork.LT.minwrk .AND. .NOT.lquery )
THEN
405 ELSE IF( liwork.LT.1 .AND. .NOT.lquery )
THEN
411 CALL xerbla(
'SGEESX', -info )
413 ELSE IF( lquery )
THEN
427 smlnum = slamch(
'S' )
428 bignum = one / smlnum
429 smlnum = sqrt( smlnum ) / eps
430 bignum = one / smlnum
434 anrm = slange(
'M', n, n, a, lda, dum )
436 IF( anrm.GT.zero .AND. anrm.LT.smlnum )
THEN
439 ELSE IF( anrm.GT.bignum )
THEN
444 $
CALL slascl(
'G', 0, 0, anrm, cscale, n, n, a, lda, ierr )
450 CALL sgebal(
'P', n, a, lda, ilo, ihi, work( ibal ), ierr )
457 CALL sgehrd( n, ilo, ihi, a, lda, work( itau ), work( iwrk ),
458 $ lwork-iwrk+1, ierr )
464 CALL slacpy(
'L', n, n, a, lda, vs, ldvs )
469 CALL sorghr( n, ilo, ihi, vs, ldvs, work( itau ), work( iwrk ),
470 $ lwork-iwrk+1, ierr )
479 CALL shseqr(
'S', jobvs, n, ilo, ihi, a, lda, wr, wi, vs, ldvs,
480 $ work( iwrk ), lwork-iwrk+1, ieval )
486 IF( wantst .AND. info.EQ.0 )
THEN
488 CALL slascl(
'G', 0, 0, cscale, anrm, n, 1, wr, n, ierr )
489 CALL slascl(
'G', 0, 0, cscale, anrm, n, 1, wi, n, ierr )
492 bwork( i ) =
SELECT( wr( i ), wi( i ) )
502 CALL strsen( sense, jobvs, bwork, n, a, lda, vs, ldvs, wr, wi,
503 $ sdim, rconde, rcondv, work( iwrk ), lwork-iwrk+1,
504 $ iwork, liwork, icond )
506 $ maxwrk = max( maxwrk, n+2*sdim*( n-sdim ) )
507 IF( icond.EQ.-15 )
THEN
512 ELSE IF( icond.EQ.-17 )
THEN
517 ELSE IF( icond.GT.0 )
THEN
530 CALL sgebak(
'P',
'R', n, ilo, ihi, work( ibal ), n, vs, ldvs,
538 CALL slascl(
'H', 0, 0, cscale, anrm, n, n, a, lda, ierr )
539 CALL scopy( n, a, lda+1, wr, 1 )
540 IF( ( wantsv .OR. wantsb ) .AND. info.EQ.0 )
THEN
542 CALL slascl(
'G', 0, 0, cscale, anrm, 1, 1, dum, 1, ierr )
545 IF( cscale.EQ.smlnum )
THEN
551 IF( ieval.GT.0 )
THEN
554 CALL slascl(
'G', 0, 0, cscale, anrm, ilo-1, 1, wi, n,
556 ELSE IF( wantst )
THEN
567 IF( wi( i ).EQ.zero )
THEN
570 IF( a( i+1, i ).EQ.zero )
THEN
573 ELSE IF( a( i+1, i ).NE.zero .AND. a( i, i+1 ).EQ.
578 $
CALL sswap( i-1, a( 1, i ), 1, a( 1, i+1 ), 1 )
580 $
CALL sswap( n-i-1, a( i, i+2 ), lda,
581 $ a( i+1, i+2 ), lda )
583 CALL sswap( n, vs( 1, i ), 1, vs( 1, i+1 ), 1 )
585 a( i, i+1 ) = a( i+1, i )
592 CALL slascl(
'G', 0, 0, cscale, anrm, n-ieval, 1,
593 $ wi( ieval+1 ), max( n-ieval, 1 ), ierr )
596 IF( wantst .AND. info.EQ.0 )
THEN
605 cursl =
SELECT( wr( i ), wi( i ) )
606 IF( wi( i ).EQ.zero )
THEN
610 IF( cursl .AND. .NOT.lastsl )
617 cursl = cursl .OR. lastsl
622 IF( cursl .AND. .NOT.lst2sl )
636 work( 1 ) = sroundup_lwork(maxwrk)
637 IF( wantsv .OR. wantsb )
THEN
638 iwork( 1 ) = sdim*(n-sdim)
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 sgeesx(jobvs, sort, select, sense, n, a, lda, sdim, wr, wi, vs, ldvs, rconde, rcondv, work, lwork, iwork, liwork, bwork, info)
SGEESX computes the eigenvalues, the Schur form, and, optionally, the matrix of Schur vectors for GE ...
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