Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_lapack_dhsein (f08pk)

Purpose

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

Syntax

[select, wr, vl, vr, m, ifaill, ifailr, info] = f08pk(job, eigsrc, initv, select, h, wr, wi, vl, vr, mm, 'n', n)
[select, wr, vl, vr, m, ifaill, ifailr, info] = nag_lapack_dhsein(job, eigsrc, initv, select, h, wr, wi, vl, vr, mm, 'n', n)

Description

nag_lapack_dhsein (f08pk) computes left and/or right eigenvectors of a real upper Hessenberg matrix H$H$, corresponding to selected eigenvalues.
The right eigenvector x$x$, and the left eigenvector y$y$, corresponding to an eigenvalue λ$\lambda$, are defined by:
 Hx = λx   and   yHH = λyH (  or HTy = λy) .
Note that even though H$H$ is real, λ$\lambda$, x$x$ and y$y$ may be complex. If x$x$ is an eigenvector corresponding to a complex eigenvalue λ$\lambda$, then the complex conjugate vector x$\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$x$, max|xi| = 1 $\mathrm{max}|{x}_{i}|=1$, and for a complex eigenvector, max  |Re(xi)| + |Imxi| = 1 $\mathrm{max}\phantom{\rule{0.25em}{0ex}}|\mathrm{Re}\left({x}_{i}\right)|+|\mathrm{Im}{x}_{i}|=1$.
If H$H$ has been formed by reduction of a real general matrix A$A$ to upper Hessenberg form, then the eigenvectors of H$H$ may be transformed to eigenvectors of A$A$ by a call to nag_lapack_dormhr (f08ng).

References

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

Parameters

Compulsory Input Parameters

1:     job – string (length ≥ 1)
Indicates whether left and/or right eigenvectors are to be computed.
job = 'R'${\mathbf{job}}=\text{'R'}$
Only right eigenvectors are computed.
job = 'L'${\mathbf{job}}=\text{'L'}$
Only left eigenvectors are computed.
job = 'B'${\mathbf{job}}=\text{'B'}$
Both left and right eigenvectors are computed.
Constraint: job = 'R'${\mathbf{job}}=\text{'R'}$, 'L'$\text{'L'}$ or 'B'$\text{'B'}$.
2:     eigsrc – string (length ≥ 1)
Indicates whether the eigenvalues of H$H$ (stored in wr and wi) were found using nag_lapack_dhseqr (f08pe).
eigsrc = 'Q'${\mathbf{eigsrc}}=\text{'Q'}$
The eigenvalues of H$H$ were found using nag_lapack_dhseqr (f08pe); thus if H$H$ has any zero subdiagonal elements (and so is block triangular), then the j$j$th eigenvalue can be assumed to be an eigenvalue of the block containing the j$j$th row/column. This property allows the function to perform inverse iteration on just one diagonal block.
eigsrc = 'N'${\mathbf{eigsrc}}=\text{'N'}$
No such assumption is made and the function performs inverse iteration using the whole matrix.
Constraint: eigsrc = 'Q'${\mathbf{eigsrc}}=\text{'Q'}$ or 'N'$\text{'N'}$.
3:     initv – string (length ≥ 1)
Indicates whether you are supplying initial estimates for the selected eigenvectors.
initv = 'N'${\mathbf{initv}}=\text{'N'}$
No initial estimates are supplied.
initv = 'U'${\mathbf{initv}}=\text{'U'}$
Initial estimates are supplied in vl and/or vr.
Constraint: initv = 'N'${\mathbf{initv}}=\text{'N'}$ or 'U'$\text{'U'}$.
4:     select( : $:$) – logical array
Note: the dimension of the array select must be at least max (1,n)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
Specifies which eigenvectors are to be computed. To obtain the real eigenvector corresponding to the real eigenvalue wr(j)${\mathbf{wr}}\left(j\right)$, select(j)${\mathbf{select}}\left(j\right)$ must be set true. To select the complex eigenvector corresponding to the complex eigenvalue (wr(j),wi(j))$\left({\mathbf{wr}}\left(j\right),{\mathbf{wi}}\left(j\right)\right)$ with complex conjugate (wr(j + 1),wi(j + 1)${\mathbf{wr}}\left(j+1\right),{\mathbf{wi}}\left(j+1\right)$), select(j)${\mathbf{select}}\left(j\right)$ and/or select(j + 1)${\mathbf{select}}\left(j+1\right)$ must be set true; the eigenvector corresponding to the first eigenvalue in the pair is computed.
5:     h(ldh, : $:$) – double array
The first dimension of the array h must be at least max (1,n)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$
The second dimension of the array must be at least max (1,n)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$
The n$n$ by n$n$ upper Hessenberg matrix H$H$.
6:     wr( : $:$) – double array
7:     wi( : $:$) – double array
Note: the dimension of the arrays wr and wi must be at least max (1,n)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
The real and imaginary parts, respectively, of the eigenvalues of the matrix H$H$. Complex conjugate pairs of values must be stored in consecutive elements of the arrays. If eigsrc = 'Q'${\mathbf{eigsrc}}=\text{'Q'}$, the arrays must be exactly as returned by nag_lapack_dhseqr (f08pe).
8:     vl(ldvl, : $:$) – double array
The first dimension, ldvl, of the array vl must satisfy
• if job = 'L'${\mathbf{job}}=\text{'L'}$ or 'B'$\text{'B'}$, ldvl max (1,n) $\mathit{ldvl}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$;
• if job = 'R'${\mathbf{job}}=\text{'R'}$, ldvl1$\mathit{ldvl}\ge 1$.
The second dimension of the array must be at least max (1,mm)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{mm}}\right)$ if job = 'L'${\mathbf{job}}=\text{'L'}$ or 'B'$\text{'B'}$ and at least 1$1$ if job = 'R'${\mathbf{job}}=\text{'R'}$
If initv = 'U'${\mathbf{initv}}=\text{'U'}$ and job = 'L'${\mathbf{job}}=\text{'L'}$ or 'B'$\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 initv = 'N'${\mathbf{initv}}=\text{'N'}$, vl need not be set.
9:     vr(ldvr, : $:$) – double array
The first dimension, ldvr, of the array vr must satisfy
• if job = 'R'${\mathbf{job}}=\text{'R'}$ or 'B'$\text{'B'}$, ldvr max (1,n) $\mathit{ldvr}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$;
• if job = 'L'${\mathbf{job}}=\text{'L'}$, ldvr1$\mathit{ldvr}\ge 1$.
The second dimension of the array must be at least max (1,mm)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{mm}}\right)$ if job = 'R'${\mathbf{job}}=\text{'R'}$ or 'B'$\text{'B'}$ and at least 1$1$ if job = 'L'${\mathbf{job}}=\text{'L'}$
If initv = 'U'${\mathbf{initv}}=\text{'U'}$ and job = 'R'${\mathbf{job}}=\text{'R'}$ or 'B'$\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 initv = 'N'${\mathbf{initv}}=\text{'N'}$, vr need not be set.
10:   mm – int64int32nag_int scalar
The number of columns in the arrays vl and/or vr . The actual number of columns required, m$\mathit{m}$, is obtained by counting 1$1$ for each selected real eigenvector and 2$2$ for each selected complex eigenvector (see select); 0mn$0\le \mathit{m}\le n$.
Constraint: mmm${\mathbf{mm}}\ge \mathit{m}$.

Optional Input Parameters

1:     n – int64int32nag_int scalar
Default: The first dimension of the array h and the second dimension of the array h. (An error is raised if these dimensions are not equal.)
n$n$, the order of the matrix H$H$.
Constraint: n0${\mathbf{n}}\ge 0$.

Input Parameters Omitted from the MATLAB Interface

ldh ldvl ldvr work

Output Parameters

1:     select( : $:$) – logical array
Note: the dimension of the array select must be at least max (1,n)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
If a complex eigenvector was selected as specified above, then select(j)${\mathbf{select}}\left(j\right)$ is set to true and select(j + 1)${\mathbf{select}}\left(j+1\right)$ to false.
2:     wr( : $:$) – double array
Note: the dimension of the arrays wr and wi must be at least max (1,n)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
Some elements of wr may be modified, as close eigenvalues are perturbed slightly in searching for independent eigenvectors.
3:     vl(ldvl, : $:$) – double array
The first dimension, ldvl, of the array vl will be
• if job = 'L'${\mathbf{job}}=\text{'L'}$ or 'B'$\text{'B'}$, ldvl max (1,n) $\mathit{ldvl}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$;
• if job = 'R'${\mathbf{job}}=\text{'R'}$, ldvl1$\mathit{ldvl}\ge 1$.
The second dimension of the array will be max (1,mm)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{mm}}\right)$ if job = 'L'${\mathbf{job}}=\text{'L'}$ or 'B'$\text{'B'}$ and at least 1$1$ if job = 'R'${\mathbf{job}}=\text{'R'}$
If job = 'L'${\mathbf{job}}=\text{'L'}$ or 'B'$\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 job = 'R'${\mathbf{job}}=\text{'R'}$, vl is not referenced.
4:     vr(ldvr, : $:$) – double array
The first dimension, ldvr, of the array vr will be
• if job = 'R'${\mathbf{job}}=\text{'R'}$ or 'B'$\text{'B'}$, ldvr max (1,n) $\mathit{ldvr}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$;
• if job = 'L'${\mathbf{job}}=\text{'L'}$, ldvr1$\mathit{ldvr}\ge 1$.
The second dimension of the array will be max (1,mm)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{mm}}\right)$ if job = 'R'${\mathbf{job}}=\text{'R'}$ or 'B'$\text{'B'}$ and at least 1$1$ if job = 'L'${\mathbf{job}}=\text{'L'}$
If job = 'R'${\mathbf{job}}=\text{'R'}$ or 'B'$\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 job = 'L'${\mathbf{job}}=\text{'L'}$, vr is not referenced.
5:     m – int64int32nag_int scalar
m$\mathit{m}$, the number of columns of vl and/or vr required to store the selected eigenvectors.
6:     ifaill( : $:$) – int64int32nag_int array
Note: the dimension of the array ifaill must be at least max (1,mm)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{mm}}\right)$ if job = 'L'${\mathbf{job}}=\text{'L'}$ or 'B'$\text{'B'}$ and at least 1$1$ if job = 'R'${\mathbf{job}}=\text{'R'}$.
If job = 'L'${\mathbf{job}}=\text{'L'}$ or 'B'$\text{'B'}$, then ifaill(i) = 0${\mathbf{ifaill}}\left(i\right)=0$ if the selected left eigenvector converged and ifaill(i) = j > 0${\mathbf{ifaill}}\left(i\right)=j>0$ if the eigenvector stored in the i$i$th column of vl (corresponding to the j$j$th eigenvalue as held in (wr(j),wi(j))$\left({\mathbf{wr}}\left(j\right),{\mathbf{wi}}\left(j\right)\right)$ failed to converge. If the i$i$th and (i + 1)$\left(i+1\right)$th columns of vl contain a selected complex eigenvector, then ifaill(i)${\mathbf{ifaill}}\left(i\right)$ and ifaill(i + 1)${\mathbf{ifaill}}\left(i+1\right)$ are set to the same value.
If job = 'R'${\mathbf{job}}=\text{'R'}$, ifaill is not referenced.
7:     ifailr( : $:$) – int64int32nag_int array
Note: the dimension of the array ifailr must be at least max (1,mm)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{mm}}\right)$ if job = 'R'${\mathbf{job}}=\text{'R'}$ or 'B'$\text{'B'}$ and at least 1$1$ if job = 'L'${\mathbf{job}}=\text{'L'}$.
If job = 'R'${\mathbf{job}}=\text{'R'}$ or 'B'$\text{'B'}$, then ifailr(i) = 0${\mathbf{ifailr}}\left(i\right)=0$ if the selected right eigenvector converged and ifailr(i) = j > 0${\mathbf{ifailr}}\left(i\right)=j>0$ if the eigenvector stored in the i$i$th row or column of vr (corresponding to the j$j$th eigenvalue as held in (wr(j),wi(j))$\left({\mathbf{wr}}\left(j\right),{\mathbf{wi}}\left(j\right)\right)$) failed to converge. If the i$i$th and (i + 1)$\left(i+1\right)$th rows or columns of vr contain a selected complex eigenvector, then ifailr(i)${\mathbf{ifailr}}\left(i\right)$ and ifailr(i + 1)${\mathbf{ifailr}}\left(i+1\right)$ are set to the same value.
If job = 'L'${\mathbf{job}}=\text{'L'}$, ifailr is not referenced.
8:     info – int64int32nag_int scalar
info = 0${\mathbf{info}}=0$ unless the function detects an error (see Section [Error Indicators and Warnings]).

Error Indicators and Warnings

Cases prefixed with W are classified as warnings and do not generate an error of type NAG:error_n. See nag_issue_warnings.

info = i${\mathbf{info}}=-i$
If info = i${\mathbf{info}}=-i$, parameter i$i$ had an illegal value on entry. The parameters are numbered as follows:
1: job, 2: eigsrc, 3: initv, 4: select, 5: n, 6: h, 7: ldh, 8: wr, 9: wi, 10: vl, 11: ldvl, 12: vr, 13: ldvr, 14: mm, 15: m, 16: work, 17: ifaill, 18: ifailr, 19: info.
It is possible that info refers to a parameter that is omitted from the MATLAB interface. This usually indicates that an error in one of the other input parameters has caused an incorrect value to be inferred.
W INFO > 0${\mathbf{INFO}}>0$
If info = i${\mathbf{info}}=i$, then i$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.

Accuracy

Each computed right eigenvector xi${x}_{i}$ is the exact eigenvector of a nearby matrix A + Ei$A+{E}_{i}$, such that Ei = O(ε)A$‖{E}_{i}‖=\mathit{O}\left(\epsilon \right)‖A‖$. Hence the residual is small:
 ‖Axi − λixi‖ = O(ε) ‖A‖ . $‖ 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.

The complex analogue of this function is nag_lapack_zhsein (f08px).

Example

```function nag_lapack_dhsein_example
job = 'Right';
eigsrc = 'QR';
initv = 'No initial vectors';
select = [false;
true;
true;
true];
h = [0.35, -0.1159524296205035, -0.3886010343233214, -0.2941840753473021;
-0.5140038910358558, 0.1224867524602574, 0.1003597896821503, 0.1125618799705319;
-0.7284721282927631, 0.6442636185270625, -0.1357001717571131, -0.09768162270493326;
0.4139046183481608, -0.1665445794905699, 0.4262443722078449, 0.1632134192968561];
wr = [0.7994821225862088;
-0.09941245329507449;
-0.09941245329507449;
-0.1006572159960586];
wi = [0;
0.4007924719897544;
-0.4007924719897544;
0];
vl = [0];
vr = [0, 0, -1.699371337890631, 0;
-1.699234008789067, -1.594946615289293e-45, 0, 0;
0, 0, 0, 0;
0, 0, -1.700016023545669, -1.699966430664062];
mm = int64(4);
[selectOut, wrOut, vlOut, vrOut, m, ifaill, ifailr, info] = ...
nag_lapack_dhsein(job, eigsrc, initv, select, h, wr, wi, vl, vr, mm)
```
```

selectOut =

0
1
0
1

wrOut =

0.7995
-0.0994
-0.0994
-0.1007

vlOut =

0

vrOut =

-0.3857   -0.0158    0.1493         0
-0.0289   -0.4061    0.1179         0
-0.7944    0.0843   -0.6191         0
0.4500    0.5500    1.0000   -1.7000

m =

3

ifaill =

0

ifailr =

0
0
0
0

info =

0

```
```function f08pk_example
job = 'Right';
eigsrc = 'QR';
initv = 'No initial vectors';
select = [false;
true;
true;
true];
h = [0.35, -0.1159524296205035, -0.3886010343233214, -0.2941840753473021;
-0.5140038910358558, 0.1224867524602574, 0.1003597896821503, 0.1125618799705319;
-0.7284721282927631, 0.6442636185270625, -0.1357001717571131, -0.09768162270493326;
0.4139046183481608, -0.1665445794905699, 0.4262443722078449, 0.1632134192968561];
wr = [0.7994821225862088;
-0.09941245329507449;
-0.09941245329507449;
-0.1006572159960586];
wi = [0;
0.4007924719897544;
-0.4007924719897544;
0];
vl = [0];
vr = [0, 0, -1.699371337890631, 0;
-1.699234008789067, -1.594946615289293e-45, 0, 0;
0, 0, 0, 0;
0, 0, -1.700016023545669, -1.699966430664062];
mm = int64(4);
[selectOut, wrOut, vlOut, vrOut, m, ifaill, ifailr, info] = ...
f08pk(job, eigsrc, initv, select, h, wr, wi, vl, vr, mm)
```
```

selectOut =

0
1
0
1

wrOut =

0.7995
-0.0994
-0.0994
-0.1007

vlOut =

0

vrOut =

-0.3857   -0.0158    0.1493         0
-0.0289   -0.4061    0.1179         0
-0.7944    0.0843   -0.6191         0
0.4500    0.5500    1.0000   -1.7000

m =

3

ifaill =

0

ifailr =

0
0
0
0

info =

0

```