# NAG CL Interfacef08pkc (dhsein)

Settings help

CL Name Style:

## 1Purpose

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

## 2Specification

 #include
 void f08pkc (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)
The function may be called by the names: f08pkc, nag_lapackeig_dhsein or nag_dhsein.

## 3Description

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 $\overline{x}$ is the eigenvector corresponding to the complex conjugate eigenvalue $\overline{\lambda }$.
The eigenvectors are computed by inverse iteration. They are scaled so that, for a real eigenvector $x$, $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(|{x}_{i}|\right)=1$, and for a complex eigenvector, $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(|\mathrm{Re}\left({x}_{i}\right)|+|\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 f08ngc.

## 4References

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

## 5Arguments

1: $\mathbf{order}$Nag_OrderType Input
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.1.3 in the Introduction to the NAG Library CL Interface for a more detailed explanation of the use of this argument.
Constraint: ${\mathbf{order}}=\mathrm{Nag_RowMajor}$ or $\mathrm{Nag_ColMajor}$.
2: $\mathbf{side}$Nag_SideType Input
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: $\mathbf{eig_source}$Nag_EigValsSourceType Input
On entry: indicates whether the eigenvalues of $H$ (stored in wr and wi) were found using f08pec.
${\mathbf{eig_source}}=\mathrm{Nag_HSEQRSource}$
The eigenvalues of $H$ were found using 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: $\mathbf{initv}$Nag_InitVeenumtype Input
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: $\mathbf{select}\left[\mathit{dim}\right]$Nag_Boolean Input/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, ${\mathbf{select}}\left[j-1\right]$ is set to Nag_TRUE and ${\mathbf{select}}\left[j\right]$ to Nag_FALSE.
6: $\mathbf{n}$Integer Input
On entry: $n$, the order of the matrix $H$.
Constraint: ${\mathbf{n}}\ge 0$.
7: $\mathbf{h}\left[\mathit{dim}\right]$const double Input
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×n$ upper Hessenberg matrix $H$. If a NaN is detected in h, the function will return with ${\mathbf{fail}}\mathbf{.}\mathbf{code}=$ NE_BAD_PARAM.
Constraint: No element of h is equal to NaN.
8: $\mathbf{pdh}$Integer Input
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: $\mathbf{wr}\left[\mathit{dim}\right]$double Input/Output
10: $\mathbf{wi}\left[\mathit{dim}\right]$const double Input
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 f08pec.
On exit: some elements of wr may be modified, as close eigenvalues are perturbed slightly in searching for independent eigenvectors.
11: $\mathbf{vl}\left[\mathit{dim}\right]$double Input/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: $\mathbf{pdvl}$Integer Input
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 {\mathbf{n}}$;
• 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: $\mathbf{vr}\left[\mathit{dim}\right]$double Input/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: $\mathbf{pdvr}$Integer Input
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 {\mathbf{n}}$;
• 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: $\mathbf{mm}$Integer Input
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{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}$.
16: $\mathbf{m}$Integer * Output
On exit: $\mathit{m}$, the number of rows or columns of vl and/or vr required to store the selected eigenvectors.
17: $\mathbf{ifaill}\left[\mathit{dim}\right]$Integer Output
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: $\mathbf{ifailr}\left[\mathit{dim}\right]$Integer Output
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: $\mathbf{fail}$NagError * Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).

## 6Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 3.1.2 in the Introduction to the NAG Library CL Interface for further information.
Constraint: No element of h is equal to NaN.
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}}⟩$ and ${\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 {\mathbf{n}}$;
if ${\mathbf{side}}=\mathrm{Nag_RightSide}$, ${\mathbf{pdvl}}\ge 1$.
On entry, ${\mathbf{side}}=⟨\mathit{\text{value}}⟩$, ${\mathbf{pdvr}}=⟨\mathit{\text{value}}⟩$ and ${\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 {\mathbf{n}}$;
if ${\mathbf{side}}=\mathrm{Nag_LeftSide}$, ${\mathbf{pdvr}}\ge 1$.
NE_INT
On entry, ${\mathbf{mm}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{mm}}\ge \mathit{m}$.
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.
See Section 7.5 in the Introduction to the NAG Library CL Interface for further information.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library CL Interface for further information.

## 7Accuracy

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.