f08 Chapter Contents
f08 Chapter Introduction
NAG Library Manual

# NAG Library Function Documentnag_zgges (f08xnc)

## 1  Purpose

nag_zgges (f08xnc) computes the generalized eigenvalues, the generalized Schur form $\left(S,T\right)$ and, optionally, the left and/or right generalized Schur vectors for a pair of $n$ by $n$ complex nonsymmetric matrices $\left(A,B\right)$.

## 2  Specification

 #include #include
void  nag_zgges (Nag_OrderType order, Nag_LeftVecsType jobvsl, Nag_RightVecsType jobvsr, Nag_SortEigValsType sort,
 Nag_Boolean (*selctg)(Complex a, Complex b),
Integer n, Complex a[], Integer pda, Complex b[], Integer pdb, Integer *sdim, Complex alpha[], Complex beta[], Complex vsl[], Integer pdvsl, Complex vsr[], Integer pdvsr, NagError *fail)

## 3  Description

The generalized Schur factorization for a pair of complex matrices $\left(A,B\right)$ is given by
 $A = QSZH , B = QTZH ,$
where $Q$ and $Z$ are unitary, $T$ and $S$ are upper triangular. The generalized eigenvalues, $\lambda$, of $\left(A,B\right)$ are computed from the diagonals of $T$ and $S$ and satisfy
 $Az = λBz ,$
where $z$ is the corresponding generalized eigenvector. $\lambda$ is actually returned as the pair $\left(\alpha ,\beta \right)$ such that
 $λ = α/β$
since $\beta$, or even both $\alpha$ and $\beta$ can be zero. The columns of $Q$ and $Z$ are the left and right generalized Schur vectors of $\left(A,B\right)$.
Optionally, nag_zgges (f08xnc) can order the generalized eigenvalues on the diagonals of $\left(S,T\right)$ so that selected eigenvalues are at the top left. The leading columns of $Q$ and $Z$ then form an orthonormal basis for the corresponding eigenspaces, the deflating subspaces.
nag_zgges (f08xnc) computes $T$ to have real non-negative diagonal entries. The generalized Schur factorization, before reordering, is computed by the $QZ$ algorithm.

## 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

## 5  Arguments

1:     orderNag_OrderTypeInput
On entry: the order argument specifies the two-dimensional storage scheme being used, i.e., row-major ordering or column-major ordering. C language defined storage is specified by ${\mathbf{order}}=\mathrm{Nag_RowMajor}$. See Section 3.2.1.3 in the Essential Introduction for a more detailed explanation of the use of this argument.
Constraint: ${\mathbf{order}}=\mathrm{Nag_RowMajor}$ or $\mathrm{Nag_ColMajor}$.
2:     jobvslNag_LeftVecsTypeInput
On entry: if ${\mathbf{jobvsl}}=\mathrm{Nag_NotLeftVecs}$, do not compute the left Schur vectors.
If ${\mathbf{jobvsl}}=\mathrm{Nag_LeftVecs}$, compute the left Schur vectors.
Constraint: ${\mathbf{jobvsl}}=\mathrm{Nag_NotLeftVecs}$ or $\mathrm{Nag_LeftVecs}$.
3:     jobvsrNag_RightVecsTypeInput
On entry: if ${\mathbf{jobvsr}}=\mathrm{Nag_NotRightVecs}$, do not compute the right Schur vectors.
If ${\mathbf{jobvsr}}=\mathrm{Nag_RightVecs}$, compute the right Schur vectors.
Constraint: ${\mathbf{jobvsr}}=\mathrm{Nag_NotRightVecs}$ or $\mathrm{Nag_RightVecs}$.
4:     sortNag_SortEigValsTypeInput
On entry: specifies whether or not to order the eigenvalues on the diagonal of the generalized Schur form.
${\mathbf{sort}}=\mathrm{Nag_NoSortEigVals}$
Eigenvalues are not ordered.
${\mathbf{sort}}=\mathrm{Nag_SortEigVals}$
Eigenvalues are ordered (see selctg).
Constraint: ${\mathbf{sort}}=\mathrm{Nag_NoSortEigVals}$ or $\mathrm{Nag_SortEigVals}$.
5:     selctgfunction, supplied by the userExternal Function
If ${\mathbf{sort}}=\mathrm{Nag_SortEigVals}$, selctg is used to select generalized eigenvalues to the top left of the generalized Schur form.
If ${\mathbf{sort}}=\mathrm{Nag_NoSortEigVals}$, selctg is not referenced by nag_zgges (f08xnc), and may be specified as NULLFN.
The specification of selctg is:
 Nag_Boolean selctg (Complex a, Complex b)
1:     aComplexInput
2:     bComplexInput
On entry: an eigenvalue ${\mathbf{a}}\left[j-1\right]/{\mathbf{b}}\left[j-1\right]$ is selected if ${\mathbf{selctg}}\left({\mathbf{a}}\left[j-1\right],{\mathbf{b}}\left[j-1\right]\right)$ is Nag_TRUE.
Note that in the ill-conditioned case, a selected generalized eigenvalue may no longer satisfy ${\mathbf{selctg}}\left({\mathbf{a}}\left[j-1\right],{\mathbf{b}}\left[j-1\right]\right)=\mathrm{Nag_TRUE}$ after ordering. ${\mathbf{fail}}\mathbf{.}\mathbf{code}=$ NE_SCHUR_REORDER_SELECT in this case.
6:     nIntegerInput
On entry: $n$, the order of the matrices $A$ and $B$.
Constraint: ${\mathbf{n}}\ge 0$.
7:     a[$\mathit{dim}$]ComplexInput/Output
Note: the dimension, dim, of the array a must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{pda}}×{\mathbf{n}}\right)$.
The $\left(i,j\right)$th element of the matrix $A$ is stored in
• ${\mathbf{a}}\left[\left(j-1\right)×{\mathbf{pda}}+i-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_ColMajor}$;
• ${\mathbf{a}}\left[\left(i-1\right)×{\mathbf{pda}}+j-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_RowMajor}$.
On entry: the first of the pair of matrices, $A$.
On exit: a has been overwritten by its generalized Schur form $S$.
8:     pdaIntegerInput
On entry: the stride separating row or column elements (depending on the value of order) in the array a.
Constraint: ${\mathbf{pda}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
9:     b[$\mathit{dim}$]ComplexInput/Output
Note: the dimension, dim, of the array b must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{pdb}}×{\mathbf{n}}\right)$.
The $\left(i,j\right)$th element of the matrix $B$ is stored in
• ${\mathbf{b}}\left[\left(j-1\right)×{\mathbf{pdb}}+i-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_ColMajor}$;
• ${\mathbf{b}}\left[\left(i-1\right)×{\mathbf{pdb}}+j-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_RowMajor}$.
On entry: the second of the pair of matrices, $B$.
On exit: b has been overwritten by its generalized Schur form $T$.
10:   pdbIntegerInput
On entry: the stride separating row or column elements (depending on the value of order) in the array b.
Constraint: ${\mathbf{pdb}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
11:   sdimInteger *Output
On exit: if ${\mathbf{sort}}=\mathrm{Nag_NoSortEigVals}$, ${\mathbf{sdim}}=0$.
If ${\mathbf{sort}}=\mathrm{Nag_SortEigVals}$, ${\mathbf{sdim}}=\text{}$ number of eigenvalues (after sorting) for which selctg is Nag_TRUE.
12:   alpha[n]ComplexOutput
On exit: see the description of beta.
13:   beta[n]ComplexOutput
On exit: ${\mathbf{alpha}}\left[\mathit{j}-1\right]/{\mathbf{beta}}\left[\mathit{j}-1\right]$, for $\mathit{j}=1,2,\dots ,{\mathbf{n}}$, will be the generalized eigenvalues. ${\mathbf{alpha}}\left[\mathit{j}-1\right]$, for $\mathit{j}=1,2,\dots ,{\mathbf{n}}$ and ${\mathbf{beta}}\left[\mathit{j}-1\right]$, for $\mathit{j}=1,2,\dots ,{\mathbf{n}}$, are the diagonals of the complex Schur form $\left(A,B\right)$ output by nag_zgges (f08xnc). The ${\mathbf{beta}}\left[j-1\right]$ will be non-negative real.
Note:  the quotients ${\mathbf{alpha}}\left[j-1\right]/{\mathbf{beta}}\left[j-1\right]$ may easily overflow or underflow, and ${\mathbf{beta}}\left[j-1\right]$ may even be zero. Thus, you should avoid naively computing the ratio $\alpha /\beta$. However, alpha will always be less than and usually comparable with $‖{\mathbf{a}}‖$ in magnitude, and beta will always be less than and usually comparable with $‖{\mathbf{b}}‖$.
14:   vsl[$\mathit{dim}$]ComplexOutput
Note: the dimension, dim, of the array vsl must be at least
• $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{pdvsl}}×{\mathbf{n}}\right)$ when ${\mathbf{jobvsl}}=\mathrm{Nag_LeftVecs}$;
• $1$ otherwise.
The $\left(i,j\right)$th element of the matrix is stored in
• ${\mathbf{vsl}}\left[\left(j-1\right)×{\mathbf{pdvsl}}+i-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_ColMajor}$;
• ${\mathbf{vsl}}\left[\left(i-1\right)×{\mathbf{pdvsl}}+j-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_RowMajor}$.
On exit: if ${\mathbf{jobvsl}}=\mathrm{Nag_LeftVecs}$, vsl will contain the left Schur vectors, $Q$.
If ${\mathbf{jobvsl}}=\mathrm{Nag_NotLeftVecs}$, vsl is not referenced.
15:   pdvslIntegerInput
On entry: the stride separating row or column elements (depending on the value of order) in the array vsl.
Constraints:
• if ${\mathbf{jobvsl}}=\mathrm{Nag_LeftVecs}$, ${\mathbf{pdvsl}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$;
• otherwise ${\mathbf{pdvsl}}\ge 1$.
16:   vsr[$\mathit{dim}$]ComplexOutput
Note: the dimension, dim, of the array vsr must be at least
• $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{pdvsr}}×{\mathbf{n}}\right)$ when ${\mathbf{jobvsr}}=\mathrm{Nag_RightVecs}$;
• $1$ otherwise.
The $\left(i,j\right)$th element of the matrix is stored in
• ${\mathbf{vsr}}\left[\left(j-1\right)×{\mathbf{pdvsr}}+i-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_ColMajor}$;
• ${\mathbf{vsr}}\left[\left(i-1\right)×{\mathbf{pdvsr}}+j-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_RowMajor}$.
On exit: if ${\mathbf{jobvsr}}=\mathrm{Nag_RightVecs}$, vsr will contain the right Schur vectors, $Z$.
If ${\mathbf{jobvsr}}=\mathrm{Nag_NotRightVecs}$, vsr is not referenced.
17:   pdvsrIntegerInput
On entry: the stride separating row or column elements (depending on the value of order) in the array vsr.
Constraints:
• if ${\mathbf{jobvsr}}=\mathrm{Nag_RightVecs}$, ${\mathbf{pdvsr}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$;
• otherwise ${\mathbf{pdvsr}}\ge 1$.
18:   failNagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).

## 6  Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
On entry, argument $⟨\mathit{\text{value}}⟩$ had an illegal value.
NE_ENUM_INT_2
On entry, ${\mathbf{jobvsl}}=⟨\mathit{\text{value}}⟩$, ${\mathbf{pdvsl}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: if ${\mathbf{jobvsl}}=\mathrm{Nag_LeftVecs}$, ${\mathbf{pdvsl}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$;
otherwise ${\mathbf{pdvsl}}\ge 1$.
On entry, ${\mathbf{jobvsr}}=⟨\mathit{\text{value}}⟩$, ${\mathbf{pdvsr}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: if ${\mathbf{jobvsr}}=\mathrm{Nag_RightVecs}$, ${\mathbf{pdvsr}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$;
otherwise ${\mathbf{pdvsr}}\ge 1$.
NE_INT
On entry, ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{n}}\ge 0$.
On entry, ${\mathbf{pda}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{pda}}>0$.
On entry, ${\mathbf{pdb}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{pdb}}>0$.
On entry, ${\mathbf{pdvsl}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{pdvsl}}>0$.
On entry, ${\mathbf{pdvsr}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{pdvsr}}>0$.
NE_INT_2
On entry, ${\mathbf{pda}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{pda}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
On entry, ${\mathbf{pdb}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{pdb}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
NE_ITERATION_QZ
The $QZ$ iteration did not converge and the matrix pair $\left(A,B\right)$ is not in the generalized Schur form. The computed ${\alpha }_{i}$ and ${\beta }_{i}$ should be correct for $i=⟨\mathit{\text{value}}⟩,\dots ,⟨\mathit{\text{value}}⟩$.
The $QZ$ iteration failed with an unexpected error, please contact NAG.
NE_SCHUR_REORDER
The eigenvalues could not be reordered because some eigenvalues were too close to separate (the problem is very ill-conditioned).
NE_SCHUR_REORDER_SELECT
After reordering, roundoff changed values of some complex eigenvalues so that leading eigenvalues in the generalized Schur form no longer satisfy ${\mathbf{selctg}}=\mathrm{Nag_TRUE}$. This could also be caused by underflow due to scaling.

## 7  Accuracy

The computed generalized Schur factorization satisfies
 $A+E = QS ZH , B+F = QT ZH ,$
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.

## 8  Parallelism and Performance

nag_zgges (f08xnc) is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
nag_zgges (f08xnc) 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.

The total number of floating-point operations is proportional to ${n}^{3}$.
The real analogue of this function is nag_dgges (f08xac).

## 10  Example

This example finds the generalized Schur factorization 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 .$

### 10.1  Program Text

Program Text (f08xnce.c)

### 10.2  Program Data

Program Data (f08xnce.d)

### 10.3  Program Results

Program Results (f08xnce.r)