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_sparseig_real_symm_monit (f12fe)

Purpose

nag_sparseig_real_symm_monit (f12fe) can be used to return additional monitoring information during computation. It is in a suite of functions which includes nag_sparseig_real_symm_init (f12fa), nag_sparseig_real_symm_iter (f12fb), nag_sparseig_real_symm_proc (f12fc) and nag_sparseig_real_symm_option (f12fd).

Syntax

[niter, nconv, ritz, rzest] = f12fe(icomm, comm)
[niter, nconv, ritz, rzest] = nag_sparseig_real_symm_monit(icomm, comm)

Description

The suite of functions is designed to calculate some of the eigenvalues, λ λ , (and optionally the corresponding eigenvectors, x x ) of a standard eigenvalue problem Ax = λx Ax = λx , or of a generalized eigenvalue problem Ax = λBx Ax = λBx  of order n n , where n n  is large and the coefficient matrices A A  and B B  are sparse, real and symmetric. The suite can also be used to find selected eigenvalues/eigenvectors of smaller scale dense, real and symmetric problems.
On an intermediate exit from nag_sparseig_real_symm_iter (f12fb) with irevcm = 4 irevcm = 4 , nag_sparseig_real_symm_monit (f12fe) may be called to return monitoring information on the progress of the Arnoldi iterative process. The information returned by nag_sparseig_real_symm_monit (f12fe) is:
the number of the current Arnoldi iteration;
the number of converged eigenvalues at this point;
the real and imaginary parts of the converged eigenvalues;
the error bounds on the converged eigenvalues.
nag_sparseig_real_symm_monit (f12fe) does not have an equivalent function from the ARPACK package which prints various levels of detail of monitoring information through an output channel controlled via a parameter value (see Lehoucq et al. (1998) for details of ARPACK routines). nag_sparseig_real_symm_monit (f12fe) should not be called at any time other than immediately following an irevcm = 4 irevcm = 4  return from nag_sparseig_real_symm_iter (f12fb).

References

Lehoucq R B (2001) Implicitly restarted Arnoldi methods and subspace iteration SIAM Journal on Matrix Analysis and Applications 23 551–562
Lehoucq R B and Scott J A (1996) An evaluation of software for computing eigenvalues of sparse nonsymmetric matrices Preprint MCS-P547-1195 Argonne National Laboratory
Lehoucq R B and Sorensen D C (1996) Deflation techniques for an implicitly restarted Arnoldi iteration SIAM Journal on Matrix Analysis and Applications 17 789–821
Lehoucq R B, Sorensen D C and Yang C (1998) ARPACK Users' Guide: Solution of Large-scale Eigenvalue Problems with Implicitly Restarted Arnoldi Methods SIAM, Philidelphia

Parameters

Compulsory Input Parameters

1:     icomm( : :) – int64int32nag_int array
Note: the dimension of the array icomm must be at least max (1,licomm)max(1,licomm), where licomm is passed to the setup function  (see nag_sparseig_real_symm_init (f12fa)).
The array icomm output by the preceding call to nag_sparseig_real_symm_iter (f12fb).
2:     comm( : :) – double array
Note: the dimension of the array comm must be at least max (1, 3 × n + ncv × ncv + 8 × ncv + 60 )max(1,3×n+ ncv× ncv+ 8×ncv +60 ) (see nag_sparseig_real_symm_init (f12fa)).
The array comm output by the preceding call to nag_sparseig_real_symm_iter (f12fb).

Optional Input Parameters

None.

Input Parameters Omitted from the MATLAB Interface

None.

Output Parameters

1:     niter – int64int32nag_int scalar
The number of the current Arnoldi iteration.
2:     nconv – int64int32nag_int scalar
The number of converged eigenvalues so far.
3:     ritz( : :) – double array
Note: the dimension of the array ritz must be at least ncvncv (see nag_sparseig_real_symm_init (f12fa)).
The first nconv locations of the array ritz contain the real converged approximate eigenvalues.
4:     rzest( : :) – double array
Note: the dimension of the array rzest must be at least ncvncv (see nag_sparseig_real_symm_init (f12fa)).
The first nconv locations of the array rzest contain the Ritz estimates (error bounds) on the real nconv converged approximate eigenvalues.

Error Indicators and Warnings

None.

Accuracy

A Ritz value, λ λ , is deemed to have converged if its Ritz estimate Tolerance × |λ| Tolerance × |λ| . The default Tolerance used is the machine precision given by nag_machine_precision (x02aj).

Further Comments

None.

Example

function nag_sparseig_real_symm_monit_example
n = int64(100);
nx = int64(10);
nev = int64(4);
ncv = int64(10);

irevcm = int64(0);
resid = zeros(100,1);
v = zeros(100,20);
x = zeros(100,1);
mx = zeros(100,1);

sigma = 0;


% Initialisation Step
[icomm, comm, ifail] = nag_sparseig_real_symm_init(n, nev, ncv);

% Set Optional Parameters
[icomm, comm, ifail] =  ...
     nag_sparseig_real_symm_option('SMALLEST MAGNITUDE', icomm, comm);

% Solve
while (irevcm ~= 5)
  [irevcm, resid, v, x, mx, nshift, comm, icomm, ifail] = ...
    nag_sparseig_real_symm_iter(irevcm, resid, v, x, mx, comm, icomm);
  if (irevcm == 1 || irevcm == -1)
    x = f12f_av(nx, x);
  elseif (irevcm == 4)
    [niter, nconv, ritz, rzest] = nag_sparseig_real_symm_monit(icomm, comm);
    fprintf('Iteration %d, No. converged = %d, norm of estimates = %16.8g\n',  ...
            niter, nconv, norm(rzest(1:double(nev)),2));
  end
end

% Post-process to compute eigenvalues/vectors
[nconv, d, z, v, comm, icomm, ifail] = ...
    nag_sparseig_real_symm_proc(sigma, resid, v, comm, icomm);
 nconv, d(1:double(nconv)), ifail



function [w] = f12f_av(nx, v)

  inx = double(nx); % nx is int64

  w = zeros(inx*inx,1);

  h2 = 1/double((inx+1)^2);

  w(1:inx) = tv(inx, v(1:inx));
  w(1:inx) = -v(inx+1:2*inx)+w(1:inx);

  for j=2:double(inx-1)
    lo = (j-1)*inx +1;
    hi = j*inx;

    w(lo:hi) = tv(inx, v(lo:hi));
    w(lo:hi) = -v(lo-inx:lo-1)+w(lo:hi);
    w(lo:hi) = -v(hi+1:hi+inx)+w(lo:hi);
  end

  lo = (inx-1)*inx +1;
  hi = inx*inx;
  w(lo:hi) = tv(inx, v(lo:hi));
  w(lo:hi) = -v(lo-inx:lo-1)+w(lo:hi);
  w = w/h2;

function [y] = tv(inx,x)

  y = zeros(inx,1);

  dd = 4;
  dl = -1;
  du = -1;

  y(1) = dd*x(1) + du*x(2);
  for j=2:double(inx-1)
    y(j) = dl*x(j-1) + dd*x(j) + du*x(j+1);
  end
  y(inx) = dl*x(inx-1) + dd*x(inx);
 
Iteration 1, No. converged = 0, norm of estimates =        81.010211
Iteration 2, No. converged = 0, norm of estimates =        45.634095
Iteration 3, No. converged = 0, norm of estimates =        42.747772
Iteration 4, No. converged = 0, norm of estimates =        8.6106757
Iteration 5, No. converged = 0, norm of estimates =       0.71330195
Iteration 6, No. converged = 0, norm of estimates =       0.15050738
Iteration 7, No. converged = 0, norm of estimates =      0.015776765
Iteration 8, No. converged = 0, norm of estimates =     0.0038996544
Iteration 9, No. converged = 0, norm of estimates =     0.0004324447
Iteration 10, No. converged = 0, norm of estimates =    0.00011026365
Iteration 11, No. converged = 0, norm of estimates =    1.2358564e-05
Iteration 12, No. converged = 0, norm of estimates =    3.1712519e-06
Iteration 13, No. converged = 1, norm of estimates =    3.5636599e-07
Iteration 14, No. converged = 1, norm of estimates =    4.2416167e-08
Iteration 15, No. converged = 1, norm of estimates =    1.3069836e-08
Iteration 16, No. converged = 1, norm of estimates =    5.5204749e-10
Iteration 17, No. converged = 1, norm of estimates =    8.0102311e-11
Iteration 18, No. converged = 1, norm of estimates =    1.9788954e-10
Iteration 19, No. converged = 2, norm of estimates =    3.1175144e-09
Iteration 20, No. converged = 2, norm of estimates =    3.0499643e-08
Iteration 21, No. converged = 2, norm of estimates =    2.2545794e-08
Iteration 22, No. converged = 2, norm of estimates =    3.8803659e-09
Iteration 23, No. converged = 2, norm of estimates =    4.3299036e-10
Iteration 24, No. converged = 2, norm of estimates =    1.9559537e-10
Iteration 25, No. converged = 2, norm of estimates =    1.3956205e-12
Iteration 26, No. converged = 2, norm of estimates =    6.7447903e-13
Iteration 27, No. converged = 2, norm of estimates =    6.4140406e-14
Iteration 28, No. converged = 2, norm of estimates =    8.9020339e-15
Iteration 29, No. converged = 3, norm of estimates =    3.8266142e-15
Iteration 30, No. converged = 3, norm of estimates =    1.3296741e-16

nconv =

                    4


ans =

   19.6054
   48.2193
   48.2193
   76.8333


ifail =

                    0


function f12fe_example
n = int64(100);
nx = int64(10);
nev = int64(4);
ncv = int64(10);

irevcm = int64(0);
resid = zeros(100,1);
v = zeros(100,20);
x = zeros(100,1);
mx = zeros(100,1);

sigma = 0;


% Initialisation Step
[icomm, comm, ifail] = f12fa(n, nev, ncv);

% Set Optional Parameters
[icomm, comm, ifail] = f12fd('SMALLEST MAGNITUDE', icomm, comm);

% Solve
while (irevcm ~= 5)
  [irevcm, resid, v, x, mx, nshift, comm, icomm, ifail] = ...
    f12fb(irevcm, resid, v, x, mx, comm, icomm);
  if (irevcm == 1 || irevcm == -1)
    x = f12f_av(nx, x);
  elseif (irevcm == 4)
    [niter, nconv, ritz, rzest] = f12fe(icomm, comm);
    fprintf('Iteration %d, No. converged = %d, norm of estimates = %16.8g\n', ...
            niter, nconv, norm(rzest(1:double(nev)),2));
  end
end

% Post-process to compute eigenvalues/vectors
[nconv, d, z, v, comm, icomm, ifail] = f12fc(sigma, resid, v, comm, icomm);
 nconv, d(1:double(nconv)), ifail



function [w] = f12f_av(nx, v)

  inx = double(nx); % nx is int64

  w = zeros(inx*inx,1);

  h2 = 1/double((inx+1)^2);

  w(1:inx) = tv(inx, v(1:inx));
  w(1:inx) = -v(inx+1:2*inx)+w(1:inx);

  for j=2:double(inx-1)
    lo = (j-1)*inx +1;
    hi = j*inx;

    w(lo:hi) = tv(inx, v(lo:hi));
    w(lo:hi) = -v(lo-inx:lo-1)+w(lo:hi);
    w(lo:hi) = -v(hi+1:hi+inx)+w(lo:hi);
  end

  lo = (inx-1)*inx +1;
  hi = inx*inx;
  w(lo:hi) = tv(inx, v(lo:hi));
  w(lo:hi) = -v(lo-inx:lo-1)+w(lo:hi);
  w = w/h2;

function [y] = tv(inx,x)

  y = zeros(inx,1);

  dd = 4;
  dl = -1;
  du = -1;

  y(1) = dd*x(1) + du*x(2);
  for j=2:double(inx-1)
    y(j) = dl*x(j-1) + dd*x(j) + du*x(j+1);
  end
  y(inx) = dl*x(inx-1) + dd*x(inx);
 
Iteration 1, No. converged = 0, norm of estimates =        81.010211
Iteration 2, No. converged = 0, norm of estimates =        45.634095
Iteration 3, No. converged = 0, norm of estimates =        42.747772
Iteration 4, No. converged = 0, norm of estimates =        8.6106757
Iteration 5, No. converged = 0, norm of estimates =       0.71330195
Iteration 6, No. converged = 0, norm of estimates =       0.15050738
Iteration 7, No. converged = 0, norm of estimates =      0.015776765
Iteration 8, No. converged = 0, norm of estimates =     0.0038996544
Iteration 9, No. converged = 0, norm of estimates =     0.0004324447
Iteration 10, No. converged = 0, norm of estimates =    0.00011026365
Iteration 11, No. converged = 0, norm of estimates =    1.2358564e-05
Iteration 12, No. converged = 0, norm of estimates =    3.1712519e-06
Iteration 13, No. converged = 1, norm of estimates =    3.5636599e-07
Iteration 14, No. converged = 1, norm of estimates =    4.2416167e-08
Iteration 15, No. converged = 1, norm of estimates =    1.3069836e-08
Iteration 16, No. converged = 1, norm of estimates =    5.5204749e-10
Iteration 17, No. converged = 1, norm of estimates =    8.0102311e-11
Iteration 18, No. converged = 1, norm of estimates =    1.9788954e-10
Iteration 19, No. converged = 2, norm of estimates =    3.1175144e-09
Iteration 20, No. converged = 2, norm of estimates =    3.0499643e-08
Iteration 21, No. converged = 2, norm of estimates =    2.2545794e-08
Iteration 22, No. converged = 2, norm of estimates =    3.8803659e-09
Iteration 23, No. converged = 2, norm of estimates =    4.3299036e-10
Iteration 24, No. converged = 2, norm of estimates =    1.9559537e-10
Iteration 25, No. converged = 2, norm of estimates =    1.3956205e-12
Iteration 26, No. converged = 2, norm of estimates =    6.7447903e-13
Iteration 27, No. converged = 2, norm of estimates =    6.4140406e-14
Iteration 28, No. converged = 2, norm of estimates =    8.9020339e-15
Iteration 29, No. converged = 3, norm of estimates =    3.8266142e-15
Iteration 30, No. converged = 3, norm of estimates =    1.3296741e-16

nconv =

                    4


ans =

   19.6054
   48.2193
   48.2193
   76.8333


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