267 SUBROUTINE cgges( JOBVSL, JOBVSR, SORT, SELCTG, N, A, LDA, B, LDB,
268 $ SDIM, ALPHA, BETA, VSL, LDVSL, VSR, LDVSR, WORK,
269 $ LWORK, RWORK, BWORK, INFO )
276 CHARACTER JOBVSL, JOBVSR, SORT
277 INTEGER INFO, LDA, LDB, LDVSL, LDVSR, LWORK, N, SDIM
282 COMPLEX A( LDA, * ), ALPHA( * ), B( LDB, * ),
283 $ beta( * ), vsl( ldvsl, * ), vsr( ldvsr, * ),
295 PARAMETER ( ZERO = 0.0e0, one = 1.0e0 )
297 parameter( czero = ( 0.0e0, 0.0e0 ),
298 $ cone = ( 1.0e0, 0.0e0 ) )
301 LOGICAL CURSL, ILASCL, ILBSCL, ILVSL, ILVSR, LASTSL,
303 INTEGER I, ICOLS, IERR, IHI, IJOBVL, IJOBVR, ILEFT,
304 $ ILO, IRIGHT, IROWS, IRWRK, ITAU, IWRK, LWKMIN,
306 REAL ANRM, ANRMTO, BIGNUM, BNRM, BNRMTO, EPS, PVSL,
320 REAL CLANGE, SLAMCH, SROUNDUP_LWORK
321 EXTERNAL lsame, ilaenv, clange, slamch, sroundup_lwork
330 IF( lsame( jobvsl,
'N' ) )
THEN
333 ELSE IF( lsame( jobvsl,
'V' ) )
THEN
341 IF( lsame( jobvsr,
'N' ) )
THEN
344 ELSE IF( lsame( jobvsr,
'V' ) )
THEN
352 wantst = lsame( sort,
'S' )
357 lquery = ( lwork.EQ.-1 )
358 IF( ijobvl.LE.0 )
THEN
360 ELSE IF( ijobvr.LE.0 )
THEN
362 ELSE IF( ( .NOT.wantst ) .AND. ( .NOT.lsame( sort,
'N' ) ) )
THEN
364 ELSE IF( n.LT.0 )
THEN
366 ELSE IF( lda.LT.max( 1, n ) )
THEN
368 ELSE IF( ldb.LT.max( 1, n ) )
THEN
370 ELSE IF( ldvsl.LT.1 .OR. ( ilvsl .AND. ldvsl.LT.n ) )
THEN
372 ELSE IF( ldvsr.LT.1 .OR. ( ilvsr .AND. ldvsr.LT.n ) )
THEN
384 lwkmin = max( 1, 2*n )
385 lwkopt = max( 1, n + n*ilaenv( 1,
'CGEQRF',
' ', n, 1, n, 0 ) )
386 lwkopt = max( lwkopt, n +
387 $ n*ilaenv( 1,
'CUNMQR',
' ', n, 1, n, -1 ) )
389 lwkopt = max( lwkopt, n +
390 $ n*ilaenv( 1,
'CUNGQR',
' ', n, 1, n, -1 ) )
392 work( 1 ) = sroundup_lwork(lwkopt)
394 IF( lwork.LT.lwkmin .AND. .NOT.lquery )
399 CALL xerbla(
'CGGES ', -info )
401 ELSE IF( lquery )
THEN
415 smlnum = slamch(
'S' )
416 bignum = one / smlnum
417 smlnum = sqrt( smlnum ) / eps
418 bignum = one / smlnum
422 anrm = clange(
'M', n, n, a, lda, rwork )
424 IF( anrm.GT.zero .AND. anrm.LT.smlnum )
THEN
427 ELSE IF( anrm.GT.bignum )
THEN
433 $
CALL clascl(
'G', 0, 0, anrm, anrmto, n, n, a, lda, ierr )
437 bnrm = clange(
'M', n, n, b, ldb, rwork )
439 IF( bnrm.GT.zero .AND. bnrm.LT.smlnum )
THEN
442 ELSE IF( bnrm.GT.bignum )
THEN
448 $
CALL clascl(
'G', 0, 0, bnrm, bnrmto, n, n, b, ldb, ierr )
456 CALL cggbal(
'P', n, a, lda, b, ldb, ilo, ihi, rwork( ileft ),
457 $ rwork( iright ), rwork( irwrk ), ierr )
462 irows = ihi + 1 - ilo
466 CALL cgeqrf( irows, icols, b( ilo, ilo ), ldb, work( itau ),
467 $ work( iwrk ), lwork+1-iwrk, ierr )
472 CALL cunmqr(
'L',
'C', irows, icols, irows, b( ilo, ilo ), ldb,
473 $ work( itau ), a( ilo, ilo ), lda, work( iwrk ),
474 $ lwork+1-iwrk, ierr )
480 CALL claset(
'Full', n, n, czero, cone, vsl, ldvsl )
481 IF( irows.GT.1 )
THEN
482 CALL clacpy(
'L', irows-1, irows-1, b( ilo+1, ilo ), ldb,
483 $ vsl( ilo+1, ilo ), ldvsl )
485 CALL cungqr( irows, irows, irows, vsl( ilo, ilo ), ldvsl,
486 $ work( itau ), work( iwrk ), lwork+1-iwrk, ierr )
492 $
CALL claset(
'Full', n, n, czero, cone, vsr, ldvsr )
497 CALL cgghrd( jobvsl, jobvsr, n, ilo, ihi, a, lda, b, ldb, vsl,
498 $ ldvsl, vsr, ldvsr, ierr )
507 CALL chgeqz(
'S', jobvsl, jobvsr, n, ilo, ihi, a, lda, b, ldb,
508 $ alpha, beta, vsl, ldvsl, vsr, ldvsr, work( iwrk ),
509 $ lwork+1-iwrk, rwork( irwrk ), ierr )
511 IF( ierr.GT.0 .AND. ierr.LE.n )
THEN
513 ELSE IF( ierr.GT.n .AND. ierr.LE.2*n )
THEN
529 $
CALL clascl(
'G', 0, 0, anrm, anrmto, n, 1, alpha, n, ierr )
531 $
CALL clascl(
'G', 0, 0, bnrm, bnrmto, n, 1, beta, n, ierr )
536 bwork( i ) = selctg( alpha( i ), beta( i ) )
539 CALL ctgsen( 0, ilvsl, ilvsr, bwork, n, a, lda, b, ldb, alpha,
540 $ beta, vsl, ldvsl, vsr, ldvsr, sdim, pvsl, pvsr,
541 $ dif, work( iwrk ), lwork-iwrk+1, idum, 1, ierr )
551 $
CALL cggbak(
'P',
'L', n, ilo, ihi, rwork( ileft ),
552 $ rwork( iright ), n, vsl, ldvsl, ierr )
554 $
CALL cggbak(
'P',
'R', n, ilo, ihi, rwork( ileft ),
555 $ rwork( iright ), n, vsr, ldvsr, ierr )
560 CALL clascl(
'U', 0, 0, anrmto, anrm, n, n, a, lda, ierr )
561 CALL clascl(
'G', 0, 0, anrmto, anrm, n, 1, alpha, n, ierr )
565 CALL clascl(
'U', 0, 0, bnrmto, bnrm, n, n, b, ldb, ierr )
566 CALL clascl(
'G', 0, 0, bnrmto, bnrm, n, 1, beta, n, ierr )
576 cursl = selctg( alpha( i ), beta( i ) )
579 IF( cursl .AND. .NOT.lastsl )
588 work( 1 ) = sroundup_lwork(lwkopt)
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 cgges(jobvsl, jobvsr, sort, selctg, n, a, lda, b, ldb, sdim, alpha, beta, vsl, ldvsl, vsr, ldvsr, work, lwork, rwork, bwork, info)
CGGES computes the eigenvalues, the Schur form, and, optionally, the matrix of Schur vectors for GE m...
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