Computes the generalized eigenvalues, Schur form, and, optionally, the left and/or right matrices of Schur vectors.
Syntax
FORTRAN 77:

call sggesx (jobvsl, jobvsr, sort, selctg, sense, n, a, lda, b, ldb, sdim, alphar, alphai, beta, vsl, ldvsl, vsr, ldvsr, rconde, rcondv, work, lwork, iwork, liwork, bwork, info)
call dggesx (jobvsl, jobvsr, sort, selctg, sense, n, a, lda, b, ldb, sdim, alphar, alphai, beta, vsl, ldvsl, vsr, ldvsr, rconde, rcondv, work, lwork, iwork, liwork, bwork, info)
call cggesx (jobvsl, jobvsr, sort, selctg, sense, n, a, lda, b, ldb, sdim, alpha, beta, vsl, ldvsl, vsr, ldvsr, rconde, rcondv, work, lwork, rwork, iwork, liwork, bwork, info)
call zggesx (jobvsl, jobvsr, sort, selctg, sense, n, a, lda, b, ldb, sdim, alpha, beta, vsl, ldvsl, vsr, ldvsr, rconde, rcondv, work, lwork, rwork, iwork, liwork, bwork, info)
Fortran 95:

call ggesx(a, b, alphar, alphai, beta [,vsl] [,vsr] [,select] [,sdim] [,rconde] [, rcondv] [,info])
call ggesx(a, b, alpha, beta [, vsl] [,vsr] [,select] [,sdim] [,rconde] [,rcondv] [, info])
C:

lapack_int LAPACKE_sggesx( int matrix_layout, char jobvsl, char jobvsr, char sort, LAPACK_S_SELECT3 select, char sense, lapack_int n, float* a, lapack_int lda, float* b, lapack_int ldb, lapack_int* sdim, float* alphar, float* alphai, float* beta, float* vsl, lapack_int ldvsl, float* vsr, lapack_int ldvsr, float* rconde, float* rcondv );
lapack_int LAPACKE_dggesx( int matrix_layout, char jobvsl, char jobvsr, char sort, LAPACK_D_SELECT3 select, char sense, lapack_int n, double* a, lapack_int lda, double* b, lapack_int ldb, lapack_int* sdim, double* alphar, double* alphai, double* beta, double* vsl, lapack_int ldvsl, double* vsr, lapack_int ldvsr, double* rconde, double* rcondv );
lapack_int LAPACKE_cggesx( int matrix_layout, char jobvsl, char jobvsr, char sort, LAPACK_C_SELECT2 select, char sense, lapack_int n, lapack_complex_float* a, lapack_int lda, lapack_complex_float* b, lapack_int ldb, lapack_int* sdim, lapack_complex_float* alpha, lapack_complex_float* beta, lapack_complex_float* vsl, lapack_int ldvsl, lapack_complex_float* vsr, lapack_int ldvsr, float* rconde, float* rcondv );
lapack_int LAPACKE_zggesx( int matrix_layout, char jobvsl, char jobvsr, char sort, LAPACK_Z_SELECT2 select, char sense, lapack_int n, lapack_complex_double* a, lapack_int lda, lapack_complex_double* b, lapack_int ldb, lapack_int* sdim, lapack_complex_double* alpha, lapack_complex_double* beta, lapack_complex_double* vsl, lapack_int ldvsl, lapack_complex_double* vsr, lapack_int ldvsr, double* rconde, double* rcondv );
Description
The routine computes for a pair of nbyn real/complex nonsymmetric matrices (A,B), the generalized eigenvalues, the generalized real/complex Schur form (S,T), optionally, the left and/or right matrices of Schur vectors (vsl and vsr). This gives the generalized Schur factorization
(A,B) = ( vsl*S *vsr^{H}, vsl*T*vsr^{H}
)
Optionally, it also orders the eigenvalues so that a selected cluster of eigenvalues appears in the leading diagonal blocks of the upper quasitriangular matrix S and the upper triangular matrix T; computes a reciprocal condition number for the average of the selected eigenvalues (rconde); and computes a reciprocal condition number for the right and left deflating subspaces corresponding to the selected eigenvalues (rcondv). The leading columns of vsl and vsr then form an orthonormal/unitary basis for the corresponding left and right eigenspaces (deflating subspaces).
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
or for both being zero. A pair of matrices (S,T) is in generalized real Schur form if T is upper triangular with nonnegative diagonal and S is block upper triangular with 1by1 and 2by2 blocks. 1by1 blocks correspond to real generalized eigenvalues, while 2by2 blocks of S will be "standardized" by making the corresponding elements of T have the form:
and the pair of corresponding 2by2 blocks in S and T will have a complex conjugate pair of generalized eigenvalues. A pair of matrices (S,T) is in generalized complex Schur form if S and T are upper triangular and, in addition, the diagonal of T are nonnegative real numbers.
Input Parameters
The data types are given for the Fortran interface. A <datatype> placeholder, if present, is used for the C interface data types in the C interface section above. See C Interface Conventions for the C interface principal conventions and type definitions.
 jobvsl

CHARACTER*1. Must be 'N' or 'V'.
If
jobvsl = 'N'
, then the left Schur vectors are not computed.If
jobvsl = 'V'
, then the left Schur vectors are computed.  jobvsr

CHARACTER*1. Must be 'N' or 'V'.
If
jobvsr = 'N'
, then the right Schur vectors are not computed.If
jobvsr = 'V'
, then the right Schur vectors are computed.  sort

CHARACTER*1. Must be 'N' or 'S'. Specifies whether or not to order the eigenvalues on the diagonal of the generalized Schur form.
If
sort = 'N'
, then eigenvalues are not ordered.If
sort = 'S'
, eigenvalues are ordered (see selctg).  selctg

LOGICAL FUNCTION of three REAL arguments for real flavors.
LOGICAL FUNCTION of two COMPLEX arguments for complex flavors.
selctg must be declared EXTERNAL in the calling subroutine.
If
sort = 'S'
, selctg is used to select eigenvalues to sort to the top left of the Schur form.If
sort = 'N'
, selctg is not referenced.For real flavors:
An eigenvalue (alphar(j) + alphai(j))/beta(j) is selected if selctg(alphar(j), alphai(j), beta(j)) is true; that is, if either one of a complex conjugate pair of eigenvalues is selected, then both complex eigenvalues are selected.
Note that in the illconditioned case, a selected complex eigenvalue may no longer satisfy
selctg(alphar(j), alphai(j), beta(j)) = .TRUE.
after ordering. In this case info is set to n+2.For complex flavors:
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 illconditioned); in this case info is set to n+2 (see info below).  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 average of selected eigenvalues only;If
sense = 'V'
, computed for selected deflating subspaces only;If
sense = 'B'
, computed for both.If
sense is 'E'
, 'V', or 'B', then sort must equal 'S'.  n

INTEGER. The order of the matrices A, B, vsl, and vsr (
n ≥ 0
).  a, b, work

REAL for sggesx
DOUBLE PRECISION for dggesx
COMPLEX for cggesx
DOUBLE COMPLEX for zggesx.
Arrays:
a(lda,*) is an array containing the nbyn 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 nbyn 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 leading dimension of the array a.
Must be at least max(1, n).
 ldb

INTEGER. The leading dimension of the array b.
Must be at least max(1, n).
 ldvsl, ldvsr

INTEGER. The leading dimensions of the output matrices vsl and vsr, respectively. Constraints:
ldvsl ≥ 1
. Ifjobvsl = 'V'
,ldvsl ≥ max(1, n)
.ldvsr ≥ 1
. Ifjobvsr = 'V'
,ldvsr ≥ max(1, n)
.  lwork

INTEGER.
The dimension of the array work.
For real flavors:
If
n=0
thenlwork≥1
.If
n>0
andsense = 'N'
, thenlwork ≥ max(8*n, 6*n+16)
.If
n>0
andsense = 'E'
, 'V', or 'B', thenlwork ≥ max(8*n, 6*n+16, 2*sdim*(nsdim))
;For complex flavors:
If
n=0
thenlwork≥1
.If
n>0
andsense = 'N'
, thenlwork ≥ max(1, 2*n)
;If
n>0
andsense = 'E'
, 'V', or 'B', thenlwork ≥ max(1, 2*n, 2*sdim*(nsdim))
.Note that
2*sdim*(nsdim) ≤ n*n/2
.An error is only returned if
lwork < max(8*n, 6*n+16)
for real flavors, andlwork < max(1, 2*n)
for complex flavors, but ifsense = 'E'
, 'V', or 'B', this may not be large enough.If
lwork=1
, then a workspace query is assumed; the routine only calculates the bound on the optimal size of the work array and the minimum size of the iwork array, returns these values as the first entries of the work and iwork arrays, and no error message related to lwork or liwork is issued by xerbla.  rwork

REAL for cggesx
DOUBLE PRECISION for zggesx
Workspace array, DIMENSION at least max(1, 8n).
This array is used in complex flavors only.
 iwork

INTEGER.
Workspace array, DIMENSION
max(1, liwork)
.  liwork

INTEGER.
The dimension of the array iwork.
If
sense = 'N'
, orn=0
, thenliwork≥1
,otherwise
liwork ≥ (n+6)
for real flavors, andliwork ≥ (n+2)
for complex flavors.If
liwork=1
, then a workspace query is assumed; the routine only calculates the bound on the optimal size of the work array and the minimum size of the iwork array, returns these values as the first entries of the work and iwork arrays, and no error message related to lwork or liwork is issued by xerbla.  bwork

LOGICAL.
Workspace array, DIMENSION at least max(1, n).
Not referenced if
sort = 'N'
.
Output Parameters
 a

On exit, this array has been overwritten by its generalized Schur form S.
 b

On exit, this array has been overwritten by its generalized Schur form T.
 sdim

INTEGER.
If
sort = 'N'
,sdim= 0
.If
sort = 'S'
, sdim is equal to the number of eigenvalues (after sorting) for which selctg is true.Note that for real flavors complex conjugate pairs for which selctg is true for either eigenvalue count as 2.
 alphar, alphai

REAL for sggesx;
DOUBLE PRECISION for dggesx.
Arrays, DIMENSION at least max(1, n) each. Contain values that form generalized eigenvalues in real flavors.
See beta.
 alpha

COMPLEX for cggesx;
DOUBLE COMPLEX for zggesx.
Array, DIMENSION at least max(1, n). Contain values that form generalized eigenvalues in complex flavors. See beta.
 beta

REAL for sggesx
DOUBLE PRECISION for dggesx
COMPLEX for cggesx
DOUBLE COMPLEX for zggesx.
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.
alphar(j) + alphai(j)*i and beta(j), j=1,..., n are the diagonals of the complex Schur form (S,T) that would result if the 2by2 diagonal blocks of the real generalized Schur form of (A,B) were further reduced to triangular form using complex unitary transformations. If alphai(j) is zero, then the jth eigenvalue is real; if positive, then the jth 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. alpha(j), j=1,..., n, and beta(j), j=1,...,n are the diagonals of the complex Schur form (S,T) output by cggesx/zggesx. The beta(j) will be nonnegative real.
See also Application Notes below.  vsl, vsr

REAL for sggesx
DOUBLE PRECISION for dggesx
COMPLEX for cggesx
DOUBLE COMPLEX for zggesx.
Arrays:
vsl(ldvsl,*), the second dimension of vsl must be at least max(1, n).
If
jobvsl = 'V'
, this array will contain the left Schur vectors.If
jobvsl = 'N'
, vsl is not referenced.vsr(ldvsr,*), the second dimension of vsr must be at least max(1, n).
If
jobvsr = 'V'
, this array will contain the right Schur vectors.If
jobvsr = 'N'
, vsr is not referenced.  rconde, rcondv

REAL for single precision flavors
DOUBLE PRECISION for double precision flavors.
Arrays, DIMENSION (2) each
If
sense = 'E'
or 'B', rconde(1) and rconde(2) contain the reciprocal condition numbers for the average of the selected eigenvalues.Not referenced if
sense = 'N'
or 'V'.If
sense = 'V'
or 'B', rcondv(1) and rcondv(2) contain the reciprocal condition numbers for the selected deflating subspaces.Not referenced if
sense = 'N'
or 'E'.  work(1)

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

On exit, if
info = 0
, then iwork(1) returns the required minimal size of liwork.  info

INTEGER.
If
info = 0
, the execution is successful.If
info = i
, the ith parameter had an illegal value.If
info = i
, andi ≤ n
:the QZ iteration failed. (A, B) is not in Schur form, 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
: after reordering, roundoff changed values of some complex eigenvalues so that leading eigenvalues in the generalized Schur form no longer satisfyselctg = .TRUE.
. This could also be caused due to scaling;i = n+3
: reordering failed in tgsen.
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 ggesx 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.
 vsl

Holds the matrix VSL of size (n, n).
 vsr

Holds the matrix VSR of size (n, n).
 rconde

Holds the vector of length (2).
 rcondv

Holds the vector of length (2).
 jobvsl

Restored based on the presence of the argument vsl as follows:
jobvsl = 'V'
, if vsl is present,jobvsl = 'N'
, if vsl is omitted.  jobvsr

Restored based on the presence of the argument vsr as follows:
jobvsr = 'V'
, if vsr is present,jobvsr = 'N'
, if vsr is omitted.  sort

Restored based on the presence of the argument select as follows:
sort = 'S'
, if select is present,sort = 'N'
, if select 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.
Note that there will be an error condition if rconde or rcondv are present and select is omitted.
Application Notes
If you are in doubt how much workspace to supply, use a generous value of lwork (or liwork) for the first run or set lwork = 1
(liwork = 1
).
If you choose the first option and set any of admissible lwork (or liwork) 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, iwork) on exit. Use this value (work(1)
, iwork(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, iwork). This operation is called a workspace query.
Note that if you set lwork (liwork) 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 will be always less than and usually comparable with norm(A) in magnitude, and beta always less than and usually comparable with norm(B).