LAPACK  3.8.0
LAPACK: Linear Algebra PACKage

◆ zgges3()

subroutine zgges3 ( character  JOBVSL,
character  JOBVSR,
character  SORT,
external  SELCTG,
integer  N,
complex*16, dimension( lda, * )  A,
integer  LDA,
complex*16, dimension( ldb, * )  B,
integer  LDB,
integer  SDIM,
complex*16, dimension( * )  ALPHA,
complex*16, dimension( * )  BETA,
complex*16, dimension( ldvsl, * )  VSL,
integer  LDVSL,
complex*16, dimension( ldvsr, * )  VSR,
integer  LDVSR,
complex*16, dimension( * )  WORK,
integer  LWORK,
double precision, dimension( * )  RWORK,
logical, dimension( * )  BWORK,
integer  INFO 
)

ZGGES3 computes the eigenvalues, the Schur form, and, optionally, the matrix of Schur vectors for GE matrices (blocked algorithm)

Download ZGGES3 + dependencies [TGZ] [ZIP] [TXT]

Purpose:
 ZGGES3 computes for a pair of N-by-N complex nonsymmetric matrices
 (A,B), the generalized eigenvalues, the generalized complex Schur
 form (S, T), and optionally left and/or right Schur vectors (VSL
 and VSR). This gives the generalized Schur factorization

         (A,B) = ( (VSL)*S*(VSR)**H, (VSL)*T*(VSR)**H )

 where (VSR)**H is the conjugate-transpose of VSR.

 Optionally, it also orders the eigenvalues so that a selected cluster
 of eigenvalues appears in the leading diagonal blocks of the upper
 triangular matrix S and the upper triangular matrix T. The leading
 columns of VSL and VSR then form an unitary basis for the
 corresponding left and right eigenspaces (deflating subspaces).

 (If only the generalized eigenvalues are needed, use the driver
 ZGGEV instead, which is faster.)

 A generalized eigenvalue for a pair of matrices (A,B) is a scalar w
 or a ratio alpha/beta = w, such that  A - w*B is singular.  It is
 usually represented as the pair (alpha,beta), as there is a
 reasonable interpretation for beta=0, and even for both being zero.

 A pair of matrices (S,T) is in generalized complex Schur form if S
 and T are upper triangular and, in addition, the diagonal elements
 of T are non-negative real numbers.
Parameters
[in]JOBVSL
          JOBVSL is CHARACTER*1
          = 'N':  do not compute the left Schur vectors;
          = 'V':  compute the left Schur vectors.
[in]JOBVSR
          JOBVSR is CHARACTER*1
          = 'N':  do not compute the right Schur vectors;
          = 'V':  compute the right Schur vectors.
[in]SORT
          SORT is CHARACTER*1
          Specifies whether or not to order the eigenvalues on the
          diagonal of the generalized Schur form.
          = 'N':  Eigenvalues are not ordered;
          = 'S':  Eigenvalues are ordered (see SELCTG).
[in]SELCTG
          SELCTG is a LOGICAL FUNCTION of two COMPLEX*16 arguments
          SELCTG must be declared EXTERNAL in the calling subroutine.
          If SORT = 'N', SELCTG is not referenced.
          If SORT = 'S', SELCTG is used to select eigenvalues to sort
          to the top left of the Schur form.
          An eigenvalue ALPHA(j)/BETA(j) is selected if
          SELCTG(ALPHA(j),BETA(j)) is true.

          Note that a selected complex eigenvalue may no longer satisfy
          SELCTG(ALPHA(j),BETA(j)) = .TRUE. after ordering, since
          ordering may change the value of complex eigenvalues
          (especially if the eigenvalue is ill-conditioned), in this
          case INFO is set to N+2 (See INFO below).
[in]N
          N is INTEGER
          The order of the matrices A, B, VSL, and VSR.  N >= 0.
[in,out]A
          A is COMPLEX*16 array, dimension (LDA, N)
          On entry, the first of the pair of matrices.
          On exit, A has been overwritten by its generalized Schur
          form S.
[in]LDA
          LDA is INTEGER
          The leading dimension of A.  LDA >= max(1,N).
[in,out]B
          B is COMPLEX*16 array, dimension (LDB, N)
          On entry, the second of the pair of matrices.
          On exit, B has been overwritten by its generalized Schur
          form T.
[in]LDB
          LDB is INTEGER
          The leading dimension of B.  LDB >= max(1,N).
[out]SDIM
          SDIM is INTEGER
          If SORT = 'N', SDIM = 0.
          If SORT = 'S', SDIM = number of eigenvalues (after sorting)
          for which SELCTG is true.
[out]ALPHA
          ALPHA is COMPLEX*16 array, dimension (N)
[out]BETA
          BETA is COMPLEX*16 array, dimension (N)
          On exit,  ALPHA(j)/BETA(j), j=1,...,N, will be the
          generalized eigenvalues.  ALPHA(j), j=1,...,N  and  BETA(j),
          j=1,...,N  are the diagonals of the complex Schur form (A,B)
          output by ZGGES3. The  BETA(j) will be non-negative real.

          Note: the quotients ALPHA(j)/BETA(j) may easily over- or
          underflow, and BETA(j) may even be zero.  Thus, the user
          should avoid naively computing the ratio alpha/beta.
          However, ALPHA will be always less than and usually
          comparable with norm(A) in magnitude, and BETA always less
          than and usually comparable with norm(B).
[out]VSL
          VSL is COMPLEX*16 array, dimension (LDVSL,N)
          If JOBVSL = 'V', VSL will contain the left Schur vectors.
          Not referenced if JOBVSL = 'N'.
[in]LDVSL
          LDVSL is INTEGER
          The leading dimension of the matrix VSL. LDVSL >= 1, and
          if JOBVSL = 'V', LDVSL >= N.
[out]VSR
          VSR is COMPLEX*16 array, dimension (LDVSR,N)
          If JOBVSR = 'V', VSR will contain the right Schur vectors.
          Not referenced if JOBVSR = 'N'.
[in]LDVSR
          LDVSR is INTEGER
          The leading dimension of the matrix VSR. LDVSR >= 1, and
          if JOBVSR = 'V', LDVSR >= N.
[out]WORK
          WORK is COMPLEX*16 array, dimension (MAX(1,LWORK))
          On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
[in]LWORK
          LWORK is INTEGER
          The dimension of the array WORK.

          If LWORK = -1, then a workspace query is assumed; the routine
          only calculates the optimal size of the WORK array, returns
          this value as the first entry of the WORK array, and no error
          message related to LWORK is issued by XERBLA.
[out]RWORK
          RWORK is DOUBLE PRECISION array, dimension (8*N)
[out]BWORK
          BWORK is LOGICAL array, dimension (N)
          Not referenced if SORT = 'N'.
[out]INFO
          INFO is INTEGER
          = 0:  successful exit
          < 0:  if INFO = -i, the i-th argument had an illegal value.
          =1,...,N:
                The QZ iteration failed.  (A,B) are not in Schur
                form, but ALPHA(j) and BETA(j) should be correct for
                j=INFO+1,...,N.
          > N:  =N+1: other than QZ iteration failed in ZHGEQZ
                =N+2: after reordering, roundoff changed values of
                      some complex eigenvalues so that leading
                      eigenvalues in the Generalized Schur form no
                      longer satisfy SELCTG=.TRUE.  This could also
                      be caused due to scaling.
                =N+3: reordering failed in ZTGSEN.
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
Date
January 2015

Definition at line 271 of file zgges3.f.

271 *
272 * -- LAPACK driver routine (version 3.6.1) --
273 * -- LAPACK is a software package provided by Univ. of Tennessee, --
274 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
275 * January 2015
276 *
277 * .. Scalar Arguments ..
278  CHARACTER jobvsl, jobvsr, sort
279  INTEGER info, lda, ldb, ldvsl, ldvsr, lwork, n, sdim
280 * ..
281 * .. Array Arguments ..
282  LOGICAL bwork( * )
283  DOUBLE PRECISION rwork( * )
284  COMPLEX*16 a( lda, * ), alpha( * ), b( ldb, * ),
285  $ beta( * ), vsl( ldvsl, * ), vsr( ldvsr, * ),
286  $ work( * )
287 * ..
288 * .. Function Arguments ..
289  LOGICAL selctg
290  EXTERNAL selctg
291 * ..
292 *
293 * =====================================================================
294 *
295 * .. Parameters ..
296  DOUBLE PRECISION zero, one
297  parameter( zero = 0.0d0, one = 1.0d0 )
298  COMPLEX*16 czero, cone
299  parameter( czero = ( 0.0d0, 0.0d0 ),
300  $ cone = ( 1.0d0, 0.0d0 ) )
301 * ..
302 * .. Local Scalars ..
303  LOGICAL cursl, ilascl, ilbscl, ilvsl, ilvsr, lastsl,
304  $ lquery, wantst
305  INTEGER i, icols, ierr, ihi, ijobvl, ijobvr, ileft,
306  $ ilo, iright, irows, irwrk, itau, iwrk, lwkopt
307  DOUBLE PRECISION anrm, anrmto, bignum, bnrm, bnrmto, eps, pvsl,
308  $ pvsr, smlnum
309 * ..
310 * .. Local Arrays ..
311  INTEGER idum( 1 )
312  DOUBLE PRECISION dif( 2 )
313 * ..
314 * .. External Subroutines ..
315  EXTERNAL dlabad, xerbla, zgeqrf, zggbak, zggbal, zgghd3,
317  $ zunmqr
318 * ..
319 * .. External Functions ..
320  LOGICAL lsame
321  DOUBLE PRECISION dlamch, zlange
322  EXTERNAL lsame, dlamch, zlange
323 * ..
324 * .. Intrinsic Functions ..
325  INTRINSIC max, sqrt
326 * ..
327 * .. Executable Statements ..
328 *
329 * Decode the input arguments
330 *
331  IF( lsame( jobvsl, 'N' ) ) THEN
332  ijobvl = 1
333  ilvsl = .false.
334  ELSE IF( lsame( jobvsl, 'V' ) ) THEN
335  ijobvl = 2
336  ilvsl = .true.
337  ELSE
338  ijobvl = -1
339  ilvsl = .false.
340  END IF
341 *
342  IF( lsame( jobvsr, 'N' ) ) THEN
343  ijobvr = 1
344  ilvsr = .false.
345  ELSE IF( lsame( jobvsr, 'V' ) ) THEN
346  ijobvr = 2
347  ilvsr = .true.
348  ELSE
349  ijobvr = -1
350  ilvsr = .false.
351  END IF
352 *
353  wantst = lsame( sort, 'S' )
354 *
355 * Test the input arguments
356 *
357  info = 0
358  lquery = ( lwork.EQ.-1 )
359  IF( ijobvl.LE.0 ) THEN
360  info = -1
361  ELSE IF( ijobvr.LE.0 ) THEN
362  info = -2
363  ELSE IF( ( .NOT.wantst ) .AND. ( .NOT.lsame( sort, 'N' ) ) ) THEN
364  info = -3
365  ELSE IF( n.LT.0 ) THEN
366  info = -5
367  ELSE IF( lda.LT.max( 1, n ) ) THEN
368  info = -7
369  ELSE IF( ldb.LT.max( 1, n ) ) THEN
370  info = -9
371  ELSE IF( ldvsl.LT.1 .OR. ( ilvsl .AND. ldvsl.LT.n ) ) THEN
372  info = -14
373  ELSE IF( ldvsr.LT.1 .OR. ( ilvsr .AND. ldvsr.LT.n ) ) THEN
374  info = -16
375  ELSE IF( lwork.LT.max( 1, 2*n ) .AND. .NOT.lquery ) THEN
376  info = -18
377  END IF
378 *
379 * Compute workspace
380 *
381  IF( info.EQ.0 ) THEN
382  CALL zgeqrf( n, n, b, ldb, work, work, -1, ierr )
383  lwkopt = max( 1, n + int( work( 1 ) ) )
384  CALL zunmqr( 'L', 'C', n, n, n, b, ldb, work, a, lda, work,
385  $ -1, ierr )
386  lwkopt = max( lwkopt, n + int( work( 1 ) ) )
387  IF( ilvsl ) THEN
388  CALL zungqr( n, n, n, vsl, ldvsl, work, work, -1, ierr )
389  lwkopt = max( lwkopt, n + int( work( 1 ) ) )
390  END IF
391  CALL zgghd3( jobvsl, jobvsr, n, 1, n, a, lda, b, ldb, vsl,
392  $ ldvsl, vsr, ldvsr, work, -1, ierr )
393  lwkopt = max( lwkopt, n + int( work( 1 ) ) )
394  CALL zhgeqz( 'S', jobvsl, jobvsr, n, 1, n, a, lda, b, ldb,
395  $ alpha, beta, vsl, ldvsl, vsr, ldvsr, work, -1,
396  $ rwork, ierr )
397  lwkopt = max( lwkopt, int( work( 1 ) ) )
398  IF( wantst ) THEN
399  CALL ztgsen( 0, ilvsl, ilvsr, bwork, n, a, lda, b, ldb,
400  $ alpha, beta, vsl, ldvsl, vsr, ldvsr, sdim,
401  $ pvsl, pvsr, dif, work, -1, idum, 1, ierr )
402  lwkopt = max( lwkopt, int( work( 1 ) ) )
403  END IF
404  work( 1 ) = dcmplx( lwkopt )
405  END IF
406 *
407  IF( info.NE.0 ) THEN
408  CALL xerbla( 'ZGGES3 ', -info )
409  RETURN
410  ELSE IF( lquery ) THEN
411  RETURN
412  END IF
413 *
414 * Quick return if possible
415 *
416  IF( n.EQ.0 ) THEN
417  sdim = 0
418  RETURN
419  END IF
420 *
421 * Get machine constants
422 *
423  eps = dlamch( 'P' )
424  smlnum = dlamch( 'S' )
425  bignum = one / smlnum
426  CALL dlabad( smlnum, bignum )
427  smlnum = sqrt( smlnum ) / eps
428  bignum = one / smlnum
429 *
430 * Scale A if max element outside range [SMLNUM,BIGNUM]
431 *
432  anrm = zlange( 'M', n, n, a, lda, rwork )
433  ilascl = .false.
434  IF( anrm.GT.zero .AND. anrm.LT.smlnum ) THEN
435  anrmto = smlnum
436  ilascl = .true.
437  ELSE IF( anrm.GT.bignum ) THEN
438  anrmto = bignum
439  ilascl = .true.
440  END IF
441 *
442  IF( ilascl )
443  $ CALL zlascl( 'G', 0, 0, anrm, anrmto, n, n, a, lda, ierr )
444 *
445 * Scale B if max element outside range [SMLNUM,BIGNUM]
446 *
447  bnrm = zlange( 'M', n, n, b, ldb, rwork )
448  ilbscl = .false.
449  IF( bnrm.GT.zero .AND. bnrm.LT.smlnum ) THEN
450  bnrmto = smlnum
451  ilbscl = .true.
452  ELSE IF( bnrm.GT.bignum ) THEN
453  bnrmto = bignum
454  ilbscl = .true.
455  END IF
456 *
457  IF( ilbscl )
458  $ CALL zlascl( 'G', 0, 0, bnrm, bnrmto, n, n, b, ldb, ierr )
459 *
460 * Permute the matrix to make it more nearly triangular
461 *
462  ileft = 1
463  iright = n + 1
464  irwrk = iright + n
465  CALL zggbal( 'P', n, a, lda, b, ldb, ilo, ihi, rwork( ileft ),
466  $ rwork( iright ), rwork( irwrk ), ierr )
467 *
468 * Reduce B to triangular form (QR decomposition of B)
469 *
470  irows = ihi + 1 - ilo
471  icols = n + 1 - ilo
472  itau = 1
473  iwrk = itau + irows
474  CALL zgeqrf( irows, icols, b( ilo, ilo ), ldb, work( itau ),
475  $ work( iwrk ), lwork+1-iwrk, ierr )
476 *
477 * Apply the orthogonal transformation to matrix A
478 *
479  CALL zunmqr( 'L', 'C', irows, icols, irows, b( ilo, ilo ), ldb,
480  $ work( itau ), a( ilo, ilo ), lda, work( iwrk ),
481  $ lwork+1-iwrk, ierr )
482 *
483 * Initialize VSL
484 *
485  IF( ilvsl ) THEN
486  CALL zlaset( 'Full', n, n, czero, cone, vsl, ldvsl )
487  IF( irows.GT.1 ) THEN
488  CALL zlacpy( 'L', irows-1, irows-1, b( ilo+1, ilo ), ldb,
489  $ vsl( ilo+1, ilo ), ldvsl )
490  END IF
491  CALL zungqr( irows, irows, irows, vsl( ilo, ilo ), ldvsl,
492  $ work( itau ), work( iwrk ), lwork+1-iwrk, ierr )
493  END IF
494 *
495 * Initialize VSR
496 *
497  IF( ilvsr )
498  $ CALL zlaset( 'Full', n, n, czero, cone, vsr, ldvsr )
499 *
500 * Reduce to generalized Hessenberg form
501 *
502  CALL zgghd3( jobvsl, jobvsr, n, ilo, ihi, a, lda, b, ldb, vsl,
503  $ ldvsl, vsr, ldvsr, work( iwrk ), lwork+1-iwrk, ierr )
504 *
505  sdim = 0
506 *
507 * Perform QZ algorithm, computing Schur vectors if desired
508 *
509  iwrk = itau
510  CALL zhgeqz( 'S', jobvsl, jobvsr, n, ilo, ihi, a, lda, b, ldb,
511  $ alpha, beta, vsl, ldvsl, vsr, ldvsr, work( iwrk ),
512  $ lwork+1-iwrk, rwork( irwrk ), ierr )
513  IF( ierr.NE.0 ) THEN
514  IF( ierr.GT.0 .AND. ierr.LE.n ) THEN
515  info = ierr
516  ELSE IF( ierr.GT.n .AND. ierr.LE.2*n ) THEN
517  info = ierr - n
518  ELSE
519  info = n + 1
520  END IF
521  GO TO 30
522  END IF
523 *
524 * Sort eigenvalues ALPHA/BETA if desired
525 *
526  IF( wantst ) THEN
527 *
528 * Undo scaling on eigenvalues before selecting
529 *
530  IF( ilascl )
531  $ CALL zlascl( 'G', 0, 0, anrm, anrmto, n, 1, alpha, n, ierr )
532  IF( ilbscl )
533  $ CALL zlascl( 'G', 0, 0, bnrm, bnrmto, n, 1, beta, n, ierr )
534 *
535 * Select eigenvalues
536 *
537  DO 10 i = 1, n
538  bwork( i ) = selctg( alpha( i ), beta( i ) )
539  10 CONTINUE
540 *
541  CALL ztgsen( 0, ilvsl, ilvsr, bwork, n, a, lda, b, ldb, alpha,
542  $ beta, vsl, ldvsl, vsr, ldvsr, sdim, pvsl, pvsr,
543  $ dif, work( iwrk ), lwork-iwrk+1, idum, 1, ierr )
544  IF( ierr.EQ.1 )
545  $ info = n + 3
546 *
547  END IF
548 *
549 * Apply back-permutation to VSL and VSR
550 *
551  IF( ilvsl )
552  $ CALL zggbak( 'P', 'L', n, ilo, ihi, rwork( ileft ),
553  $ rwork( iright ), n, vsl, ldvsl, ierr )
554  IF( ilvsr )
555  $ CALL zggbak( 'P', 'R', n, ilo, ihi, rwork( ileft ),
556  $ rwork( iright ), n, vsr, ldvsr, ierr )
557 *
558 * Undo scaling
559 *
560  IF( ilascl ) THEN
561  CALL zlascl( 'U', 0, 0, anrmto, anrm, n, n, a, lda, ierr )
562  CALL zlascl( 'G', 0, 0, anrmto, anrm, n, 1, alpha, n, ierr )
563  END IF
564 *
565  IF( ilbscl ) THEN
566  CALL zlascl( 'U', 0, 0, bnrmto, bnrm, n, n, b, ldb, ierr )
567  CALL zlascl( 'G', 0, 0, bnrmto, bnrm, n, 1, beta, n, ierr )
568  END IF
569 *
570  IF( wantst ) THEN
571 *
572 * Check if reordering is correct
573 *
574  lastsl = .true.
575  sdim = 0
576  DO 20 i = 1, n
577  cursl = selctg( alpha( i ), beta( i ) )
578  IF( cursl )
579  $ sdim = sdim + 1
580  IF( cursl .AND. .NOT.lastsl )
581  $ info = n + 2
582  lastsl = cursl
583  20 CONTINUE
584 *
585  END IF
586 *
587  30 CONTINUE
588 *
589  work( 1 ) = dcmplx( lwkopt )
590 *
591  RETURN
592 *
593 * End of ZGGES3
594 *
double precision function dlamch(CMACH)
DLAMCH
Definition: dlamch.f:65
subroutine zgghd3(COMPQ, COMPZ, N, ILO, IHI, A, LDA, B, LDB, Q, LDQ, Z, LDZ, WORK, LWORK, INFO)
ZGGHD3
Definition: zgghd3.f:229
subroutine zggbal(JOB, N, A, LDA, B, LDB, ILO, IHI, LSCALE, RSCALE, WORK, INFO)
ZGGBAL
Definition: zggbal.f:179
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
Definition: ztgsen.f:435
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.
Definition: zlascl.f:145
subroutine zlacpy(UPLO, M, N, A, LDA, B, LDB)
ZLACPY copies all or part of one two-dimensional array to another.
Definition: zlacpy.f:105
subroutine zungqr(M, N, K, A, LDA, TAU, WORK, LWORK, INFO)
ZUNGQR
Definition: zungqr.f:130
subroutine zgeqrf(M, N, A, LDA, TAU, WORK, LWORK, INFO)
ZGEQRF VARIANT: left-looking Level 3 BLAS of the algorithm.
Definition: zgeqrf.f:151
subroutine zhgeqz(JOB, COMPQ, COMPZ, N, ILO, IHI, H, LDH, T, LDT, ALPHA, BETA, Q, LDQ, Z, LDZ, WORK, LWORK, RWORK, INFO)
ZHGEQZ
Definition: zhgeqz.f:286
subroutine zggbak(JOB, SIDE, N, ILO, IHI, LSCALE, RSCALE, M, V, LDV, INFO)
ZGGBAK
Definition: zggbak.f:150
double precision function zlange(NORM, M, N, A, LDA, WORK)
ZLANGE returns the value of the 1-norm, Frobenius norm, infinity-norm, or the largest absolute value ...
Definition: zlange.f:117
subroutine zunmqr(SIDE, TRANS, M, N, K, A, LDA, TAU, C, LDC, WORK, LWORK, INFO)
ZUNMQR
Definition: zunmqr.f:169
subroutine xerbla(SRNAME, INFO)
XERBLA
Definition: xerbla.f:62
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...
Definition: zlaset.f:108
logical function lsame(CA, CB)
LSAME
Definition: lsame.f:55
subroutine dlabad(SMALL, LARGE)
DLABAD
Definition: dlabad.f:76
Here is the call graph for this function:
Here is the caller graph for this function: