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_init (f12fa)


    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example


nag_sparseig_real_symm_init (f12fa) is a setup function in a suite of functions consisting of nag_sparseig_real_symm_init (f12fa), nag_sparseig_real_symm_iter (f12fb), nag_sparseig_real_symm_proc (f12fc), nag_sparseig_real_symm_option (f12fd) and nag_sparseig_real_symm_monit (f12fe). It is used to find some of the eigenvalues (and optionally the corresponding eigenvectors) of a standard or generalized eigenvalue problem defined by real symmetric matrices.
The suite of functions is suitable for the solution of large sparse, standard or generalized, symmetric eigenproblems where only a few eigenvalues from a selected range of the spectrum are required.


[icomm, comm, ifail] = f12fa(n, nev, ncv)
[icomm, comm, ifail] = nag_sparseig_real_symm_init(n, nev, ncv)


The suite of functions is designed to calculate some of the eigenvalues, λ , (and optionally the corresponding eigenvectors, x ) of a standard eigenvalue problem Ax = λx , or of a generalized eigenvalue problem Ax = λBx  of order n , where n  is large and the coefficient matrices A  and 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.
nag_sparseig_real_symm_init (f12fa) is a setup function which must be called before nag_sparseig_real_symm_iter (f12fb), the reverse communication iterative solver, and before nag_sparseig_real_symm_option (f12fd), the options setting function. nag_sparseig_real_symm_proc (f12fc), is a post-processing function that must be called following a successful final exit from nag_sparseig_real_symm_iter (f12fb), while nag_sparseig_real_symm_monit (f12fe) can be used to return additional monitoring information during the computation.
This setup function initializes the communication arrays, sets (to their default values) all options that can be set by you via the option setting function nag_sparseig_real_symm_option (f12fd), and checks that the lengths of the communication arrays as passed by you are of sufficient length. For details of the options available and how to set them see Description of the s in nag_sparseig_real_symm_option (f12fd).


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


Compulsory Input Parameters

1:     n int64int32nag_int scalar
The order of the matrix A (and the order of the matrix B for the generalized problem) that defines the eigenvalue problem.
Constraint: n>0.
2:     nev int64int32nag_int scalar
The number of eigenvalues to be computed.
Constraint: 0<nev<n-1.
3:     ncv int64int32nag_int scalar
The number of Lanczos basis vectors to use during the computation.
At present there is no a priori analysis to guide the selection of ncv relative to nev. However, it is recommended that ncv2×nev+1. If many problems of the same type are to be solved, you should experiment with increasing ncv while keeping nev fixed for a given test problem. This will usually decrease the required number of matrix-vector operations but it also increases the work and storage required to maintain the orthogonal basis vectors. The optimal ‘cross-over’ with respect to CPU time is problem dependent and must be determined empirically.
Constraint: nev<ncvn.

Optional Input Parameters


Output Parameters

1:     icommmax1,licomm int64int32nag_int array
Contains data to be communicated to the other functions in the suite.
2:     commmax1,lcomm – double array
Contains data to be communicated to the other functions in the suite.
3:     ifail int64int32nag_int scalar
ifail=0 unless the function detects an error (see Error Indicators and Warnings).

Error Indicators and Warnings

Errors or warnings detected by the function:
On entry, n0.
On entry, nev0.
On entry, ncvnev or ncv>n.
On entry, licomm<140 and licomm-1.
On entry, lcomm<3×n+ncv×ncv+8×ncv+60 and lcomm-1.
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.


Not applicable.

Further Comments



This example solves Ax = λx  in regular mode, where A  is obtained from the standard central difference discretization of the Laplacian operator 2u x2 + 2u y2  on the unit square, with zero Dirichlet boundary conditions. Eigenvalues of smallest magnitude are selected.
function f12fa_example

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

nx  = int64(10);
n   = nx^2;
nev = int64(4);
ncv = int64(10);
imon = 0;

irevcm = int64(0);
resid  = zeros(n,1);
v      = zeros(n,ncv);
x      = zeros(n,1);
mx     = zeros(n,1);

% 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 = f12fa_Ax(nx, x);
  elseif (irevcm == 4 && imon==1)
    [niter, nconv, ritz, rzest] = f12fe(icomm, comm);
    fprintf(['Iteration %2d, No. converged = %d, ', ...
             'norm of estimates = %10.2e\n'], ...
            niter, nconv, norm(rzest(1:nev),2));

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

fprintf('Smallest %d Eigenvalues are:\n',nconv);

function [y] = f12fa_Ax(nx, x)

  y = zeros(nx*nx,1);

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

  y(1:nx) = f12fa_Bx(nx, x(1:nx));
  y(1:nx) = y(1:nx) - x(nx+1:2*nx);

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

    y(lo:hi) = f12fa_Bx(nx, x(lo:hi));
    y(lo:hi) = y(lo:hi) - x(lo-nx:lo-1) - x(hi+1:hi+nx);

  lo = (nx-1)*nx +1;
  hi = nx*nx;
  y(lo:hi) = f12fa_Bx(nx, x(lo:hi));
  y(lo:hi) = y(lo:hi) - x(lo-nx:lo-1);
  y = y/h2;

function [y] = f12fa_Bx(nx,x)

  y = zeros(nx,1);

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

  y(1) = dd*x(1) + du*x(2);
  for j=2:nx-1
    y(j) = dl*x(j-1) + dd*x(j) + du*x(j+1);
  y(nx) = dl*x(nx-1) + dd*x(nx);
f12fa example results

Smallest 4 Eigenvalues are:

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