268 SUBROUTINE cgges3( JOBVSL, JOBVSR, SORT, SELCTG, N, A, LDA, B,
269 $ ldb, sdim, alpha, beta, vsl, ldvsl, vsr, ldvsr,
270 $ work, lwork, rwork, bwork, info )
278 CHARACTER JOBVSL, JOBVSR, SORT
279 INTEGER INFO, LDA, LDB, LDVSL, LDVSR, LWORK, N, SDIM
284 COMPLEX A( lda, * ), ALPHA( * ), B( ldb, * ),
285 $ beta( * ), vsl( ldvsl, * ), vsr( ldvsr, * ),
297 parameter ( zero = 0.0e0, one = 1.0e0 )
299 parameter ( czero = ( 0.0e0, 0.0e0 ),
300 $ cone = ( 1.0e0, 0.0e0 ) )
303 LOGICAL CURSL, ILASCL, ILBSCL, ILVSL, ILVSR, LASTSL,
305 INTEGER I, ICOLS, IERR, IHI, IJOBVL, IJOBVR, ILEFT,
306 $ ilo, iright, irows, irwrk, itau, iwrk, lwkopt
307 REAL ANRM, ANRMTO, BIGNUM, BNRM, BNRMTO, EPS, PVSL,
322 EXTERNAL lsame, clange, slamch
331 IF( lsame( jobvsl,
'N' ) )
THEN
334 ELSE IF( lsame( jobvsl,
'V' ) )
THEN
342 IF( lsame( jobvsr,
'N' ) )
THEN
345 ELSE IF( lsame( jobvsr,
'V' ) )
THEN
353 wantst = lsame( sort,
'S' )
358 lquery = ( lwork.EQ.-1 )
359 IF( ijobvl.LE.0 )
THEN
361 ELSE IF( ijobvr.LE.0 )
THEN
363 ELSE IF( ( .NOT.wantst ) .AND. ( .NOT.lsame( sort,
'N' ) ) )
THEN
365 ELSE IF( n.LT.0 )
THEN
367 ELSE IF( lda.LT.max( 1, n ) )
THEN
369 ELSE IF( ldb.LT.max( 1, n ) )
THEN
371 ELSE IF( ldvsl.LT.1 .OR. ( ilvsl .AND. ldvsl.LT.n ) )
THEN
373 ELSE IF( ldvsr.LT.1 .OR. ( ilvsr .AND. ldvsr.LT.n ) )
THEN
375 ELSE IF( lwork.LT.max( 1, 2*n ) .AND. .NOT.lquery )
THEN
382 CALL cgeqrf( n, n, b, ldb, work, work, -1, ierr )
383 lwkopt = max( 1, n + int( work( 1 ) ) )
384 CALL cunmqr(
'L',
'C', n, n, n, b, ldb, work, a, lda, work,
386 lwkopt = max( lwkopt, n + int( work( 1 ) ) )
388 CALL cungqr( n, n, n, vsl, ldvsl, work, work, -1,
390 lwkopt = max( lwkopt, n + int( work( 1 ) ) )
392 CALL cgghd3( jobvsl, jobvsr, n, 1, n, a, lda, b, ldb, vsl,
393 $ ldvsl, vsr, ldvsr, work, -1, ierr )
394 lwkopt = max( lwkopt, n + int( work( 1 ) ) )
395 CALL chgeqz(
'S', jobvsl, jobvsr, n, 1, n, a, lda, b, ldb,
396 $ alpha, beta, vsl, ldvsl, vsr, ldvsr, work, -1,
398 lwkopt = max( lwkopt, int( work( 1 ) ) )
400 CALL ctgsen( 0, ilvsl, ilvsr, bwork, n, a, lda, b, ldb,
401 $ alpha, beta, vsl, ldvsl, vsr, ldvsr, sdim,
402 $ pvsl, pvsr, dif, work, -1, idum, 1, ierr )
403 lwkopt = max( lwkopt, int( work( 1 ) ) )
405 work( 1 ) = cmplx( lwkopt )
410 CALL xerbla(
'CGGES3 ', -info )
412 ELSE IF( lquery )
THEN
426 smlnum = slamch(
'S' )
427 bignum = one / smlnum
428 CALL slabad( smlnum, bignum )
429 smlnum = sqrt( smlnum ) / eps
430 bignum = one / smlnum
434 anrm = clange(
'M', n, n, a, lda, rwork )
436 IF( anrm.GT.zero .AND. anrm.LT.smlnum )
THEN
439 ELSE IF( anrm.GT.bignum )
THEN
445 $
CALL clascl(
'G', 0, 0, anrm, anrmto, n, n, a, lda, ierr )
449 bnrm = clange(
'M', n, n, b, ldb, rwork )
451 IF( bnrm.GT.zero .AND. bnrm.LT.smlnum )
THEN
454 ELSE IF( bnrm.GT.bignum )
THEN
460 $
CALL clascl(
'G', 0, 0, bnrm, bnrmto, n, n, b, ldb, ierr )
467 CALL cggbal(
'P', n, a, lda, b, ldb, ilo, ihi, rwork( ileft ),
468 $ rwork( iright ), rwork( irwrk ), ierr )
472 irows = ihi + 1 - ilo
476 CALL cgeqrf( irows, icols, b( ilo, ilo ), ldb, work( itau ),
477 $ work( iwrk ), lwork+1-iwrk, ierr )
481 CALL cunmqr(
'L',
'C', irows, icols, irows, b( ilo, ilo ), ldb,
482 $ work( itau ), a( ilo, ilo ), lda, work( iwrk ),
483 $ lwork+1-iwrk, ierr )
488 CALL claset(
'Full', n, n, czero, cone, vsl, ldvsl )
489 IF( irows.GT.1 )
THEN
490 CALL clacpy(
'L', irows-1, irows-1, b( ilo+1, ilo ), ldb,
491 $ vsl( ilo+1, ilo ), ldvsl )
493 CALL cungqr( irows, irows, irows, vsl( ilo, ilo ), ldvsl,
494 $ work( itau ), work( iwrk ), lwork+1-iwrk, ierr )
500 $
CALL claset(
'Full', n, n, czero, cone, vsr, ldvsr )
504 CALL cgghd3( jobvsl, jobvsr, n, ilo, ihi, a, lda, b, ldb, vsl,
505 $ ldvsl, vsr, ldvsr, work( iwrk ), lwork+1-iwrk, ierr )
512 CALL chgeqz(
'S', jobvsl, jobvsr, n, ilo, ihi, a, lda, b, ldb,
513 $ alpha, beta, vsl, ldvsl, vsr, ldvsr, work( iwrk ),
514 $ lwork+1-iwrk, rwork( irwrk ), ierr )
516 IF( ierr.GT.0 .AND. ierr.LE.n )
THEN
518 ELSE IF( ierr.GT.n .AND. ierr.LE.2*n )
THEN
533 $
CALL clascl(
'G', 0, 0, anrm, anrmto, n, 1, alpha, n, ierr )
535 $
CALL clascl(
'G', 0, 0, bnrm, bnrmto, n, 1, beta, n, ierr )
540 bwork( i ) = selctg( alpha( i ), beta( i ) )
543 CALL ctgsen( 0, ilvsl, ilvsr, bwork, n, a, lda, b, ldb, alpha,
544 $ beta, vsl, ldvsl, vsr, ldvsr, sdim, pvsl, pvsr,
545 $ dif, work( iwrk ), lwork-iwrk+1, idum, 1, ierr )
554 $
CALL cggbak(
'P',
'L', n, ilo, ihi, rwork( ileft ),
555 $ rwork( iright ), n, vsl, ldvsl, ierr )
557 $
CALL cggbak(
'P',
'R', n, ilo, ihi, rwork( ileft ),
558 $ rwork( iright ), n, vsr, ldvsr, ierr )
563 CALL clascl(
'U', 0, 0, anrmto, anrm, n, n, a, lda, ierr )
564 CALL clascl(
'G', 0, 0, anrmto, anrm, n, 1, alpha, n, ierr )
568 CALL clascl(
'U', 0, 0, bnrmto, bnrm, n, n, b, ldb, ierr )
569 CALL clascl(
'G', 0, 0, bnrmto, bnrm, n, 1, beta, n, ierr )
579 cursl = selctg( alpha( i ), beta( i ) )
582 IF( cursl .AND. .NOT.lastsl )
591 work( 1 ) = cmplx( lwkopt )
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 cggbal(JOB, N, A, LDA, B, LDB, ILO, IHI, LSCALE, RSCALE, WORK, INFO)
CGGBAL
subroutine slabad(SMALL, LARGE)
SLABAD
subroutine cgghd3(COMPQ, COMPZ, N, ILO, IHI, A, LDA, B, LDB, Q, LDQ, Z, LDZ, WORK, LWORK, INFO)
CGGHD3
subroutine xerbla(SRNAME, INFO)
XERBLA
subroutine cgges3(JOBVSL, JOBVSR, SORT, SELCTG, N, A, LDA, B, LDB, SDIM, ALPHA, BETA, VSL, LDVSL, VSR, LDVSR, WORK, LWORK, RWORK, BWORK, INFO)
CGGES3 computes the eigenvalues, the Schur form, and, optionally, the matrix of Schur vectors for GE...
subroutine cunmqr(SIDE, TRANS, M, N, K, A, LDA, TAU, C, LDC, WORK, LWORK, INFO)
CUNMQR
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 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 chgeqz(JOB, COMPQ, COMPZ, N, ILO, IHI, H, LDH, T, LDT, ALPHA, BETA, Q, LDQ, Z, LDZ, WORK, LWORK, RWORK, INFO)
CHGEQZ
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 clacpy(UPLO, M, N, A, LDA, B, LDB)
CLACPY copies all or part of one two-dimensional array to another.
subroutine cungqr(M, N, K, A, LDA, TAU, WORK, LWORK, INFO)
CUNGQR