326 SUBROUTINE cggesx( JOBVSL, JOBVSR, SORT, SELCTG, SENSE, N, A, LDA,
327 $ B, LDB, SDIM, ALPHA, BETA, VSL, LDVSL, VSR,
328 $ LDVSR, RCONDE, RCONDV, WORK, LWORK, RWORK,
329 $ IWORK, LIWORK, BWORK, INFO )
336 CHARACTER JOBVSL, JOBVSR, SENSE, SORT
337 INTEGER INFO, LDA, LDB, LDVSL, LDVSR, LIWORK, LWORK, N,
343 REAL RCONDE( 2 ), RCONDV( 2 ), RWORK( * )
344 COMPLEX A( LDA, * ), ALPHA( * ), B( LDB, * ),
345 $ beta( * ), vsl( ldvsl, * ), vsr( ldvsr, * ),
357 PARAMETER ( ZERO = 0.0e+0, one = 1.0e+0 )
359 parameter( czero = ( 0.0e+0, 0.0e+0 ),
360 $ cone = ( 1.0e+0, 0.0e+0 ) )
363 LOGICAL CURSL, ILASCL, ILBSCL, ILVSL, ILVSR, LASTSL,
364 $ LQUERY, WANTSB, WANTSE, WANTSN, WANTST, WANTSV
365 INTEGER I, ICOLS, IERR, IHI, IJOB, IJOBVL, IJOBVR,
366 $ ileft, ilo, iright, irows, irwrk, itau, iwrk,
367 $ liwmin, lwrk, maxwrk, minwrk
368 REAL ANRM, ANRMTO, BIGNUM, BNRM, BNRMTO, EPS, PL,
381 REAL CLANGE, SLAMCH, SROUNDUP_LWORK
382 EXTERNAL lsame, ilaenv, clange, slamch, sroundup_lwork
391 IF( lsame( jobvsl,
'N' ) )
THEN
394 ELSE IF( lsame( jobvsl,
'V' ) )
THEN
402 IF( lsame( jobvsr,
'N' ) )
THEN
405 ELSE IF( lsame( jobvsr,
'V' ) )
THEN
413 wantst = lsame( sort,
'S' )
414 wantsn = lsame( sense,
'N' )
415 wantse = lsame( sense,
'E' )
416 wantsv = lsame( sense,
'V' )
417 wantsb = lsame( sense,
'B' )
418 lquery = ( lwork.EQ.-1 .OR. liwork.EQ.-1 )
421 ELSE IF( wantse )
THEN
423 ELSE IF( wantsv )
THEN
425 ELSE IF( wantsb )
THEN
432 IF( ijobvl.LE.0 )
THEN
434 ELSE IF( ijobvr.LE.0 )
THEN
436 ELSE IF( ( .NOT.wantst ) .AND. ( .NOT.lsame( sort,
'N' ) ) )
THEN
438 ELSE IF( .NOT.( wantsn .OR. wantse .OR. wantsv .OR. wantsb ) .OR.
439 $ ( .NOT.wantst .AND. .NOT.wantsn ) )
THEN
441 ELSE IF( n.LT.0 )
THEN
443 ELSE IF( lda.LT.max( 1, n ) )
THEN
445 ELSE IF( ldb.LT.max( 1, n ) )
THEN
447 ELSE IF( ldvsl.LT.1 .OR. ( ilvsl .AND. ldvsl.LT.n ) )
THEN
449 ELSE IF( ldvsr.LT.1 .OR. ( ilvsr .AND. ldvsr.LT.n ) )
THEN
463 maxwrk = n*(1 + ilaenv( 1,
'CGEQRF',
' ', n, 1, n, 0 ) )
464 maxwrk = max( maxwrk, n*( 1 +
465 $ ilaenv( 1,
'CUNMQR',
' ', n, 1, n, -1 ) ) )
467 maxwrk = max( maxwrk, n*( 1 +
468 $ ilaenv( 1,
'CUNGQR',
' ', n, 1, n, -1 ) ) )
472 $ lwrk = max( lwrk, n*n/2 )
478 work( 1 ) = sroundup_lwork(lwrk)
479 IF( wantsn .OR. n.EQ.0 )
THEN
486 IF( lwork.LT.minwrk .AND. .NOT.lquery )
THEN
488 ELSE IF( liwork.LT.liwmin .AND. .NOT.lquery)
THEN
494 CALL xerbla(
'CGGESX', -info )
496 ELSE IF (lquery)
THEN
510 smlnum = slamch(
'S' )
511 bignum = one / smlnum
512 smlnum = sqrt( smlnum ) / eps
513 bignum = one / smlnum
517 anrm = clange(
'M', n, n, a, lda, rwork )
519 IF( anrm.GT.zero .AND. anrm.LT.smlnum )
THEN
522 ELSE IF( anrm.GT.bignum )
THEN
527 $
CALL clascl(
'G', 0, 0, anrm, anrmto, n, n, a, lda, ierr )
531 bnrm = clange(
'M', n, n, b, ldb, rwork )
533 IF( bnrm.GT.zero .AND. bnrm.LT.smlnum )
THEN
536 ELSE IF( bnrm.GT.bignum )
THEN
541 $
CALL clascl(
'G', 0, 0, bnrm, bnrmto, n, n, b, ldb, ierr )
549 CALL cggbal(
'P', n, a, lda, b, ldb, ilo, ihi, rwork( ileft ),
550 $ rwork( iright ), rwork( irwrk ), ierr )
555 irows = ihi + 1 - ilo
559 CALL cgeqrf( irows, icols, b( ilo, ilo ), ldb, work( itau ),
560 $ work( iwrk ), lwork+1-iwrk, ierr )
565 CALL cunmqr(
'L',
'C', irows, icols, irows, b( ilo, ilo ), ldb,
566 $ work( itau ), a( ilo, ilo ), lda, work( iwrk ),
567 $ lwork+1-iwrk, ierr )
573 CALL claset(
'Full', n, n, czero, cone, vsl, ldvsl )
574 IF( irows.GT.1 )
THEN
575 CALL clacpy(
'L', irows-1, irows-1, b( ilo+1, ilo ), ldb,
576 $ vsl( ilo+1, ilo ), ldvsl )
578 CALL cungqr( irows, irows, irows, vsl( ilo, ilo ), ldvsl,
579 $ work( itau ), work( iwrk ), lwork+1-iwrk, ierr )
585 $
CALL claset(
'Full', n, n, czero, cone, vsr, ldvsr )
590 CALL cgghrd( jobvsl, jobvsr, n, ilo, ihi, a, lda, b, ldb, vsl,
591 $ ldvsl, vsr, ldvsr, ierr )
600 CALL chgeqz(
'S', jobvsl, jobvsr, n, ilo, ihi, a, lda, b, ldb,
601 $ alpha, beta, vsl, ldvsl, vsr, ldvsr, work( iwrk ),
602 $ lwork+1-iwrk, rwork( irwrk ), ierr )
604 IF( ierr.GT.0 .AND. ierr.LE.n )
THEN
606 ELSE IF( ierr.GT.n .AND. ierr.LE.2*n )
THEN
622 $
CALL clascl(
'G', 0, 0, anrmto, anrm, n, 1, alpha, n, ierr )
624 $
CALL clascl(
'G', 0, 0, bnrmto, bnrm, n, 1, beta, n, ierr )
629 bwork( i ) = selctg( alpha( i ), beta( i ) )
637 CALL ctgsen( ijob, ilvsl, ilvsr, bwork, n, a, lda, b, ldb,
638 $ alpha, beta, vsl, ldvsl, vsr, ldvsr, sdim, pl, pr,
639 $ dif, work( iwrk ), lwork-iwrk+1, iwork, liwork,
643 $ maxwrk = max( maxwrk, 2*sdim*( n-sdim ) )
644 IF( ierr.EQ.-21 )
THEN
650 IF( ijob.EQ.1 .OR. ijob.EQ.4 )
THEN
654 IF( ijob.EQ.2 .OR. ijob.EQ.4 )
THEN
655 rcondv( 1 ) = dif( 1 )
656 rcondv( 2 ) = dif( 2 )
668 $
CALL cggbak(
'P',
'L', n, ilo, ihi, rwork( ileft ),
669 $ rwork( iright ), n, vsl, ldvsl, ierr )
672 $
CALL cggbak(
'P',
'R', n, ilo, ihi, rwork( ileft ),
673 $ rwork( iright ), n, vsr, ldvsr, ierr )
678 CALL clascl(
'U', 0, 0, anrmto, anrm, n, n, a, lda, ierr )
679 CALL clascl(
'G', 0, 0, anrmto, anrm, n, 1, alpha, n, ierr )
683 CALL clascl(
'U', 0, 0, bnrmto, bnrm, n, n, b, ldb, ierr )
684 CALL clascl(
'G', 0, 0, bnrmto, bnrm, n, 1, beta, n, ierr )
694 cursl = selctg( alpha( i ), beta( i ) )
697 IF( cursl .AND. .NOT.lastsl )
706 work( 1 ) = sroundup_lwork(maxwrk)
subroutine xerbla(srname, info)
subroutine cgeqrf(m, n, a, lda, tau, work, lwork, info)
CGEQRF
subroutine cggbak(job, side, n, ilo, ihi, lscale, rscale, m, v, ldv, info)
CGGBAK
subroutine cggbal(job, n, a, lda, b, ldb, ilo, ihi, lscale, rscale, work, info)
CGGBAL
subroutine cggesx(jobvsl, jobvsr, sort, selctg, sense, n, a, lda, b, ldb, sdim, alpha, beta, vsl, ldvsl, vsr, ldvsr, rconde, rcondv, work, lwork, rwork, iwork, liwork, bwork, info)
CGGESX computes the eigenvalues, the Schur form, and, optionally, the matrix of Schur vectors for GE ...
subroutine cgghrd(compq, compz, n, ilo, ihi, a, lda, b, ldb, q, ldq, z, ldz, info)
CGGHRD
subroutine chgeqz(job, compq, compz, n, ilo, ihi, h, ldh, t, ldt, alpha, beta, q, ldq, z, ldz, work, lwork, rwork, info)
CHGEQZ
subroutine clacpy(uplo, m, n, a, lda, b, ldb)
CLACPY copies all or part of one two-dimensional array to another.
subroutine clascl(type, kl, ku, cfrom, cto, m, n, a, lda, info)
CLASCL multiplies a general rectangular matrix by a real scalar defined as cto/cfrom.
subroutine claset(uplo, m, n, alpha, beta, a, lda)
CLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values.
subroutine ctgsen(ijob, wantq, wantz, select, n, a, lda, b, ldb, alpha, beta, q, ldq, z, ldz, m, pl, pr, dif, work, lwork, iwork, liwork, info)
CTGSEN
subroutine cungqr(m, n, k, a, lda, tau, work, lwork, info)
CUNGQR
subroutine cunmqr(side, trans, m, n, k, a, lda, tau, c, ldc, work, lwork, info)
CUNMQR