# ?hgeqz

Implements the QZ method for finding the generalized eigenvalues of the matrix pair (H,T).

## Syntax

FORTRAN 77:

call shgeqz(job, compq, compz, n, ilo, ihi, h, ldh, t, ldt, alphar, alphai, beta, q, ldq, z, ldz, work, lwork, info)

call dhgeqz(job, compq, compz, n, ilo, ihi, h, ldh, t, ldt, alphar, alphai, beta, q, ldq, z, ldz, work, lwork, info)

call chgeqz(job, compq, compz, n, ilo, ihi, h, ldh, t, ldt, alpha, beta, q, ldq, z, ldz, work, lwork, rwork, info)

call zhgeqz(job, compq, compz, n, ilo, ihi, h, ldh, t, ldt, alpha, beta, q, ldq, z, ldz, work, lwork, rwork, info)

Fortran 95:

call hgeqz(h, t [,ilo] [,ihi] [,alphar] [,alphai] [,beta] [,q] [,z] [,job] [,compq] [,compz] [,info])

call hgeqz(h, t [,ilo] [,ihi] [,alpha] [,beta] [,q] [,z] [,job] [,compq] [, compz] [,info])

## Description

This routine computes the eigenvalues of a real/complex matrix pair (H,T), where H is an upper Hessenberg matrix and T is upper triangular, using the double-shift version (for real flavors) or single-shift version (for complex flavors) of the QZ method. Matrix pairs of this type are produced by the reduction to generalized upper Hessenberg form of a real/complex matrix pair (A,B):

`A = Q1*H*Z1H` , `B = Q1*T*Z1H`,

as computed by ?gghrd.

For real flavors:

If `job = 'S'`, then the Hessenberg-triangular pair (H,T) is also reduced to generalized Schur form,

`H = Q*S*ZT`, `T = Q` `*P*ZT`,

where Q and Z are orthogonal matrices, P is an upper triangular matrix, and S is a quasi-triangular matrix with 1-by-1 and 2-by-2 diagonal blocks. The 1-by-1 blocks correspond to real eigenvalues of the matrix pair (H,T) and the 2-by-2 blocks correspond to complex conjugate pairs of eigenvalues.

Additionally, the 2-by-2 upper triangular diagonal blocks of P corresponding to 2-by-2 blocks of S are reduced to positive diagonal form, that is, if S(j+1,j) is non-zero, then `P(j+1,j) = P(j,j+1) = 0`, `P(j,j) > 0`, and `P(j+1,j+1) > 0`.

For complex flavors:

If `job = 'S'`, then the Hessenberg-triangular pair (H,T) is also reduced to generalized Schur form,

`H = Q* S*ZH`, `T = Q*P*ZH`,

where Q and Z are unitary matrices, and S and P are upper triangular.

For all function flavors:

Optionally, the orthogonal/unitary matrix Q from the generalized Schur factorization may be postmultiplied into an input matrix Q1, and the orthogonal/unitary matrix Z may be postmultiplied into an input matrix Z1.

If Q1 and Z1 are the orthogonal/unitary matrices from ?gghrd that reduced the matrix pair (A,B) to generalized upper Hessenberg form, then the output matrices Q1Q and Z 1Z are the orthogonal/unitary factors from the generalized Schur factorization of (A,B):

`A = (Q1Q)*S *(Z1Z)H`, `B = (Q1Q)*P*(Z1Z)H`.

To avoid overflow, eigenvalues of the matrix pair (H,T) (equivalently, of (A,B)) are computed as a pair of values (alpha,beta). For chgeqz/zhgeqz, alpha and beta are complex, and for shgeqz/dhgeqz, alpha is complex and beta real. If beta is nonzero, `λ = alpha/beta` is an eigenvalue of the generalized nonsymmetric eigenvalue problem (GNEP)

`A*x = λ*B*x`

and if alpha is nonzero, `μ = beta`/alpha is an eigenvalue of the alternate form of the GNEP

`μ*A*y = B*y` .

Real eigenvalues (for real flavors) or the values of alpha and beta for the i-th eigenvalue (for complex flavors) can be read directly from the generalized Schur form:

`alpha = S(i,i)`, `beta = P(i,i)`.

## Input Parameters

job

  CHARACTER*1. Specifies the operations to be performed. Must be 'E' or 'S'.

  If `job = 'E'`, then compute eigenvalues only;

  If `job = 'S'`, then compute eigenvalues and the Schur form.

compq

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

  If `compq = 'N'`, left Schur vectors (q) are not computed;

  If `compq = 'I'`, q is initialized to the unit matrix and the matrix of left Schur vectors of (H,T) is returned;

  If `compq = 'V'`, q must contain an orthogonal/unitary matrix Q1 on entry and the product Q1*Q is returned.

compz

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

  If `compz = 'N'`, right Schur vectors (z) are not computed;

  If `compz = 'I'`, z is initialized to the unit matrix and the matrix of right Schur vectors of (H,T) is returned;

  If `compz = 'V'`, z must contain an orthogonal/unitary matrix Z1 on entry and the product Z1*Z is returned.

n

  INTEGER. The order of the matrices H, T, Q, and Z

  (`n ≥ 0`).

ilo, ihi

  INTEGER. ilo and ihi mark the rows and columns of H which are in Hessenberg form. It is assumed that H is already upper triangular in rows and columns 1:ilo-1 and ihi+1:n.

  Constraint:

  If `n > 0`, then `1 ≤ ilo ≤ ihi ≤ n`;

  if `n = 0`, then `ilo = 1` and `ihi = 0`.

h, t, q, z, work

  REAL for shgeqz

  DOUBLE PRECISION for dhgeqz

  COMPLEX for chgeqz

  DOUBLE COMPLEX for zhgeqz.

  Arrays:

  On entry, h(ldh,*) contains the n-by-n upper Hessenberg matrix H.

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

  On entry, t(ldt,*) contains the n-by-n upper triangular matrix T.

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

  q (ldq,*):

  On entry, if `compq = 'V'`, this array contains the orthogonal/unitary matrix Q1 used in the reduction of (A,B) to generalized Hessenberg form.

  If `compq = 'N'`, then q is not referenced.

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

  z (ldz,*):

  On entry, if `compz = 'V'`, this array contains the orthogonal/unitary matrix Z1 used in the reduction of (A,B) to generalized Hessenberg form.

  If `compz = 'N'`, then z is not referenced.

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

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

ldh

  INTEGER. The first dimension of h; at least max(1, n).

ldt

  INTEGER. The first dimension of t; at least max(1, n).

ldq

  INTEGER. The first dimension of q;

  If `compq = 'N'`, then `ldq ≥ 1`.

  If `compq = 'I'`or 'V', then `ldq ≥ max(1, n)`.

ldz

  INTEGER. The first dimension of z;

  If `compq = 'N'`, then `ldz ≥ 1`.

  If `compq = 'I'`or 'V', then `ldz ≥ max(1, n)`.

lwork

  INTEGER. The dimension of the array work.

  `lwork ≥ max(1, 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. See Application Notes for details.

rwork

  REAL for chgeqz

  DOUBLE PRECISION for zhgeqz.

  Workspace array, DIMENSION at least max(1, n). Used in complex flavors only.

## Output Parameters

h

  For real flavors:

  If `job = 'S'`, then, on exit, h contains the upper quasi-triangular matrix S from the generalized Schur factorization; 2-by-2 diagonal blocks (corresponding to complex conjugate pairs of eigenvalues) are returned in standard form, with `h(i,i) = h(i+1, i+1)` and `h(i+1, i) * h(i, i+1) < 0`.

  If `job = 'E'`, then on exit the diagonal blocks of h match those of S, but the rest of h is unspecified.

  For complex flavors:

  If `job = 'S'`, then, on exit, h contains the upper triangular matrix S from the generalized Schur factorization.

  If `job = 'E'`, then on exit the diagonal of h matches that of S, but the rest of h is unspecified.

t

  If `job = 'S'`, then, on exit, t contains the upper triangular matrix P from the generalized Schur factorization.

  For real flavors:

  2-by-2 diagonal blocks of P corresponding to 2-by-2 blocks of S are reduced to positive diagonal form, that is, if h(j+1,j) is non-zero, then `t(j+1,j)=t(j,j+1)=0` and t(j,j) and t(j+1,j+1) will be positive.

  If `job = 'E'`, then on exit the diagonal blocks of t match those of P, but the rest of t is unspecified.

  For complex flavors:

  if `job = 'E'`, then on exit the diagonal of t matches that of P, but the rest of t is unspecified.

alphar, alphai

  REAL for shgeqz;

  DOUBLE PRECISION for dhgeqz.

  Arrays, DIMENSION at least max(1, n). The real and imaginary parts, respectively, of each scalar alpha defining an eigenvalue of GNEP.

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

  `alphai(j+1) = -alphai(j)`.

alpha

  COMPLEX for chgeqz;

  DOUBLE COMPLEX for zhgeqz.

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

  The complex scalars alpha that define the eigenvalues of GNEP. `alphai(i) = S(i,i)` in the generalized Schur factorization.

beta

  REAL for shgeqz

  DOUBLE PRECISION for dhgeqz

  COMPLEX for chgeqz

  DOUBLE COMPLEX for zhgeqz.

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

  For real flavors:

  The scalars beta that define the eigenvalues of GNEP.

  Together, the quantities `alpha = (alphar(j), alphai(j))` and `beta = beta(j)` represent the j-th eigenvalue of the matrix pair (A,B), in one of the forms `lambda = alpha/beta` or `mu = beta/alpha`. Since either lambda or mu may overflow, they should not, in general, be computed.

  For complex flavors:

  The real non-negative scalars beta that define the eigenvalues of GNEP.

  `beta(i) = P(i,i)` in the generalized Schur factorization. Together, the quantities `alpha = alpha(j)` and `beta = beta(j)` represent the j-th eigenvalue of the matrix pair (A,B), in one of the forms `lambda = alpha/beta` or `mu = beta/alpha`. Since either lambda or mu may overflow, they should not, in general, be computed.

q

  On exit, if `compq = 'I'`, q is overwritten by the orthogonal/unitary matrix of left Schur vectors of the pair (H,T), and if `compq = 'V'`, q is overwritten by the orthogonal/unitary matrix of left Schur vectors of (A,B).

z

  On exit, if `compz = 'I'`, z is overwritten by the orthogonal/unitary matrix of right Schur vectors of the pair (H,T), and if `compz = 'V'`, z is overwritten by the orthogonal/unitary matrix of right Schur vectors of (A,B).

work`(1)`

  If `info ≥ 0`, on exit, `work(1)` contains the minimum value of lwork required for optimum performance. Use this lwork for subsequent runs.

info

  INTEGER.

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

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

  If `info = 1,..., n`, the QZ iteration did not converge.

  (H,T) is not in Schur form, but alphar(i), alphai(i) (for real flavors), alpha(i) (for complex flavors), and beta(i), `i=info+1,..., n` should be correct.

  If `info = n+1,...,2n`, the shift calculation failed.

  (H,T) is not in Schur form, but alphar(i), alphai(i) (for real flavors), alpha(i) (for complex flavors), and beta(i), `i =info-n+1,..., n` should be correct.

## 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 hgeqz interface are the following:

h

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

t

  Holds the matrix T 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).

q

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

z

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

ilo

  Default value for this argument is `ilo = 1`.

ihi

  Default value for this argument is `ihi = n`.

job

  Must be 'E' or 'S'. The default value is 'E'.

compq

  If omitted, this argument is restored based on the presence of argument q as follows:

  `compq = 'I'`, if q is present,

  `compq = 'N'`, if q is omitted.

  If present, compq must be equal to 'I' or 'V' and the argument q must also be present.

  Note that there will be an error condition if compq is present and q omitted.

compz

  If omitted, this argument is restored based on the presence of argument z as follows:

  `compz = 'I'`, if z is present,

  `compz = 'N'`, if z is omitted.

  If present, compz must be equal to 'I' or 'V' and the argument z must also be present.

  Note an error condition if compz is present and z is 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.

Parent topic: Generalized Nonsymmetric Eigenvalue Problems