F08XEF (DHGEQZ) (PDF version)
F08 Chapter Contents
F08 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentF08XEF (DHGEQZ)

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

## 1  Purpose

F08XEF (DHGEQZ) implements the $QZ$ method for finding generalized eigenvalues of the real matrix pair $\left(A,B\right)$ of order $n$, which is in the generalized upper Hessenberg form.

## 2  Specification

 SUBROUTINE F08XEF ( JOB, COMPQ, COMPZ, N, ILO, IHI, A, LDA, B, LDB, ALPHAR, ALPHAI, BETA, Q, LDQ, Z, LDZ, WORK, LWORK, INFO)
 INTEGER N, ILO, IHI, LDA, LDB, LDQ, LDZ, LWORK, INFO REAL (KIND=nag_wp) A(LDA,*), B(LDB,*), ALPHAR(N), ALPHAI(N), BETA(N), Q(LDQ,*), Z(LDZ,*), WORK(max(1,LWORK)) CHARACTER(1) JOB, COMPQ, COMPZ
The routine may be called by its LAPACK name dhgeqz.

## 3  Description

F08XEF (DHGEQZ) implements a single-double-shift version of the $QZ$ method for finding the generalized eigenvalues of the real matrix pair $\left(A,B\right)$ which is in the generalized upper Hessenberg form. If the matrix pair $\left(A,B\right)$ is not in the generalized upper Hessenberg form, then the routine F08WEF (DGGHRD) should be called before invoking F08XEF (DHGEQZ).
This problem is mathematically equivalent to solving the equation
 $detA-λB=0.$
Note that, to avoid underflow, overflow and other arithmetic problems, the generalized eigenvalues ${\lambda }_{j}$ are never computed explicitly by this routine but defined as ratios between two computed values, ${\alpha }_{j}$ and ${\beta }_{j}$:
 $λj=αj/βj.$
The parameters ${\alpha }_{j}$, in general, are finite complex values and ${\beta }_{j}$ are finite real non-negative values.
If desired, the matrix pair $\left(A,B\right)$ may be reduced to generalized Schur form. That is, the transformed matrix $B$ is upper triangular and the transformed matrix $A$ is block upper triangular, where the diagonal blocks are either $1$ by $1$ or $2$ by $2$. The $1$ by $1$ blocks provide generalized eigenvalues which are real and the $2$ by $2$ blocks give complex generalized eigenvalues.
The parameter JOB specifies two options. If ${\mathbf{JOB}}=\text{'S'}$ then the matrix pair $\left(A,B\right)$ is simultaneously reduced to Schur form by applying one orthogonal transformation (usually called $Q$) on the left and another (usually called $Z$) on the right. That is,
 $A←QTAZ B←QTBZ$
The $2$ by $2$ upper-triangular diagonal blocks of $B$ corresponding to $2$ by $2$ blocks of A will be reduced to non-negative diagonal matrices. That is, if ${\mathbf{A}}\left(j+1,j\right)$ is nonzero, then ${\mathbf{B}}\left(j+1,j\right)={\mathbf{B}}\left(j,j+1\right)=0$ and ${\mathbf{B}}\left(j,j\right)$ and ${\mathbf{B}}\left(j+1,j+1\right)$ will be non-negative.
If ${\mathbf{JOB}}=\text{'E'}$, then at each iteration the same transformations are computed but they are only applied to those parts of $A$ and $B$ which are needed to compute $\alpha$ and $\beta$. This option could be used if generalized eigenvalues are required but not generalized eigenvectors.
If ${\mathbf{JOB}}=\text{'S'}$ and ${\mathbf{COMPQ}}=\text{'V'}$ or $\text{'I'}$, and ${\mathbf{COMPZ}}=\text{'V'}$ or $\text{'I'}$, then the orthogonal transformations used to reduce the pair $\left(A,B\right)$ are accumulated into the input arrays Q and Z. If generalized eigenvectors are required then JOB must be set to ${\mathbf{JOB}}=\text{'S'}$ and if left (right) generalized eigenvectors are to be computed then COMPQ (COMPZ) must be set to ${\mathbf{COMPQ}}=\text{'V'}$ or $\text{'I'}$ and not ${\mathbf{COMPQ}}\ne \text{'N'}$.
If ${\mathbf{COMPQ}}=\text{'I'}$, then eigenvectors are accumulated on the identity matrix and on exit the array Q contains the left eigenvector matrix $Q$. However, if ${\mathbf{COMPQ}}=\text{'V'}$ then the transformations are accumulated on the user-supplied matrix ${Q}_{0}$ in array Q on entry and thus on exit Q contains the matrix product $Q{Q}_{0}$. A similar convention is used for COMPZ.

## 4  References

Anderson E, Bai Z, Bischof C, Blackford S, Demmel J, Dongarra J J, Du Croz J J, Greenbaum A, Hammarling S, McKenney A and Sorensen D (1999) LAPACK Users' Guide (3rd Edition) SIAM, Philadelphia
Golub G H and Van Loan C F (1996) Matrix Computations (3rd Edition) Johns Hopkins University Press, Baltimore
Moler C B and Stewart G W (1973) An algorithm for generalized matrix eigenproblems SIAM J. Numer. Anal. 10 241–256
Stewart G W and Sun J-G (1990) Matrix Perturbation Theory Academic Press, London

## 5  Parameters

1:     $\mathrm{JOB}$ – CHARACTER(1)Input
On entry: specifies the operations to be performed on $\left(A,B\right)$.
${\mathbf{JOB}}=\text{'E'}$
The matrix pair $\left(A,B\right)$ on exit might not be in the generalized Schur form.
${\mathbf{JOB}}=\text{'S'}$
The matrix pair $\left(A,B\right)$ on exit will be in the generalized Schur form.
Constraint: ${\mathbf{JOB}}=\text{'E'}$ or $\text{'S'}$.
2:     $\mathrm{COMPQ}$ – CHARACTER(1)Input
On entry: specifies the operations to be performed on $Q$:
${\mathbf{COMPQ}}=\text{'N'}$
The array Q is unchanged.
${\mathbf{COMPQ}}=\text{'V'}$
The left transformation $Q$ is accumulated on the array Q.
${\mathbf{COMPQ}}=\text{'I'}$
The array Q is initialized to the identity matrix before the left transformation $Q$ is accumulated in Q.
Constraint: ${\mathbf{COMPQ}}=\text{'N'}$, $\text{'V'}$ or $\text{'I'}$.
3:     $\mathrm{COMPZ}$ – CHARACTER(1)Input
On entry: specifies the operations to be performed on $Z$.
${\mathbf{COMPZ}}=\text{'N'}$
The array Z is unchanged.
${\mathbf{COMPZ}}=\text{'V'}$
The right transformation $Z$ is accumulated on the array Z.
${\mathbf{COMPZ}}=\text{'I'}$
The array Z is initialized to the identity matrix before the right transformation $Z$ is accumulated in Z.
Constraint: ${\mathbf{COMPZ}}=\text{'N'}$, $\text{'V'}$ or $\text{'I'}$.
4:     $\mathrm{N}$ – INTEGERInput
On entry: $n$, the order of the matrices $A$, $B$, $Q$ and $Z$.
Constraint: ${\mathbf{N}}\ge 0$.
5:     $\mathrm{ILO}$ – INTEGERInput
6:     $\mathrm{IHI}$ – INTEGERInput
On entry: the indices ${i}_{\mathrm{lo}}$ and ${i}_{\mathrm{hi}}$, respectively which define the upper triangular parts of $A$. The submatrices $A\left(1:{i}_{\mathrm{lo}}-1,1:{i}_{\mathrm{lo}}-1\right)$ and $A\left({i}_{\mathrm{hi}}+1:n,{i}_{\mathrm{hi}}+1:n\right)$ are then upper triangular. These parameters are provided by F08WHF (DGGBAL) if the matrix pair was previously balanced; otherwise, ${\mathbf{ILO}}=1$ and ${\mathbf{IHI}}={\mathbf{N}}$.
Constraints:
• if ${\mathbf{N}}>0$, $1\le {\mathbf{ILO}}\le {\mathbf{IHI}}\le {\mathbf{N}}$;
• if ${\mathbf{N}}=0$, ${\mathbf{ILO}}=1$ and ${\mathbf{IHI}}=0$.
7:     $\mathrm{A}\left({\mathbf{LDA}},*\right)$ – REAL (KIND=nag_wp) arrayInput/Output
Note: the second dimension of the array A must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$.
On entry: the $n$ by $n$ upper Hessenberg matrix $A$. The elements below the first subdiagonal must be set to zero.
On exit: if ${\mathbf{JOB}}=\text{'S'}$, the matrix pair $\left(A,B\right)$ will be simultaneously reduced to generalized Schur form.
If ${\mathbf{JOB}}=\text{'E'}$, the $1$ by $1$ and $2$ by $2$ diagonal blocks of the matrix pair $\left(A,B\right)$ will give generalized eigenvalues but the remaining elements will be irrelevant.
8:     $\mathrm{LDA}$ – INTEGERInput
On entry: the first dimension of the array A as declared in the (sub)program from which F08XEF (DHGEQZ) is called.
Constraint: ${\mathbf{LDA}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$.
9:     $\mathrm{B}\left({\mathbf{LDB}},*\right)$ – REAL (KIND=nag_wp) arrayInput/Output
Note: the second dimension of the array B must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$.
On entry: the $n$ by $n$ upper triangular matrix $B$. The elements below the diagonal must be zero.
On exit: if ${\mathbf{JOB}}=\text{'S'}$, the matrix pair $\left(A,B\right)$ will be simultaneously reduced to generalized Schur form.
If ${\mathbf{JOB}}=\text{'E'}$, the $1$ by $1$ and $2$ by $2$ diagonal blocks of the matrix pair $\left(A,B\right)$ will give generalized eigenvalues but the remaining elements will be irrelevant.
10:   $\mathrm{LDB}$ – INTEGERInput
On entry: the first dimension of the array B as declared in the (sub)program from which F08XEF (DHGEQZ) is called.
Constraint: ${\mathbf{LDB}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$.
11:   $\mathrm{ALPHAR}\left({\mathbf{N}}\right)$ – REAL (KIND=nag_wp) arrayOutput
On exit: the real parts of ${\alpha }_{\mathit{j}}$, for $\mathit{j}=1,2,\dots ,n$.
12:   $\mathrm{ALPHAI}\left({\mathbf{N}}\right)$ – REAL (KIND=nag_wp) arrayOutput
On exit: the imaginary parts of ${\alpha }_{\mathit{j}}$, for $\mathit{j}=1,2,\dots ,n$.
13:   $\mathrm{BETA}\left({\mathbf{N}}\right)$ – REAL (KIND=nag_wp) arrayOutput
On exit: ${\beta }_{\mathit{j}}$, for $\mathit{j}=1,2,\dots ,n$.
14:   $\mathrm{Q}\left({\mathbf{LDQ}},*\right)$ – REAL (KIND=nag_wp) arrayInput/Output
Note: the second dimension of the array Q must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$ if ${\mathbf{COMPQ}}=\text{'V'}$ or $\text{'I'}$ and at least $1$ if ${\mathbf{COMPQ}}=\text{'N'}$.
On entry: if ${\mathbf{COMPQ}}=\text{'V'}$, the matrix ${Q}_{0}$. The matrix ${Q}_{0}$ is usually the matrix $Q$ returned by F08WEF (DGGHRD).
If ${\mathbf{COMPQ}}=\text{'N'}$, Q is not referenced.
On exit: if ${\mathbf{COMPQ}}=\text{'V'}$, Q contains the matrix product $Q{Q}_{0}$.
If ${\mathbf{COMPQ}}=\text{'I'}$, Q contains the transformation matrix $Q$.
15:   $\mathrm{LDQ}$ – INTEGERInput
On entry: the first dimension of the array Q as declared in the (sub)program from which F08XEF (DHGEQZ) is called.
Constraints:
• if ${\mathbf{COMPQ}}=\text{'V'}$ or $\text{'I'}$, ${\mathbf{LDQ}}\ge {\mathbf{N}}$;
• if ${\mathbf{COMPQ}}=\text{'N'}$, ${\mathbf{LDQ}}\ge 1$.
16:   $\mathrm{Z}\left({\mathbf{LDZ}},*\right)$ – REAL (KIND=nag_wp) arrayInput/Output
Note: the second dimension of the array Z must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$ if ${\mathbf{COMPZ}}=\text{'V'}$ or $\text{'I'}$ and at least $1$ if ${\mathbf{COMPZ}}=\text{'N'}$.
On entry: if ${\mathbf{COMPZ}}=\text{'V'}$, the matrix ${Z}_{0}$. The matrix ${Z}_{0}$ is usually the matrix $Z$ returned by F08WEF (DGGHRD).
If ${\mathbf{COMPZ}}=\text{'N'}$, Z is not referenced.
On exit: if ${\mathbf{COMPZ}}=\text{'V'}$, Z contains the matrix product $Z{Z}_{0}$.
If ${\mathbf{COMPZ}}=\text{'I'}$, Z contains the transformation matrix $Z$.
17:   $\mathrm{LDZ}$ – INTEGERInput
On entry: the first dimension of the array Z as declared in the (sub)program from which F08XEF (DHGEQZ) is called.
Constraints:
• if ${\mathbf{COMPZ}}=\text{'V'}$ or $\text{'I'}$, ${\mathbf{LDZ}}\ge {\mathbf{N}}$;
• if ${\mathbf{COMPZ}}=\text{'N'}$, ${\mathbf{LDZ}}\ge 1$.
18:   $\mathrm{WORK}\left(\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{LWORK}}\right)\right)$ – REAL (KIND=nag_wp) arrayWorkspace
On exit: if ${\mathbf{INFO}}={\mathbf{0}}$, ${\mathbf{WORK}}\left(1\right)$ contains the minimum value of LWORK required for optimal performance.
19:   $\mathrm{LWORK}$ – INTEGERInput
On entry: the dimension of the array WORK as declared in the (sub)program from which F08XEF (DHGEQZ) is called.
If ${\mathbf{LWORK}}=-1$, a workspace query is assumed; the routine only calculates the minimum 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.
Constraint: ${\mathbf{LWORK}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$ or ${\mathbf{LWORK}}=-1$.
20:   $\mathrm{INFO}$ – INTEGEROutput
On exit: ${\mathbf{INFO}}=0$ unless the routine detects an error (see Section 6).

## 6  Error Indicators and Warnings

${\mathbf{INFO}}<0$
If ${\mathbf{INFO}}=-i$, argument $i$ had an illegal value. An explanatory message is output, and execution of the program is terminated.
${\mathbf{INFO}}>0$
If $1\le {\mathbf{INFO}}\le {\mathbf{N}}$, the $QZ$ iteration did not converge and the matrix pair $\left(A,B\right)$ is not in the generalized Schur form at exit. However, if ${\mathbf{INFO}}<{\mathbf{N}}$, then the computed ${\alpha }_{i}$ and ${\beta }_{i}$ should be correct for $i={\mathbf{INFO}}+1,\dots ,{\mathbf{N}}$.
If ${\mathbf{N}}+1\le {\mathbf{INFO}}\le 2×{\mathbf{N}}$, the computation of shifts failed and the matrix pair $\left(A,B\right)$ is not in the generalized Schur form at exit. However, if ${\mathbf{INFO}}<2×{\mathbf{N}}$, then the computed ${\alpha }_{i}$ and ${\beta }_{i}$ should be correct for $i={\mathbf{INFO}}-{\mathbf{N}}+1,\dots ,{\mathbf{N}}$.
If ${\mathbf{INFO}}>2×{\mathbf{N}}$, then an unexpected Library error has occurred. Please contact NAG with details of your program.

## 7  Accuracy

Please consult Section 4.11 of the LAPACK Users' Guide (see Anderson et al. (1999)) and Chapter 6 of Stewart and Sun (1990), for more information.

## 8  Parallelism and Performance

F08XEF (DHGEQZ) is not threaded by NAG in any implementation.
F08XEF (DHGEQZ) makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the Users' Note for your implementation for any additional implementation-specific information.

## 9  Further Comments

F08XEF (DHGEQZ) is the fifth step in the solution of the real generalized eigenvalue problem and is called after F08WEF (DGGHRD).
The complex analogue of this routine is F08XSF (ZHGEQZ).

## 10  Example

This example computes the $\alpha$ and $\beta$ parameters, which defines the generalized eigenvalues, of the matrix pair $\left(A,B\right)$ given by
 $A = 1.0 1.0 1.0 1.0 1.0 2.0 4.0 8.0 16.0 32.0 3.0 9.0 27.0 81.0 243.0 4.0 16.0 64.0 256.0 1024.0 5.0 25.0 125.0 625.0 3125.0$
 $B = 1.0 2.0 3.0 4.0 5.0 1.0 4.0 9.0 16.0 25.0 1.0 8.0 27.0 64.0 125.0 1.0 16.0 81.0 256.0 625.0 1.0 32.0 243.0 1024.0 3125.0 .$
This requires calls to five routines: F08WHF (DGGBAL) to balance the matrix, F08AEF (DGEQRF) to perform the $QR$ factorization of $B$, F08AGF (DORMQR) to apply $Q$ to $A$, F08WEF (DGGHRD) to reduce the matrix pair to the generalized Hessenberg form and F08XEF (DHGEQZ) to compute the eigenvalues using the $QZ$ algorithm.

### 10.1  Program Text

Program Text (f08xefe.f90)

### 10.2  Program Data

Program Data (f08xefe.d)

### 10.3  Program Results

Program Results (f08xefe.r)

F08XEF (DHGEQZ) (PDF version)
F08 Chapter Contents
F08 Chapter Introduction
NAG Library Manual