F08 Chapter Contents
F08 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentF08WNF (ZGGEV)

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

F08WNF (ZGGEV) computes for a pair of $n$ by $n$ complex nonsymmetric matrices $\left(A,B\right)$ the generalized eigenvalues and, optionally, the left and/or right generalized eigenvectors using the $QZ$ algorithm.

## 2  Specification

 SUBROUTINE F08WNF ( JOBVL, JOBVR, N, A, LDA, B, LDB, ALPHA, BETA, VL, LDVL, VR, LDVR, WORK, LWORK, RWORK, INFO)
 INTEGER N, LDA, LDB, LDVL, LDVR, LWORK, INFO REAL (KIND=nag_wp) RWORK(max(1,8*N)) COMPLEX (KIND=nag_wp) A(LDA,*), B(LDB,*), ALPHA(N), BETA(N), VL(LDVL,*), VR(LDVR,*), WORK(max(1,LWORK)) CHARACTER(1) JOBVL, JOBVR
The routine may be called by its LAPACK name zggev.

## 3  Description

A generalized eigenvalue for a pair of matrices $\left(A,B\right)$ is a scalar $\lambda$ or a ratio $\alpha /\beta =\lambda$, such that $A-\lambda B$ is singular. It is usually represented as the pair $\left(\alpha ,\beta \right)$, 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 ${\lambda }_{j}$ of $\left(A,B\right)$ satisfies
 $A vj = λj B vj .$
The left generalized eigenvector ${u}_{j}$ corresponding to the generalized eigenvalue ${\lambda }_{j}$ of $\left(A,B\right)$ satisfies
 $ujH A = λj ujH B ,$
where ${u}_{j}^{\mathrm{H}}$ is the conjugate-transpose of ${u}_{j}$.
All the eigenvalues and, if required, all the eigenvectors of the complex generalized eigenproblem $Ax=\lambda Bx$, where $A$ and $B$ are complex, square matrices, are determined using the $QZ$ algorithm. The complex $QZ$ algorithm consists of three stages:
1. $A$ is reduced to upper Hessenberg form (with real, non-negative subdiagonal elements) and at the same time $B$ is reduced to upper triangular form.
2. $A$ is further reduced to triangular form while the triangular form of $B$ is maintained and the diagonal elements of $B$ are made real and non-negative. This is the generalized Schur form of the pair $\left(A,B\right)$.
This routine does not actually produce the eigenvalues ${\lambda }_{j}$, but instead returns ${\alpha }_{j}$ and ${\beta }_{j}$ such that
 $λj=αj/βj, j=1,2,…,n.$
The division by ${\beta }_{j}$ becomes your responsibility, since ${\beta }_{j}$ may be zero, indicating an infinite eigenvalue.
3. If the eigenvectors are required they are obtained from the triangular matrices and then transformed back into the original coordinate system.

## 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 http://www.netlib.org/lapack/lug
Golub G H and Van Loan C F (1996) Matrix Computations (3rd Edition) Johns Hopkins University Press, Baltimore
Wilkinson J H (1979) Kronecker's canonical form and the $QZ$ algorithm Linear Algebra Appl. 28 285–303

## 5  Parameters

1:     JOBVL – CHARACTER(1)Input
On entry: if ${\mathbf{JOBVL}}=\text{'N'}$, do not compute the left generalized eigenvectors.
If ${\mathbf{JOBVL}}=\text{'V'}$, compute the left generalized eigenvectors.
Constraint: ${\mathbf{JOBVL}}=\text{'N'}$ or $\text{'V'}$.
2:     JOBVR – CHARACTER(1)Input
On entry: if ${\mathbf{JOBVR}}=\text{'N'}$, do not compute the right generalized eigenvectors.
If ${\mathbf{JOBVR}}=\text{'V'}$, compute the right generalized eigenvectors.
Constraint: ${\mathbf{JOBVR}}=\text{'N'}$ or $\text{'V'}$.
3:     N – INTEGERInput
On entry: $n$, the order of the matrices $A$ and $B$.
Constraint: ${\mathbf{N}}\ge 0$.
4:     A(LDA,$*$) – COMPLEX (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 matrix $A$ in the pair $\left(A,B\right)$.
On exit: A has been overwritten.
5:     LDA – INTEGERInput
On entry: the first dimension of the array A as declared in the (sub)program from which F08WNF (ZGGEV) is called.
Constraint: ${\mathbf{LDA}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$.
6:     B(LDB,$*$) – COMPLEX (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 matrix $B$ in the pair $\left(A,B\right)$.
On exit: B has been overwritten.
7:     LDB – INTEGERInput
On entry: the first dimension of the array B as declared in the (sub)program from which F08WNF (ZGGEV) is called.
Constraint: ${\mathbf{LDB}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$.
8:     ALPHA(N) – COMPLEX (KIND=nag_wp) arrayOutput
On exit: see the description of BETA.
9:     BETA(N) – COMPLEX (KIND=nag_wp) arrayOutput
On exit: ${\mathbf{ALPHA}}\left(\mathit{j}\right)/{\mathbf{BETA}}\left(\mathit{j}\right)$, for $\mathit{j}=1,2,\dots ,{\mathbf{N}}$, will be the generalized eigenvalues.
Note:  the quotients ${\mathbf{ALPHA}}\left(j\right)/{\mathbf{BETA}}\left(j\right)$ may easily overflow or underflow, and ${\mathbf{BETA}}\left(j\right)$ may even be zero. Thus, you should avoid naively computing the ratio ${\alpha }_{j}/{\beta }_{j}$. However, $\mathrm{max}\left|{\alpha }_{j}\right|$ will always be less than and usually comparable with ${‖{\mathbf{A}}‖}_{2}$ in magnitude, and $\mathrm{max}\left|{\beta }_{j}\right|$ will always be less than and usually comparable with ${‖{\mathbf{B}}‖}_{2}$.
10:   VL(LDVL,$*$) – COMPLEX (KIND=nag_wp) arrayOutput
Note: the second dimension of the array VL must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$ if ${\mathbf{JOBVL}}=\text{'V'}$, and at least $1$ otherwise.
On exit: if ${\mathbf{JOBVL}}=\text{'V'}$, the left generalized eigenvectors ${u}_{j}$ are stored one after another in the columns of VL, in the same order as the corresponding eigenvalues. Each eigenvector will be scaled so the largest component will have $\left|\text{real part}\right|+\left|\text{imag. part}\right|=1$.
If ${\mathbf{JOBVL}}=\text{'N'}$, VL is not referenced.
11:   LDVL – INTEGERInput
On entry: the first dimension of the array VL as declared in the (sub)program from which F08WNF (ZGGEV) is called.
Constraints:
• if ${\mathbf{JOBVL}}=\text{'V'}$, ${\mathbf{LDVL}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$;
• otherwise ${\mathbf{LDVL}}\ge 1$.
12:   VR(LDVR,$*$) – COMPLEX (KIND=nag_wp) arrayOutput
Note: the second dimension of the array VR must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$ if ${\mathbf{JOBVR}}=\text{'V'}$, and at least $1$ otherwise.
On exit: if ${\mathbf{JOBVR}}=\text{'V'}$, the right generalized eigenvectors ${v}_{j}$ are stored one after another in the columns of VR, in the same order as the corresponding eigenvalues. Each eigenvector will be scaled so the largest component will have $\left|\text{real part}\right|+\left|\text{imag. part}\right|=1$.
If ${\mathbf{JOBVR}}=\text{'N'}$, VR is not referenced.
13:   LDVR – INTEGERInput
On entry: the first dimension of the array VR as declared in the (sub)program from which F08WNF (ZGGEV) is called.
Constraints:
• if ${\mathbf{JOBVR}}=\text{'V'}$, ${\mathbf{LDVR}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$;
• otherwise ${\mathbf{LDVR}}\ge 1$.
14:   WORK($\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{LWORK}}\right)$) – COMPLEX (KIND=nag_wp) arrayWorkspace
On exit: if ${\mathbf{INFO}}={\mathbf{0}}$, the real part of ${\mathbf{WORK}}\left(1\right)$ contains the minimum value of LWORK required for optimal performance.
15:   LWORK – INTEGERInput
On entry: the dimension of the array WORK as declared in the (sub)program from which F08WNF (ZGGEV) is called.
If ${\mathbf{LWORK}}=-1$, 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.
Suggested value: for optimal performance, LWORK must generally be larger than the minimum; increase workspace by, say, $\mathit{nb}×{\mathbf{N}}$, where $\mathit{nb}$ is the optimal block size.
Constraint: ${\mathbf{LWORK}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,2×{\mathbf{N}}\right)$.
16:   RWORK($\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,8×{\mathbf{N}}\right)$) – REAL (KIND=nag_wp) arrayWorkspace
17:   INFO – INTEGEROutput
On exit: ${\mathbf{INFO}}=0$ unless the routine detects an error (see Section 6).

## 6  Error Indicators and Warnings

Errors or warnings detected by the routine:
${\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.
The $QZ$ iteration failed. No eigenvectors have been calculated, but ${\mathbf{ALPHA}}\left(j\right)$ and ${\mathbf{BETA}}\left(j\right)$ should be correct for $j={\mathbf{INFO}}+1,\dots ,{\mathbf{N}}$.
${\mathbf{INFO}}={\mathbf{N}}+1$
Unexpected error returned from F08XSF (ZHGEQZ).
${\mathbf{INFO}}={\mathbf{N}}+2$
Error returned from F08YXF (ZTGEVC).

## 7  Accuracy

The computed eigenvalues and eigenvectors are exact for a nearby matrices $\left(A+E\right)$ and $\left(B+F\right)$, where
 $E,F F = Oε A,B F ,$
and $\epsilon$ is the machine precision. See Section 4.11 of Anderson et al. (1999) for further details.
Note:  interpretation of results obtained with the $QZ$ algorithm often requires a clear understanding of the effects of small changes in the original data. These effects are reviewed in Wilkinson (1979), in relation to the significance of small values of ${\alpha }_{j}$ and ${\beta }_{j}$. It should be noted that if ${\alpha }_{j}$ and ${\beta }_{j}$ are both small for any $j$, it may be that no reliance can be placed on any of the computed eigenvalues ${\lambda }_{i}={\alpha }_{i}/{\beta }_{i}$. You are recommended to study Wilkinson (1979) and, if in difficulty, to seek expert advice on determining the sensitivity of the eigenvalues to perturbations in the data.

The total number of floating point operations is proportional to ${n}^{3}$.
The real analogue of this routine is F08WAF (DGGEV).

## 9  Example

This example finds all the eigenvalues and right eigenvectors of the matrix pair $\left(A,B\right)$, where
 $A = -21.10-22.50i 53.50-50.50i -34.50+127.50i 7.50+00.50i -0.46-07.78i -3.50-37.50i -15.50+058.50i -10.50-01.50i 4.30-05.50i 39.70-17.10i -68.50+012.50i -7.50-03.50i 5.50+04.40i 14.40+43.30i -32.50-046.00i -19.00-32.50i$
and
 $B = 1.00-5.00i 1.60+1.20i -3.00+0.00i 0.00-1.00i 0.80-0.60i 3.00-5.00i -4.00+3.00i -2.40-3.20i 1.00+0.00i 2.40+1.80i -4.00-5.00i 0.00-3.00i 0.00+1.00i -1.80+2.40i 0.00-4.00i 4.00-5.00i .$
Note that the block size (NB) of $64$ assumed in this example is not realistic for such a small problem, but should be suitable for large problems.

### 9.1  Program Text

Program Text (f08wnfe.f90)

### 9.2  Program Data

Program Data (f08wnfe.d)

### 9.3  Program Results

Program Results (f08wnfe.r)