F08 Chapter Contents
F08 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentF08PKF (DHSEIN)

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

## 1  Purpose

F08PKF (DHSEIN) computes selected left and/or right eigenvectors of a real upper Hessenberg matrix corresponding to specified eigenvalues, by inverse iteration.

## 2  Specification

 SUBROUTINE F08PKF ( JOB, EIGSRC, INITV, SELECT, N, H, LDH, WR, WI, VL, LDVL, VR, LDVR, MM, M, WORK, IFAILL, IFAILR, INFO)
 INTEGER N, LDH, LDVL, LDVR, MM, M, IFAILL(*), IFAILR(*), INFO REAL (KIND=nag_wp) H(LDH,*), WR(*), WI(*), VL(LDVL,*), VR(LDVR,*), WORK((N+2)*N) LOGICAL SELECT(*) CHARACTER(1) JOB, EIGSRC, INITV
The routine may be called by its LAPACK name dhsein.

## 3  Description

F08PKF (DHSEIN) computes left and/or right eigenvectors of a real upper Hessenberg matrix $H$, corresponding to selected eigenvalues.
The right eigenvector $x$, and the left eigenvector $y$, corresponding to an eigenvalue $\lambda$, are defined by:
Note that even though $H$ is real, $\lambda$, $x$ and $y$ may be complex. If $x$ is an eigenvector corresponding to a complex eigenvalue $\lambda$, then the complex conjugate vector $\stackrel{-}{x}$ is the eigenvector corresponding to the complex conjugate eigenvalue $\stackrel{-}{\lambda }$.
The eigenvectors are computed by inverse iteration. They are scaled so that, for a real eigenvector $x$, $\mathrm{max}\left|{x}_{i}\right|=1$, and for a complex eigenvector, $\mathrm{max}\phantom{\rule{0.25em}{0ex}}\left|\mathrm{Re}\left({x}_{i}\right)\right|+\left|\mathrm{Im}{x}_{i}\right|=1$.
If $H$ has been formed by reduction of a real general matrix $A$ to upper Hessenberg form, then the eigenvectors of $H$ may be transformed to eigenvectors of $A$ by a call to F08NGF (DORMHR).

## 4  References

Golub G H and Van Loan C F (1996) Matrix Computations (3rd Edition) Johns Hopkins University Press, Baltimore

## 5  Parameters

1:     JOB – CHARACTER(1)Input
On entry: indicates whether left and/or right eigenvectors are to be computed.
${\mathbf{JOB}}=\text{'R'}$
Only right eigenvectors are computed.
${\mathbf{JOB}}=\text{'L'}$
Only left eigenvectors are computed.
${\mathbf{JOB}}=\text{'B'}$
Both left and right eigenvectors are computed.
Constraint: ${\mathbf{JOB}}=\text{'R'}$, $\text{'L'}$ or $\text{'B'}$.
2:     EIGSRC – CHARACTER(1)Input
On entry: indicates whether the eigenvalues of $H$ (stored in WR and WI) were found using F08PEF (DHSEQR).
${\mathbf{EIGSRC}}=\text{'Q'}$
The eigenvalues of $H$ were found using F08PEF (DHSEQR); thus if $H$ has any zero subdiagonal elements (and so is block triangular), then the $j$th eigenvalue can be assumed to be an eigenvalue of the block containing the $j$th row/column. This property allows the routine to perform inverse iteration on just one diagonal block.
${\mathbf{EIGSRC}}=\text{'N'}$
No such assumption is made and the routine performs inverse iteration using the whole matrix.
Constraint: ${\mathbf{EIGSRC}}=\text{'Q'}$ or $\text{'N'}$.
3:     INITV – CHARACTER(1)Input
On entry: indicates whether you are supplying initial estimates for the selected eigenvectors.
${\mathbf{INITV}}=\text{'N'}$
No initial estimates are supplied.
${\mathbf{INITV}}=\text{'U'}$
Initial estimates are supplied in VL and/or VR.
Constraint: ${\mathbf{INITV}}=\text{'N'}$ or $\text{'U'}$.
4:     SELECT($*$) – LOGICAL arrayInput/Output
Note: the dimension of the array SELECT must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$.
On entry: specifies which eigenvectors are to be computed. To obtain the real eigenvector corresponding to the real eigenvalue ${\mathbf{WR}}\left(j\right)$, ${\mathbf{SELECT}}\left(j\right)$ must be set .TRUE.. To select the complex eigenvector corresponding to the complex eigenvalue $\left({\mathbf{WR}}\left(j\right),{\mathbf{WI}}\left(j\right)\right)$ with complex conjugate (${\mathbf{WR}}\left(j+1\right),{\mathbf{WI}}\left(j+1\right)$), ${\mathbf{SELECT}}\left(j\right)$ and/or ${\mathbf{SELECT}}\left(j+1\right)$ must be set .TRUE.; the eigenvector corresponding to the first eigenvalue in the pair is computed.
On exit: if a complex eigenvector was selected as specified above, then ${\mathbf{SELECT}}\left(j\right)$ is set to .TRUE. and ${\mathbf{SELECT}}\left(j+1\right)$ to .FALSE..
5:     N – INTEGERInput
On entry: $n$, the order of the matrix $H$.
Constraint: ${\mathbf{N}}\ge 0$.
6:     H(LDH,$*$) – REAL (KIND=nag_wp) arrayInput
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$.
7:     LDH – INTEGERInput
On entry: the first dimension of the array H as declared in the (sub)program from which F08PKF (DHSEIN) is called.
Constraint: ${\mathbf{LDH}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$.
8:     WR($*$) – REAL (KIND=nag_wp) arrayInput/Output
9:     WI($*$) – REAL (KIND=nag_wp) arrayInput
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 entry: the real and imaginary parts, respectively, of the eigenvalues of the matrix $H$. Complex conjugate pairs of values must be stored in consecutive elements of the arrays. If ${\mathbf{EIGSRC}}=\text{'Q'}$, the arrays must be exactly as returned by F08PEF (DHSEQR).
On exit: some elements of WR may be modified, as close eigenvalues are perturbed slightly in searching for independent eigenvectors.
10:   VL(LDVL,$*$) – REAL (KIND=nag_wp) arrayInput/Output
Note: the second dimension of the array VL must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{MM}}\right)$ if ${\mathbf{JOB}}=\text{'L'}$ or $\text{'B'}$ and at least $1$ if ${\mathbf{JOB}}=\text{'R'}$.
On entry: if ${\mathbf{INITV}}=\text{'U'}$ and ${\mathbf{JOB}}=\text{'L'}$ or $\text{'B'}$, VL must contain starting vectors for inverse iteration for the left eigenvectors. Each starting vector must be stored in the same column or columns as will be used to store the corresponding eigenvector (see below).
If ${\mathbf{INITV}}=\text{'N'}$, VL need not be set.
On exit: if ${\mathbf{JOB}}=\text{'L'}$ or $\text{'B'}$, VL contains the computed left eigenvectors (as specified by SELECT). The eigenvectors are stored consecutively in the columns of the array, in the same order as their eigenvalues. Corresponding to each selected real eigenvalue is a real eigenvector, occupying one column. Corresponding to each selected complex eigenvalue is a complex eigenvector, occupying two columns: the first column holds the real part and the second column holds the imaginary part.
If ${\mathbf{JOB}}=\text{'R'}$, VL is not referenced.
11:   LDVL – INTEGERInput
On entry: the first dimension of the array VL as declared in the (sub)program from which F08PKF (DHSEIN) is called.
Constraints:
• if ${\mathbf{JOB}}=\text{'L'}$ or $\text{'B'}$, ${\mathbf{LDVL}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$;
• if ${\mathbf{JOB}}=\text{'R'}$, ${\mathbf{LDVL}}\ge 1$.
12:   VR(LDVR,$*$) – REAL (KIND=nag_wp) arrayInput/Output
Note: the second dimension of the array VR must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{MM}}\right)$ if ${\mathbf{JOB}}=\text{'R'}$ or $\text{'B'}$ and at least $1$ if ${\mathbf{JOB}}=\text{'L'}$.
On entry: if ${\mathbf{INITV}}=\text{'U'}$ and ${\mathbf{JOB}}=\text{'R'}$ or $\text{'B'}$, VR must contain starting vectors for inverse iteration for the right eigenvectors. Each starting vector must be stored in the same column or columns as will be used to store the corresponding eigenvector (see below).
If ${\mathbf{INITV}}=\text{'N'}$, VR need not be set.
On exit: if ${\mathbf{JOB}}=\text{'R'}$ or $\text{'B'}$, VR contains the computed right eigenvectors (as specified by SELECT). The eigenvectors are stored consecutively in the columns of the array, in the same order as their eigenvalues. Corresponding to each selected real eigenvalue is a real eigenvector, occupying one column. Corresponding to each selected complex eigenvalue is a complex eigenvector, occupying two columns: the first column holds the real part and the second column holds the imaginary part.
If ${\mathbf{JOB}}=\text{'L'}$, VR is not referenced.
13:   LDVR – INTEGERInput
On entry: the first dimension of the array VR as declared in the (sub)program from which F08PKF (DHSEIN) is called.
Constraints:
• if ${\mathbf{JOB}}=\text{'R'}$ or $\text{'B'}$, ${\mathbf{LDVR}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$;
• if ${\mathbf{JOB}}=\text{'L'}$, ${\mathbf{LDVR}}\ge 1$.
14:   MM – INTEGERInput
On entry: the number of columns in the arrays VL and/or VR . The actual number of columns required, $\mathit{m}$, is obtained by counting $1$ for each selected real eigenvector and $2$ for each selected complex eigenvector (see SELECT); $0\le \mathit{m}\le n$.
Constraint: ${\mathbf{MM}}\ge \mathit{m}$.
15:   M – INTEGEROutput
On exit: $\mathit{m}$, the number of columns of VL and/or VR required to store the selected eigenvectors.
16:   WORK($\left({\mathbf{N}}+2\right)×{\mathbf{N}}$) – REAL (KIND=nag_wp) arrayWorkspace
17:   IFAILL($*$) – INTEGER arrayOutput
Note: the dimension of the array IFAILL must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{MM}}\right)$ if ${\mathbf{JOB}}=\text{'L'}$ or $\text{'B'}$ and at least $1$ if ${\mathbf{JOB}}=\text{'R'}$.
On exit: if ${\mathbf{JOB}}=\text{'L'}$ or $\text{'B'}$, then ${\mathbf{IFAILL}}\left(i\right)=0$ if the selected left eigenvector converged and ${\mathbf{IFAILL}}\left(i\right)=j>0$ if the eigenvector stored in the $i$th column of VL (corresponding to the $j$th eigenvalue as held in $\left({\mathbf{WR}}\left(j\right),{\mathbf{WI}}\left(j\right)\right)$ failed to converge. If the $i$th and $\left(i+1\right)$th columns of VL contain a selected complex eigenvector, then ${\mathbf{IFAILL}}\left(i\right)$ and ${\mathbf{IFAILL}}\left(i+1\right)$ are set to the same value.
If ${\mathbf{JOB}}=\text{'R'}$, IFAILL is not referenced.
18:   IFAILR($*$) – INTEGER arrayOutput
Note: the dimension of the array IFAILR must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{MM}}\right)$ if ${\mathbf{JOB}}=\text{'R'}$ or $\text{'B'}$ and at least $1$ if ${\mathbf{JOB}}=\text{'L'}$.
On exit: if ${\mathbf{JOB}}=\text{'R'}$ or $\text{'B'}$, then ${\mathbf{IFAILR}}\left(i\right)=0$ if the selected right eigenvector converged and ${\mathbf{IFAILR}}\left(i\right)=j>0$ if the eigenvector stored in the $i$th row or column of VR (corresponding to the $j$th eigenvalue as held in $\left({\mathbf{WR}}\left(j\right),{\mathbf{WI}}\left(j\right)\right)$) failed to converge. If the $i$th and $\left(i+1\right)$th rows or columns of VR contain a selected complex eigenvector, then ${\mathbf{IFAILR}}\left(i\right)$ and ${\mathbf{IFAILR}}\left(i+1\right)$ are set to the same value.
If ${\mathbf{JOB}}=\text{'L'}$, IFAILR is not referenced.
19:   INFO – INTEGEROutput
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$
If ${\mathbf{INFO}}=i$, then $i$ eigenvectors (as indicated by the parameters IFAILL and/or IFAILR above) failed to converge. The corresponding columns of VL and/or VR contain no useful information.

## 7  Accuracy

Each computed right eigenvector ${x}_{i}$ is the exact eigenvector of a nearby matrix $A+{E}_{i}$, such that $‖{E}_{i}‖=\mathit{O}\left(\epsilon \right)‖A‖$. Hence the residual is small:
 $Axi - λixi = Oε A .$
However, eigenvectors corresponding to close or coincident eigenvalues may not accurately span the relevant subspaces.
Similar remarks apply to computed left eigenvectors.