266 SUBROUTINE zgges3( 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
280 DOUBLE PRECISION RWORK( * )
281 COMPLEX*16 A( LDA, * ), ALPHA( * ), B( LDB, * ),
282 $ beta( * ), vsl( ldvsl, * ), vsr( ldvsr, * ),
293 DOUBLE PRECISION ZERO, ONE
294 PARAMETER ( ZERO = 0.0d0, one = 1.0d0 )
295 COMPLEX*16 CZERO, CONE
296 parameter( czero = ( 0.0d0, 0.0d0 ),
297 $ cone = ( 1.0d0, 0.0d0 ) )
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 DOUBLE PRECISION ANRM, ANRMTO, BIGNUM, BNRM, BNRMTO, EPS, PVSL,
309 DOUBLE PRECISION DIF( 2 )
317 DOUBLE PRECISION DLAMCH, ZLANGE
318 EXTERNAL lsame, dlamch, zlange
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 zgeqrf( n, n, b, ldb, work, work, -1, ierr )
379 lwkopt = max( 1, n + int( work( 1 ) ) )
380 CALL zunmqr(
'L',
'C', n, n, n, b, ldb, work, a, lda, work,
382 lwkopt = max( lwkopt, n + int( work( 1 ) ) )
384 CALL zungqr( n, n, n, vsl, ldvsl, work, work, -1, ierr )
385 lwkopt = max( lwkopt, n + int( work( 1 ) ) )
387 CALL zgghd3( jobvsl, jobvsr, n, 1, n, a, lda, b, ldb, vsl,
388 $ ldvsl, vsr, ldvsr, work, -1, ierr )
389 lwkopt = max( lwkopt, n + int( work( 1 ) ) )
390 CALL zlaqz0(
'S', jobvsl, jobvsr, n, 1, n, a, lda, b, ldb,
391 $ alpha, beta, vsl, ldvsl, vsr, ldvsr, work, -1,
393 lwkopt = max( lwkopt, int( work( 1 ) ) )
395 CALL ztgsen( 0, ilvsl, ilvsr, bwork, n, a, lda, b, ldb,
396 $ alpha, beta, vsl, ldvsl, vsr, ldvsr, sdim,
397 $ pvsl, pvsr, dif, work, -1, idum, 1, ierr )
398 lwkopt = max( lwkopt, int( work( 1 ) ) )
400 work( 1 ) = dcmplx( lwkopt )
404 CALL xerbla(
'ZGGES3 ', -info )
406 ELSE IF( lquery )
THEN
420 smlnum = dlamch(
'S' )
421 bignum = one / smlnum
422 smlnum = sqrt( smlnum ) / eps
423 bignum = one / smlnum
427 anrm = zlange(
'M', n, n, a, lda, rwork )
429 IF( anrm.GT.zero .AND. anrm.LT.smlnum )
THEN
432 ELSE IF( anrm.GT.bignum )
THEN
438 $
CALL zlascl(
'G', 0, 0, anrm, anrmto, n, n, a, lda, ierr )
442 bnrm = zlange(
'M', n, n, b, ldb, rwork )
444 IF( bnrm.GT.zero .AND. bnrm.LT.smlnum )
THEN
447 ELSE IF( bnrm.GT.bignum )
THEN
453 $
CALL zlascl(
'G', 0, 0, bnrm, bnrmto, n, n, b, ldb, ierr )
460 CALL zggbal(
'P', n, a, lda, b, ldb, ilo, ihi, rwork( ileft ),
461 $ rwork( iright ), rwork( irwrk ), ierr )
465 irows = ihi + 1 - ilo
469 CALL zgeqrf( irows, icols, b( ilo, ilo ), ldb, work( itau ),
470 $ work( iwrk ), lwork+1-iwrk, ierr )
474 CALL zunmqr(
'L',
'C', irows, icols, irows, b( ilo, ilo ), ldb,
475 $ work( itau ), a( ilo, ilo ), lda, work( iwrk ),
476 $ lwork+1-iwrk, ierr )
481 CALL zlaset(
'Full', n, n, czero, cone, vsl, ldvsl )
482 IF( irows.GT.1 )
THEN
483 CALL zlacpy(
'L', irows-1, irows-1, b( ilo+1, ilo ), ldb,
484 $ vsl( ilo+1, ilo ), ldvsl )
486 CALL zungqr( irows, irows, irows, vsl( ilo, ilo ), ldvsl,
487 $ work( itau ), work( iwrk ), lwork+1-iwrk, ierr )
493 $
CALL zlaset(
'Full', n, n, czero, cone, vsr, ldvsr )
497 CALL zgghd3( jobvsl, jobvsr, n, ilo, ihi, a, lda, b, ldb, vsl,
498 $ ldvsl, vsr, ldvsr, work( iwrk ), lwork+1-iwrk, ierr )
505 CALL zlaqz0(
'S', jobvsl, jobvsr, n, ilo, ihi, a, lda, b, ldb,
506 $ alpha, beta, vsl, ldvsl, vsr, ldvsr, work( iwrk ),
507 $ lwork+1-iwrk, rwork( irwrk ), 0, ierr )
509 IF( ierr.GT.0 .AND. ierr.LE.n )
THEN
511 ELSE IF( ierr.GT.n .AND. ierr.LE.2*n )
THEN
526 $
CALL zlascl(
'G', 0, 0, anrm, anrmto, n, 1, alpha, n, ierr )
528 $
CALL zlascl(
'G', 0, 0, bnrm, bnrmto, n, 1, beta, n, ierr )
533 bwork( i ) = selctg( alpha( i ), beta( i ) )
536 CALL ztgsen( 0, ilvsl, ilvsr, bwork, n, a, lda, b, ldb, alpha,
537 $ beta, vsl, ldvsl, vsr, ldvsr, sdim, pvsl, pvsr,
538 $ dif, work( iwrk ), lwork-iwrk+1, idum, 1, ierr )
547 $
CALL zggbak(
'P',
'L', n, ilo, ihi, rwork( ileft ),
548 $ rwork( iright ), n, vsl, ldvsl, ierr )
550 $
CALL zggbak(
'P',
'R', n, ilo, ihi, rwork( ileft ),
551 $ rwork( iright ), n, vsr, ldvsr, ierr )
556 CALL zlascl(
'U', 0, 0, anrmto, anrm, n, n, a, lda, ierr )
557 CALL zlascl(
'G', 0, 0, anrmto, anrm, n, 1, alpha, n, ierr )
561 CALL zlascl(
'U', 0, 0, bnrmto, bnrm, n, n, b, ldb, ierr )
562 CALL zlascl(
'G', 0, 0, bnrmto, bnrm, n, 1, beta, n, ierr )
572 cursl = selctg( alpha( i ), beta( i ) )
575 IF( cursl .AND. .NOT.lastsl )
584 work( 1 ) = dcmplx( lwkopt )
subroutine xerbla(srname, info)
subroutine zgeqrf(m, n, a, lda, tau, work, lwork, info)
ZGEQRF
subroutine zggbak(job, side, n, ilo, ihi, lscale, rscale, m, v, ldv, info)
ZGGBAK
subroutine zggbal(job, n, a, lda, b, ldb, ilo, ihi, lscale, rscale, work, info)
ZGGBAL
subroutine zgges3(jobvsl, jobvsr, sort, selctg, n, a, lda, b, ldb, sdim, alpha, beta, vsl, ldvsl, vsr, ldvsr, work, lwork, rwork, bwork, info)
ZGGES3 computes the eigenvalues, the Schur form, and, optionally, the matrix of Schur vectors for GE ...
subroutine zgghd3(compq, compz, n, ilo, ihi, a, lda, b, ldb, q, ldq, z, ldz, work, lwork, info)
ZGGHD3
subroutine zlacpy(uplo, m, n, a, lda, b, ldb)
ZLACPY copies all or part of one two-dimensional array to another.
recursive subroutine zlaqz0(wants, wantq, wantz, n, ilo, ihi, a, lda, b, ldb, alpha, beta, q, ldq, z, ldz, work, lwork, rwork, rec, info)
ZLAQZ0
subroutine zlascl(type, kl, ku, cfrom, cto, m, n, a, lda, info)
ZLASCL multiplies a general rectangular matrix by a real scalar defined as cto/cfrom.
subroutine zlaset(uplo, m, n, alpha, beta, a, lda)
ZLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values.
subroutine ztgsen(ijob, wantq, wantz, select, n, a, lda, b, ldb, alpha, beta, q, ldq, z, ldz, m, pl, pr, dif, work, lwork, iwork, liwork, info)
ZTGSEN
subroutine zungqr(m, n, k, a, lda, tau, work, lwork, info)
ZUNGQR
subroutine zunmqr(side, trans, m, n, k, a, lda, tau, c, ldc, work, lwork, info)
ZUNMQR