266 SUBROUTINE cgges3( JOBVSL, JOBVSR, SORT, SELCTG, N, A, LDA, B,
267 $ LDB, SDIM, ALPHA, BETA, VSL, LDVSL, VSR, LDVSR,
268 $ WORK, LWORK, RWORK, BWORK, INFO )
275 CHARACTER JOBVSL, JOBVSR, SORT
276 INTEGER INFO, LDA, LDB, LDVSL, LDVSR, LWORK, N, SDIM
281 COMPLEX A( LDA, * ), ALPHA( * ), B( LDB, * ),
282 $ beta( * ), vsl( ldvsl, * ), vsr( ldvsr, * ),
294 PARAMETER ( ZERO = 0.0e0, one = 1.0e0 )
296 parameter( czero = ( 0.0e0, 0.0e0 ),
297 $ cone = ( 1.0e0, 0.0e0 ) )
300 LOGICAL CURSL, ILASCL, ILBSCL, ILVSL, ILVSR, LASTSL,
302 INTEGER I, ICOLS, IERR, IHI, IJOBVL, IJOBVR, ILEFT,
303 $ ILO, IRIGHT, IROWS, IRWRK, ITAU, IWRK, LWKOPT
304 REAL ANRM, ANRMTO, BIGNUM, BNRM, BNRMTO, EPS, PVSL,
318 EXTERNAL lsame, clange, slamch
327 IF( lsame( jobvsl,
'N' ) )
THEN
330 ELSE IF( lsame( jobvsl,
'V' ) )
THEN
338 IF( lsame( jobvsr,
'N' ) )
THEN
341 ELSE IF( lsame( jobvsr,
'V' ) )
THEN
349 wantst = lsame( sort,
'S' )
354 lquery = ( lwork.EQ.-1 )
355 IF( ijobvl.LE.0 )
THEN
357 ELSE IF( ijobvr.LE.0 )
THEN
359 ELSE IF( ( .NOT.wantst ) .AND. ( .NOT.lsame( sort,
'N' ) ) )
THEN
361 ELSE IF( n.LT.0 )
THEN
363 ELSE IF( lda.LT.max( 1, n ) )
THEN
365 ELSE IF( ldb.LT.max( 1, n ) )
THEN
367 ELSE IF( ldvsl.LT.1 .OR. ( ilvsl .AND. ldvsl.LT.n ) )
THEN
369 ELSE IF( ldvsr.LT.1 .OR. ( ilvsr .AND. ldvsr.LT.n ) )
THEN
371 ELSE IF( lwork.LT.max( 1, 2*n ) .AND. .NOT.lquery )
THEN
378 CALL cgeqrf( n, n, b, ldb, work, work, -1, ierr )
379 lwkopt = max( 1, n + int( work( 1 ) ) )
380 CALL cunmqr(
'L',
'C', n, n, n, b, ldb, work, a, lda, work,
382 lwkopt = max( lwkopt, n + int( work( 1 ) ) )
384 CALL cungqr( n, n, n, vsl, ldvsl, work, work, -1,
386 lwkopt = max( lwkopt, n + int( work( 1 ) ) )
388 CALL cgghd3( jobvsl, jobvsr, n, 1, n, a, lda, b, ldb, vsl,
389 $ ldvsl, vsr, ldvsr, work, -1, ierr )
390 lwkopt = max( lwkopt, n + int( work( 1 ) ) )
391 CALL claqz0(
'S', jobvsl, jobvsr, n, 1, n, a, lda, b, ldb,
392 $ alpha, beta, vsl, ldvsl, vsr, ldvsr, work, -1,
394 lwkopt = max( lwkopt, int( work( 1 ) ) )
396 CALL ctgsen( 0, ilvsl, ilvsr, bwork, n, a, lda, b, ldb,
397 $ alpha, beta, vsl, ldvsl, vsr, ldvsr, sdim,
398 $ pvsl, pvsr, dif, work, -1, idum, 1, ierr )
399 lwkopt = max( lwkopt, int( work( 1 ) ) )
401 work( 1 ) = cmplx( lwkopt )
406 CALL xerbla(
'CGGES3 ', -info )
408 ELSE IF( lquery )
THEN
422 smlnum = slamch(
'S' )
423 bignum = one / smlnum
424 smlnum = sqrt( smlnum ) / eps
425 bignum = one / smlnum
429 anrm = clange(
'M', n, n, a, lda, rwork )
431 IF( anrm.GT.zero .AND. anrm.LT.smlnum )
THEN
434 ELSE IF( anrm.GT.bignum )
THEN
440 $
CALL clascl(
'G', 0, 0, anrm, anrmto, n, n, a, lda, ierr )
444 bnrm = clange(
'M', n, n, b, ldb, rwork )
446 IF( bnrm.GT.zero .AND. bnrm.LT.smlnum )
THEN
449 ELSE IF( bnrm.GT.bignum )
THEN
455 $
CALL clascl(
'G', 0, 0, bnrm, bnrmto, n, n, b, ldb, ierr )
462 CALL cggbal(
'P', n, a, lda, b, ldb, ilo, ihi, rwork( ileft ),
463 $ rwork( iright ), rwork( irwrk ), ierr )
467 irows = ihi + 1 - ilo
471 CALL cgeqrf( irows, icols, b( ilo, ilo ), ldb, work( itau ),
472 $ work( iwrk ), lwork+1-iwrk, ierr )
476 CALL cunmqr(
'L',
'C', irows, icols, irows, b( ilo, ilo ), ldb,
477 $ work( itau ), a( ilo, ilo ), lda, work( iwrk ),
478 $ lwork+1-iwrk, ierr )
483 CALL claset(
'Full', n, n, czero, cone, vsl, ldvsl )
484 IF( irows.GT.1 )
THEN
485 CALL clacpy(
'L', irows-1, irows-1, b( ilo+1, ilo ), ldb,
486 $ vsl( ilo+1, ilo ), ldvsl )
488 CALL cungqr( irows, irows, irows, vsl( ilo, ilo ), ldvsl,
489 $ work( itau ), work( iwrk ), lwork+1-iwrk, ierr )
495 $
CALL claset(
'Full', n, n, czero, cone, vsr, ldvsr )
499 CALL cgghd3( jobvsl, jobvsr, n, ilo, ihi, a, lda, b, ldb, vsl,
500 $ ldvsl, vsr, ldvsr, work( iwrk ), lwork+1-iwrk, ierr )
507 CALL claqz0(
'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 ), 0, ierr )
511 IF( ierr.GT.0 .AND. ierr.LE.n )
THEN
513 ELSE IF( ierr.GT.n .AND. ierr.LE.2*n )
THEN
528 $
CALL clascl(
'G', 0, 0, anrm, anrmto, n, 1, alpha, n, ierr )
530 $
CALL clascl(
'G', 0, 0, bnrm, bnrmto, n, 1, beta, n, ierr )
535 bwork( i ) = selctg( alpha( i ), beta( i ) )
538 CALL ctgsen( 0, ilvsl, ilvsr, bwork, n, a, lda, b, ldb, alpha,
539 $ beta, vsl, ldvsl, vsr, ldvsr, sdim, pvsl, pvsr,
540 $ dif, work( iwrk ), lwork-iwrk+1, idum, 1, ierr )
549 $
CALL cggbak(
'P',
'L', n, ilo, ihi, rwork( ileft ),
550 $ rwork( iright ), n, vsl, ldvsl, ierr )
552 $
CALL cggbak(
'P',
'R', n, ilo, ihi, rwork( ileft ),
553 $ rwork( iright ), n, vsr, ldvsr, ierr )
558 CALL clascl(
'U', 0, 0, anrmto, anrm, n, n, a, lda, ierr )
559 CALL clascl(
'G', 0, 0, anrmto, anrm, n, 1, alpha, n, ierr )
563 CALL clascl(
'U', 0, 0, bnrmto, bnrm, n, n, b, ldb, ierr )
564 CALL clascl(
'G', 0, 0, bnrmto, bnrm, n, 1, beta, n, ierr )
574 cursl = selctg( alpha( i ), beta( i ) )
577 IF( cursl .AND. .NOT.lastsl )
586 work( 1 ) = cmplx( 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 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 cgghd3(compq, compz, n, ilo, ihi, a, lda, b, ldb, q, ldq, z, ldz, work, lwork, info)
CGGHD3
subroutine clacpy(uplo, m, n, a, lda, b, ldb)
CLACPY copies all or part of one two-dimensional array to another.
recursive subroutine claqz0(wants, wantq, wantz, n, ilo, ihi, a, lda, b, ldb, alpha, beta, q, ldq, z, ldz, work, lwork, rwork, rec, info)
CLAQZ0
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