PDF version (NAG web site
, 64bit version, 64bit version)
NAG Toolbox: nag_sparseig_real_iter (f12ab)
Purpose
nag_sparseig_real_iter (f12ab) is an iterative solver used to find some of the eigenvalues (and optionally the corresponding eigenvectors) of a standard or generalized eigenvalue problem defined by real nonsymmetric matrices. This is part of a suite of functions that also includes
nag_sparseig_real_init (f12aa),
nag_sparseig_real_proc (f12ac),
nag_sparseig_real_option (f12ad) and
nag_sparseig_real_monit (f12ae). It is
Syntax
[
irevcm,
resid,
v,
x,
mx,
nshift,
comm,
icomm,
ifail] = f12ab(
irevcm,
resid,
v,
x,
mx,
comm,
icomm)
[
irevcm,
resid,
v,
x,
mx,
nshift,
comm,
icomm,
ifail] = nag_sparseig_real_iter(
irevcm,
resid,
v,
x,
mx,
comm,
icomm)
Description
The suite of functions is designed to calculate some of the eigenvalues, $\lambda $, (and optionally the corresponding eigenvectors, $x$) of a standard eigenvalue problem $Ax=\lambda x$, or of a generalized eigenvalue problem $Ax=\lambda Bx$ of order $n$, where $n$ is large and the coefficient matrices $A$ and $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.
nag_sparseig_real_iter (f12ab) is a
reverse communication function, based on the ARPACK routine
dnaupd, using 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 the interface of
nag_sparseig_real_iter (f12ab).
The setup function
nag_sparseig_real_init (f12aa) must be called before
nag_sparseig_real_iter (f12ab), the reverse communication iterative solver. Options may be set for
nag_sparseig_real_iter (f12ab) by prior calls to the option setting function
nag_sparseig_real_option (f12ad) and a postprocessing function
nag_sparseig_real_proc (f12ac) must be called following a successful final exit from
nag_sparseig_real_iter (f12ab).
nag_sparseig_real_monit (f12ae), may be called following certain flagged, intermediate exits from
nag_sparseig_real_iter (f12ab) to provide additional monitoring information about the computation.
nag_sparseig_real_iter (f12ab) uses
reverse communication, i.e., it returns repeatedly to the calling program with the argument
irevcm (see
Arguments) set to specified values which require the calling program to carry out one of the following tasks:
 – compute the matrixvector product $y=\mathrm{OP}x$, where $\mathrm{OP}$ is defined by the computational mode;
 – compute the matrixvector product $y=Bx$;
 – notify the completion of the computation;
 – allow the calling program to monitor the solution.
The problem type to be solved (standard or generalized), the spectrum of eigenvalues of interest, the mode used (regular, regular inverse, shifted inverse, shifted real or shifted imaginary) and other options can all be set using the option setting function
nag_sparseig_real_option (f12ad) (see
Description of the s in
nag_sparseig_real_option (f12ad) for details on setting options and of the default settings).
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 MCSP5471195 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 Largescale Eigenvalue Problems with Implicitly Restarted Arnoldi Methods SIAM, Philidelphia
Parameters
Note: this function uses
reverse communication. Its use involves an initial entry, intermediate exits and reentries, and a final exit, as indicated by the argument
irevcm. Between intermediate exits and reentries,
all arguments other than x, mx and comm must remain unchanged.
Compulsory Input Parameters
 1:
$\mathrm{irevcm}$ – int64int32nag_int scalar

On initial entry: ${\mathbf{irevcm}}=0$, otherwise an error condition will be raised.
On intermediate reentry: must be unchanged from its previous exit value. Changing
irevcm to any other value between calls will result in an error.
Constraint:
on initial entry,
${\mathbf{irevcm}}=0$; on reentry
irevcm must remain unchanged.
 2:
$\mathrm{resid}\left(:\right)$ – double array

The dimension of the array
resid
must be at least
${\mathbf{n}}$ (see
nag_sparseig_real_init (f12aa))
On initial entry: need not be set unless the option
Initial Residual has been set in a prior call to
nag_sparseig_real_option (f12ad) in which case
resid should contain an initial residual vector, possibly from a previous run.
On intermediate reentry: must be unchanged from its previous exit. Changing
resid to any other value between calls may result in an error exit.
 3:
$\mathrm{v}\left(\mathit{ldv},:\right)$ – double array

The first dimension of the array
v must be at least
${\mathbf{n}}$.
The second dimension of the array
v must be at least
$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{ncv}}\right)$.
On initial entry: need not be set.
On intermediate reentry: must be unchanged from its previous exit.
 4:
$\mathrm{x}\left(:\right)$ – double array

The dimension of the array
x
must be at least
${\mathbf{n}}$ (see
nag_sparseig_real_init (f12aa))
On initial entry: need not be set, it is used as a convenient mechanism for accessing elements of
comm.
On intermediate reentry: if
${\mathbf{Pointers}}=\mathrm{YES}$,
x need not be set.
If
${\mathbf{Pointers}}=\mathrm{NO}$,
x must contain the result of
$y=\mathrm{OP}x$ when
irevcm returns the value
$1$ or
$+1$. It must return the real parts of the computed shifts when
irevcm returns the value
$3$.
 5:
$\mathrm{mx}\left(:\right)$ – double array

The dimension of the array
mx
must be at least
${\mathbf{n}}$ (see
nag_sparseig_real_init (f12aa))
On initial entry: need not be set, it is used as a convenient mechanism for accessing elements of
comm.
On intermediate reentry: if
${\mathbf{Pointers}}=\mathrm{YES}$,
mx need not be set.
If
${\mathbf{Pointers}}=\mathrm{NO}$,
mx must contain the result of
$y=Bx$ when
irevcm returns the value
$2$. It must return the imaginary parts of the computed shifts when
irevcm returns the value
$3$.
 6:
$\mathrm{comm}\left(:\right)$ – double array

The dimension of the array
comm
must be at least
$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{lcomm}}\right)$ (see
nag_sparseig_real_init (f12aa))
On initial entry: must remain unchanged following a call to the setup function
nag_sparseig_real_init (f12aa).
 7:
$\mathrm{icomm}\left(:\right)$ – int64int32nag_int array

The dimension of the array
icomm
must be at least
$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{licomm}}\right)$ (see
nag_sparseig_real_init (f12aa))
On initial entry: must remain unchanged following a call to the setup function
nag_sparseig_real_init (f12aa).
Optional Input Parameters
None.
Output Parameters
 1:
$\mathrm{irevcm}$ – int64int32nag_int scalar

On intermediate exit:
has the following meanings.
 ${\mathbf{irevcm}}=1$
 The calling program must compute the matrixvector product $y=\mathrm{OP}x$, where $x$ is stored in x (by default) or in the array comm (starting from the location given by the first element of icomm) when the option ${\mathbf{Pointers}}=\mathrm{YES}$ is set in a prior call to nag_sparseig_real_option (f12ad). The result $y$ is returned in x (by default) or in the array comm (starting from the location given by the second element of icomm) when the option ${\mathbf{Pointers}}=\mathrm{YES}$ is set.
If $B$ is not symmetric semidefinite then the precomputed values in mx should not be used (see the explanation under ${\mathbf{irevcm}}=2$).
 ${\mathbf{irevcm}}=1$
 The calling program must compute the matrixvector product $y=\mathrm{OP}x$. This is similar to the case ${\mathbf{irevcm}}=1$ except that the result of the matrixvector product $Bx$ (as required in some computational modes) has already been computed and is available in mx (by default) or in the array comm (starting from the location given by the third element of icomm) when the option ${\mathbf{Pointers}}=\mathrm{YES}$ is set.
 ${\mathbf{irevcm}}=2$
 The calling program must compute the matrixvector product $y=Bx$, where $x$ is stored as described in the case ${\mathbf{irevcm}}=1$ and $y$ is returned in the location described by the case ${\mathbf{irevcm}}=1$.
This computation is requested when solving the Generalized problem using either Shifted Inverse Imaginary or Shifted Inverse Real; in these cases $B$ is used as an innerproduct space and requires that $B$ be symmetric semidefinite. If neither $A$ nor $B$ is symmetric semidefinite then the problem should be reformulated in a Standard form.
 ${\mathbf{irevcm}}=3$
 Compute the nshift real and imaginary parts of the shifts where the real parts are to be returned in the first nshift locations of the array x and the imaginary parts are to be returned in the first nshift locations of the array mx. Only complex conjugate pairs of shifts may be applied and the pairs must be placed in consecutive locations. This value of irevcm will only arise if the optional parameter Supplied Shifts is set in a prior call to nag_sparseig_real_option (f12ad) which is intended for experienced users only; the default and recommended option is to use exact shifts (see Lehoucq et al. (1998) for details).
 ${\mathbf{irevcm}}=4$
 Monitoring step: a call to nag_sparseig_real_monit (f12ae) can now be made to return the number of Arnoldi iterations, the number of converged Ritz values, their real and imaginary parts, and the corresponding Ritz estimates.
On final exit:
${\mathbf{irevcm}}=5$:
nag_sparseig_real_iter (f12ab) has completed its tasks. The value of
ifail determines whether the iteration has been successfully completed, or whether errors have been detected. On successful completion
nag_sparseig_real_proc (f12ac) must be called to return the requested eigenvalues and eigenvectors (and/or Schur vectors).
 2:
$\mathrm{resid}\left(:\right)$ – double array

The dimension of the array
resid will be
${\mathbf{n}}$ (see
nag_sparseig_real_init (f12aa))
On intermediate exit:
contains the current residual vector.
On final exit: contains the final residual vector.
 3:
$\mathrm{v}\left(\mathit{ldv},:\right)$ – double array

The first dimension of the array
v will be
${\mathbf{n}}$.
The second dimension of the array
v will be
$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{ncv}}\right)$.
On intermediate exit:
contains the current set of Arnoldi basis vectors.
On final exit: contains the final set of Arnoldi basis vectors.
 4:
$\mathrm{x}\left(:\right)$ – double array

The dimension of the array
x will be
${\mathbf{n}}$ (see
nag_sparseig_real_init (f12aa))
On intermediate exit:
if
${\mathbf{Pointers}}=\mathrm{YES}$,
x is not referenced.
If
${\mathbf{Pointers}}=\mathrm{NO}$,
x contains the vector
$x$ when
irevcm returns the value
$1$ or
$+1$.
On final exit: does not contain useful data.
 5:
$\mathrm{mx}\left(:\right)$ – double array

The dimension of the array
mx will be
${\mathbf{n}}$ (see
nag_sparseig_real_init (f12aa))
On intermediate exit:
if
${\mathbf{Pointers}}=\mathrm{YES}$,
mx is not referenced.
If
${\mathbf{Pointers}}=\mathrm{NO}$,
mx contains the vector
$Bx$ when
irevcm returns the value
$+1$.
On final exit: does not contain any useful data.
 6:
$\mathrm{nshift}$ – int64int32nag_int scalar

On intermediate exit:
if the option
Supplied Shifts is set and
irevcm returns a value of
$3$,
nshift returns the number of complex shifts required.
 7:
$\mathrm{comm}\left(:\right)$ – double array

The dimension of the array
comm will be
$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{lcomm}}\right)$ (see
nag_sparseig_real_init (f12aa))
Contains data defining the current state of the iterative process.
 8:
$\mathrm{icomm}\left(:\right)$ – int64int32nag_int array

The dimension of the array
icomm will be
$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{licomm}}\right)$ (see
nag_sparseig_real_init (f12aa))
Contains data defining the current state of the iterative process.
 9:
$\mathrm{ifail}$ – int64int32nag_int scalar
On final exit:
${\mathbf{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.
 ${\mathbf{ifail}}=1$

On initial entry, the maximum number of iterations
$\le 0$, the option
Iteration Limit has been set to a nonpositive value.
 ${\mathbf{ifail}}=2$

The options
Generalized and
Regular are incompatible.
 ${\mathbf{ifail}}=3$

The option
Initial Residual was selected but the starting vector held in
resid is zero.
 W ${\mathbf{ifail}}=4$

The maximum number of iterations has been reached. Some Ritz values may have converged; a subsequent call to
nag_sparseig_real_proc (f12ac) will return the number of converged values and the converged values.
 ${\mathbf{ifail}}=5$

No shifts could be applied during a cycle of the implicitly restarted Arnoldi iteration. One possibility is to increase the size of
ncv relative to
nev (see
Arguments in
nag_sparseig_real_init (f12aa) for details of these arguments).
 ${\mathbf{ifail}}=6$

Could not build an Arnoldi factorization. Consider changing
ncv or
nev in the initialization function (see
Arguments in
nag_sparseig_real_init (f12aa) for details of these arguments).
 ${\mathbf{ifail}}=7$

Unexpected error in internal call to compute eigenvalues and corresponding error bounds of the current upper Hessenberg matrix. Please contact
NAG.
 ${\mathbf{ifail}}=8$

Either the initialization function
nag_sparseig_real_init (f12aa) has not been called prior to the first call of this function or a communication array has become corrupted.
 ${\mathbf{ifail}}=9$

An unexpected error has occurred. Please contact
NAG.
 ${\mathbf{ifail}}=99$
An unexpected error has been triggered by this routine. Please
contact
NAG.
 ${\mathbf{ifail}}=399$
Your licence key may have expired or may not have been installed correctly.
 ${\mathbf{ifail}}=999$
Dynamic memory allocation failed.
Accuracy
The relative accuracy of a Ritz value,
$\lambda $, is considered acceptable if its Ritz estimate
$\text{}\le {\mathbf{Tolerance}}\times \left\lambda \right$. The default
Tolerance used is the
machine precision given by
nag_machine_precision (x02aj).
Further Comments
None.
Example
This example solves $Ax=\lambda x$ in shiftinvert mode, where $A$ is obtained from the standard central difference discretization of the convectiondiffusion operator $\frac{{\partial}^{2}u}{\partial {x}^{2}}+\frac{{\partial}^{2}u}{\partial {y}^{2}}+\rho \frac{\partial u}{\partial x}$ on the unit square, with zero Dirichlet boundary conditions. The shift used is a real number.
Open in the MATLAB editor:
f12ab_example
function f12ab_example
fprintf('f12ab example results\n\n');
load('west0479.mat')
S = west0479;
[irow,icol,a] = find(S);
n = int64(size(S,1));
sigma = 100;
C = S  sigma*eye(n);
C = inv(C);
nev = int64(10);
ncv = int64(30);
irevcm = int64(0);
resid = zeros(n,1);
v = zeros(n, ncv);
x = zeros(n, 1);
mx = zeros(n);
[icomm, comm, ifail] = f12aa( ...
n, nev, ncv);
[icomm, comm, ifail] = f12ad( ...
'Shifted Inverse Real', icomm, comm);
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)
x = C*x;
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 = %10.2e\n', ...
niter, nconv, norm(rzest));
end
end
[nconv, dr, di, z, v, comm, icomm, ifail] = ...
f12ac( ...
sigma, 0, resid, v, comm, icomm);
fprintf('\nThe %4d Ritz values closest to %8.2f are:\n\n', size(dr,1), sigma);
fprintf('%9.3f %+9.3fi\n', [dr di]');
f12ab example results
Iteration 1 No. converged = 1 Norm of estimates = 3.31e05
Iteration 2 No. converged = 5 Norm of estimates = 3.04e05
Iteration 3 No. converged = 7 Norm of estimates = 2.07e04
Iteration 4 No. converged = 7 Norm of estimates = 2.22e04
Iteration 5 No. converged = 8 Norm of estimates = 2.43e04
The 10 Ritz values closest to 100.00 are:
74.635 +0.000i
108.125 54.066i
108.125 +54.066i
59.789 43.689i
59.789 +43.689i
43.062 39.164i
43.062 +39.164i
33.707 17.557i
33.707 +17.557i
35.662 +0.000i
PDF version (NAG web site
, 64bit version, 64bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015