# NAG C Library Function Document

## 1Purpose

nag_dhgeqz (f08xec) 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.

## 2Specification

 #include #include
 void nag_dhgeqz (Nag_OrderType order, Nag_JobType job, Nag_ComputeQType compq, Nag_ComputeZType compz, Integer n, Integer ilo, Integer ihi, double a[], Integer pda, double b[], Integer pdb, double alphar[], double alphai[], double beta[], double q[], Integer pdq, double z[], Integer pdz, NagError *fail)

## 3Description

nag_dhgeqz (f08xec) 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 function nag_dgghrd (f08wec) should be called before invoking nag_dhgeqz (f08xec).
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 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 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 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 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}}=\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 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}}=\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}$ and not ${\mathbf{compq}}\ne \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 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.
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_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.3.1.3 in How to Use the NAG Library and its Documentation 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_JobTypeInput
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_ComputeQTypeInput
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_ComputeZTypeInput
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}$IntegerInput
On entry: $n$, the order of the matrices $A$, $B$, $Q$ and $Z$.
Constraint: ${\mathbf{n}}\ge 0$.
6:    $\mathbf{ilo}$IntegerInput
7:    $\mathbf{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 arguments are provided by nag_dggbal (f08whc) 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]$doubleInput/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)$.
Where ${\mathbf{A}}\left(i,j\right)$ appears in this document, it refers to the array element
• ${\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$ by $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$ 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.
9:    $\mathbf{pda}$IntegerInput
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]$doubleInput/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)$.
Where ${\mathbf{B}}\left(i,j\right)$ appears in this document, it refers to the array element
• ${\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$ by $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$ 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.
11:  $\mathbf{pdb}$IntegerInput
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{alphar}\left[{\mathbf{n}}\right]$doubleOutput
On exit: the real parts of ${\alpha }_{\mathit{j}}$, for $\mathit{j}=1,2,\dots ,n$.
13:  $\mathbf{alphai}\left[{\mathbf{n}}\right]$doubleOutput
On exit: the imaginary parts of ${\alpha }_{\mathit{j}}$, for $\mathit{j}=1,2,\dots ,n$.
14:  $\mathbf{beta}\left[{\mathbf{n}}\right]$doubleOutput
On exit: ${\beta }_{\mathit{j}}$, for $\mathit{j}=1,2,\dots ,n$.
15:  $\mathbf{q}\left[\mathit{dim}\right]$doubleInput/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 nag_dgghrd (f08wec).
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$.
16:  $\mathbf{pdq}$IntegerInput
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$.
17:  $\mathbf{z}\left[\mathit{dim}\right]$doubleInput/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 nag_dgghrd (f08wec).
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$.
18:  $\mathbf{pdz}$IntegerInput
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$.
19:  $\mathbf{fail}$NagError *Input/Output
The NAG error argument (see Section 3.7 in How to Use the NAG Library and its Documentation).

## 6Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 2.3.1.2 in How to Use the NAG Library and its Documentation 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}}〉$, ${\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}}〉$, ${\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 2.7.6 in How to Use the NAG Library and its Documentation 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 2.7.5 in How to Use the NAG Library and its Documentation 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

nag_dhgeqz (f08xec) 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.

nag_dhgeqz (f08xec) is the fifth step in the solution of the real generalized eigenvalue problem and is called after nag_dgghrd (f08wec).
The complex analogue of this function is nag_zhgeqz (f08xsc).

## 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 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 functions: nag_dggbal (f08whc) to balance the matrix, nag_dgeqrf (f08aec) to perform the $QR$ factorization of $B$, nag_dormqr (f08agc) to apply $Q$ to $A$, nag_dgghrd (f08wec) to reduce the matrix pair to the generalized Hessenberg form and nag_dhgeqz (f08xec) to compute the eigenvalues using the $QZ$ algorithm.

### 10.1Program Text

Program Text (f08xece.c)

### 10.2Program Data

Program Data (f08xece.d)

### 10.3Program Results

Program Results (f08xece.r)