Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

Chapter Contents
Chapter Introduction
NAG Toolbox

# NAG Toolbox: nag_sparseig_real_symm_band_init (f12ff)

## Purpose

nag_sparseig_real_symm_band_init (f12ff) is a setup function for nag_sparseig_real_symm_band_solve (f12fg) which can be used to find some eigenvalues (and optionally the corresponding eigenvectors) of a standard or generalized eigenvalue problem defined by real, banded, symmetric matrices. The banded matrix must be stored using the LAPACK storage format for real banded nonsymmetric matrices.

## Syntax

[icomm, comm, ifail] = f12ff(n, nev, ncv)
[icomm, comm, ifail] = nag_sparseig_real_symm_band_init(n, nev, ncv)

## Description

The pair of functions nag_sparseig_real_symm_band_init (f12ff) and nag_sparseig_real_symm_band_solve (f12fg) together with the option setting function nag_sparseig_real_symm_option (f12fd) are designed to calculate some of the eigenvalues, λ $\lambda$, (and optionally the corresponding eigenvectors, x $x$) of a standard eigenvalue problem Ax = λx $Ax=\lambda x$, or of a generalized eigenvalue problem Ax = λBx $Ax=\lambda Bx$ of order n $n$, where n $n$ is large and the coefficient matrices A $A$ and B $B$ are banded real and symmetric.
nag_sparseig_real_symm_band_init (f12ff) is a setup function which must be called before the option setting function nag_sparseig_real_symm_option (f12fd) and the solver function nag_sparseig_real_symm_band_solve (f12fg). Internally, nag_sparseig_real_symm_band_solve (f12fg) makes calls to nag_sparseig_real_symm_iter (f12fb) and nag_sparseig_real_symm_proc (f12fc); the function documents for nag_sparseig_real_symm_iter (f12fb) and nag_sparseig_real_symm_proc (f12fc) should be consulted for details of the algorithm used.
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 Section [Description of the Optional s] in (f12fd).

## 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:     n – int64int32nag_int scalar
The order of the matrix A$A$ (and the order of the matrix B$B$ for the generalized problem) that defines the eigenvalue problem.
Constraint: n > 0${\mathbf{n}}>0$.
2:     nev – int64int32nag_int scalar
The number of eigenvalues to be computed.
Constraint: 0 < nev < n1$0<{\mathbf{nev}}<{\mathbf{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${\mathbf{ncv}}\ge 2×{\mathbf{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${\mathbf{nev}}<{\mathbf{ncv}}\le {\mathbf{n}}$.

None.

licomm lcomm

### Output Parameters

1:     icomm(max (1,licomm)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,\mathit{licomm}\right)$) – int64int32nag_int array
Contains data to be communicated to nag_sparseig_real_symm_band_solve (f12fg).
2:     comm(max (1,lcomm)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,\mathit{lcomm}\right)$) – double array
Contains data to be communicated to nag_sparseig_real_symm_band_solve (f12fg).
3:     ifail – int64int32nag_int scalar
${\mathrm{ifail}}={\mathbf{0}}$ unless the function detects an error (see [Error Indicators and Warnings]).

## Error Indicators and Warnings

Errors or warnings detected by the function:
ifail = 1${\mathbf{ifail}}=1$
On entry, n0${\mathbf{n}}\le 0$.
ifail = 2${\mathbf{ifail}}=2$
On entry, nev0${\mathbf{nev}}\le 0$.
ifail = 3${\mathbf{ifail}}=3$
On entry, ${\mathbf{ncv}}\le {\mathbf{nev}}$ or ncv > n${\mathbf{ncv}}>{\mathbf{n}}$.
ifail = 4${\mathbf{ifail}}=4$
On entry, licomm < 140$\mathit{licomm}<140$ and licomm1$\mathit{licomm}\ne -1$.
ifail = 5${\mathbf{ifail}}=5$
On entry, lcomm < 60$\mathit{lcomm}<60$ and lcomm1$\mathit{lcomm}\ne -1$.

Not applicable.

None.

## Example

function nag_sparseig_real_symm_band_init_example
n = 100;
nev = int64(4);
ncv = int64(10);
kl = 10;
ku = 10;
mb = zeros(2*kl+ku+1,n);
sigma = 0;
resid = zeros(100,1);
[icomm, comm, ifail] = nag_sparseig_real_symm_band_init(int64(n), nev, ncv);
% Construct the matrix A in banded form and store in AB.
ab = zeros(2*kl+ku+1, n);
nx = 10;
% Main diagonal of A.
h2 = 1/((nx+1)*(nx+1));
idiag = kl + ku + 1;
for j = 1:n
ab(idiag,j) = 4/h2;
end
% First subdiagonal and superdiagonal of A.
isup = kl + ku;
isub = kl + ku + 2;
for i = 1:nx
lo = (i-1)*nx;
for j = lo + 1:lo + nx - 1
ab(isup,j+1) = -1/h2;
ab(isub,j) = -1/h2;
end
end
% kl-th subdiagonal and ku-th super-diagonal.
isup = kl + 1;
isub = 2*kl + ku + 1;
for i = 1:nx - 1
lo = (i-1)*nx;
for j = lo + 1:lo + nx
ab(isup,nx+j) = -1/h2;
ab(isub,j) = -1/h2;
end
end
[nconv, d, z, residOut, v, comm, icomm, ifail] = ...
nag_sparseig_real_symm_band_solve(int64(kl), int64(ku), ab, mb, sigma, resid, comm, icomm);
nconv, d(1:double(nconv)), ifail

nconv =

4

ans =

891.1667
919.7807
919.7807
948.3946

ifail =

0

function f12ff_example
n = 100;
nev = int64(4);
ncv = int64(10);
kl = 10;
ku = 10;
mb = zeros(2*kl+ku+1,n);
sigma = 0;
resid = zeros(100,1);
[icomm, comm, ifail] = f12ff(int64(n), nev, ncv);
% Construct the matrix A in banded form and store in AB.
ab = zeros(2*kl+ku+1, n);
nx = 10;
% Main diagonal of A.
h2 = 1/((nx+1)*(nx+1));
idiag = kl + ku + 1;
for j = 1:n
ab(idiag,j) = 4/h2;
end
% First subdiagonal and superdiagonal of A.
isup = kl + ku;
isub = kl + ku + 2;
for i = 1:nx
lo = (i-1)*nx;
for j = lo + 1:lo + nx - 1
ab(isup,j+1) = -1/h2;
ab(isub,j) = -1/h2;
end
end
% kl-th subdiagonal and ku-th super-diagonal.
isup = kl + 1;
isub = 2*kl + ku + 1;
for i = 1:nx - 1
lo = (i-1)*nx;
for j = lo + 1:lo + nx
ab(isup,nx+j) = -1/h2;
ab(isub,j) = -1/h2;
end
end
[nconv, d, z, residOut, v, comm, icomm, ifail] = ...
f12fg(int64(kl), int64(ku), ab, mb, sigma, resid, comm, icomm);
nconv, d(1:double(nconv)), ifail

nconv =

4

ans =

891.1667
919.7807
919.7807
948.3946

ifail =

0