PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_eigen_real_symm_sparse_eigsys (f02fj)
Purpose
nag_eigen_real_symm_sparse_eigsys (f02fj) finds eigenvalues and eigenvectors of a real sparse symmetric or generalized symmetric eigenvalue problem.
Syntax
[
m,
noits,
x,
d,
user,
ifail] = f02fj(
m,
noits,
tol,
dot,
image,
monit,
novecs,
x, 'n',
n, 'k',
k, 'user',
user)
[
m,
noits,
x,
d,
user,
ifail] = nag_eigen_real_symm_sparse_eigsys(
m,
noits,
tol,
dot,
image,
monit,
novecs,
x, 'n',
n, 'k',
k, 'user',
user)
Note: the interface to this routine has changed since earlier releases of the toolbox:
At Mark 22: |
n was made optional |
Description
nag_eigen_real_symm_sparse_eigsys (f02fj) finds the
eigenvalues of largest absolute value and the corresponding eigenvectors for the real eigenvalue problem
where
is an
by
matrix such that
for a given positive definite matrix
.
is said to be
-symmetric. Different specifications of
allow for the solution of a variety of eigenvalue problems. For example, when
the function finds the
eigenvalues of largest absolute magnitude for the standard symmetric eigenvalue problem
The function is intended for the case where
is sparse.
As a second example, when
where
the function finds the
eigenvalues of largest absolute magnitude for the generalized symmetric eigenvalue problem
The function is intended for the case where
and
are sparse.
The function does not require
explicitly, but
is specified via
image which, given an
-element vector
, computes the image
given by
For instance, in the above example, where
,
image will need to solve the positive definite system of equations
for
.
To find the
eigenvalues of smallest absolute magnitude of
(3) we can choose
and hence find the reciprocals of the required eigenvalues, so that
image will need to solve
for
, and correspondingly for
(4) we can choose
and solve
for
.
A table of examples of choice of
image is given in
Table 1. It should be remembered that the function also returns the corresponding eigenvectors and that
is positive definite. Throughout
is assumed to be symmetric and, where necessary, nonsingularity is also assumed.
Eigenvalues Required |
Problem |
|
|
|
|
Largest |
Compute |
Solve |
Compute |
Smallest (Find ) |
Solve |
Solve |
Solve , |
Furthest from
(Find ) |
Compute
|
Solve |
Compute
|
Closest to
(Find ) |
Solve |
Solve |
Solve |
Table 1The Requirement of
image for Various Problems.
The matrix
also need not be supplied explicitly, but is specified via
dot which, given
-element vectors
and
, computes the generalized dot product
.
nag_eigen_real_symm_sparse_eigsys (f02fj) is based upon routine SIMITZ (see
Nikolai (1979)), which is itself a derivative of the Algol procedure ritzit (see
Rutishauser (1970)), and uses the method of simultaneous (subspace) iteration. (See
Parlett (1998) for a description, analysis and advice on the use of the method.)
The function performs simultaneous iteration on vectors. Initial estimates to eigenvectors, corresponding to the eigenvalues of of largest absolute value, may be supplied to nag_eigen_real_symm_sparse_eigsys (f02fj). When possible should be chosen so that the th eigenvalue is not too close to the required eigenvalues, but if is initially chosen too small then nag_eigen_real_symm_sparse_eigsys (f02fj) may be re-entered, supplying approximations to the eigenvectors found so far and with then increased.
At each major iteration nag_eigen_real_symm_sparse_eigsys (f02fj) solves an by () eigenvalue sub-problem in order to obtain an approximation to the eigenvalues for which convergence has not yet occurred. This approximation is refined by Chebyshev acceleration.
References
Nikolai P J (1979) Algorithm 538: Eigenvectors and eigenvalues of real generalized symmetric matrices by simultaneous iteration ACM Trans. Math. Software 5 118–125
Parlett B N (1998) The Symmetric Eigenvalue Problem SIAM, Philadelphia
Rutishauser H (1969) Computational aspects of F L Bauer's simultaneous iteration method Numer. Math. 13 4–13
Rutishauser H (1970) Simultaneous iteration method for symmetric matrices Numer. Math. 16 205–223
Parameters
Compulsory Input Parameters
- 1:
– int64int32nag_int scalar
-
, the number of eigenvalues required.
Constraint:
.
- 2:
– int64int32nag_int scalar
-
The maximum number of major iterations (eigenvalue sub-problems) to be performed. If
, the value
is used in place of
noits.
- 3:
– double scalar
-
A relative tolerance to be used in accepting eigenvalues and eigenvectors. If the eigenvalues are required to about
significant figures,
tol should be set to about
.
is accepted as an eigenvalue as soon as two successive approximations to
differ by less than
, where
is the latest approximation to
. Once an eigenvalue has been accepted, an eigenvector is accepted as soon as
, where
is the normalized residual of the current approximation to the eigenvector (see
Further Comments for further information). The values of the
and
can be printed from
monit. If
tol is supplied outside the range (
), where
is the
machine precision, the value
is used in place of
tol.
- 4:
– function handle or string containing name of m-file
-
dot must return the value
for given vectors
and
. For the standard eigenvalue problem, where
,
dot must return the dot product
.
[result, iflag, user] = dot(iflag, n, z, w, user)
Input Parameters
- 1:
– int64int32nag_int scalar
-
Is always non-negative.
- 2:
– int64int32nag_int scalar
-
The number of elements in the vectors and and the order of the matrix .
- 3:
– double array
-
The vector for which is required.
- 4:
– double array
-
The vector for which is required.
- 5:
– Any MATLAB object
dot is called from
nag_eigen_real_symm_sparse_eigsys (f02fj) with the object supplied to
nag_eigen_real_symm_sparse_eigsys (f02fj).
Output Parameters
- 1:
– double scalar
-
result returns the value for given vectors and .
- 2:
– int64int32nag_int scalar
-
May be used as a flag to indicate a failure in the computation of
. If
iflag is negative on exit from
dot,
nag_eigen_real_symm_sparse_eigsys (f02fj) will exit immediately with
ifail set to
iflag. Note that in this case
dot must still be assigned a value.
- 3:
– Any MATLAB object
- 5:
– function handle or string containing name of m-file
-
image must return the vector
for a given vector
.
[iflag, w, user] = image(iflag, n, z, user)
Input Parameters
- 1:
– int64int32nag_int scalar
-
Is always non-negative.
- 2:
– int64int32nag_int scalar
-
, the number of elements in the vectors and , and the order of the matrix .
- 3:
– double array
-
The vector for which is required.
- 4:
– Any MATLAB object
image is called from
nag_eigen_real_symm_sparse_eigsys (f02fj) with the object supplied to
nag_eigen_real_symm_sparse_eigsys (f02fj).
Output Parameters
- 1:
– int64int32nag_int scalar
-
May be used as a flag to indicate a failure in the computation of
. If
iflag is negative on exit from
image,
nag_eigen_real_symm_sparse_eigsys (f02fj) will exit immediately with
ifail set to
iflag.
- 2:
– double array
-
The vector .
- 3:
– Any MATLAB object
- 6:
– function handle or string containing name of m-file
-
monit is used to monitor the progress of
nag_eigen_real_symm_sparse_eigsys (f02fj).
monit may be the dummy function
nag_eigen_real_symm_sparse_eigsys_dummy_monit (f02fjz) if no monitoring is actually required. (
nag_eigen_real_symm_sparse_eigsys_dummy_monit (f02fjz) is included in the NAG Toolbox.)
monit is called after the solution of each eigenvalue sub-problem and also just prior to return from
nag_eigen_real_symm_sparse_eigsys (f02fj). The arguments
istate and
nextit allow selective printing by
monit.
monit(istate, nextit, nevals, nevecs, k, f, d)
Input Parameters
- 1:
– int64int32nag_int scalar
-
Specifies the state of
nag_eigen_real_symm_sparse_eigsys (f02fj).
- No eigenvalue or eigenvector has just been accepted.
- One or more eigenvalues have been accepted since the last call to monit.
- One or more eigenvectors have been accepted since the last call to monit.
- One or more eigenvalues and eigenvectors have been accepted since the last call to monit.
- Return from nag_eigen_real_symm_sparse_eigsys (f02fj) is about to occur.
- 2:
– int64int32nag_int scalar
-
The number of the next iteration.
- 3:
– int64int32nag_int scalar
-
The number of eigenvalues accepted so far.
- 4:
– int64int32nag_int scalar
-
The number of eigenvectors accepted so far.
- 5:
– int64int32nag_int scalar
-
, the number of simultaneous iteration vectors.
- 6:
– double array
-
A vector of error quantities measuring the state of convergence of the simultaneous iteration vectors. See
tol and
Further Comments for further details. Each element of
f is initially set to the value
and an element remains at
until the corresponding vector is tested.
- 7:
– double array
-
contains the latest approximation to the absolute value of the th eigenvalue of .
- 7:
– int64int32nag_int scalar
-
The number of approximate vectors that are being supplied in
x. If
novecs is outside the range
, the value
is used in place of
novecs.
- 8:
– double array
-
ldx, the first dimension of the array, must satisfy the constraint
.
If
, the first
novecs columns of
x must contain approximations to the eigenvectors corresponding to the
novecs eigenvalues of largest absolute value of
. Supplying approximate eigenvectors can be useful when reasonable approximations are known, or when
nag_eigen_real_symm_sparse_eigsys (f02fj) is being restarted with a larger value of
k. Otherwise it is not necessary to supply approximate vectors, as simultaneous iteration vectors will be generated randomly by
nag_eigen_real_symm_sparse_eigsys (f02fj).
Optional Input Parameters
- 1:
– int64int32nag_int scalar
-
Default:
the first dimension of the array
x.
, the order of the matrix .
Constraint:
.
- 2:
– int64int32nag_int scalar
Suggested value:
will often be a reasonable choice in the absence of better information.
Default:
the second dimension of the array
x.
The number of simultaneous iteration vectors to be used. Too small a value of
k may inhibit convergence, while a larger value of
k incurs additional storage and additional work per iteration.
Constraint:
.
- 3:
– Any MATLAB object
user is not used by
nag_eigen_real_symm_sparse_eigsys (f02fj), but is passed to
dot and
image. Note that for large objects it may be more efficient to use a global variable which is accessible from the m-files than to use
user.
Output Parameters
- 1:
– int64int32nag_int scalar
-
, the number of eigenvalues actually found. It is equal to
if
on exit, and is less than
if
,
or
. See
Error Indicators and Warnings and
Further Comments for further information.
- 2:
– int64int32nag_int scalar
-
The number of iterations actually performed.
- 3:
– double array
-
If
,
,
or
, the first
columns contain the eigenvectors corresponding to the eigenvalues returned in the first
elements of
d; and the next
columns contain approximations to the eigenvectors corresponding to the approximate eigenvalues returned in the next
elements of
d. Here
is the value returned in
m, the number of eigenvalues actually found. The
th column is used as workspace.
- 4:
– double array
-
If
,
,
or
, the first
elements contain the first
eigenvalues in decreasing order of magnitude; and the next
elements contain approximations to the next
eigenvalues. Here
is the value returned in
m, the number of eigenvalues actually found.
contains the value
where
is the latest interval over which Chebyshev acceleration is performed.
- 5:
– Any MATLAB object
- 6:
– int64int32nag_int scalar
unless the function detects an error (see
Error Indicators and Warnings).
Error Indicators and Warnings
Errors or warnings detected by the function:
Cases prefixed with W are classified as warnings and
do not generate an error of type NAG:error_n. See nag_issue_warnings.
- W
-
A negative value of
ifail indicates an exit from
nag_eigen_real_symm_sparse_eigsys (f02fj) because you have set
iflag negative in
dot or
image. The value of
ifail will be the same as your setting of
iflag.
-
-
On entry, | , |
or | , |
or | , |
or | , |
or | , |
or | , |
or | , |
or | . |
- W
-
Not all the requested eigenvalues and vectors have been obtained. Approximations to the
th eigenvalue are oscillating rapidly indicating that severe cancellation is occurring in the
th eigenvector and so
m is returned as
. A restart with a larger value of
k may permit convergence.
- W
-
Not all the requested eigenvalues and vectors have been obtained. The rate of convergence of the remaining eigenvectors suggests that more than
noits iterations would be required and so the input value of
m has been reduced. A restart with a larger value of
k may permit convergence.
- W
-
Not all the requested eigenvalues and vectors have been obtained.
noits iterations have been performed. A restart, possibly with a larger value of
k, may permit convergence.
-
-
This error is very unlikely to occur, but indicates that convergence of the eigenvalue sub-problem has not taken place. Restarting with a different set of approximate vectors may allow convergence. If this error occurs you should check carefully that nag_eigen_real_symm_sparse_eigsys (f02fj) is being called correctly.
-
An unexpected error has been triggered by this routine. Please
contact
NAG.
-
Your licence key may have expired or may not have been installed correctly.
-
Dynamic memory allocation failed.
Accuracy
Eigenvalues and eigenvectors will normally be computed to the accuracy requested by the argument
tol, but eigenvectors corresponding to small or to close eigenvalues may not always be computed to the accuracy requested by the argument
tol. Use of the
monit to monitor acceptance of eigenvalues and eigenvectors is recommended.
Further Comments
The time taken by
nag_eigen_real_symm_sparse_eigsys (f02fj) will be principally determined by the time taken to solve the eigenvalue sub-problem and the time taken by
dot and
image. The time taken to solve an eigenvalue sub-problem is approximately proportional to
. It is important to be aware that several calls to
dot and
image may occur on each major iteration.
As can be seen from
Table 1, many applications of
nag_eigen_real_symm_sparse_eigsys (f02fj) will require the
image to solve a system of linear equations. For example, to find the smallest eigenvalues of
,
image needs to solve equations of the form
for
and functions from
Chapters F01 and
F04
will frequently be useful in this context. In particular, if
is a positive definite variable band matrix,
nag_linsys_real_posdef_vband_solve (f04mc) may be used after
has been factorized by
nag_matop_real_vband_posdef_fac (f01mc). Thus factorization need be performed only once prior to calling
nag_eigen_real_symm_sparse_eigsys (f02fj). An illustration of this type of use is given in the example program.
An approximation
, to the
th eigenvalue, is accepted as soon as
and the previous approximation differ by less than
. Eigenvectors are accepted in groups corresponding to clusters of eigenvalues that are equal, or nearly equal, in absolute value and that have already been accepted. If
is the last eigenvalue in such a group and we define the residual
as
where
is the projection of
, with respect to
, onto the space spanned by
, and
is the current approximation to the
th eigenvector, then the value
returned in
monit is given by
and each vector in the group is accepted as an eigenvector if
where
is the current approximation to
. The values of the
are systematically increased if the convergence criteria appear to be too strict. See
Rutishauser (1970) for further details.
The algorithm implemented by
nag_eigen_real_symm_sparse_eigsys (f02fj) differs slightly from SIMITZ (see
Nikolai (1979)) in that the eigenvalue sub-problem is solved using the singular value decomposition of the upper triangular matrix
of the Gram–Schmidt factorization of
, rather than forming
.
Example
This example finds the four eigenvalues of smallest absolute value and corresponding eigenvectors for the generalized symmetric eigenvalue problem
, where
and
are the
by
matrices
tol is taken as
and
iteration vectors are used.
nag_sparse_real_symm_precon_ichol (f11ja) is used to factorize the matrix
, prior to calling
nag_eigen_real_symm_sparse_eigsys (f02fj), and
nag_sparse_real_symm_solve_ichol (f11jc) is used within
image to solve the equations
for
.
Output from
monit occurs each time
istate is nonzero. Note that the required eigenvalues are the reciprocals of the eigenvalues returned by
nag_eigen_real_symm_sparse_eigsys (f02fj).
Open in the MATLAB editor:
f02fj_example
function f02fj_example
fprintf('f02fj example results\n\n');
n = 16;
m = int64(4);
noits = int64(1000);
tol = 0.0001;
novecs = int64(0);
x = zeros(n, m+2);
a = diag(ones(n,1)) + diag(-0.25*ones(n-1,1),1) + ...
diag(-0.25*ones(n-1,1),-1) + diag(-0.25*ones(n-4,1),4) + ...
diag(-0.25*ones(n-4,1),-4);
b = diag(ones(n,1)) + diag(-0.5*ones(n-1,1),1) + diag(-0.5*ones(n-1,1),-1);
[m, noits, x, d, user, ifail] = ...
f02fj(...
m, noits, tol, @dot, @image, @monit, novecs, x, 'user', {a, b});
fprintf('\nFinal results\n\n');
disp('Eigenvalues');
disp(1./d(1:m)');
disp('Eigenvectors');
disp(x(:,1:m)/diag(x(1,1:m)));
function [result, iflag, user] = dot(iflag, n, z, w, user)
b = user{2};
result=transpose(w)*b*z;
function [iflag, w, user] = image(iflag, n, z, user)
a=user{1};
b=user{2};
w=inv(a)*b*z;
function monit(istate, nextit, nevals, nevecs, k, f, d)
if (istate ~= 0)
fprintf('\n istate = %d nextit = %d\n', istate, nextit);
fprintf(' nevals = %d nevecs = %d\n', nevals, nevecs);
fprintf(' f d \n');
for i=1:double(k)
fprintf('%11.3f %11.3f\n',f(i), d(i));
end
end
f02fj example results
istate = 3 nextit = 17
nevals = 1 nevecs = 1
f d
0.000 1.822
4.000 1.695
4.000 1.668
4.000 1.460
4.000 1.275
4.000 1.132
istate = 4 nextit = 30
nevals = 4 nevecs = 4
f d
0.000 1.822
0.000 1.695
0.000 1.668
0.000 1.460
4.000 1.275
4.000 1.153
Final results
Eigenvalues
0.5488 0.5900 0.5994 0.6850
Eigenvectors
1.0000 1.0000 1.0000 1.0000
-1.1586 -0.8089 1.1274 -1.2368
1.1682 -0.7555 -1.0699 1.9252
-1.1298 0.7444 -1.3512 -1.3185
1.6919 1.4943 1.8266 0.8027
-1.8797 -1.2826 1.7928 -0.4766
1.8854 -1.2505 -1.7589 1.4809
-1.7604 1.3538 -2.0148 -0.6525
1.7604 1.3538 2.0148 -0.6525
-1.8854 -1.2505 1.7589 1.4809
1.8797 -1.2826 -1.7928 -0.4766
-1.6919 1.4943 -1.8266 0.8027
1.1298 0.7444 1.3512 -1.3185
-1.1682 -0.7555 1.0699 1.9252
1.1586 -0.8089 -1.1274 -1.2368
-1.0000 1.0000 -1.0000 1.0000
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015