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_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:
Mark 22: n has been made optional
.

Description

nag_eigen_real_symm_sparse_eigsys (f02fj) finds the mm eigenvalues of largest absolute value and the corresponding eigenvectors for the real eigenvalue problem
Cx = λ x
Cx=λ x
(1)
where CC is an nn by nn matrix such that
BC = CTB
BC=CTB
(2)
for a given positive definite matrix BB. CC is said to be BB-symmetric. Different specifications of CC allow for the solution of a variety of eigenvalue problems. For example, when
C = A  and  B = I  where  A = AT
C=A  and  B=I  where  A=AT
the function finds the mm eigenvalues of largest absolute magnitude for the standard symmetric eigenvalue problem
Ax = λx.
Ax=λx.
(3)
The function is intended for the case where AA is sparse.
As a second example, when
C = B1A
C=B-1A
where
A = AT
A=AT
the function finds the mm eigenvalues of largest absolute magnitude for the generalized symmetric eigenvalue problem
Ax = λBx.
Ax=λBx.
(4)
The function is intended for the case where AA and BB are sparse.
The function does not require CC explicitly, but CC is specified via image which, given an nn-element vector zz, computes the image ww given by
w = Cz.
w=Cz.
For instance, in the above example, where C = B1AC=B-1A, image will need to solve the positive definite system of equations Bw = AzBw=Az for ww.
To find the mm eigenvalues of smallest absolute magnitude of (3) we can choose C = A1C=A-1 and hence find the reciprocals of the required eigenvalues, so that image will need to solve Aw = zAw=z for ww, and correspondingly for (4) we can choose C = A1BC=A-1B and solve Aw = BzAw=Bz for ww.
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 BB is positive definite. Throughout AA is assumed to be symmetric and, where necessary, nonsingularity is also assumed.
Eigenvalues
Required
Problem
  Ax = λx (B = I)Ax=λx (B=I) Ax = λBxAx=λBx ABx = λxABx=λx
Largest Compute w = Azw=Az Solve Bw = AzBw=Az Compute w = ABzw=ABz
Smallest (Find 1 / λ1/λ) Solve Aw = zAw=z Solve Aw = BzAw=Bz Solve Av = zAv=z, Bw = vBw=v
Furthest from σσ 
(Find λσλ-σ)
Compute
w = (AσI)zw=(A-σI)z
Solve Bw = (AσB)zBw=(A-σB)z Compute
w = (ABσI)zw=(AB-σI)z
Closest to σσ 
(Find 1 / (λσ)1/(λ-σ))
Solve (AσI)w = z(A-σI)w=z Solve (AσB)w = Bz(A-σB)w=Bz Solve (ABσI)w = z(AB-σI)w=z
Table 1
The Requirement of image for Various Problems.
The matrix BB also need not be supplied explicitly, but is specified via dot which, given nn-element vectors zz and ww, computes the generalized dot product wTBzwTBz.
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 k > mk>m vectors. Initial estimates to pkpk eigenvectors, corresponding to the pp eigenvalues of CC of largest absolute value, may be supplied to nag_eigen_real_symm_sparse_eigsys (f02fj). When possible kk should be chosen so that the kkth eigenvalue is not too close to the mm required eigenvalues, but if kk is initially chosen too small then nag_eigen_real_symm_sparse_eigsys (f02fj) may be re-entered, supplying approximations to the kk eigenvectors found so far and with kk then increased.
At each major iteration nag_eigen_real_symm_sparse_eigsys (f02fj) solves an rr by rr (rkrk) 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:     m – int64int32nag_int scalar
mm, the number of eigenvalues required.
Constraint: m1m1.
2:     noits – int64int32nag_int scalar
The maximum number of major iterations (eigenvalue sub-problems) to be performed. If noits0noits0, the value 100100 is used in place of noits.
3:     tol – double scalar
A relative tolerance to be used in accepting eigenvalues and eigenvectors. If the eigenvalues are required to about tt significant figures, tol should be set to about 10t10-t. didi is accepted as an eigenvalue as soon as two successive approximations to didi differ by less than (|i| × tol) / 10(|d~i|×tol)/10, where id~i is the latest approximation to didi. Once an eigenvalue has been accepted, an eigenvector is accepted as soon as (difi) / (didk) < tol(difi)/(di-dk)<tol, where fifi is the normalized residual of the current approximation to the eigenvector (see Section [Further Comments] for further information). The values of the fifi and didi can be printed from monit. If tol is supplied outside the range (ε,1.0ε,1.0), where εε is the machine precision, the value εε is used in place of tol.
4:     dot – function handle or string containing name of m-file
dot must return the value wTBzwTBz for given vectors ww and zz. For the standard eigenvalue problem, where B = IB=I, dot must return the dot product wTzwTz.
[result, iflag, user] = dot(iflag, n, z, w, user)

Input Parameters

1:     iflag – int64int32nag_int scalar
Is always non-negative.
2:     n – int64int32nag_int scalar
The number of elements in the vectors zz and ww and the order of the matrix BB.
3:     z(n) – double array
The vector zz for which wTBzwTBz is required.
4:     w(n) – double array
The vector ww for which wTBzwTBz is required.
5:     user – 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:     result – double scalar
The result of the function.
2:     iflag – int64int32nag_int scalar
May be used as a flag to indicate a failure in the computation of wTBzwTBz. 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:     user – Any MATLAB object
5:     image – function handle or string containing name of m-file
image must return the vector w = Czw=Cz for a given vector zz.
[iflag, w, user] = image(iflag, n, z, user)

Input Parameters

1:     iflag – int64int32nag_int scalar
Is always non-negative.
2:     n – int64int32nag_int scalar
nn, the number of elements in the vectors ww and zz, and the order of the matrix CC.
3:     z(n) – double array
The vector zz for which CzCz is required.
4:     user – 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:     iflag – int64int32nag_int scalar
May be used as a flag to indicate a failure in the computation of ww. If iflag is negative on exit from image, nag_eigen_real_symm_sparse_eigsys (f02fj) will exit immediately with ifail set to iflag.
2:     w(n) – double array
The vector w = Czw=Cz.
3:     user – Any MATLAB object
6:     monit – 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 parameters istate and nextit allow selective printing by monit.
monit(istate, nextit, nevals, nevecs, k, f, d)

Input Parameters

1:     istate – int64int32nag_int scalar
Specifies the state of nag_eigen_real_symm_sparse_eigsys (f02fj).
istate = 0istate=0
No eigenvalue or eigenvector has just been accepted.
istate = 1istate=1
One or more eigenvalues have been accepted since the last call to monit.
istate = 2istate=2
One or more eigenvectors have been accepted since the last call to monit.
istate = 3istate=3
One or more eigenvalues and eigenvectors have been accepted since the last call to monit.
istate = 4istate=4
Return from nag_eigen_real_symm_sparse_eigsys (f02fj) is about to occur.
2:     nextit – int64int32nag_int scalar
The number of the next iteration.
3:     nevals – int64int32nag_int scalar
The number of eigenvalues accepted so far.
4:     nevecs – int64int32nag_int scalar
The number of eigenvectors accepted so far.
5:     k – int64int32nag_int scalar
kk, the number of simultaneous iteration vectors.
6:     f(k) – double array
A vector of error quantities measuring the state of convergence of the simultaneous iteration vectors. See tol and Section [Further Comments] for further details. Each element of f is initially set to the value 4.04.0 and an element remains at 4.04.0 until the corresponding vector is tested.
7:     d(k) – double array
d(i)di contains the latest approximation to the absolute value of the iith eigenvalue of CC.
7:     novecs – int64int32nag_int scalar
The number of approximate vectors that are being supplied in x. If novecs is outside the range (0,k)(0,k), the value 00 is used in place of novecs.
8:     x(ldx,k) – double array
ldx, the first dimension of the array, must satisfy the constraint ldxnldxn.
If 0 < novecsk0<novecsk, the first novecs columns of x must contain approximations to the eigenvectors corresponding to the novecs eigenvalues of largest absolute value of CC. 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:     n – int64int32nag_int scalar
Default: The first dimension of the array x.
nn, the order of the matrix CC.
Constraint: n1n1.
2:     k – int64int32nag_int scalar
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.
Default: m + 4m+4
Constraint: m < knm<kn.
3:     user – 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.

Input Parameters Omitted from the MATLAB Interface

ldx work lwork ruser lruser iuser liuser

Output Parameters

1:     m – int64int32nag_int scalar
mm, the number of eigenvalues actually found. It is equal to mm if ifail = 0ifail=0 on exit, and is less than mm if ifail = 2ifail=2, 33 or 44. See Sections [Error Indicators and Warnings] and [Further Comments] for further information.
2:     noits – int64int32nag_int scalar
The number of iterations actually performed.
3:     x(ldx,k) – double array
ldxnldxn.
If ifail = 0ifail=0, 22, 33 or 44, the first mm columns contain the eigenvectors corresponding to the eigenvalues returned in the first mm elements of d; and the next km1k-m-1 columns contain approximations to the eigenvectors corresponding to the approximate eigenvalues returned in the next km1k-m-1 elements of d. Here mm is the value returned in m, the number of eigenvalues actually found. The kkth column is used as workspace.
4:     d(k) – double array
If ifail = 0ifail=0, 22, 33 or 44, the first mm elements contain the first mm eigenvalues in decreasing order of magnitude; and the next km1k-m-1 elements contain approximations to the next km1k-m-1 eigenvalues. Here mm is the value returned in m, the number of eigenvalues actually found. d(k)dk contains the value ee where (e,e)(-e,e) is the latest interval over which Chebyshev acceleration is performed.
5:     user – Any MATLAB object
6:     ifail – int64int32nag_int scalar
ifail = 0ifail=0 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 ifail < 0ifail<0
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.
  ifail = 1ifail=1
On entry,n < 1n<1,
orm < 1m<1,
ormkmk,
ork > nk>n,
orldx < nldx<n,
orlwork < 3 × k + max (k × k,2 × n)lwork<3×k+max(k×k,2×n),
orlruser < 1lruser<1,
orliuser < 1liuser<1.
W ifail = 2ifail=2
Not all the requested eigenvalues and vectors have been obtained. Approximations to the rrth eigenvalue are oscillating rapidly indicating that severe cancellation is occurring in the rrth eigenvector and so m is returned as (r1)(r-1). A restart with a larger value of k may permit convergence.
W ifail = 3ifail=3
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 ifail = 4ifail=4
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.
  ifail = 5ifail=5
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.

Accuracy

Eigenvalues and eigenvectors will normally be computed to the accuracy requested by the parameter tol, but eigenvectors corresponding to small or to close eigenvalues may not always be computed to the accuracy requested by the parameter 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 nk2nk2. 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 Ax = λ BxAx=λ Bx, image needs to solve equations of the form Aw = BzAw=Bz for ww and functions from Chapters F01 and F04 will frequently be useful in this context. In particular, if AA is a positive definite variable band matrix, nag_linsys_real_posdef_vband_solve (f04mc) may be used after AA 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 hd~h, to the iith eigenvalue, is accepted as soon as hd~h and the previous approximation differ by less than |h| × tol / 10| d~h|×tol/ 10. 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 drdr is the last eigenvalue in such a group and we define the residual rjrj as
rj = Cxjyr
rj=Cxj-yr
where yryr is the projection of CxjCxj, with respect to BB, onto the space spanned by x1,x2,, xrx1,x2,, xr, and xjxj is the current approximation to the jjth eigenvector, then the value fifi returned in monit is given by
fi = maxrjB / CxjB xB2 = xTBx
fi = maxrjB / CxjB xB2 = xTBx
and each vector in the group is accepted as an eigenvector if
(|dr|fr) / (|dr|e) < tol,
(|dr| fr)/(|dr|-e)<tol,
where ee is the current approximation to |k||d~k|. The values of the fifi 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 RR of the Gram–Schmidt factorization of CxrCxr, rather than forming RTRRTR.

Example

function nag_eigen_real_symm_sparse_eigsys_example
n = 16;
m = 4;
noits = int64(1000);
tol = 0.0001;
novecs = int64(0);
x = zeros(n, m+2);
% a, b will be passed in user
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);
[mOut, noitsOut, xOut, d, user, ifail] = ...
     nag_eigen_real_symm_sparse_eigsys(int64(m), noits, tol, ...
     @dot, @image, @monit, novecs, x, 'user', {a, b})

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
 

  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

mOut =

                    4


noitsOut =

                   30


xOut =

   -0.1189    0.2153    0.1648    0.1561   -0.4139    0.5277
    0.1378   -0.1741    0.1858   -0.1931    0.2347   -0.2991
   -0.1389   -0.1626   -0.1763    0.3005    0.1768   -0.2255
    0.1343    0.1602   -0.2227   -0.2058   -0.1628    0.2075
   -0.2012    0.3217    0.3010    0.1253   -0.2233    0.2848
    0.2235   -0.2761    0.2954   -0.0744    0.0672   -0.0856
   -0.2242   -0.2692   -0.2899    0.2312    0.1936   -0.2468
    0.2093    0.2914   -0.3320   -0.1018   -0.1668    0.2126
   -0.2093    0.2914    0.3320   -0.1018    0.1668   -0.2126
    0.2242   -0.2692    0.2899    0.2312   -0.1936    0.2468
   -0.2235   -0.2761   -0.2954   -0.0744   -0.0667    0.0850
    0.2012    0.3217   -0.3010    0.1253    0.2241   -0.2856
   -0.1343    0.1602    0.2227   -0.2058    0.1621   -0.2067
    0.1389   -0.1626    0.1763    0.3005   -0.1770    0.2256
   -0.1378   -0.1741   -0.1858   -0.1931   -0.2338    0.2981
    0.1189    0.2153   -0.1648    0.1561    0.4142   -0.5280


d =

    1.8223
    1.6949
    1.6684
    1.4600
    1.2748
    1.1528


user = 

    [16x16 double]    [16x16 double]


ifail =

                    0


function f02fj_example
n = 16;
m = 4;
noits = int64(1000);
tol = 0.0001;
novecs = int64(0);
x = zeros(n, m+2);
% a, b will be passed in user
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);
[mOut, noitsOut, xOut, d, user, ifail] = ...
     f02fj(int64(m), noits, tol, @dot, @image, @monit, novecs, x, 'user', {a, b})

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
 

  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

mOut =

                    4


noitsOut =

                   30


xOut =

   -0.1189    0.2153    0.1648    0.1561   -0.4139    0.5277
    0.1378   -0.1741    0.1858   -0.1931    0.2347   -0.2991
   -0.1389   -0.1626   -0.1763    0.3005    0.1768   -0.2255
    0.1343    0.1602   -0.2227   -0.2058   -0.1628    0.2075
   -0.2012    0.3217    0.3010    0.1253   -0.2233    0.2848
    0.2235   -0.2761    0.2954   -0.0744    0.0672   -0.0856
   -0.2242   -0.2692   -0.2899    0.2312    0.1936   -0.2468
    0.2093    0.2914   -0.3320   -0.1018   -0.1668    0.2126
   -0.2093    0.2914    0.3320   -0.1018    0.1668   -0.2126
    0.2242   -0.2692    0.2899    0.2312   -0.1936    0.2468
   -0.2235   -0.2761   -0.2954   -0.0744   -0.0667    0.0850
    0.2012    0.3217   -0.3010    0.1253    0.2241   -0.2856
   -0.1343    0.1602    0.2227   -0.2058    0.1621   -0.2067
    0.1389   -0.1626    0.1763    0.3005   -0.1770    0.2256
   -0.1378   -0.1741   -0.1858   -0.1931   -0.2338    0.2981
    0.1189    0.2153   -0.1648    0.1561    0.4142   -0.5280


d =

    1.8223
    1.6949
    1.6684
    1.4600
    1.2748
    1.1528


user = 

    [16x16 double]    [16x16 double]


ifail =

                    0



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–2013