NAG FL Interface
f02fkf (real_symm_sparse_arnoldi)
Note: this routine uses optional parameters to define choices in the problem specification. If you wish to use default
settings for all of the optional parameters, you need only read Sections 1 to 10 of this document. If, however, you wish to reset some or all of the settings this must be done by calling the option setting routine f12fdf from the user-supplied subroutine option. Please refer to Section 11 for a detailed description of the specification of the optional parameters.
1
Purpose
f02fkf computes selected eigenvalues and eigenvectors of a real sparse symmetric matrix.
2
Specification
Fortran Interface
Subroutine f02fkf ( |
n, nnz, a, irow, icol, nev, ncv, sigma, monit, option, nconv, w, v, ldv, resid, iuser, ruser, ifail) |
Integer, Intent (In) |
:: |
n, nnz, irow(nnz), icol(nnz), nev, ncv, ldv |
Integer, Intent (Inout) |
:: |
iuser(*), ifail |
Integer, Intent (Out) |
:: |
nconv |
Real (Kind=nag_wp), Intent (In) |
:: |
a(nnz), sigma |
Real (Kind=nag_wp), Intent (Inout) |
:: |
v(ldv,*), ruser(*) |
Real (Kind=nag_wp), Intent (Out) |
:: |
w(ncv), resid(nev) |
External |
:: |
monit, option |
|
C Header Interface
#include <nag.h>
void |
f02fkf_ (const Integer *n, const Integer *nnz, const double a[], const Integer irow[], const Integer icol[], const Integer *nev, const Integer *ncv, const double *sigma, void (NAG_CALL *monit)(const Integer *ncv, const Integer *niter, const Integer *nconv, const double w[], const double rzest[], Integer *istat, Integer iuser[], double ruser[]), void (NAG_CALL *option)(Integer icomm[], double comm[], Integer *istat, Integer iuser[], double ruser[]), Integer *nconv, double w[], double v[], const Integer *ldv, double resid[], Integer iuser[], double ruser[], Integer *ifail) |
|
C++ Header Interface
#include <nag.h> extern "C" {
void |
f02fkf_ (const Integer &n, const Integer &nnz, const double a[], const Integer irow[], const Integer icol[], const Integer &nev, const Integer &ncv, const double &sigma, void (NAG_CALL *monit)(const Integer &ncv, const Integer &niter, const Integer &nconv, const double w[], const double rzest[], Integer &istat, Integer iuser[], double ruser[]), void (NAG_CALL *option)(Integer icomm[], double comm[], Integer &istat, Integer iuser[], double ruser[]), Integer &nconv, double w[], double v[], const Integer &ldv, double resid[], Integer iuser[], double ruser[], Integer &ifail) |
}
|
The routine may be called by the names f02fkf or nagf_eigen_real_symm_sparse_arnoldi.
3
Description
f02fkf computes selected eigenvalues and the corresponding right eigenvectors of a real sparse symmetric matrix
:
A specified number, , of eigenvalues , or the shifted inverses , may be selected either by largest or smallest modulus, largest or smallest value, or, largest and smallest values (both ends). Convergence is generally faster when selecting larger eigenvalues, smaller eigenvalues can always be selected by choosing a zero inverse shift (). When eigenvalues closest to a given value are required then the shifted inverses of largest magnitude should be selected with shift equal to the required value.
The sparse matrix
is stored in symmetric coordinate storage (SCS) format. See
Section 2.1.2 in the
F11 Chapter Introduction.
f02fkf uses an implicitly restarted Arnoldi (Lanczos) iterative method to converge approximations to a set of required eigenvalues and corresponding eigenvectors. Further algorithmic information is given in
Section 9 while a fuller discussion is provided in the
F12 Chapter Introduction. If shifts are to be performed then operations using shifted inverse matrices are performed using a direct sparse solver.
4
References
Golub G H and Van Loan C F (1996) Matrix Computations (3rd Edition) Johns Hopkins University Press, Baltimore
HSL (2011) A collection of Fortran codes for large-scale scientific computation
http://www.hsl.rl.ac.uk/
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
5
Arguments
-
1:
– Integer
Input
-
On entry: , the order of the matrix .
Constraint:
.
-
2:
– Integer
Input
-
On entry: the dimension of the array
a as declared in the (sub)program from which
f02fkf is called. The number of nonzero elements in the lower triangular part of the matrix
.
Constraint:
.
-
3:
– Real (Kind=nag_wp) array
Input
-
On entry: the array of nonzero elements of the lower triangular part of the by symmetric matrix .
-
4:
– Integer array
Input
-
5:
– Integer array
Input
-
On entry: the row and column indices of the elements supplied in array
a.
If
and
then
is stored in
.
irow does not need to be ordered: an internal sort will force the correct ordering.
Constraint:
irow and
icol must satisfy these constraints:
and
, for
.
-
6:
– Integer
Input
-
On entry: the number of eigenvalues to be computed.
Constraint:
.
-
7:
– Integer
Input
-
On entry: the dimension of the array
w as declared in the (sub)program from which
f02fkf is called.
The number of Arnoldi 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
. 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 computation time is problem dependent and must be determined empirically.
Constraint:
.
-
8:
– Real (Kind=nag_wp)
Input
-
On entry: if the
Shifted Inverse mode has been selected then
sigma contains the real shift used; otherwise
sigma is not referenced. This mode can be selected by setting the appropriate options in the user-supplied subroutine
option.
-
9:
– Subroutine, supplied by the NAG Library or the user.
External Procedure
-
monit is used to monitor the progress of
f02fkf.
monit may be the dummy subroutine
f02fkz if no monitoring is actually required. (
f02fkz is included in the NAG Library.)
monit is called after the solution of each eigenvalue sub-problem and also just prior to return from
f02fkf.
The specification of
monit is:
Fortran Interface
Integer, Intent (In) |
:: |
ncv, niter, nconv |
Integer, Intent (Inout) |
:: |
istat, iuser(*) |
Real (Kind=nag_wp), Intent (In) |
:: |
w(ncv), rzest(ncv) |
Real (Kind=nag_wp), Intent (Inout) |
:: |
ruser(*) |
|
C++ Header Interface
#include <nag.h> extern "C" {
}
|
-
1:
– Integer
Input
-
On entry: the dimension of the arrays
w and
rzest. The number of Arnoldi basis vectors used during the computation.
-
2:
– Integer
Input
-
On entry: the number of the current Arnoldi iteration.
-
3:
– Integer
Input
-
On entry: the number of converged eigenvalues so far.
-
4:
– Real (Kind=nag_wp) array
Input
-
On entry: the first
nconv elements of
w contain the converged approximate eigenvalues.
-
5:
– Real (Kind=nag_wp) array
Input
-
On entry: the first
nconv elements of
rzest contain the Ritz estimates (error bounds) on the converged approximate eigenvalues.
-
6:
– Integer
Input/Output
-
On entry: set to zero.
On exit: if set to a nonzero value f02fkf returns immediately with .
-
7:
– Integer array
User Workspace
-
8:
– Real (Kind=nag_wp) array
User Workspace
-
monit is called with the arguments
iuser and
ruser as supplied to
f02fkf. You should use the arrays
iuser and
ruser to supply information to
monit.
monit must either be a module subprogram USEd by, or declared as EXTERNAL in, the (sub)program from which
f02fkf is called. Arguments denoted as
Input must
not be changed by this procedure.
-
10:
– Subroutine, supplied by the NAG Library or the user.
External Procedure
-
You can supply non-default options to the Arnoldi eigensolver by repeated calls to
f12fdf from within
option. (Please note that it is only necessary to call
f12fdf; no call to
f12faf is required from within
option.) For example, you can set the mode to
Shifted Inverse, you can increase the
Iteration Limit beyond its default and you can print varying levels of detail on the iterative process using
Print Level.
If only the default options (including that the eigenvalues of largest magnitude are sought) are to be used then
option may be the dummy subroutine
f02eky (
f02eky is included in the NAG Library). See
Section 10 for an example of using
option to set some non-default options.
The specification of
option is:
Fortran Interface
Integer, Intent (Inout) |
:: |
icomm(*), istat, iuser(*) |
Real (Kind=nag_wp), Intent (Inout) |
:: |
comm(*), ruser(*) |
|
C++ Header Interface
#include <nag.h> extern "C" {
}
|
-
1:
– Integer array
Communication Array
-
On entry: contains details of the default option set. This array must be passed as argument
icomm in any call to
f12fdf.
On exit: contains data on the current options set which may be altered from the default set via calls to
f12fdf.
-
2:
– Real (Kind=nag_wp) array
Communication Array
-
On entry: contains details of the default option set. This array must be passed as argument
comm in any call to
f12fdf.
On exit: contains data on the current options set which may be altered from the default set via calls to
f12fdf.
-
3:
– Integer
Input/Output
-
On entry: set to zero.
On exit: if set to a nonzero value f02fkf returns immediately with .
-
4:
– Integer array
User Workspace
-
5:
– Real (Kind=nag_wp) array
User Workspace
-
option is called with the arguments
iuser and
ruser as supplied to
f02fkf. You should use the arrays
iuser and
ruser to supply information to
option.
option must either be a module subprogram USEd by, or declared as EXTERNAL in, the (sub)program from which
f02fkf is called.
-
11:
– Integer
Output
-
On exit: the number of converged approximations to the selected eigenvalues. On successful exit, this will normally be
nev.
-
12:
– Real (Kind=nag_wp) array
Output
-
On exit: the first
nconv elements contain the converged approximations to the selected eigenvalues.
-
13:
– Real (Kind=nag_wp) array
Output
-
Note: the second dimension of the array
v
must be at least
.
On exit: contains the eigenvectors associated with the eigenvalue
, for
(stored in
w). For eigenvalue,
, the corresponding eigenvector is stored in
, for
.
-
14:
– Integer
Input
-
On entry: the first dimension of the array
v as declared in the (sub)program from which
f02fkf is called.
Constraint:
.
-
15:
– Real (Kind=nag_wp) array
Output
-
On exit: the residual for the estimates to the eigenpair and is returned in , for .
-
16:
– Integer array
User Workspace
-
iuser is not used by
f02fkf, but is passed directly to
monit and
option and may be used to pass information to these routines.
-
17:
– Real (Kind=nag_wp) array
User Workspace
-
ruser is not used by
f02fkf, but is passed directly to
monit and
option and may be used to pass information to these routines.
-
18:
– Integer
Input/Output
-
On entry:
ifail must be set to
,
or
to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of means that an error message is printed while a value of means that it is not.
If halting is not appropriate, the value
or
is recommended. If message printing is undesirable, then the value
is recommended. Otherwise, the value
is recommended.
When the value or is used it is essential to test the value of ifail on exit.
On exit:
unless the routine detects an error or a warning has been flagged (see
Section 6).
6
Error Indicators and Warnings
If on entry
or
, explanatory error messages are output on the current error message unit (as defined by
x04aaf).
Errors or warnings detected by the routine:
-
On entry, .
Constraint: .
-
On entry, .
Constraint: .
On entry, and .
Constraint: .
-
On entry, for , .
Constraint: .
-
On entry, for , , .
Constraint: .
-
On entry, .
Constraint: .
On entry, and .
Constraint: .
-
On entry, and .
Constraint: .
On entry, and .
Constraint: .
-
On entry, the matrix is numerically singular and could not be inverted. Try perturbing the value of .
-
User requested termination in
monit,
.
-
User requested termination in
option,
.
-
On entry, and .
Constraint: .
-
The maximum number of iterations, through the optional parameter
Iteration Limit, has been set to a non-positive value.
-
The option
Both Ends has been set but only
eigenvalue is requested.
-
The maximum number of iterations has been reached.
The maximum number of iterations .
The number of converged eigenvalues .
See the routine document for further details.
-
A serious error, code
, has occurred in an internal call. Check all subroutine calls and array sizes. If the call is correct then please contact
NAG for assistance.
An unexpected error has been triggered by this routine. Please
contact
NAG.
See
Section 7 in the Introduction to the NAG Library FL Interface for further information.
Your licence key may have expired or may not have been installed correctly.
See
Section 8 in the Introduction to the NAG Library FL Interface for further information.
Dynamic memory allocation failed.
See
Section 9 in the Introduction to the NAG Library FL Interface for further information.
7
Accuracy
The relative accuracy of a Ritz value (eigenvalue approximation),
, is considered acceptable if its Ritz estimate
. The default value for
Tolerance is the
machine precision given by
x02ajf. The Ritz estimates are available via the
monit subroutine at each iteration in the Arnoldi process, or can be printed by setting option
Print Level to a positive value.
8
Parallelism and Performance
f02fkf is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
f02fkf makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the
X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the
Users' Note for your implementation for any additional implementation-specific information.
f02fkf calls routines based on the ARPACK suite in
Chapter F12. These routines use an implicitly restarted Lanczos iterative method to converge to approximations to a set of required eigenvalues (see the
F12 Chapter Introduction).
In the default
Regular mode, only matrix-vector multiplications are performed using the sparse matrix
during the Lanczos process;
f11xef can be used to perform this task. Each iteration is therefore cheap computationally, relative to the alternative,
Shifted Inverse, mode described below. It is most efficient (i.e., the total number of iterations required is small) when the eigenvalues of largest magnitude are sought and these are distinct.
Although there is an option for returning the smallest eigenvalues using this mode (see
Smallest Magnitude option), the number of iterations required for convergence will be far greater or the method may not converge at all. However, where convergence is achieved,
Regular mode may still prove to be the most efficient since no inversions are required. Where smallest eigenvalues are sought and
Regular mode is not suitable, or eigenvalues close to a given real value are sought, the
Shifted Inverse mode should be used.
If the
Shifted Inverse mode is used (via a call to
f12fdf in
option) then the matrix
is used in linear system solves by the Lanczos process. This is first factorized internally using a direct sparse
factorization under the assumption that the matrix is indefinite. If the factorization determines that the matrix is numerically singular then the routine exits with an error. In this situation it is normally sufficient to perturb
by a small amount and call
f02fkf again. After successful factorization, subsequent solves are performed by backsubstitution using the sparse factorization.
Finally, f02fkf transforms the eigenvectors. Each eigenvector is normalized so that .
The monitoring routine
monit provides some basic information on the convergence of the Lanczos iterations. Much greater levels of detail on the Lanczos process are available via option
Print Level. If this is set to a positive value then information will be printed, by default, to standard output. The destination of monitoring information can be changed using the
Monitoring option.
9.1
Additional Licensor
The direct sparse factorization is performed by an implementation of HSL_MA97 (see
HSL (2011)).
10
Example
This example solves
in
Shifted Inverse mode, where
is obtained from the standard central difference discretization of the one-dimensional Laplacian operator
on
, with zero Dirichlet boundary conditions.
10.1
Program Text
10.2
Program Data
10.3
Program Results
11
Optional Parameters
Internally
f02fkf calls routines from the suite
f12faf,
f12fbf,
f12fcf,
f12fdf and
f12fef. Several optional parameters for these computational routines define choices in the problem specification or the algorithm logic. In order to reduce the number of formal arguments of
f02fkf these optional parameters are also used here and have associated
default values that are usually appropriate. Therefore, you need only specify those optional parameters whose values are to be different from their default values.
Optional parameters may be specified via the user-supplied subroutine
option in the call to
f02fkf.
option must be coded such that one call to
f12fdf is necessary to set each optional parameter. All optional parameters you do not specify are set to their default values.
The remainder of this section can be skipped if you wish to use the default values for all optional parameters.
The following is a list of the optional parameters available. A full description of each optional parameter is provided in
Section 11.1.
11.1
Description of the Optional Parameters
For each option, we give a summary line, a description of the optional parameter and details of constraints.
The summary line contains:
- the keywords, where the minimum abbreviation of each keyword is underlined;
- a parameter value,
where the letters , and denote options that take character, integer and real values respectively;
- the default value, where the symbol is a generic notation for machine precision (see x02ajf).
Keywords and character values are case and white space insensitive.
Advisory | | Default |
If the optional parameter
List is set then optional parameter specifications are listed in a
List file by setting the option to a file identification (unit) number associated with advisory messages (see
x04abf and
x04acf).
This special keyword may be used to reset all optional parameters to their default values.
Iteration Limit | |
Default
|
The limit on the number of Lanczos iterations that can be performed before
f12fbf exits. If not all requested eigenvalues have converged to within
Tolerance and the number of Lanczos iterations has reached this limit then
f12fbf exits with an error;
f12fcf can still be called subsequently to return the number of converged eigenvalues, the converged eigenvalues and, if requested, the corresponding eigenvectors.
Largest Magnitude | | Default |
The Lanczos iterative method converges on a number of eigenvalues with given properties. The default is for
f12fbf to compute the eigenvalues of largest magnitude using
Largest Magnitude. Alternatively, eigenvalues may be chosen which have
Largest Algebraic part,
Smallest Magnitude, or
Smallest Algebraic part; or eigenvalues which are from
Both Ends of the algebraic spectrum.
Optional parameter
List enables printing of each optional parameter specification as it is supplied.
Nolist suppresses this printing.
If
, monitoring information is output to unit number
during the solution of each problem; this may be the same as the
Advisory unit number. The type of information produced is dependent on the value of
Print Level, see the description of the optional parameter
Print Level for details of the information produced. Please see
x04acf to associate a file with a given unit number.
This controls the amount of printing produced by
f02fkf as follows.
|
No output except error messages. If you want to suppress all output, set . |
|
The set of selected options. |
|
Problem and timing statistics on final exit from f12fbf. |
|
A single line of summary output at each Lanczos iteration. |
|
If
Monitoring is set, then at each iteration, the length and additional steps of the current Lanczos factorization and the number of converged Ritz values; during re-orthogonalization, the norm of initial/restarted starting vector; on a final Lanczos iteration, the number of update iterations taken, the number of converged eigenvalues, the converged eigenvalues and their Ritz estimates. |
|
Problem and timing statistics on final exit from f12fbf. If
,
Monitoring is set,
then at each iteration, the number of shifts being applied, the eigenvalues and estimates of the symmetric tridiagonal matrix , the size of the Lanczos basis, the wanted Ritz values and associated Ritz estimates and the shifts applied; vector norms prior to and following re-orthogonalization. |
|
If
,
Monitoring is set,
then on final iteration, the norm of the residual; when computing the Schur form, the eigenvalues and Ritz estimates both before and after sorting; for each iteration, the norm of residual for compressed factorization and the symmetric tridiagonal matrix ; during re-orthogonalization, the initial/restarted starting vector; during the Lanczos iteration loop, a restart is flagged and the number of the residual requiring iterative refinement; while applying shifts, some indices. |
|
If
,
Monitoring is set,
then during the Lanczos iteration loop, the Lanczos vector number and norm of the current residual; while applying shifts, key measures of progress and the order of ; while computing eigenvalues of , the last rows of the Schur and eigenvector matrices; when computing implicit shifts, the eigenvalues and Ritz estimates of . |
|
If Monitoring is set, then during Lanczos iteration loop: norms of key components and the active column of , norms of residuals during iterative refinement, the final symmetric tridiagonal matrix ; while applying shifts: number of shifts, shift values, block indices, updated tridiagonal matrix ; while computing eigenvalues of : the diagonals of , the computed eigenvalues and Ritz estimates. |
Note that setting
can result in very lengthy
Monitoring output.
These options define the computational mode which in turn defines the form of operation to be performed.
An approximate eigenvalue has deemed to have converged when the corresponding Ritz estimate is within
Tolerance relative to the magnitude of the eigenvalue.