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

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

# NAG Toolbox: nag_lapack_zhsein (f08px)

## Purpose

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

## Syntax

[w, vl, vr, m, ifaill, ifailr, info] = f08px(job, eigsrc, initv, select, h, w, vl, vr, mm, 'n', n)
[w, vl, vr, m, ifaill, ifailr, info] = nag_lapack_zhsein(job, eigsrc, initv, select, h, w, vl, vr, mm, 'n', n)

## Description

nag_lapack_zhsein (f08px) computes left and/or right eigenvectors of a complex 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:
The eigenvectors are computed by inverse iteration. They are scaled so that $\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 complex general matrix $A$ to upper Hessenberg form, then the eigenvectors of $H$ may be transformed to eigenvectors of $A$ by a call to nag_lapack_zunmhr (f08nu).

## References

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

## Parameters

### Compulsory Input Parameters

1:     $\mathrm{job}$ – string (length ≥ 1)
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:     $\mathrm{eigsrc}$ – string (length ≥ 1)
Indicates whether the eigenvalues of $H$ (stored in w) were found using nag_lapack_zhseqr (f08ps).
${\mathbf{eigsrc}}=\text{'Q'}$
The eigenvalues of $H$ were found using nag_lapack_zhseqr (f08ps); 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{eigsrc}}=\text{'N'}$
No such assumption is made and the function performs inverse iteration using the whole matrix.
Constraint: ${\mathbf{eigsrc}}=\text{'Q'}$ or $\text{'N'}$.
3:     $\mathrm{initv}$ – string (length ≥ 1)
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:     $\mathrm{select}\left(:\right)$ – logical array
The dimension of the array select must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$
Specifies which eigenvectors are to be computed. To select the eigenvector corresponding to the eigenvalue ${\mathbf{w}}\left(j\right)$, ${\mathbf{select}}\left(j\right)$ must be set to true.
5:     $\mathrm{h}\left(\mathit{ldh},:\right)$ – complex array
The first dimension of the array h must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
The second dimension of the array h must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
The $n$ by $n$ upper Hessenberg matrix $H$.
6:     $\mathrm{w}\left(:\right)$ – complex array
The dimension of the array w must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$
The eigenvalues of the matrix $H$. If ${\mathbf{eigsrc}}=\text{'Q'}$, the array must be exactly as returned by nag_lapack_zhseqr (f08ps).
7:     $\mathrm{vl}\left(\mathit{ldvl},:\right)$ – complex array
The first dimension, $\mathit{ldvl}$, of the array vl must satisfy
• if ${\mathbf{job}}=\text{'L'}$ or $\text{'B'}$, $\mathit{ldvl}\ge {\mathbf{n}}$;
• if ${\mathbf{job}}=\text{'R'}$, $\mathit{ldvl}\ge 1$.
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'}$.
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 as will be used to store the corresponding eigenvector (see below).
If ${\mathbf{initv}}=\text{'N'}$, vl need not be set.
8:     $\mathrm{vr}\left(\mathit{ldvr},:\right)$ – complex array
The first dimension, $\mathit{ldvr}$, of the array vr must satisfy
• if ${\mathbf{job}}=\text{'R'}$ or $\text{'B'}$, $\mathit{ldvr}\ge {\mathbf{n}}$;
• if ${\mathbf{job}}=\text{'L'}$, $\mathit{ldvr}\ge 1$.
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'}$.
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 as will be used to store the corresponding eigenvector (see below).
If ${\mathbf{initv}}=\text{'N'}$, vr need not be set.
9:     $\mathrm{mm}$int64int32nag_int scalar
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}$.

### Optional Input Parameters

1:     $\mathrm{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$, the order of the matrix $H$.
Constraint: ${\mathbf{n}}\ge 0$.

### Output Parameters

1:     $\mathrm{w}\left(:\right)$ – complex array
The dimension of the array w will be $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$
The real parts of some elements of w may be modified, as close eigenvalues are perturbed slightly in searching for independent eigenvectors.
2:     $\mathrm{vl}\left(\mathit{ldvl},:\right)$ – complex array
The first dimension, $\mathit{ldvl}$, of the array vl will be
• if ${\mathbf{job}}=\text{'L'}$ or $\text{'B'}$, $\mathit{ldvl}={\mathbf{n}}$;
• if ${\mathbf{job}}=\text{'R'}$, $\mathit{ldvl}=1$.
The second dimension of the array vl will be $\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'}$.
The second dimension of the array vl will be $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}\right)$ if ${\mathbf{job}}=\text{'L'}$ or $\text{'B'}$ and at least $1$ if ${\mathbf{job}}=\text{'R'}$.
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.
If ${\mathbf{job}}=\text{'R'}$, vl is not referenced.
3:     $\mathrm{vr}\left(\mathit{ldvr},:\right)$ – complex array
The first dimension, $\mathit{ldvr}$, of the array vr will be
• if ${\mathbf{job}}=\text{'R'}$ or $\text{'B'}$, $\mathit{ldvr}={\mathbf{n}}$;
• if ${\mathbf{job}}=\text{'L'}$, $\mathit{ldvr}=1$.
The second dimension of the array vr will be $\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'}$.
The second dimension of the array vr will be $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}\right)$ if ${\mathbf{job}}=\text{'R'}$ or $\text{'B'}$ and at least $1$ if ${\mathbf{job}}=\text{'L'}$.
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.
If ${\mathbf{job}}=\text{'L'}$, vr is not referenced.
4:     $\mathrm{m}$int64int32nag_int scalar
$\mathit{m}$, the number of selected eigenvectors.
5:     $\mathrm{ifaill}\left(:\right)$int64int32nag_int array
The dimension of the array ifaill will be $\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'}$
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 row or column of vl (corresponding to the $j$th eigenvalue) failed to converge.
If ${\mathbf{job}}=\text{'R'}$, ifaill is not referenced.
6:     $\mathrm{ifailr}\left(:\right)$int64int32nag_int array
The dimension of the array ifailr will be $\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'}$
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 column of vr (corresponding to the $j$th eigenvalue) failed to converge.
If ${\mathbf{job}}=\text{'L'}$, ifailr is not referenced.
7:     $\mathrm{info}$int64int32nag_int scalar
${\mathbf{info}}=0$ unless the function detects an error (see Error Indicators and Warnings).

## Error Indicators and Warnings

${\mathbf{info}}=-i$
If ${\mathbf{info}}=-i$, parameter $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: w, 9: vl, 10: ldvl, 11: vr, 12: ldvr, 13: mm, 14: m, 15: work, 16: rwork, 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.
${\mathbf{info}}>0$
If ${\mathbf{info}}=i$, then $i$ eigenvectors (as indicated by the arguments 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 ${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.

The real analogue of this function is nag_lapack_dhsein (f08pk).

## Example

See Example in nag_lapack_zunmhr (f08nu).
```function f08px_example

fprintf('f08px example results\n\n');

% Complex matrix A
a = [ -3.97 - 5.04i, -4.11 + 3.70i, -0.34 + 1.01i,  1.29 - 0.86i;
0.34 - 1.50i,  1.52 - 0.43i,  1.88 - 5.38i,  3.36 + 0.65i;
3.31 - 3.85i,  2.50 + 3.45i,  0.88 - 1.08i,  0.64 - 1.48i;
-1.10 + 0.82i,  1.81 - 1.59i,  3.25 + 1.33i,  1.57 - 3.44i];

% Reduce (all of) A to upper Hessenberg Form
n   = int64(4);
ilo = int64(1);
ihi = n;
[H, tau, info] = f08ns(ilo, ihi, a);

% Form Q
[Q, info] = f08nt(ilo, ihi, H, tau);

% Schur factorize H = Y*T*Y^H
job   = 'Schur form';
compz = 'Vectors';
[~, w, ~, info] = f08ps( ...
job, compz, ilo, ihi, H, Q);

disp('Eigenvalues of A');
disp(w);

% Calculate eigenvectors of H for negative real part eigenvalues
select = (real(w) < 0);

job = 'Right';
eigsrc = 'QR';
initv = 'No initial vectors';
vl = [];
vr = complex(zeros(n,n));
[~, ~, VR, m, ifaill, ifailr, info] = ...
f08px( ...
job, eigsrc, initv, select, H, w, vl, vr, n);

% Eigenvectors of A = Q*VR
side = 'Left';
trans = 'No transpose';
[z, info] = f08nu( ...
side, trans, ilo, ihi, H, tau, VR);

% Normalize eigenvectors: largest elements are real
for i = 1:m
[~,k] = max(abs(real(z(:,i)))+abs(imag(z(:,i))));
z(:,i) = z(:,i)*conj(z(k,i))/abs(z(k,i));
end

disp('Eigenvectors corresponding to eigenvalues with negative real part');
% Normalize eigenvectors before printing
disp(z/diag(z(1,:)));

```
```f08px example results

Eigenvalues of A
-6.0004 - 6.9998i
-5.0000 + 2.0060i
7.9982 - 0.9964i
3.0023 - 3.9998i

Eigenvectors corresponding to eigenvalues with negative real part
1.0000 + 0.0000i   1.0000 + 0.0000i
-0.0210 + 0.3590i   1.1997 - 0.6339i
0.1035 + 0.3683i  -1.3192 - 0.5912i
-0.0664 - 0.3436i  -0.1319 + 0.7904i

```

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015