NAG FL Interface
f08pef (dhseqr)
1
Purpose
f08pef computes all the eigenvalues and, optionally, the Schur factorization of a real Hessenberg matrix or a real general matrix which has been reduced to Hessenberg form.
2
Specification
Fortran Interface
Subroutine f08pef ( 
job, compz, n, ilo, ihi, h, ldh, wr, wi, z, ldz, work, lwork, info) 
Integer, Intent (In) 
:: 
n, ilo, ihi, ldh, ldz, lwork 
Integer, Intent (Out) 
:: 
info 
Real (Kind=nag_wp), Intent (Inout) 
:: 
h(ldh,*), wr(*), wi(*), z(ldz,*) 
Real (Kind=nag_wp), Intent (Out) 
:: 
work(max(1,lwork)) 
Character (1), Intent (In) 
:: 
job, compz 

C Header Interface
#include <nag.h>
void 
f08pef_ (const char *job, const char *compz, const Integer *n, const Integer *ilo, const Integer *ihi, double h[], const Integer *ldh, double wr[], double wi[], double z[], const Integer *ldz, double work[], const Integer *lwork, Integer *info, const Charlen length_job, const Charlen length_compz) 

C++ Header Interface
#include <nag.h> extern "C" {
void 
f08pef_ (const char *job, const char *compz, const Integer &n, const Integer &ilo, const Integer &ihi, double h[], const Integer &ldh, double wr[], double wi[], double z[], const Integer &ldz, double work[], const Integer &lwork, Integer &info, const Charlen length_job, const Charlen length_compz) 
}

The routine may be called by the names f08pef, nagf_lapackeig_dhseqr or its LAPACK name dhseqr.
3
Description
f08pef computes all the eigenvalues and, optionally, the Schur factorization of a real upper Hessenberg matrix
$H$:
where
$T$ is an upper quasitriangular matrix (the Schur form of
$H$), and
$Z$ is the orthogonal matrix whose columns are the Schur vectors
${z}_{i}$. See
Section 9 for details of the structure of
$T$.
The routine may also be used to compute the Schur factorization of a real general matrix
$A$ which has been reduced to upper Hessenberg form
$H$:
In this case, after
f08nef has been called to reduce
$A$ to Hessenberg form,
f08nff must be called to form
$Q$ explicitly;
$Q$ is then passed to
f08pef, which must be called with
${\mathbf{compz}}=\text{'V'}$.
The routine can also take advantage of a previous call to
f08nhf which may have balanced the original matrix before reducing it to Hessenberg form, so that the Hessenberg matrix
$H$ has the structure:
where
${H}_{11}$ and
${H}_{33}$ are upper triangular. If so, only the central diagonal block
${H}_{22}$ (in rows and columns
${i}_{\mathrm{lo}}$ to
${i}_{\mathrm{hi}}$) needs to be further reduced to Schur form (the blocks
${H}_{12}$ and
${H}_{23}$ are also affected). Therefore the values of
${i}_{\mathrm{lo}}$ and
${i}_{\mathrm{hi}}$ can be supplied to
f08pef directly. Also,
f08njf must be called after this routine to permute the Schur vectors of the balanced matrix to those of the original matrix. If
f08nhf has not been called however, then
${i}_{\mathrm{lo}}$ must be set to
$1$ and
${i}_{\mathrm{hi}}$ to
$n$. Note that if the Schur factorization of
$A$ is required,
f08nhf must
not be called with
${\mathbf{job}}=\text{'S'}$ or
$\text{'B'}$, because the balancing transformation is not orthogonal.
f08pef uses a multishift form of the upper Hessenberg
$QR$ algorithm, due to
Bai and Demmel (1989). The Schur vectors are normalized so that
${\Vert {z}_{i}\Vert}_{2}=1$, but are determined only to within a factor
$\pm 1$.
4
References
Bai Z and Demmel J W (1989) On a block implementation of Hessenberg multishift $QR$ iteration Internat. J. High Speed Comput. 1 97–112
Golub G H and Van Loan C F (1996) Matrix Computations (3rd Edition) Johns Hopkins University Press, Baltimore
5
Arguments

1:
$\mathbf{job}$ – Character(1)
Input

On entry: indicates whether eigenvalues only or the Schur form
$T$ is required.
 ${\mathbf{job}}=\text{'E'}$
 Eigenvalues only are required.
 ${\mathbf{job}}=\text{'S'}$
 The Schur form $T$ is required.
Constraint:
${\mathbf{job}}=\text{'E'}$ or $\text{'S'}$.

2:
$\mathbf{compz}$ – Character(1)
Input

On entry: indicates whether the Schur vectors are to be computed.
 ${\mathbf{compz}}=\text{'N'}$
 No Schur vectors are computed (and the array z is not referenced).
 ${\mathbf{compz}}=\text{'V'}$
 The Schur vectors of $A$ are computed (and the array z must contain the matrix $Q$ on entry).
 ${\mathbf{compz}}=\text{'I'}$
 The Schur vectors of $H$ are computed (and the array z is initialized by the routine).
Constraint:
${\mathbf{compz}}=\text{'N'}$, $\text{'V'}$ or $\text{'I'}$.

3:
$\mathbf{n}$ – Integer
Input

On entry: $n$, the order of the matrix $H$.
Constraint:
${\mathbf{n}}\ge 0$.

4:
$\mathbf{ilo}$ – Integer
Input

5:
$\mathbf{ihi}$ – Integer
Input

On entry: if the matrix
$A$ has been balanced by
f08nhf,
ilo and
ihi must contain the values returned by that routine. Otherwise,
ilo must be set to
$1$ and
ihi to
n.
Constraint:
${\mathbf{ilo}}\ge 1$ and $\mathrm{min}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{ilo}},{\mathbf{n}}\right)\le {\mathbf{ihi}}\le {\mathbf{n}}$.

6:
$\mathbf{h}\left({\mathbf{ldh}},*\right)$ – Real (Kind=nag_wp) array
Input/Output

Note: the second dimension of the array
h
must be at least
$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
On entry: the
$n$ by
$n$ upper Hessenberg matrix
$H$, as returned by
f08nef.
On exit: if
${\mathbf{job}}=\text{'E'}$, the array contains no useful information.
If
${\mathbf{job}}=\text{'S'}$,
h is overwritten by the upper quasitriangular matrix
$T$ from the Schur decomposition (the Schur form) unless
${\mathbf{info}}>{\mathbf{0}}$.

7:
$\mathbf{ldh}$ – Integer
Input

On entry: the first dimension of the array
h as declared in the (sub)program from which
f08pef is called.
Constraint:
${\mathbf{ldh}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.

8:
$\mathbf{wr}\left(*\right)$ – Real (Kind=nag_wp) array
Output

9:
$\mathbf{wi}\left(*\right)$ – Real (Kind=nag_wp) array
Output

Note: the dimension of the arrays
wr and
wi
must be at least
$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
On exit: the real and imaginary parts, respectively, of the computed eigenvalues, unless
${\mathbf{info}}>{\mathbf{0}}$ (in which case see
Section 6). Complex conjugate pairs of eigenvalues appear consecutively with the eigenvalue having positive imaginary part first. The eigenvalues are stored in the same order as on the diagonal of the Schur form
$T$ (if computed); see
Section 9 for details.

10:
$\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 the orthogonal matrix
$Q$ from the reduction to Hessenberg form.
If
${\mathbf{compz}}=\text{'I'}$,
z need not be set.
On exit: if
${\mathbf{compz}}=\text{'V'}$ or
$\text{'I'}$,
z contains the orthogonal matrix of the required Schur vectors, unless
${\mathbf{info}}>{\mathbf{0}}$.
If
${\mathbf{compz}}=\text{'N'}$,
z is not referenced.

11:
$\mathbf{ldz}$ – Integer
Input

On entry: the first dimension of the array
z as declared in the (sub)program from which
f08pef 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$.

12:
$\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.

13:
$\mathbf{lwork}$ – Integer
Input

On entry: the dimension of the array
work as declared in the (sub)program from which
f08pef is called, unless
${\mathbf{lwork}}=1$, in which case a workspace query is assumed and the routine only calculates the minimum dimension of
work.
Constraint:
${\mathbf{lwork}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$ or ${\mathbf{lwork}}=1$.

14:
$\mathbf{info}$ – Integer
Output

On exit:
${\mathbf{info}}=0$ unless the routine detects an error (see
Section 6).
6
Error 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.
 ${\mathbf{info}}>0$

The algorithm has failed to find all the eigenvalues after a total of
$30\left({\mathbf{ihi}}{\mathbf{ilo}}+1\right)$ iterations.
If
${\mathbf{info}}=i$, elements
$1,2,\dots ,{\mathbf{ilo}}1$ and
$i+1,i+2,\dots ,n$ of
wr and
wi contain the real and imaginary parts of contain the eigenvalues which have been found.
If
${\mathbf{job}}=\text{'E'}$, then on exit, the remaining unconverged eigenvalues are the eigenvalues of the upper Hessenberg matrix
$\hat{H}$, formed from
${\mathbf{h}}\left({\mathbf{ilo}}:{\mathbf{info}},{\mathbf{ilo}}:{\mathbf{info}}\right)$, i.e., the
ilo through
info rows and columns of the final output matrix
$H$.
If
${\mathbf{job}}=\text{'S'}$, then on exit
for some matrix
$U$, where
${H}_{i}$ is the input upper Hessenberg matrix and
$\stackrel{~}{H}$ is an upper Hessenberg matrix formed from
${\mathbf{h}}\left({\mathbf{info}}+1:{\mathbf{ihi}},{\mathbf{info}}+1:{\mathbf{ihi}}\right)$.
If
${\mathbf{compz}}=\text{'V'}$, then on exit
where
$U$ is defined in
$\left(*\right)$ (regardless of the value of
job).
If
${\mathbf{compz}}=\text{'I'}$, then on exit
where
$U$ is defined in
$\left(*\right)$ (regardless of the value of
job).
If
${\mathbf{info}}>{\mathbf{0}}$ and
${\mathbf{compz}}=\text{'N'}$,
z is not accessed.
7
Accuracy
The computed Schur factorization is the exact factorization of a nearby matrix
$\left(H+E\right)$, where
and
$\epsilon $ is the
machine precision.
If
${\lambda}_{i}$ is an exact eigenvalue, and
${\stackrel{~}{\lambda}}_{i}$ is the corresponding computed value, then
where
$c\left(n\right)$ is a modestly increasing function of
$n$, and
${s}_{i}$ is the reciprocal condition number of
${\lambda}_{i}$. The condition numbers
${s}_{i}$ may be computed by calling
f08qlf.
8
Parallelism and Performance
f08pef is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
f08pef 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 routine. Please also consult the
Users' Note for your implementation for any additional implementationspecific information.
The total number of floatingpoint operations depends on how rapidly the algorithm converges, but is typically about:
 $7{n}^{3}$ if only eigenvalues are computed;
 $10{n}^{3}$ if the Schur form is computed;
 $20{n}^{3}$ if the full Schur factorization is computed.
The Schur form $T$ has the following structure (referred to as canonical Schur form).
If all the computed eigenvalues are real, $T$ is upper triangular, and the diagonal elements of $T$ are the eigenvalues; ${\mathbf{wr}}\left(\mathit{i}\right)={t}_{\mathit{i}\mathit{i}}$, for $\mathit{i}=1,2,\dots ,n$, and ${\mathbf{wi}}\left(i\right)=0.0$.
If some of the computed eigenvalues form complex conjugate pairs, then
$T$ has
$2$ by
$2$ diagonal blocks. Each diagonal block has the form
where
$\beta \gamma <0$. The corresponding eigenvalues are
$\alpha \pm \sqrt{\beta \gamma}$;
${\mathbf{wr}}\left(i\right)={\mathbf{wr}}\left(i+1\right)=\alpha $;
${\mathbf{wi}}\left(i\right)=+\sqrt{\left\beta \gamma \right}$;
${\mathbf{wi}}\left(i+1\right)={\mathbf{wi}}\left(i\right)$.
The complex analogue of this routine is
f08psf.
10
Example
This example computes all the eigenvalues and the Schur factorization of the upper Hessenberg matrix
$H$, where
See also
Section 10 in
f08nff, which illustrates the use of this routine to compute the Schur factorization of a general matrix.
10.1
Program Text
10.2
Program Data
10.3
Program Results