hide long namesshow long names
hide short namesshow short names
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_dhsein (f08pk)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

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, corresponding to selected eigenvalues.
The right eigenvector x, and the left eigenvector y, corresponding to an eigenvalue λ, are defined by:
Hx = λx   and   yHH = λyH   or  HTy = λ-y .  
Note that even though H is real, λ, x and y may be complex. If x is an eigenvector corresponding to a complex eigenvalue λ, then the complex conjugate vector x- is the eigenvector corresponding to the complex conjugate eigenvalue λ-.
The eigenvectors are computed by inverse iteration. They are scaled so that, for a real eigenvector x, maxxi = 1 , and for a complex eigenvector, max Rexi + Imxi = 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_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'
Only right eigenvectors are computed.
job='L'
Only left eigenvectors are computed.
job='B'
Both left and right eigenvectors are computed.
Constraint: job='R', 'L' or 'B'.
2:     eigsrc – string (length ≥ 1)
Indicates whether the eigenvalues of H (stored in wr and wi) were found using nag_lapack_dhseqr (f08pe).
eigsrc='Q'
The eigenvalues of H were found using nag_lapack_dhseqr (f08pe); thus if H has any zero subdiagonal elements (and so is block triangular), then the jth eigenvalue can be assumed to be an eigenvalue of the block containing the jth row/column. This property allows the function to perform inverse iteration on just one diagonal block.
eigsrc='N'
No such assumption is made and the function performs inverse iteration using the whole matrix.
Constraint: eigsrc='Q' or 'N'.
3:     initv – string (length ≥ 1)
Indicates whether you are supplying initial estimates for the selected eigenvectors.
initv='N'
No initial estimates are supplied.
initv='U'
Initial estimates are supplied in vl and/or vr.
Constraint: initv='N' or 'U'.
4:     select: – logical array
The dimension of the array select must be at least max1,n
Specifies which eigenvectors are to be computed. To obtain the real eigenvector corresponding to the real eigenvalue wrj, selectj must be set true. To select the complex eigenvector corresponding to the complex eigenvalue wrj,wij with complex conjugate (wrj+1,wij+1), selectj and/or selectj+1 must be set true; the eigenvector corresponding to the first eigenvalue in the pair is computed.
5:     hldh: – double array
The first dimension of the array h must be at least max1,n.
The second dimension of the array h must be at least max1,n.
The n by n upper Hessenberg matrix H.
6:     wr: – double array
7:     wi: – double array
The dimension of the arrays wr and wi must be at least max1,n
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 eigsrc='Q', the arrays must be exactly as returned by nag_lapack_dhseqr (f08pe).
8:     vlldvl: – double array
The first dimension, ldvl, of the array vl must satisfy
  • if job='L' or 'B', ldvln;
  • if job='R', ldvl1.
The second dimension of the array vl must be at least max1,mm if job='L' or 'B' and at least 1 if job='R'.
If initv='U' and job='L' or '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', vl need not be set.
9:     vrldvr: – double array
The first dimension, ldvr, of the array vr must satisfy
  • if job='R' or 'B', ldvrn;
  • if job='L', ldvr1.
The second dimension of the array vr must be at least max1,mm if job='R' or 'B' and at least 1 if job='L'.
If initv='U' and job='R' or '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', 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, is obtained by counting 1 for each selected real eigenvector and 2 for each selected complex eigenvector (see select); 0mn.
Constraint: mmm.

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, the order of the matrix H.
Constraint: n0.

Output Parameters

1:     select: – logical array
The dimension of the array select will be max1,n
If a complex eigenvector was selected as specified above, then selectj is set to true and selectj+1 to false.
2:     wr: – double array
The dimension of the arrays wr and wi will be max1,n
Some elements of wr may be modified, as close eigenvalues are perturbed slightly in searching for independent eigenvectors.
3:     vlldvl: – double array
The first dimension, ldvl, of the array vl will be
  • if job='L' or 'B', ldvl=n;
  • if job='R', ldvl=1.
The second dimension of the array vl will be max1,mm if job='L' or 'B' and at least 1 if job='R'.
If job='L' or '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', vl is not referenced.
4:     vrldvr: – double array
The first dimension, ldvr, of the array vr will be
  • if job='R' or 'B', ldvr=n;
  • if job='L', ldvr=1.
The second dimension of the array vr will be max1,mm if job='R' or 'B' and at least 1 if job='L'.
If job='R' or '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', vr is not referenced.
5:     m int64int32nag_int scalar
m, the number of columns of vl and/or vr required to store the selected eigenvectors.
6:     ifaill: int64int32nag_int array
The dimension of the array ifaill will be max1,mm if job='L' or 'B' and at least 1 if job='R'
If job='L' or 'B', then ifailli=0 if the selected left eigenvector converged and ifailli=j>0 if the eigenvector stored in the ith column of vl (corresponding to the jth eigenvalue as held in wrj,wij failed to converge. If the ith and i+1th columns of vl contain a selected complex eigenvector, then ifailli and ifailli+1 are set to the same value.
If job='R', ifaill is not referenced.
7:     ifailr: int64int32nag_int array
The dimension of the array ifailr will be max1,mm if job='R' or 'B' and at least 1 if job='L'
If job='R' or 'B', then ifailri=0 if the selected right eigenvector converged and ifailri=j>0 if the eigenvector stored in the ith row or column of vr (corresponding to the jth eigenvalue as held in wrj,wij) failed to converge. If the ith and i+1th rows or columns of vr contain a selected complex eigenvector, then ifailri and ifailri+1 are set to the same value.
If job='L', ifailr is not referenced.
8:     info int64int32nag_int scalar
info=0 unless the function detects an error (see 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
If 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: 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
If 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 xi is the exact eigenvector of a nearby matrix A+Ei, such that Ei=Oε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.

Further Comments

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

Example

See Example in nag_lapack_dormhr (f08ng).
function f08pk_example


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

% Matrix A
n   = int64(4);
a = [ 0.35,  0.45, -0.14, -0.17;
      0.09,  0.07, -0.54,  0.35;
     -0.44, -0.33, -0.03,  0.17;
      0.25, -0.32, -0.13,  0.11];

% Reduce A to upper Hessenberg Form A = QHQ^T
ilo = int64(1);
ihi = n;
[H, tau, info] = f08ne(ilo, ihi, a);

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

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

w = wr + i*wi;
disp('Eigenvalues of A');
disp(w);

% Calculate eigenvetors of H corresponding to negative real part eigenvalues
select = (wr < 0);

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

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

% Combine columns of V into complex eigenvectors Z
j = 0;
for k = 1:n
  if select(k)
    j = j+1;
    if (wi(k)==0)
      % Normalize real eigenvector: largest element positive
      [~,l] = max(abs(V(:,j)));
      if V(l,j) < 0;
        V(:,j) = -V(:,j);
      end                      
      Z(:,j) = complex(V(:,j));
    else
      % Normalize complex eigenvectors: largest elements are real
      [~,l] = max(abs(V(:,j))+abs(V(:,j+1)));
      Z(:,j)   = V(:,j) + i*V(:,j+1);
      Z(:,j+1) = V(:,j) - i*V(:,j+1);
      Z(:,j)   = Z(:,j)  *conj(Z(l,j))  /abs(Z(l,j));
      Z(:,j+1) = Z(:,j+1)*conj(Z(l,j+1))/abs(Z(l,j+1));
      j = j+1;
      select(k+1) = false;
    end
  end
end
disp('Eigenvectors corresponding to eigenvalues with negative real part');
disp(Z);


f08pk example results

Eigenvalues of A
   0.7995 + 0.0000i
  -0.0994 + 0.4008i
  -0.0994 - 0.4008i
  -0.1007 + 0.0000i

Eigenvectors corresponding to eigenvalues with negative real part
  -0.2379 + 0.3134i  -0.2379 - 0.3134i   0.1493 + 0.0000i
   0.3100 - 0.6430i   0.3100 + 0.6430i   0.3956 + 0.0000i
   0.1196 - 0.3795i   0.1196 + 0.3795i   0.7075 + 0.0000i
   0.8319 + 0.0000i   0.8319 + 0.0000i   0.8603 + 0.0000i


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