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_dstevd (f08jc)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

Purpose

nag_lapack_dstevd (f08jc) computes all the eigenvalues and, optionally, all the eigenvectors of a real symmetric tridiagonal matrix. If the eigenvectors are requested, then it uses a divide-and-conquer algorithm to compute eigenvalues and eigenvectors. However, if only eigenvalues are required, then it uses the Pal–Walker–Kahan variant of the QL or QR algorithm.

Syntax

[d, e, z, info] = f08jc(job, d, e, 'n', n)
[d, e, z, info] = nag_lapack_dstevd(job, d, e, 'n', n)

Description

nag_lapack_dstevd (f08jc) computes all the eigenvalues and, optionally, all the eigenvectors of a real symmetric tridiagonal matrix T. In other words, it can compute the spectral factorization of T as
T=ZΛZT,  
where Λ is a diagonal matrix whose diagonal elements are the eigenvalues λi, and Z is the orthogonal matrix whose columns are the eigenvectors zi. Thus
Tzi=λizi,  i=1,2,,n.  

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 eigenvectors are computed.
job='N'
Only eigenvalues are computed.
job='V'
Eigenvalues and eigenvectors are computed.
Constraint: job='N' or 'V'.
2:     d: – double array
The dimension of the array d must be at least max1,n
The n diagonal elements of the tridiagonal matrix T.
3:     e: – double array
The dimension of the array e must be at least max1,n
The n-1 off-diagonal elements of the tridiagonal matrix T. The nth element of this array is used as workspace.

Optional Input Parameters

1:     n int64int32nag_int scalar
Default: the first dimension of the array d and the second dimension of the array d. (An error is raised if these dimensions are not equal.)
n, the order of the matrix T.
Constraint: n0.

Output Parameters

1:     d: – double array
The dimension of the array d will be max1,n
The eigenvalues of the matrix T in ascending order.
2:     e: – double array
The dimension of the array e will be max1,n
e is overwritten with intermediate results.
3:     zldz: – double array
The first dimension, ldz, of the array z will be
  • if job='V', ldz= max1,n ;
  • if job='N', ldz=1.
The second dimension of the array z will be max1,n if job='V' and at least 1 if job='N'.
If job='V', z stores the orthogonal matrix Z which contains the eigenvectors of T.
If job='N', z is not referenced.
4:     info int64int32nag_int scalar
info=0 unless the function detects an error (see Error Indicators and Warnings).

Error Indicators and Warnings

   info=-i
If info=-i, parameter i had an illegal value on entry. The parameters are numbered as follows:
1: job, 2: n, 3: d, 4: e, 5: z, 6: ldz, 7: work, 8: lwork, 9: iwork, 10: liwork, 11: 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.
   info>0
if info=i and job='N', the algorithm failed to converge; i elements of an intermediate tridiagonal form did not converge to zero; if info=i and job='V', then the algorithm failed to compute an eigenvalue while working on the submatrix lying in rows and column i/n+1 through i mod n+1.

Accuracy

The computed eigenvalues and eigenvectors are exact for a nearby matrix T+E, where
E2 = Oε T2 ,  
and ε is the machine precision.
If λi is an exact eigenvalue and λ~i is the corresponding computed value, then
λ~i - λi c n ε T2 ,  
where cn is a modestly increasing function of n.
If zi is the corresponding exact eigenvector, and z~i is the corresponding computed eigenvector, then the angle θz~i,zi between them is bounded as follows:
θ z~i,zi c n ε T2 min ij λi - λj .  
Thus the accuracy of a computed eigenvector depends on the gap between its eigenvalue and all the other eigenvalues.

Further Comments

There is no complex analogue of this function.

Example

This example computes all the eigenvalues and eigenvectors of the symmetric tridiagonal matrix T, where
T = 1.0 1.0 0.0 0.0 1.0 4.0 2.0 0.0 0.0 2.0 9.0 3.0 0.0 0.0 3.0 16.0 .  
function f08jc_example


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

% Symmetric tridiagonal A stored as diagonal and off-diagonal
n = 4;
d = [1;     4;     9;     16];
e = [1;     2;     3;     0];

% All eigenvalues and eigenvectors of A
job = 'Vectors';
[w, ~, z, info] = f08jc( ...
                         job, d, e);

% Normalize eigenvectors: largest element positive
for j = 1:n
  [~,k] = max(abs(z(:,j)));
  if z(k,j) < 0;
    z(:,j) = -z(:,j);
  end
end                            

disp(' Eigenvalues:');
disp(w');
disp(' Eigenvectors:');
disp(z);


f08jc example results

 Eigenvalues:
    0.6476    3.5470    8.6578   17.1477

 Eigenvectors:
    0.9396    0.3388    0.0494    0.0034
   -0.3311    0.8628    0.3781    0.0545
    0.0853   -0.3648    0.8558    0.3568
   -0.0167    0.0879   -0.3497    0.9326


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