# ?ggevx

Computes the generalized eigenvalues, and, optionally, the left and/or right generalized eigenvectors.

## Syntax

FORTRAN 77:

call sggevx(balanc, jobvl, jobvr, sense, n, a, lda, b, ldb, alphar, alphai, beta, vl, ldvl, vr, ldvr, ilo, ihi, lscale, rscale, abnrm, bbnrm, rconde, rcondv, work, lwork, iwork, bwork, info)

call dggevx(balanc, jobvl, jobvr, sense, n, a, lda, b, ldb, alphar, alphai, beta, vl, ldvl, vr, ldvr, ilo, ihi, lscale, rscale, abnrm, bbnrm, rconde, rcondv, work, lwork, iwork, bwork, info)

call cggevx(balanc, jobvl, jobvr, sense, n, a, lda, b, ldb, alpha, beta, vl, ldvl, vr, ldvr, ilo, ihi, lscale, rscale, abnrm, bbnrm, rconde, rcondv, work, lwork, rwork, iwork, bwork, info)

call zggevx(balanc, jobvl, jobvr, sense, n, a, lda, b, ldb, alpha, beta, vl, ldvl, vr, ldvr, ilo, ihi, lscale, rscale, abnrm, bbnrm, rconde, rcondv, work, lwork, rwork, iwork, bwork, info)

Fortran 95:

call ggevx(a, b, alphar, alphai, beta [,vl] [,vr] [,balanc] [,ilo] [,ihi] [, lscale] [,rscale] [,abnrm] [,bbnrm] [,rconde] [,rcondv] [,info])

call ggevx(a, b, alpha, beta [, vl] [,vr] [,balanc] [,ilo] [,ihi] [,lscale] [, rscale] [,abnrm] [,bbnrm] [,rconde] [,rcondv] [,info])

## Description

This routine computes for a pair of n-by-n real/complex nonsymmetric matrices (A,B), the generalized eigenvalues, and optionally, the left and/or right generalized eigenvectors.

Optionally also, it computes a balancing transformation to improve the conditioning of the eigenvalues and eigenvectors (ilo, ihi, lscale, rscale, abnrm, and bbnrm), reciprocal condition numbers for the eigenvalues (rconde), and reciprocal condition numbers for the right eigenvectors (rcondv).

A generalized eigenvalue for a pair of matrices (A,B) is a scalar λ or a ratio alpha / `beta = λ`, such that `A - λ*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. The right generalized eigenvector `v(j)` corresponding to the generalized eigenvalue `λ(j)` of (A,B) satisfies

`A*v(j) = λ(j)*B*v(j)`.

The left generalized eigenvector `u(j)` corresponding to the generalized eigenvalue `λ(j)` of (A,B) satisfies

`u(j)H*A = λ(j)*u(j)H*B`

where `u(j)H` denotes the conjugate transpose of `u(j)`.

## Input Parameters

balanc

  CHARACTER*1. Must be 'N', 'P', 'S', or 'B'. Specifies the balance option to be performed.

  If `balanc = 'N'`, do not diagonally scale or permute;

  If `balanc = 'P'`, permute only;

  If `balanc = 'S'`, scale only;

  If `balanc = 'B'`, both permute and scale.

  Computed reciprocal condition numbers will be for the matrices after balancing and/or permuting. Permuting does not change condition numbers (in exact arithmetic), but balancing does.

jobvl

  CHARACTER*1. Must be 'N' or 'V'.

  If `jobvl = 'N'`, the left generalized eigenvectors are not computed;

  If `jobvl = 'V'`, the left generalized eigenvectors are computed.

jobvr

  CHARACTER*1. Must be 'N' or 'V'.

  If `jobvr = 'N'`, the right generalized eigenvectors are not computed;

  If `jobvr = 'V'`, the right generalized eigenvectors are computed.

sense

  CHARACTER*1. Must be 'N', 'E', 'V', or 'B'. Determines which reciprocal condition number are computed.

  If `sense = 'N'`, none are computed;

  If `sense = 'E'`, computed for eigenvalues only;

  If `sense = 'V'`, computed for eigenvectors only;

  If `sense = 'B'`, computed for eigenvalues and eigenvectors.

n

  INTEGER. The order of the matrices A, B, vl, and vr (`n ≥ 0`).

a, b, work

  REAL for sggevx

  DOUBLE PRECISION for dggevx

  COMPLEX for cggevx

  DOUBLE COMPLEX for zggevx.

  Arrays:

  a(lda,*) is an array containing the n-by-n matrix A (first of the pair of matrices).

  The second dimension of a must be at least max(1, n).

  b(ldb,*) is an array containing the n-by-n matrix B (second of the pair of matrices).

  The second dimension of b must be at least max(1, n).

  work is a workspace array, its dimension `max(1, lwork)`.

lda

  INTEGER. The first dimension of the array a.

  Must be at least max(1, n).

ldb

  INTEGER. The first dimension of the array b.

  Must be at least max(1, n).

ldvl, ldvr

  INTEGER. The first dimensions of the output matrices vl and vr, respectively.

  Constraints:

  `ldvl ≥ 1`. If `jobvl = 'V'`, `ldvl ≥ max(1, n)`.

  `ldvr ≥ 1`. If `jobvr = 'V'`, `ldvr ≥ max(1, n)`.

lwork

  INTEGER.

  The dimension of the array work. `lwork ≥ max(1, 2*n)`;

  For real flavors:

  If `balanc = 'S'`, or 'B', or `jobvl = 'V'`, or `jobvr = 'V'`, then `lwork ≥ max(1, 6*n)`;

  if `sense = 'E'`, or 'B', then `lwork ≥ max(1, 10*n)`;

  if `sense = 'V'`, or 'B', `lwork ≥ (2n2+ 8*n+16)`.

  For complex flavors:

  if `sense = 'E'`, `lwork ≥ max(1, 4*n)`;

  if `sense = 'V'`, or 'B', `lwork ≥max(1, 2*n2+ 2*n)`.

  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.

rwork

  REAL for cggevx

  DOUBLE PRECISION for zggevx

  Workspace array, DIMENSION at least `max(1, 6*n)` if `balanc = 'S'`, or 'B', and at least `max(1, 2*n)` otherwise.

  This array is used in complex flavors only.

iwork

  INTEGER.

  Workspace array, DIMENSION at least (n+6) for real flavors and at least (n+2) for complex flavors.

  Not referenced if `sense = 'E'`.

bwork

  LOGICAL. Workspace array, DIMENSION at least max(1, n).

  Not referenced if `sense = 'N'`.

## Output Parameters

a, b

  On exit, these arrays have been overwritten.

  If `jobvl = 'V'` or `jobvr = 'V'` or both, then a contains the first part of the real Schur form of the “balanced” versions of the input A and B, and b contains its second part.

alphar, alphai

  REAL for sggevx;

  DOUBLE PRECISION for dggevx.

  Arrays, DIMENSION at least max(1, n) each. Contain values that form generalized eigenvalues in real flavors.

  See beta.

alpha

  COMPLEX for cggevx;

  DOUBLE COMPLEX for zggevx.

  Array, DIMENSION at least max(1, n). Contain values that form generalized eigenvalues in complex flavors. See beta.

beta

  REAL for sggevx

  DOUBLE PRECISION for dggevx

  COMPLEX for cggevx

  DOUBLE COMPLEX for zggevx.

  Array, DIMENSION at least max(1, n).

  For real flavors:

  On exit, (alphar(j) + alphai(j)*i)/beta(j), j=1,..., n, will be the generalized eigenvalues.

  If alphai(j) is zero, then the j-th eigenvalue is real; if positive, then the j-th and (j+1)-st eigenvalues are a complex conjugate pair, with alphai(j+1) negative.

  For complex flavors:

  On exit, alpha(j)/beta(j), j=1,..., n, will be the generalized eigenvalues.

  See also Application Notes below.
vl, vr

  REAL for sggevx

  DOUBLE PRECISION for dggevx

  COMPLEX for cggevx

  DOUBLE COMPLEX for zggevx.

  Arrays:

  vl(ldvl,*); the second dimension of vl must be at least max(1, n).

  If `jobvl = 'V'`, the left generalized eigenvectors `u(j)` are stored one after another in the columns of vl, in the same order as their eigenvalues. Each eigenvector will be scaled so the largest component have abs(Re) + abs(Im) = 1.

  If `jobvl = 'N'`, vl is not referenced.

  For real flavors:

  If the j-th eigenvalue is real, then `u(j) = vl(:,j)`, the j-th column of vl.

  If the j-th and (j+1)-st eigenvalues form a complex conjugate pair, then `u(j) = vl(:,j) + i*vl(:,j+1)` and `u(j+1) = vl(:,j) - i*vl(:,j+1)`, where `i = sqrt(-1)`.

  For complex flavors:

  `u(j) = vl(:,j)`, the j-th column of vl.

  vr(ldvr,*); the second dimension of vr must be at least max(1, n).

  If `jobvr = 'V'`, the right generalized eigenvectors v(j) are stored one after another in the columns of vr, in the same order as their eigenvalues. Each eigenvector will be scaled so the largest component have abs(Re) + abs(Im) = 1.

  If `jobvr = 'N'`, vr is not referenced.

  For real flavors:

  If the j-th eigenvalue is real, then `v(j) = vr(:,j)`, the j-th column of vr.

  If the j-th and (j+1)-st eigenvalues form a complex conjugate pair, then `v(j) = vr(:,j) + i*vr(:,j+1)` and `v(j+1) = vr(:,j) - i*vr(:,j+1)`.

  For complex flavors:

  `v(j) = vr(:,j)`, the j-th column of vr.

ilo, ihi

  INTEGER. ilo and ihi are integer values such that on exit `A(i,j) = 0` and `B(i,j) = 0` if `i > j` and `j = 1,..., ilo-1` or `i = ihi+1,..., n`.

  If `balanc = 'N'` or 'S', `ilo = 1` and `ihi = n`.

lscale, rscale

  REAL for single-precision flavors

  DOUBLE PRECISION for double-precision flavors.

  Arrays, DIMENSION at least max(1, n) each.

  lscale contains details of the permutations and scaling factors applied to the left side of A and B.

  If `PL(j)` is the index of the row interchanged with row j, and `DL(j)` is the scaling factor applied to row j, then

  `lscale(j) = PL(j)`, for `j = 1,..., ilo-1`

  `= DL(j)`, for `j = ilo,...,ihi`

  `= PL(j)` for `j = ihi+1,..., n`.

  The order in which the interchanges are made is n to ihi+1, then 1 to ilo-1.

  rscale contains details of the permutations and scaling factors applied to the right side of A and B.

  If `PR(j)` is the index of the column interchanged with column j, and `DR(j)` is the scaling factor applied to column j, then

  `rscale(j) = PR(j)`, for `j = 1,..., ilo-1`

  `= DR(j)`, for `j = ilo,...,ihi`

  `= PR(j)` for `j = ihi+1,..., n`.

  The order in which the interchanges are made is n to ihi+1, then 1 to ilo-1.

abnrm, bbnrm

  REAL for single-precision flavors

  DOUBLE PRECISION for double-precision flavors.

  The one-norms of the balanced matrices A and B, respectively.

rconde, rcondv

  REAL for single precision flavors DOUBLE PRECISION for double precision flavors.

  Arrays, DIMENSION at least max(1, n) each.

  If `sense = 'E'`, or 'B', rconde contains the reciprocal condition numbers of the eigenvalues, stored in consecutive elements of the array. For a complex conjugate pair of eigenvalues two consecutive elements of rconde are set to the same value. Thus rconde(j), rcondv(j), and the j-th columns of vl and vr all correspond to the same eigenpair (but not in general the j-th eigenpair, unless all eigenpairs are selected).

  If `sense = 'N'`, or 'V', rconde is not referenced.

  If `sense = 'V'`, or 'B', rcondv contains the estimated reciprocal condition numbers of the eigenvectors, stored in consecutive elements of the array. For a complex eigenvector two consecutive elements of rcondv are set to the same value.

  If the eigenvalues cannot be reordered to compute rcondv(j), rcondv(j) is set to 0; this can only occur when the true value would be very small anyway.

  If `sense = 'N'`, or 'E', rcondv is not referenced.

work(1)

  On exit, if `info = 0`, then work(1) returns the required minimal size of lwork.

info

  INTEGER.

  If `info = 0`, the execution is successful.

  If `info = -i`, the i-th parameter had an illegal value.

  If `info = i`, and

  `i ≤ n`:

  the QZ iteration failed. No eigenvectors have been calculated, but alphar(j), alphai(j) (for real flavors), or alpha(j) (for complex flavors), and beta(j), `j=info+1,..., n` should be correct.

  `i > n`: errors that usually indicate LAPACK problems:

  `i = n+1`: other than QZ iteration failed in ?hgeqz;

  `i = n+2`: error return from ?tgevc.

## Fortran 95 Interface Notes

Routines in Fortran 95 interface have fewer arguments in the calling sequence than their FORTRAN 77 counterparts. For general conventions applied to skip redundant or restorable arguments, see Fortran 95 Interface Conventions.

Specific details for the routine ggevx interface are the following:

a

  Holds the matrix A of size (n, n).

b

  Holds the matrix B of size (n, n).

alphar

  Holds the vector of length (n). Used in real flavors only.

alphai

  Holds the vector of length (n). Used in real flavors only.

alpha

  Holds the vector of length (n). Used in complex flavors only.

beta

  Holds the vector of length (n).

vl

  Holds the matrix VL of size (n, n).

vr

  Holds the matrix VR of size (n, n).

lscale

  Holds the vector of length (n).

rscale

  Holds the vector of length (n).

rconde

  Holds the vector of length (n).

rcondv

  Holds the vector of length (n).

balanc

  Must be 'N', 'B', or 'P'. The default value is 'N'.

jobvl

  Restored based on the presence of the argument vl as follows:

  `jobvl = 'V'`, if vl is present,

  `jobvl = 'N'`, if vl is omitted.

jobvr

  Restored based on the presence of the argument vr as follows:

  `jobvr = 'V'`, if vr is present,

  `jobvr = 'N'`, if vr is omitted.

sense

  Restored based on the presence of arguments rconde and rcondv as follows:

  `sense = 'B'`, if both rconde and rcondv are present,

  `sense = 'E'`, if rconde is present and rcondv omitted,

  `sense = 'V'`, if rconde is omitted and rcondv present,

  `sense = 'N'`, if both rconde and rcondv are omitted.

## Application Notes

If you are in doubt how much workspace to supply, use a generous value of lwork for the first run or set `lwork = -1`.

If you choose the first option and set any of admissible lwork sizes, which is no less than the minimal value described, the routine completes the task, though probably not so fast as with a recommended workspace, and provides the recommended workspace in the first element of the corresponding array work on exit. Use this value (`work(1)`) for subsequent runs.

If you set `lwork = -1`, the routine returns immediately and provides the recommended workspace in the first element of the corresponding array (work). This operation is called a workspace query.

Note that if you set lwork to less than the minimal required value and not -1, the routine returns immediately with an error exit and does not provide any information on the recommended workspace.

The quotients alphar(j)/beta(j) and alphai(j)/beta(j) may easily over- or underflow, and beta(j) may even be zero. Thus, you should avoid simply computing the ratio. However, alphar and alphai (for real flavors) or alpha (for complex flavors) will be always less than and usually comparable with norm(A) in magnitude, and beta always less than and usually comparable with norm(B).

Parent topic: Generalized Nonsymmetric Eigenproblems