# NAG CL Interfacef08xsc (zhgeqz)

Settings help

CL Name Style:

## 1Purpose

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

## 2Specification

 #include
 void f08xsc (Nag_OrderType order, Nag_JobType job, Nag_ComputeQType compq, Nag_ComputeZType compz, Integer n, Integer ilo, Integer ihi, Complex a[], Integer pda, Complex b[], Integer pdb, Complex alpha[], Complex beta[], Complex q[], Integer pdq, Complex z[], Integer pdz, NagError *fail)
The function may be called by the names: f08xsc, nag_lapackeig_zhgeqz or nag_zhgeqz.

## 3Description

f08xsc implements a single-shift version of the $QZ$ method for finding the generalized eigenvalues of the complex 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 function f08wtc should be called before invoking f08xsc.
This problem is mathematically equivalent to solving the matrix equation
 $det(A-λB)=0.$
Note that, to avoid underflow, overflow and other arithmetic problems, the generalized eigenvalues ${\lambda }_{j}$ are never computed explicitly by this function but defined as ratios between two computed values, ${\alpha }_{j}$ and ${\beta }_{j}$:
 $λj=αj/βj.$
The arguments ${\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 matrices $A$ and $B$ are upper triangular and the diagonal values of $A$ and $B$ provide $\alpha$ and $\beta$.
The argument job specifies two options. If ${\mathbf{job}}=\mathrm{Nag_Schur}$ then the matrix pair $\left(A,B\right)$ is simultaneously reduced to Schur form by applying one unitary transformation (usually called $Q$) on the left and another (usually called $Z$) on the right. That is,
 $A←QHAZ B←QHBZ$
If ${\mathbf{job}}=\mathrm{Nag_EigVals}$, 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}}=\mathrm{Nag_Schur}$ and ${\mathbf{compq}}=\mathrm{Nag_AccumulateQ}$ or $\mathrm{Nag_InitQ}$, and ${\mathbf{compz}}=\mathrm{Nag_AccumulateZ}$ or $\mathrm{Nag_InitZ}$, then the unitary 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}}=\mathrm{Nag_Schur}$ and if left (right) generalized eigenvectors are to be computed then compq (compz) must be set to ${\mathbf{compq}}=\mathrm{Nag_AccumulateQ}$ or $\mathrm{Nag_InitQ}$ rather than ${\mathbf{compq}}=\mathrm{Nag_NotQ}$.
If ${\mathbf{compq}}=\mathrm{Nag_InitQ}$, then eigenvectors are accumulated on the identity matrix and on exit the array q contains the left eigenvector matrix $Q$. However, if ${\mathbf{compq}}=\mathrm{Nag_AccumulateQ}$ then the transformations are accumulated in 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.

## 4References

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

## 5Arguments

1: $\mathbf{order}$Nag_OrderType Input
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.1.3 in the Introduction to the NAG Library CL Interface for a more detailed explanation of the use of this argument.
Constraint: ${\mathbf{order}}=\mathrm{Nag_RowMajor}$ or $\mathrm{Nag_ColMajor}$.
2: $\mathbf{job}$Nag_JobType Input
On entry: specifies the operations to be performed on $\left(A,B\right)$.
${\mathbf{job}}=\mathrm{Nag_EigVals}$
The matrix pair $\left(A,B\right)$ on exit might not be in the generalized Schur form.
${\mathbf{job}}=\mathrm{Nag_Schur}$
The matrix pair $\left(A,B\right)$ on exit will be in the generalized Schur form.
Constraint: ${\mathbf{job}}=\mathrm{Nag_EigVals}$ or $\mathrm{Nag_Schur}$.
3: $\mathbf{compq}$Nag_ComputeQType Input
On entry: specifies the operations to be performed on $Q$:
${\mathbf{compq}}=\mathrm{Nag_NotQ}$
The array q is unchanged.
${\mathbf{compq}}=\mathrm{Nag_AccumulateQ}$
The left transformation $Q$ is accumulated on the array q.
${\mathbf{compq}}=\mathrm{Nag_InitQ}$
The array q is initialized to the identity matrix before the left transformation $Q$ is accumulated in q.
Constraint: ${\mathbf{compq}}=\mathrm{Nag_NotQ}$, $\mathrm{Nag_AccumulateQ}$ or $\mathrm{Nag_InitQ}$.
4: $\mathbf{compz}$Nag_ComputeZType Input
On entry: specifies the operations to be performed on $Z$.
${\mathbf{compz}}=\mathrm{Nag_NotZ}$
The array z is unchanged.
${\mathbf{compz}}=\mathrm{Nag_AccumulateZ}$
The right transformation $Z$ is accumulated on the array z.
${\mathbf{compz}}=\mathrm{Nag_InitZ}$
The array z is initialized to the identity matrix before the right transformation $Z$ is accumulated in z.
Constraint: ${\mathbf{compz}}=\mathrm{Nag_NotZ}$, $\mathrm{Nag_AccumulateZ}$ or $\mathrm{Nag_InitZ}$.
5: $\mathbf{n}$Integer Input
On entry: $n$, the order of the matrices $A$, $B$, $Q$ and $Z$.
Constraint: ${\mathbf{n}}\ge 0$.
6: $\mathbf{ilo}$Integer Input
7: $\mathbf{ihi}$Integer Input
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 arguments are provided by f08wvc 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$.
8: $\mathbf{a}\left[\mathit{dim}\right]$Complex Input/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 $n×n$ upper Hessenberg matrix $A$. The elements below the first subdiagonal must be set to zero.
On exit: if ${\mathbf{job}}=\mathrm{Nag_Schur}$, the matrix pair $\left(A,B\right)$ will be simultaneously reduced to generalized Schur form.
If ${\mathbf{job}}=\mathrm{Nag_EigVals}$, the $1×1$ and $2×2$ diagonal blocks of the matrix pair $\left(A,B\right)$ will give generalized eigenvalues but the remaining elements will be irrelevant.
9: $\mathbf{pda}$Integer Input
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)$.
10: $\mathbf{b}\left[\mathit{dim}\right]$Complex Input/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 $n×n$ upper triangular matrix $B$. The elements below the diagonal must be zero.
On exit: if ${\mathbf{job}}=\mathrm{Nag_Schur}$, the matrix pair $\left(A,B\right)$ will be simultaneously reduced to generalized Schur form.
If ${\mathbf{job}}=\mathrm{Nag_EigVals}$, the $1×1$ and $2×2$ diagonal blocks of the matrix pair $\left(A,B\right)$ will give generalized eigenvalues but the remaining elements will be irrelevant.
11: $\mathbf{pdb}$Integer Input
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)$.
12: $\mathbf{alpha}\left[{\mathbf{n}}\right]$Complex Output
On exit: ${\alpha }_{\mathit{j}}$, for $\mathit{j}=1,2,\dots ,n$.
13: $\mathbf{beta}\left[{\mathbf{n}}\right]$Complex Output
On exit: ${\beta }_{\mathit{j}}$, for $\mathit{j}=1,2,\dots ,n$.
14: $\mathbf{q}\left[\mathit{dim}\right]$Complex Input/Output
Note: the dimension, dim, of the array q must be at least
• $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{pdq}}×{\mathbf{n}}\right)$ when ${\mathbf{compq}}=\mathrm{Nag_AccumulateQ}$ or $\mathrm{Nag_InitQ}$;
• $1$ when ${\mathbf{compq}}=\mathrm{Nag_NotQ}$.
The $\left(i,j\right)$th element of the matrix $Q$ is stored in
• ${\mathbf{q}}\left[\left(j-1\right)×{\mathbf{pdq}}+i-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_ColMajor}$;
• ${\mathbf{q}}\left[\left(i-1\right)×{\mathbf{pdq}}+j-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_RowMajor}$.
On entry: if ${\mathbf{compq}}=\mathrm{Nag_AccumulateQ}$, the matrix ${Q}_{0}$. The matrix ${Q}_{0}$ is usually the matrix $Q$ returned by f08wtc.
If ${\mathbf{compq}}=\mathrm{Nag_NotQ}$, q is not referenced.
On exit: if ${\mathbf{compq}}=\mathrm{Nag_AccumulateQ}$, q contains the matrix product $Q{Q}_{0}$.
If ${\mathbf{compq}}=\mathrm{Nag_InitQ}$, q contains the transformation matrix $Q$.
15: $\mathbf{pdq}$Integer Input
On entry: the stride separating row or column elements (depending on the value of order) in the array q.
Constraints:
• if ${\mathbf{order}}=\mathrm{Nag_ColMajor}$,
• if ${\mathbf{compq}}=\mathrm{Nag_AccumulateQ}$ or $\mathrm{Nag_InitQ}$, ${\mathbf{pdq}}\ge {\mathbf{n}}$;
• if ${\mathbf{compq}}=\mathrm{Nag_NotQ}$, ${\mathbf{pdq}}\ge 1$;
• if ${\mathbf{order}}=\mathrm{Nag_RowMajor}$,
• if ${\mathbf{compq}}=\mathrm{Nag_AccumulateQ}$ or $\mathrm{Nag_InitQ}$, ${\mathbf{pdq}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$;
• if ${\mathbf{compq}}=\mathrm{Nag_NotQ}$, ${\mathbf{pdq}}\ge 1$.
16: $\mathbf{z}\left[\mathit{dim}\right]$Complex Input/Output
Note: the dimension, dim, of the array z must be at least
• $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{pdz}}×{\mathbf{n}}\right)$ when ${\mathbf{compz}}=\mathrm{Nag_AccumulateZ}$ or $\mathrm{Nag_InitZ}$;
• $1$ when ${\mathbf{compz}}=\mathrm{Nag_NotZ}$.
The $\left(i,j\right)$th element of the matrix $Z$ is stored in
• ${\mathbf{z}}\left[\left(j-1\right)×{\mathbf{pdz}}+i-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_ColMajor}$;
• ${\mathbf{z}}\left[\left(i-1\right)×{\mathbf{pdz}}+j-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_RowMajor}$.
On entry: if ${\mathbf{compz}}=\mathrm{Nag_AccumulateZ}$, the matrix ${Z}_{0}$. The matrix ${Z}_{0}$ is usually the matrix $Z$ returned by f08wtc.
If ${\mathbf{compz}}=\mathrm{Nag_NotZ}$, z is not referenced.
On exit: if ${\mathbf{compz}}=\mathrm{Nag_AccumulateZ}$, z contains the matrix product $Z{Z}_{0}$.
If ${\mathbf{compz}}=\mathrm{Nag_InitZ}$, z contains the transformation matrix $Z$.
17: $\mathbf{pdz}$Integer Input
On entry: the stride separating row or column elements (depending on the value of order) in the array z.
Constraints:
• if ${\mathbf{order}}=\mathrm{Nag_ColMajor}$,
• if ${\mathbf{compz}}=\mathrm{Nag_AccumulateZ}$ or $\mathrm{Nag_InitZ}$, ${\mathbf{pdz}}\ge {\mathbf{n}}$;
• if ${\mathbf{compz}}=\mathrm{Nag_NotZ}$, ${\mathbf{pdz}}\ge 1$;
• if ${\mathbf{order}}=\mathrm{Nag_RowMajor}$,
• if ${\mathbf{compz}}=\mathrm{Nag_AccumulateZ}$ or $\mathrm{Nag_InitZ}$, ${\mathbf{pdz}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$;
• if ${\mathbf{compz}}=\mathrm{Nag_NotZ}$, ${\mathbf{pdz}}\ge 1$.
18: $\mathbf{fail}$NagError * Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).

## 6Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 3.1.2 in the Introduction to the NAG Library CL Interface for further information.
On entry, argument $⟨\mathit{\text{value}}⟩$ had an illegal value.
NE_ENUM_INT_2
On entry, ${\mathbf{compq}}=⟨\mathit{\text{value}}⟩$, ${\mathbf{pdq}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: if ${\mathbf{compq}}=\mathrm{Nag_AccumulateQ}$ or $\mathrm{Nag_InitQ}$, ${\mathbf{pdq}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$;
if ${\mathbf{compq}}=\mathrm{Nag_NotQ}$, ${\mathbf{pdq}}\ge 1$.
On entry, ${\mathbf{compq}}=⟨\mathit{\text{value}}⟩$, ${\mathbf{pdq}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: if ${\mathbf{compq}}=\mathrm{Nag_AccumulateQ}$ or $\mathrm{Nag_InitQ}$, ${\mathbf{pdq}}\ge {\mathbf{n}}$;
if ${\mathbf{compq}}=\mathrm{Nag_NotQ}$, ${\mathbf{pdq}}\ge 1$.
On entry, ${\mathbf{compz}}=⟨\mathit{\text{value}}⟩$, ${\mathbf{pdz}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: if ${\mathbf{compz}}=\mathrm{Nag_AccumulateZ}$ or $\mathrm{Nag_InitZ}$, ${\mathbf{pdz}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$;
if ${\mathbf{compz}}=\mathrm{Nag_NotZ}$, ${\mathbf{pdz}}\ge 1$.
On entry, ${\mathbf{compz}}=⟨\mathit{\text{value}}⟩$, ${\mathbf{pdz}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: if ${\mathbf{compz}}=\mathrm{Nag_AccumulateZ}$ or $\mathrm{Nag_InitZ}$, ${\mathbf{pdz}}\ge {\mathbf{n}}$;
if ${\mathbf{compz}}=\mathrm{Nag_NotZ}$, ${\mathbf{pdz}}\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{pdq}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{pdq}}>0$.
On entry, ${\mathbf{pdz}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{pdz}}>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_INT_3
On entry, ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$, ${\mathbf{ilo}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{ihi}}=⟨\mathit{\text{value}}⟩$.
Constraint: 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$.
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.
See Section 7.5 in the Introduction to the NAG Library CL Interface for further information.
An unexpected Library error has occurred.
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}}⟩$.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library CL Interface for further information.
NE_SCHUR
The computation of shifts failed 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}}⟩$.

## 7Accuracy

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.

## 8Parallelism and Performance

f08xsc 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 function. Please also consult the Users' Note for your implementation for any additional implementation-specific information.

f08xsc is the fifth step in the solution of the complex generalized eigenvalue problem and is called after f08wtc.
The number of floating-point operations taken by this function is proportional to ${n}^{3}$.
The real analogue of this function is f08xec.

## 10Example

This example computes the $\alpha$ and $\beta$ arguments, which defines the generalized eigenvalues, of the matrix pair $\left(A,B\right)$ given by
 $A = ( 1.0+3.0i 1.0+4.0i 1.0+5.0i 1.0+6.0i 2.0+2.0i 4.0+3.0i 8.0+4.0i 16.0+5.0i 3.0+1.0i 9.0+2.0i 27.0+3.0i 81.0+4.0i 4.0+0.0i 16.0+1.0i 64.0+2.0i 256.0+3.0i )$
and
 $B = ( 1.0+0.0i 2.0+1.0i 3.0+2.0i 4.0+3.0i 1.0+1.0i 4.0+2.0i 9.0+3.0i 16.0+4.0i 1.0+2.0i 8.0+3.0i 27.0+4.0i 64.0+5.0i 1.0+3.0i 16.0+4.0i 81.0+5.0i 256.0+6.0i ) .$
This requires calls to five functions: f08wvc to balance the matrix, f08asc to perform the $QR$ factorization of $B$, f08auc to apply $Q$ to $A$, f08wtc to reduce the matrix pair to the generalized Hessenberg form and f08xsc to compute the eigenvalues using the $QZ$ algorithm.

### 10.1Program Text

Program Text (f08xsce.c)

### 10.2Program Data

Program Data (f08xsce.d)

### 10.3Program Results

Program Results (f08xsce.r)