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_proc (f12ac)

Purpose

nag_sparseig_real_proc (f12ac) is a post-processing function that must be called following a final exit from nag_sparseig_real_iter (f12ab). These are part of a suite of functions for the solution of real sparse eigensystems. The suite also includes nag_sparseig_real_init (f12aa), nag_sparseig_real_option (f12ad) and nag_sparseig_real_monit (f12ae).

Syntax

[nconv, dr, di, z, v, comm, icomm, ifail] = f12ac(sigmar, sigmai, resid, v, comm, icomm)
[nconv, dr, di, z, v, comm, icomm, ifail] = nag_sparseig_real_proc(sigmar, sigmai, resid, v, comm, icomm)

Description

The suite of functions is 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 sparse, real and nonsymmetric. The suite can also be used to find selected eigenvalues/eigenvectors of smaller scale dense, real and nonsymmetric problems.
Following a call to nag_sparseig_real_iter (f12ab), nag_sparseig_real_proc (f12ac) returns the converged approximations to eigenvalues and (optionally) the corresponding approximate eigenvectors and/or an orthonormal basis for the associated approximate invariant subspace. The eigenvalues (and eigenvectors) are selected from those of a standard or generalized eigenvalue problem defined by real nonsymmetric matrices. There is negligible additional cost to obtain eigenvectors; an orthonormal basis is always computed, but there is an additional storage cost if both are requested.
nag_sparseig_real_proc (f12ac) is based on the function dneupd from the ARPACK package, which uses the Implicitly Restarted Arnoldi iteration method. The method is described in Lehoucq and Sorensen (1996) and Lehoucq (2001) while its use within the ARPACK software is described in great detail in Lehoucq et al. (1998). An evaluation of software for computing eigenvalues of sparse nonsymmetric matrices is provided in Lehoucq and Scott (1996). This suite of functions offers the same functionality as the ARPACK software for real nonsymmetric problems, but the interface design is quite different in order to make the option setting clearer and to simplify some of the interfaces.
nag_sparseig_real_proc (f12ac), is a post-processing function that must be called following a successful final exit from nag_sparseig_real_iter (f12ab). nag_sparseig_real_proc (f12ac) uses data returned from nag_sparseig_real_iter (f12ab) and options, set either by default or explicitly by calling nag_sparseig_real_option (f12ad), to return the converged approximations to selected eigenvalues and (optionally):
 – the corresponding approximate eigenvectors; – an orthonormal basis for the associated approximate invariant subspace; – both.

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:     sigmar – double scalar
If one of the Shifted Inverse Real modes have been selected then sigmar contains the real part of the shift used; otherwise sigmar is not referenced.
2:     sigmai – double scalar
If one of the Shifted Inverse Real modes have been selected then sigmai contains the imaginary part of the shift used; otherwise sigmai is not referenced.
3:     resid( : $:$) – double array
Note: the dimension of the array resid must be at least n${\mathbf{n}}$ (see nag_sparseig_real_init (f12aa)).
Must not be modified following a call to nag_sparseig_real_iter (f12ab) since it contains data required by nag_sparseig_real_proc (f12ac).
4:     v(ldv, : $:$) – double array
The first dimension of the array v must be at least n${\mathbf{n}}$
The second dimension of the array must be at least max (1,ncv) $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{ncv}}\right)$
The ncv columns of v contain the Arnoldi basis vectors for OP$\mathrm{OP}$ as constructed by nag_sparseig_real_iter (f12ab).
5:     comm( : $:$) – double array
Note: the dimension of the array comm must be at least max (1,lcomm)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{lcomm}}\right)$ (see nag_sparseig_real_init (f12aa)).
On initial entry: must remain unchanged from the prior call to nag_sparseig_real_iter (f12ab).
6:     icomm( : $:$) – int64int32nag_int array
Note: the dimension of the array icomm must be at least max (1,licomm)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{licomm}}\right)$ (see nag_sparseig_real_init (f12aa)).
On initial entry: must remain unchanged from the prior call to nag_sparseig_real_iter (f12ab).

None.

ldz ldv

Output Parameters

1:     nconv – int64int32nag_int scalar
The number of converged eigenvalues as found by nag_sparseig_real_iter (f12ab).
2:     dr( : $:$) – double array
Note: the dimension of the array dr must be at least ${\mathbf{nev}}$ (see nag_sparseig_real_init (f12aa)).
The first nconv locations of the array dr contain the real parts of the converged approximate eigenvalues.
3:     di( : $:$) – double array
Note: the dimension of the array di must be at least ${\mathbf{nev}}$ (see nag_sparseig_real_init (f12aa)).
The first nconv locations of the array di contain the imaginary parts of the converged approximate eigenvalues.
4:     z(n × (nev + 1)${\mathbf{n}}×\left({\mathbf{nev}}+1\right)$) – double array
If the default option Vectors = RITZ${\mathbf{Vectors}}=\mathrm{RITZ}$ (see nag_sparseig_real_option (f12ad)) has been selected then z contains the final set of eigenvectors corresponding to the eigenvalues held in dr and di. The complex eigenvector associated with the eigenvalue with positive imaginary part is stored in two consecutive columns. The first column holds the real part of the eigenvector and the second column holds the imaginary part. The eigenvector associated with the eigenvalue with negative imaginary part is simply the complex conjugate of the eigenvector associated with the positive imaginary part.
5:     v(ldv, : $:$) – double array
The first dimension of the array v will be n${\mathbf{n}}$
The second dimension of the array will be max (1,ncv) $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{ncv}}\right)$
ldv = icomm(comm(1) + 1)$\mathit{ldv}={\mathbf{icomm}}\left({\mathbf{comm}}\left(1\right)+1\right)$.
If the option Vectors = SCHUR${\mathbf{Vectors}}=\mathrm{SCHUR}$ has been set, or the option Vectors = RITZ${\mathbf{Vectors}}=\mathrm{RITZ}$ has been set and a separate array z has been passed (i.e., z does not equal v), then the first nconv columns of v will contain approximate Schur vectors that span the desired invariant subspace.
6:     comm( : $:$) – double array
Note: the dimension of the array comm must be at least max (1,lcomm)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{lcomm}}\right)$ (see nag_sparseig_real_init (f12aa)).
Contains data on the current state of the solution.
7:     icomm( : $:$) – int64int32nag_int array
Note: the dimension of the array icomm must be at least max (1,licomm)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{licomm}}\right)$ (see nag_sparseig_real_init (f12aa)).
Contains data on the current state of the solution.
8:     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:

Cases prefixed with W are classified as warnings and do not generate an error of type NAG:error_n. See nag_issue_warnings.

ifail = 1${\mathbf{ifail}}=1$
On entry, ldz < max (1,n) $\mathit{ldz}<\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$ or ldz < 1 $\mathit{ldz}<1$ when no vectors are required.
W ifail = 2${\mathbf{ifail}}=2$
On entry, the option Vectors = Select ${\mathbf{Vectors}}=\text{Select}$ was selected, but this is not yet implemented.
ifail = 3${\mathbf{ifail}}=3$
The number of eigenvalues found to sufficient accuracy prior to calling nag_sparseig_real_proc (f12ac), as communicated through the parameter icomm, is zero.
ifail = 4${\mathbf{ifail}}=4$
The number of converged eigenvalues as calculated by nag_sparseig_real_iter (f12ab) differ from the value passed to it through the parameter icomm.
ifail = 5${\mathbf{ifail}}=5$
Unexpected error during calculation of a real Schur form: there was a failure to compute all the converged eigenvalues. Please contact NAG.
ifail = 6${\mathbf{ifail}}=6$
Unexpected error: the computed Schur form could not be reordered by an internal call. Please contact NAG.
ifail = 7${\mathbf{ifail}}=7$
ifail = 8${\mathbf{ifail}}=8$
Either the solver function nag_sparseig_real_iter (f12ab) has not been called prior to the call of this function or a communication array has become corrupted.
ifail = 9${\mathbf{ifail}}=9$
ifail = 10${\mathbf{ifail}}=10$

Accuracy

The relative accuracy of a Ritz value, λ $\lambda$, is considered acceptable if its Ritz estimate Tolerance × |λ| $\le {\mathbf{Tolerance}}×|\lambda |$. The default Tolerance used is the machine precision given by nag_machine_precision (x02aj).

None.

Example

function nag_sparseig_real_proc_example
n = 100;
nev = 4;
ncv = 20;

h = 1/(double(n)+1);
rho = 10;
md = repmat(4*h, double(n), 1);
me = repmat(h, double(n-1), 1);

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

dd = 2/h;
dl = -1/h - rho/2;
du = -1/h + rho/2;
y = zeros(n,1);

[icomm, comm, ifail] = nag_sparseig_real_init(int64(n), int64(nev), int64(ncv));
[icomm, comm, ifail] = nag_sparseig_real_option('REGULAR INVERSE', icomm, comm);
[icomm, comm, ifail] = nag_sparseig_real_option('GENERALIZED', icomm, comm);

% Construct m and factorise
[md, me, info] = nag_lapack_dpttrf(md, me);

while (irevcm ~= 5)
[irevcm, resid, v, x, mx, nshift, comm, icomm, ifail] = ...
nag_sparseig_real_iter(irevcm, resid, v, x, mx, comm, icomm);
if (irevcm == -1 || irevcm == 1)
y(1) = dd*x(1) + du*x(2);
for i = 2:n-1
y(i) = dl*x(i-1) + dd*x(i) + du*x(i+1);
end
y(n) = dl*x(n-1) + dd*x(n);
[x, info] = nag_lapack_dpttrs(md, me, y);
elseif (irevcm == 2)
y(1) = 4*x(1) + x(2);
for i=2:n-1
y(i) = x(i-1) + 4*x(i) + x(i+1);
end
y(n) = x(n-1) + 4*x(n);
x = h*y;
elseif (irevcm == 4)
[niter, nconv, ritzr, ritzi, rzest] = nag_sparseig_real_monit(icomm, comm);
if (niter == 1)
fprintf('\n');
end
fprintf('Iteration %2d No. converged = %d Norm of estimates = %16.8e\n', niter, nconv, norm(rzest));
end
end
[nconv, dr, di, z, v, comm, icomm, ifail] = ...
nag_sparseig_real_proc(0, 0, resid, v, comm, icomm);
nconv, dr, di, ifail

Iteration  1 No. converged = 0 Norm of estimates =   5.56325675e+03
Iteration  2 No. converged = 0 Norm of estimates =   5.44836588e+03
Iteration  3 No. converged = 0 Norm of estimates =   5.30320774e+03
Iteration  4 No. converged = 0 Norm of estimates =   6.24234186e+03
Iteration  5 No. converged = 0 Norm of estimates =   7.15674705e+03
Iteration  6 No. converged = 0 Norm of estimates =   5.45460864e+03
Iteration  7 No. converged = 0 Norm of estimates =   6.43147571e+03
Iteration  8 No. converged = 0 Norm of estimates =   5.11241161e+03
Iteration  9 No. converged = 0 Norm of estimates =   7.19327824e+03
Iteration 10 No. converged = 1 Norm of estimates =   5.77945489e+03
Iteration 11 No. converged = 2 Norm of estimates =   4.73125738e+03
Iteration 12 No. converged = 3 Norm of estimates =   5.00078500e+03

nconv =

4

dr =

1.0e+04 *

2.0383
2.0339
2.0265
2.0163

di =

0
0
0
0

ifail =

0

function f12ac_example
n = 100;
nev = 4;
ncv = 20;

h = 1/(double(n)+1);
rho = 10;
md = repmat(4*h, double(n), 1);
me = repmat(h, double(n-1), 1);

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

dd = 2/h;
dl = -1/h - rho/2;
du = -1/h + rho/2;
y = zeros(n,1);

[icomm, comm, ifail] = f12aa(int64(n), int64(nev), int64(ncv));
[icomm, comm, ifail] = f12ad('REGULAR INVERSE', icomm, comm);
[icomm, comm, ifail] = f12ad('GENERALIZED', icomm, comm);

% Construct m and factorise
[md, me, info] = f07jd(md, me);

while (irevcm ~= 5)
[irevcm, resid, v, x, mx, nshift, comm, icomm, ifail] = ...
f12ab(irevcm, resid, v, x, mx, comm, icomm);
if (irevcm == -1 || irevcm == 1)
y(1) = dd*x(1) + du*x(2);
for i = 2:n-1
y(i) = dl*x(i-1) + dd*x(i) + du*x(i+1);
end
y(n) = dl*x(n-1) + dd*x(n);
[x, info] = f07je(md, me, y);
elseif (irevcm == 2)
y(1) = 4*x(1) + x(2);
for i=2:n-1
y(i) = x(i-1) + 4*x(i) + x(i+1);
end
y(n) = x(n-1) + 4*x(n);
x = h*y;
elseif (irevcm == 4)
[niter, nconv, ritzr, ritzi, rzest] = f12ae(icomm, comm);
if (niter == 1)
fprintf('\n');
end
fprintf('Iteration %2d No. converged = %d Norm of estimates = %16.8e\n', ...
niter, nconv, norm(rzest));
end
end
[nconv, dr, di, z, v, comm, icomm, ifail] = f12ac(0, 0, resid, v, comm, icomm);
nconv, dr, di, ifail

Iteration  1 No. converged = 0 Norm of estimates =   5.56325675e+03
Iteration  2 No. converged = 0 Norm of estimates =   5.44836588e+03
Iteration  3 No. converged = 0 Norm of estimates =   5.30320774e+03
Iteration  4 No. converged = 0 Norm of estimates =   6.24234186e+03
Iteration  5 No. converged = 0 Norm of estimates =   7.15674705e+03
Iteration  6 No. converged = 0 Norm of estimates =   5.45460864e+03
Iteration  7 No. converged = 0 Norm of estimates =   6.43147571e+03
Iteration  8 No. converged = 0 Norm of estimates =   5.11241161e+03
Iteration  9 No. converged = 0 Norm of estimates =   7.19327824e+03
Iteration 10 No. converged = 1 Norm of estimates =   5.77945489e+03
Iteration 11 No. converged = 2 Norm of estimates =   4.73125738e+03
Iteration 12 No. converged = 3 Norm of estimates =   5.00078500e+03

nconv =

4

dr =

1.0e+04 *

2.0383
2.0339
2.0265
2.0163

di =

0
0
0
0

ifail =

0