f08 Chapter Contents
f08 Chapter Introduction
NAG C Library Manual

# NAG Library Function Documentnag_dhsein (f08pkc)

## 1  Purpose

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

## 2  Specification

 #include #include
 void nag_dhsein (Nag_OrderType order, Nag_SideType side, Nag_EigValsSourceType eig_source, Nag_InitVeenumtype initv, Nag_Boolean select[], Integer n, const double h[], Integer pdh, double wr[], const double wi[], double vl[], Integer pdvl, double vr[], Integer pdvr, Integer mm, Integer *m, Integer ifaill[], Integer ifailr[], NagError *fail)

## 3  Description

nag_dhsein (f08pkc) 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 nag_dormhr (f08ngc).

## 4  References

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

## 5  Arguments

1:     orderNag_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.2.1.3 in the Essential Introduction for a more detailed explanation of the use of this argument.
Constraint: ${\mathbf{order}}=\mathrm{Nag_RowMajor}$ or Nag_ColMajor.
2:     sideNag_SideTypeInput
On entry: indicates whether left and/or right eigenvectors are to be computed.
${\mathbf{side}}=\mathrm{Nag_RightSide}$
Only right eigenvectors are computed.
${\mathbf{side}}=\mathrm{Nag_LeftSide}$
Only left eigenvectors are computed.
${\mathbf{side}}=\mathrm{Nag_BothSides}$
Both left and right eigenvectors are computed.
Constraint: ${\mathbf{side}}=\mathrm{Nag_RightSide}$, $\mathrm{Nag_LeftSide}$ or $\mathrm{Nag_BothSides}$.
3:     eig_sourceNag_EigValsSourceTypeInput
On entry: indicates whether the eigenvalues of $H$ (stored in wr and wi) were found using nag_dhseqr (f08pec).
${\mathbf{eig_source}}=\mathrm{Nag_HSEQRSource}$
The eigenvalues of $H$ were found using nag_dhseqr (f08pec); 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 function to perform inverse iteration on just one diagonal block.
${\mathbf{eig_source}}=\mathrm{Nag_NotKnown}$
No such assumption is made and the function performs inverse iteration using the whole matrix.
Constraint: ${\mathbf{eig_source}}=\mathrm{Nag_HSEQRSource}$ or $\mathrm{Nag_NotKnown}$.
4:     initvNag_InitVeenumtypeInput
On entry: indicates whether you are supplying initial estimates for the selected eigenvectors.
${\mathbf{initv}}=\mathrm{Nag_NoVec}$
No initial estimates are supplied.
${\mathbf{initv}}=\mathrm{Nag_UserVec}$
Initial estimates are supplied in vl and/or vr.
Constraint: ${\mathbf{initv}}=\mathrm{Nag_NoVec}$ or $\mathrm{Nag_UserVec}$.
5:     select[$\mathit{dim}$]Nag_BooleanInput/Output
Note: the dimension, dim, 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-1\right]$, ${\mathbf{select}}\left[j-1\right]$ must be set Nag_TRUE. To select the complex eigenvector corresponding to the complex eigenvalue $\left({\mathbf{wr}}\left[j-1\right],{\mathbf{wi}}\left[j-1\right]\right)$ with complex conjugate (${\mathbf{wr}}\left[j\right],{\mathbf{wi}}\left[j\right]$), ${\mathbf{select}}\left[j-1\right]$ and/or ${\mathbf{select}}\left[j\right]$ must be set Nag_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-1\right]$ is set to Nag_TRUE and ${\mathbf{select}}\left[j\right]$ to Nag_FALSE.
6:     nIntegerInput
On entry: $n$, the order of the matrix $H$.
Constraint: ${\mathbf{n}}\ge 0$.
7:     h[$\mathit{dim}$]const doubleInput
Note: the dimension, dim, of the array h must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{pdh}}×{\mathbf{n}}\right)$.
The $\left(i,j\right)$th element of the matrix $H$ is stored in
• ${\mathbf{h}}\left[\left(j-1\right)×{\mathbf{pdh}}+i-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_ColMajor}$;
• ${\mathbf{h}}\left[\left(i-1\right)×{\mathbf{pdh}}+j-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_RowMajor}$.
On entry: the $n$ by $n$ upper Hessenberg matrix $H$.
8:     pdhIntegerInput
On entry: the stride separating row or column elements (depending on the value of order) in the array h.
Constraint: ${\mathbf{pdh}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
9:     wr[$\mathit{dim}$]doubleInput/Output
10:   wi[$\mathit{dim}$]const doubleInput
Note: the dimension, dim, 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{eig_source}}=\mathrm{Nag_HSEQRSource}$, the arrays must be exactly as returned by nag_dhseqr (f08pec).
On exit: some elements of wr may be modified, as close eigenvalues are perturbed slightly in searching for independent eigenvectors.
11:   vl[$\mathit{dim}$]doubleInput/Output
Note: the dimension, dim, of the array vl must be at least
• $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{pdvl}}×{\mathbf{mm}}\right)$ when ${\mathbf{side}}=\mathrm{Nag_LeftSide}$ or $\mathrm{Nag_BothSides}$ and ${\mathbf{order}}=\mathrm{Nag_ColMajor}$;
• $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}×{\mathbf{pdvl}}\right)$ when ${\mathbf{side}}=\mathrm{Nag_LeftSide}$ or $\mathrm{Nag_BothSides}$ and ${\mathbf{order}}=\mathrm{Nag_RowMajor}$;
• $1$ when ${\mathbf{side}}=\mathrm{Nag_RightSide}$.
The $\left(i,j\right)$th element of the matrix is stored in
• ${\mathbf{vl}}\left[\left(j-1\right)×{\mathbf{pdvl}}+i-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_ColMajor}$;
• ${\mathbf{vl}}\left[\left(i-1\right)×{\mathbf{pdvl}}+j-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_RowMajor}$.
On entry: if ${\mathbf{initv}}=\mathrm{Nag_UserVec}$ and ${\mathbf{side}}=\mathrm{Nag_LeftSide}$ or $\mathrm{Nag_BothSides}$, vl must contain starting vectors for inverse iteration for the left eigenvectors. Each starting vector must be stored in the same rows or columns as will be used to store the corresponding eigenvector (see below).
If ${\mathbf{initv}}=\mathrm{Nag_NoVec}$, vl need not be set.
On exit: if ${\mathbf{side}}=\mathrm{Nag_LeftSide}$ or $\mathrm{Nag_BothSides}$, vl contains the computed left eigenvectors (as specified by select). The eigenvectors are stored consecutively in the rows or columns of the array (depending on the value of order), in the same order as their eigenvalues. Corresponding to each selected real eigenvalue is a real eigenvector, occupying one row or column. Corresponding to each selected complex eigenvalue is a complex eigenvector, occupying two rows or columns: the first row or column holds the real part and the second row or column holds the imaginary part.
If ${\mathbf{side}}=\mathrm{Nag_RightSide}$, vl is not referenced.
12:   pdvlIntegerInput
On entry: the stride separating row or column elements (depending on the value of order) in the array vl.
Constraints:
• if ${\mathbf{order}}=\mathrm{Nag_ColMajor}$,
• if ${\mathbf{side}}=\mathrm{Nag_LeftSide}$ or $\mathrm{Nag_BothSides}$, ${\mathbf{pdvl}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$;
• if ${\mathbf{side}}=\mathrm{Nag_RightSide}$, ${\mathbf{pdvl}}\ge 1$;
• if ${\mathbf{order}}=\mathrm{Nag_RowMajor}$,
• if ${\mathbf{side}}=\mathrm{Nag_LeftSide}$ or $\mathrm{Nag_BothSides}$, ${\mathbf{pdvl}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{mm}}\right)$;
• if ${\mathbf{side}}=\mathrm{Nag_RightSide}$, ${\mathbf{pdvl}}\ge 1$.
13:   vr[$\mathit{dim}$]doubleInput/Output
Note: the dimension, dim, of the array vr must be at least
• $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{pdvr}}×{\mathbf{mm}}\right)$ when ${\mathbf{side}}=\mathrm{Nag_RightSide}$ or $\mathrm{Nag_BothSides}$ and ${\mathbf{order}}=\mathrm{Nag_ColMajor}$;
• $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}×{\mathbf{pdvr}}\right)$ when ${\mathbf{side}}=\mathrm{Nag_RightSide}$ or $\mathrm{Nag_BothSides}$ and ${\mathbf{order}}=\mathrm{Nag_RowMajor}$;
• $1$ when ${\mathbf{side}}=\mathrm{Nag_LeftSide}$.
The $\left(i,j\right)$th element of the matrix is stored in
• ${\mathbf{vr}}\left[\left(j-1\right)×{\mathbf{pdvr}}+i-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_ColMajor}$;
• ${\mathbf{vr}}\left[\left(i-1\right)×{\mathbf{pdvr}}+j-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_RowMajor}$.
On entry: if ${\mathbf{initv}}=\mathrm{Nag_UserVec}$ and ${\mathbf{side}}=\mathrm{Nag_RightSide}$ or $\mathrm{Nag_BothSides}$, vr must contain starting vectors for inverse iteration for the right eigenvectors. Each starting vector must be stored in the same rows or columns as will be used to store the corresponding eigenvector (see below).
If ${\mathbf{initv}}=\mathrm{Nag_NoVec}$, vr need not be set.
On exit: if ${\mathbf{side}}=\mathrm{Nag_RightSide}$ or $\mathrm{Nag_BothSides}$, vr contains the computed right eigenvectors (as specified by select). The eigenvectors are stored consecutively in the rows or columns of the array (depending on the order argument), in the same order as their eigenvalues. Corresponding to each selected real eigenvalue is a real eigenvector, occupying one row or column. Corresponding to each selected complex eigenvalue is a complex eigenvector, occupying two rows or columns: the first row or column holds the real part and the second row or column holds the imaginary part.
If ${\mathbf{side}}=\mathrm{Nag_LeftSide}$, vr is not referenced.
14:   pdvrIntegerInput
On entry: the stride separating row or column elements (depending on the value of order) in the array vr.
Constraints:
• if ${\mathbf{order}}=\mathrm{Nag_ColMajor}$,
• if ${\mathbf{side}}=\mathrm{Nag_RightSide}$ or $\mathrm{Nag_BothSides}$, ${\mathbf{pdvr}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$;
• if ${\mathbf{side}}=\mathrm{Nag_LeftSide}$, ${\mathbf{pdvr}}\ge 1$;
• if ${\mathbf{order}}=\mathrm{Nag_RowMajor}$,
• if ${\mathbf{side}}=\mathrm{Nag_RightSide}$ or $\mathrm{Nag_BothSides}$, ${\mathbf{pdvr}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{mm}}\right)$;
• if ${\mathbf{side}}=\mathrm{Nag_LeftSide}$, ${\mathbf{pdvr}}\ge 1$.
15:   mmIntegerInput
On entry: the number of columns in the arrays vl and/or vr if ${\mathbf{order}}=\mathrm{Nag_ColMajor}$ or the number of rows in the arrays if ${\mathbf{order}}=\mathrm{Nag_RowMajor}$. The actual number of rows or columns required, $\mathit{required_rowcol}$, is obtained by counting $1$ for each selected real eigenvector and $2$ for each selected complex eigenvector (see select); $0\le \mathit{required_rowcol}\le n$.
Constraint: ${\mathbf{mm}}\ge \mathit{required_rowcol}$.
16:   mInteger *Output
On exit: $\mathit{required_rowcol}$, the number of rows or columns of vl and/or vr required to store the selected eigenvectors.
17:   ifaill[$\mathit{dim}$]IntegerOutput
Note: the dimension, dim, of the array ifaill must be at least
• $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{mm}}\right)$ when ${\mathbf{side}}=\mathrm{Nag_LeftSide}$ or $\mathrm{Nag_BothSides}$;
• $1$ when ${\mathbf{side}}=\mathrm{Nag_RightSide}$.
On exit: if ${\mathbf{side}}=\mathrm{Nag_LeftSide}$ or $\mathrm{Nag_BothSides}$, then ${\mathbf{ifaill}}\left[i-1\right]=0$ if the selected left eigenvector converged and ${\mathbf{ifaill}}\left[i-1\right]=j\ge 0$ if the eigenvector stored in the $i$th row or column of vl (corresponding to the $j$th eigenvalue as held in $\left({\mathbf{wr}}\left[j-1\right],{\mathbf{wi}}\left[j-1\right]\right)$ failed to converge. If the $i$th and $\left(i+1\right)$th rows or columns of vl contain a selected complex eigenvector, then ${\mathbf{ifaill}}\left[i-1\right]$ and ${\mathbf{ifaill}}\left[i\right]$ are set to the same value.
If ${\mathbf{side}}=\mathrm{Nag_RightSide}$, ifaill is not referenced.
18:   ifailr[$\mathit{dim}$]IntegerOutput
Note: the dimension, dim, of the array ifailr must be at least
• $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{mm}}\right)$ when ${\mathbf{side}}=\mathrm{Nag_RightSide}$ or $\mathrm{Nag_BothSides}$;
• $1$ when ${\mathbf{side}}=\mathrm{Nag_LeftSide}$.
On exit: if ${\mathbf{side}}=\mathrm{Nag_RightSide}$ or $\mathrm{Nag_BothSides}$, then ${\mathbf{ifailr}}\left[i-1\right]=0$ if the selected right eigenvector converged and ${\mathbf{ifailr}}\left[i-1\right]=j\ge 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-1\right],{\mathbf{wi}}\left[j-1\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-1\right]$ and ${\mathbf{ifailr}}\left[i\right]$ are set to the same value.
If ${\mathbf{side}}=\mathrm{Nag_LeftSide}$, ifailr is not referenced.
19:   failNagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).

## 6  Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
On entry, argument $〈\mathit{\text{value}}〉$ had an illegal value.
NE_CONVERGENCE
$〈\mathit{\text{value}}〉$ eigenvectors (as indicated by arguments ifaill and/or ifailr) failed to converge. The corresponding columns of vl and/or vr contain no useful information.
NE_ENUM_INT_2
On entry, ${\mathbf{side}}=〈\mathit{\text{value}}〉$, ${\mathbf{pdvl}}=〈\mathit{\text{value}}〉$, ${\mathbf{mm}}=〈\mathit{\text{value}}〉$.
Constraint: if ${\mathbf{side}}=\mathrm{Nag_LeftSide}$ or $\mathrm{Nag_BothSides}$, ${\mathbf{pdvl}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{mm}}\right)$;
if ${\mathbf{side}}=\mathrm{Nag_RightSide}$, ${\mathbf{pdvl}}\ge 1$.
On entry, ${\mathbf{side}}=〈\mathit{\text{value}}〉$, ${\mathbf{pdvl}}=〈\mathit{\text{value}}〉$ and ${\mathbf{n}}=〈\mathit{\text{value}}〉$.
Constraint: if ${\mathbf{side}}=\mathrm{Nag_LeftSide}$ or $\mathrm{Nag_BothSides}$, ${\mathbf{pdvl}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$;
if ${\mathbf{side}}=\mathrm{Nag_RightSide}$, ${\mathbf{pdvl}}\ge 1$.
On entry, ${\mathbf{side}}=〈\mathit{\text{value}}〉$, ${\mathbf{pdvr}}=〈\mathit{\text{value}}〉$, ${\mathbf{mm}}=〈\mathit{\text{value}}〉$.
Constraint: if ${\mathbf{side}}=\mathrm{Nag_RightSide}$ or $\mathrm{Nag_BothSides}$, ${\mathbf{pdvr}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{mm}}\right)$;
if ${\mathbf{side}}=\mathrm{Nag_LeftSide}$, ${\mathbf{pdvr}}\ge 1$.
On entry, ${\mathbf{side}}=〈\mathit{\text{value}}〉$, ${\mathbf{pdvr}}=〈\mathit{\text{value}}〉$ and ${\mathbf{n}}=〈\mathit{\text{value}}〉$.
Constraint: if ${\mathbf{side}}=\mathrm{Nag_RightSide}$ or $\mathrm{Nag_BothSides}$, ${\mathbf{pdvr}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$;
if ${\mathbf{side}}=\mathrm{Nag_LeftSide}$, ${\mathbf{pdvr}}\ge 1$.
NE_INT
On entry, ${\mathbf{mm}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{mm}}\ge \mathit{required_rowcol}$, where $\mathit{required_rowcol}$ is obtained by counting $1$ for each selected real eigenvector and $2$ for each selected complex eigenvector.
On entry, ${\mathbf{n}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{n}}\ge 0$.
On entry, ${\mathbf{pdh}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{pdh}}>0$.
On entry, ${\mathbf{pdvl}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{pdvl}}>0$.
On entry, ${\mathbf{pdvr}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{pdvr}}>0$.
NE_INT_2
On entry, ${\mathbf{pdh}}=〈\mathit{\text{value}}〉$ and ${\mathbf{n}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{pdh}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
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.

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