# NAG FL Interfacef08wff (dgghd3)

## ▸▿ Contents

Settings help

FL Name Style:

FL Specification Language:

## 1Purpose

f08wff reduces a pair of real matrices $\left(A,B\right)$, where $B$ is upper triangular, to the generalized upper Hessenberg form using orthogonal transformations.

## 2Specification

Fortran Interface
 Subroutine f08wff ( n, ilo, ihi, a, lda, b, ldb, q, ldq, z, ldz, work, info)
 Integer, Intent (In) :: n, ilo, ihi, lda, ldb, ldq, ldz, lwork Integer, Intent (Out) :: info Real (Kind=nag_wp), Intent (Inout) :: a(lda,*), b(ldb,*), q(ldq,*), z(ldz,*) Real (Kind=nag_wp), Intent (Out) :: work(max(1,lwork)) Character (1), Intent (In) :: compq, compz
#include <nag.h>
 void f08wff_ (const char *compq, const char *compz, const Integer *n, const Integer *ilo, const Integer *ihi, double a[], const Integer *lda, double b[], const Integer *ldb, double q[], const Integer *ldq, double z[], const Integer *ldz, double work[], const Integer *lwork, Integer *info, const Charlen length_compq, const Charlen length_compz)
The routine may be called by the names f08wff, nagf_lapackeig_dgghd3 or its LAPACK name dgghd3.

## 3Description

f08wff is the third step in the solution of the real generalized eigenvalue problem
 $Ax=λBx.$
The (optional) first step balances the two matrices using f08whf. In the second step, matrix $B$ is reduced to upper triangular form using the $QR$ factorization routine f08aef and this orthogonal transformation $Q$ is applied to matrix $A$ by calling f08agf. The driver, f08wcf, solves the real generalized eigenvalue problem by combining all the required steps including those just listed.
f08wff reduces a pair of real matrices $\left(A,B\right)$, where $B$ is upper triangular, to the generalized upper Hessenberg form using orthogonal transformations. This two-sided transformation is of the form
 $QTAZ=H, QTBZ=T$
where $H$ is an upper Hessenberg matrix, $T$ is an upper triangular matrix and $Q$ and $Z$ are orthogonal matrices determined as products of Givens rotations. They may either be formed explicitly, or they may be postmultiplied into input matrices ${Q}_{1}$ and ${Z}_{1}$, so that
 $Q1AZ1T=(Q1Q)H(Z1Z)T, Q1BZ1T=(Q1Q)T(Z1Z)T.$

## 4References

Golub G H and Van Loan C F (2012) Matrix Computations (4th 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

## 5Arguments

1: $\mathbf{compq}$Character(1) Input
On entry: specifies the form of the computed orthogonal matrix $Q$.
${\mathbf{compq}}=\text{'N'}$
Do not compute $Q$.
${\mathbf{compq}}=\text{'I'}$
The orthogonal matrix $Q$ is returned.
${\mathbf{compq}}=\text{'V'}$
q must contain an orthogonal matrix ${Q}_{1}$, and the product ${Q}_{1}Q$ is returned.
Constraint: ${\mathbf{compq}}=\text{'N'}$, $\text{'I'}$ or $\text{'V'}$.
2: $\mathbf{compz}$Character(1) Input
On entry: specifies the form of the computed orthogonal matrix $Z$.
${\mathbf{compz}}=\text{'N'}$
Do not compute $Z$.
${\mathbf{compz}}=\text{'I'}$
The orthogonal matrix $Z$ is returned.
${\mathbf{compz}}=\text{'V'}$
z must contain an orthogonal matrix ${Z}_{1}$, and the product ${Z}_{1}Z$ is returned.
Constraint: ${\mathbf{compz}}=\text{'N'}$, $\text{'V'}$ or $\text{'I'}$.
3: $\mathbf{n}$Integer Input
On entry: $n$, the order of the matrices $A$ and $B$.
Constraint: ${\mathbf{n}}\ge 0$.
4: $\mathbf{ilo}$Integer Input
5: $\mathbf{ihi}$Integer Input
On entry: ${i}_{\mathrm{lo}}$ and ${i}_{\mathrm{hi}}$ as determined by a previous call to f08whf. Otherwise, they should be set to $1$ and $n$, respectively.
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$.
6: $\mathbf{a}\left({\mathbf{lda}},*\right)$Real (Kind=nag_wp) array Input/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$ of the matrix pair $\left(A,B\right)$. Usually, this is the matrix $A$ returned by f08agf.
On exit: a is overwritten by the upper Hessenberg matrix $H$.
7: $\mathbf{lda}$Integer Input
On entry: the first dimension of the array a as declared in the (sub)program from which f08wff is called.
Constraint: ${\mathbf{lda}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
8: $\mathbf{b}\left({\mathbf{ldb}},*\right)$Real (Kind=nag_wp) array Input/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 upper triangular matrix $B$ of the matrix pair $\left(A,B\right)$. Usually, this is the matrix $B$ returned by the $QR$ factorization routine f08aef.
On exit: b is overwritten by the upper triangular matrix $T$.
9: $\mathbf{ldb}$Integer Input
On entry: the first dimension of the array b as declared in the (sub)program from which f08wff is called.
Constraint: ${\mathbf{ldb}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
10: $\mathbf{q}\left({\mathbf{ldq}},*\right)$Real (Kind=nag_wp) array Input/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{'I'}$ or $\text{'V'}$ and at least $1$ if ${\mathbf{compq}}=\text{'N'}$.
On entry: if ${\mathbf{compq}}=\text{'V'}$, q must contain an orthogonal matrix ${Q}_{1}$.
If ${\mathbf{compq}}=\text{'N'}$, q is not referenced.
On exit: if ${\mathbf{compq}}=\text{'I'}$, q contains the orthogonal matrix $Q$.
If ${\mathbf{compq}}=\text{'V'}$, q is overwritten by ${Q}_{1}Q$.
11: $\mathbf{ldq}$Integer Input
On entry: the first dimension of the array q as declared in the (sub)program from which f08wff is called.
Constraints:
• if ${\mathbf{compq}}=\text{'I'}$ or $\text{'V'}$, ${\mathbf{ldq}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$;
• if ${\mathbf{compq}}=\text{'N'}$, ${\mathbf{ldq}}\ge 1$.
12: $\mathbf{z}\left({\mathbf{ldz}},*\right)$Real (Kind=nag_wp) array Input/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'}$, z must contain an orthogonal matrix ${Z}_{1}$.
If ${\mathbf{compz}}=\text{'N'}$, z is not referenced.
On exit: if ${\mathbf{compz}}=\text{'I'}$, z contains the orthogonal matrix $Z$.
If ${\mathbf{compz}}=\text{'V'}$, z is overwritten by ${Z}_{1}Z$.
13: $\mathbf{ldz}$Integer Input
On entry: the first dimension of the array z as declared in the (sub)program from which f08wff is called.
Constraints:
• if ${\mathbf{compz}}=\text{'V'}$ or $\text{'I'}$, ${\mathbf{ldz}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$;
• if ${\mathbf{compz}}=\text{'N'}$, ${\mathbf{ldz}}\ge 1$.
14: $\mathbf{work}\left(\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{lwork}}\right)\right)$Real (Kind=nag_wp) array Workspace
On exit: if ${\mathbf{info}}={\mathbf{0}}$, ${\mathbf{work}}\left(1\right)$ contains the minimum value of lwork required for optimal performance.
15: $\mathbf{lwork}$Integer Input
On entry: the dimension of the array work as declared in the (sub)program from which f08wff 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, $6×\mathit{nb}×{\mathbf{n}}$, where $\mathit{nb}$ is the optimal block size.
16: $\mathbf{info}$Integer Output
On exit: ${\mathbf{info}}=0$ unless the routine detects an error (see Section 6).

## 6Error 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.

## 7Accuracy

The reduction to the generalized Hessenberg form is implemented using orthogonal transformations which are backward stable.

## 8Parallelism and Performance

This routine is usually followed by f08xef which implements the $QZ$ algorithm for computing generalized eigenvalues of a reduced pair of matrices.