NAG Library Function Document
nag_eigen_real_gen_sparse_arnoldi (f02ekc)
Note: this function uses optional arguments to define choices in the problem specification. If you wish to use default
settings for all of the optional arguments, 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 function nag_real_sparse_eigensystem_option (f12adc) from the user-supplied function option. Please refer to Section 11 for a detailed description of the specification of the optional arguments.
1 Purpose
nag_eigen_real_gen_sparse_arnoldi (f02ekc) computes selected eigenvalues and eigenvectors of a real sparse general matrix.
2 Specification
#include <nag.h> |
#include <nagf02.h> |
void |
nag_eigen_real_gen_sparse_arnoldi (Integer n,
Integer nnz,
double a[],
const Integer icolzp[],
const Integer irowix[],
Integer nev,
Integer ncv,
double sigma,
Integer *nconv,
Complex w[],
double v[],
Integer pdv,
double resid[],
Nag_Comm *comm,
NagError *fail) |
|
3 Description
nag_eigen_real_gen_sparse_arnoldi (f02ekc) computes selected eigenvalues and the corresponding right eigenvectors of a real sparse general matrix
:
A specified number, , of eigenvalues , or the shifted inverses , may be selected either by largest or smallest modulus, largest or smallest real part, or, largest or smallest imaginary part. 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 real value are required then the shifted inverses of largest magnitude should be selected with shift equal to the required real value.
Note that even though is real, and may be complex. If is an eigenvector corresponding to a complex eigenvalue , then the complex conjugate vector is the eigenvector corresponding to the complex conjugate eigenvalue . The eigenvalues in a complex conjugate pair and are either both selected or both not selected.
The sparse matrix
is stored in compressed column storage (CCS) format. See
Section 2.1.3 in the f11 Chapter Introduction.
nag_eigen_real_gen_sparse_arnoldi (f02ekc) uses an implicitly restarted Arnoldi 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; further information on the solver used is provided in the
f11 Chapter Introduction.
4 References
Golub G H and Van Loan C F (1996) Matrix Computations (3rd Edition) Johns Hopkins University Press, Baltimore
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:
– IntegerInput
-
On entry: , the order of the matrix .
Constraint:
.
- 2:
– IntegerInput
-
On entry: the dimension of the array
a.The number of nonzero elements of the matrix
and, if a nonzero shifted inverse is to be applied, all diagonal elements. Each nonzero is counted once in the latter case.
Constraint:
.
- 3:
– doubleInput/Output
-
On entry: the array of nonzero elements (and diagonal elements if a nonzero inverse shift is to be applied) of the by general matrix .
On exit: if a nonzero shifted inverse is to be applied then the diagonal elements of
have the shift value, as supplied in
sigma, subtracted.
- 4:
– const IntegerInput
-
On entry:
contains the index in
a of the start of column
, for
;
must contain the value
. Thus the number of nonzero elements in column
of
is
; when shifts are applied this includes diagonal elements irrespective of value. See
Section 2.1.3 in the f11 Chapter Introduction.
- 5:
– const IntegerInput
-
On entry:
contains the row index for each entry in
a. See
Section 2.1.3 in the f11 Chapter Introduction.
- 6:
– IntegerInput
-
On entry: the number of eigenvalues to be computed.
Constraint:
.
- 7:
– IntegerInput
-
On entry: the dimension of the array
w.
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 CPU time is problem dependent and must be determined empirically.
Constraint:
.
- 8:
– doubleInput
-
On entry: if the
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 function
option.
- 9:
– function, supplied by the userExternal Function
-
monit is used to monitor the progress of nag_eigen_real_gen_sparse_arnoldi (f02ekc).
monit may be specified as
NULLFN
if no monitoring is actually required.
monit is called after the solution of each eigenvalue sub-problem and also just prior to return from nag_eigen_real_gen_sparse_arnoldi (f02ekc).
The specification of
monit is:
- 1:
– IntegerInput
-
On entry: the dimension of the arrays
w and
rzest. The number of Arnoldi basis vectors used during the computation.
- 2:
– IntegerInput
-
On entry: the number of the current Arnoldi iteration.
- 3:
– IntegerInput
-
On entry: the number of converged eigenvalues so far.
- 4:
– const ComplexInput
-
On entry: the first
nconv elements of
w contain the converged approximate eigenvalues.
- 5:
– const doubleInput
-
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 nag_eigen_real_gen_sparse_arnoldi (f02ekc) returns immediately with
NE_USER_STOP.
- 7:
– Nag_Comm *
Pointer to structure of type Nag_Comm; the following members are relevant to
monit.
- user – double *
- iuser – Integer *
- p – Pointer
The type Pointer will be
void *. Before calling nag_eigen_real_gen_sparse_arnoldi (f02ekc) you may allocate memory and initialize these pointers with various quantities for use by
monit when called from nag_eigen_real_gen_sparse_arnoldi (f02ekc) (see
Section 3.2.1.1 in the Essential Introduction).
- 10:
– function, supplied by the userExternal Function
-
You can supply non-default options to the Arnoldi eigensolver by repeated calls to
nag_real_sparse_eigensystem_option (f12adc) from within
option. (Please note that it is only necessary to call
nag_real_sparse_eigensystem_option (f12adc); no call to
nag_real_sparse_eigensystem_init (f12aac) is required from within
option.) For example, you can set the mode to
, you can increase the
beyond its default and you can print varying levels of detail on the iterative process using
.
If only the default options (including that the eigenvalues of largest magnitude are sought) are to be used then
option may be specified as
NULLFN. See
Section 10 for an example of using
option to set some non-default options.
The specification of
option is:
- 1:
– IntegerCommunication Array
-
On entry: contains details of the default option set. This array must be passed as argument
icomm in any call to
nag_real_sparse_eigensystem_option (f12adc).
On exit: contains data on the current options set which may be altered from the default set via calls to
nag_real_sparse_eigensystem_option (f12adc).
- 2:
– doubleCommunication Array
-
On entry: contains details of the default option set. This array must be passed as argument
comm in any call to
nag_real_sparse_eigensystem_option (f12adc).
On exit: contains data on the current options set which may be altered from the default set via calls to
nag_real_sparse_eigensystem_option (f12adc).
- 3:
– Integer *Input/Output
-
On entry: set to zero.
On exit: if set to a nonzero value nag_eigen_real_gen_sparse_arnoldi (f02ekc) returns immediately with
NE_USER_STOP.
- 4:
– Nag_Comm *
Pointer to structure of type Nag_Comm; the following members are relevant to
option.
- user – double *
- iuser – Integer *
- p – Pointer
The type Pointer will be
void *. Before calling nag_eigen_real_gen_sparse_arnoldi (f02ekc) you may allocate memory and initialize these pointers with various quantities for use by
option when called from nag_eigen_real_gen_sparse_arnoldi (f02ekc) (see
Section 3.2.1.1 in the Essential Introduction).
- 11:
– Integer *Output
-
On exit: the number of converged approximations to the selected eigenvalues. On successful exit, this will normally be either
nev or
depending on the number of complex conjugate pairs of eigenvalues returned.
- 12:
– ComplexOutput
-
On exit: the first
nconv elements contain the converged approximations to the selected eigenvalues. Since complex conjugate pairs of eigenvalues appear together, it is possible (given an odd number of converged real eigenvalues) for nag_eigen_real_gen_sparse_arnoldi (f02ekc) to return one more eigenvalue than requested.
- 13:
– doubleOutput
-
Note: the dimension,
dim, of the array
v
must be at least
.
On exit: contains the eigenvectors associated with the eigenvalue
, for
(stored in
w). For a real eigenvalue,
, the corresponding eigenvector is real and is stored in
, for
. For complex conjugate pairs of eigenvalues,
, the real and imaginary parts of the corresponding eigenvectors are stored, respectively, in
and
, for
. The imaginary parts stored are for the first of the conjugate pair of eigenvectors; the other eigenvector in the pair is obtained by negating these imaginary parts.
- 14:
– IntegerInput
-
On entry: the stride separating, in the array
v, real and imaginary parts of elements of a conjugate pair of eigenvectors, or separating the elements of a real eigenvector from the corresponding real parts of the next eigenvector.
Constraint:
.
- 15:
– doubleOutput
-
On exit: the residual for the estimates to the eigenpair and is returned in , for .
- 16:
– Nag_Comm *
-
The NAG communication argument (see
Section 3.2.1.1 in the Essential Introduction).
- 17:
– NagError *Input/Output
-
The NAG error argument (see
Section 3.6 in the Essential Introduction).
6 Error Indicators and Warnings
- NE_ALLOC_FAIL
-
Dynamic memory allocation failed.
See
Section 3.2.1.2 in the Essential Introduction for further information.
- NE_BAD_PARAM
-
On entry, argument had an illegal value.
- NE_DIAG_ELEMENTS
-
On entry, in shifted inverse mode, the th diagonal element of is not defined, for .
- NE_EIGENVALUES
-
The number of eigenvalues found to sufficient accuracy is zero.
- NE_INT
-
On entry, .
Constraint: .
On entry, .
Constraint: .
On entry, .
Constraint: .
- NE_INT_2
-
On entry, and .
Constraint: .
On entry, and .
Constraint: .
On entry, and .
Constraint: .
On entry, and .
Constraint: .
- NE_INTERNAL_EIGVAL_FAIL
-
Error in internal call to compute eigenvalues and corresponding error bounds of the current upper Hessenberg matrix.
Please contact
NAG.
- NE_INTERNAL_EIGVEC_FAIL
-
In calculating eigenvectors, an internal call returned with an error.
Please contact
NAG.
- NE_INTERNAL_ERROR
-
An internal call to
nag_real_sparse_eigensystem_iter (f12abc) returned with
NE_OPT_INCOMPAT.
This error should not occur. Please contact
NAG.
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact
NAG for assistance.
An unexpected error has been triggered by this function. Please contact
NAG.
See
Section 3.6.6 in the Essential Introduction for further information.
Internal inconsistency in the number of converged Ritz values. Number counted , number expected .
- NE_INVALID_OPTION
-
The maximum number of iterations , the optional argument has been set to .
- NE_NO_ARNOLDI_FAC
-
Could not build an Arnoldi factorization. The size of the current Arnoldi factorization .
- NE_NO_LICENCE
-
Your licence key may have expired or may not have been installed correctly.
See
Section 3.6.5 in the Essential Introduction for further information.
- NE_NO_SHIFTS_APPLIED
-
No shifts could be applied during a cycle of the implicitly restarted Arnoldi iteration.
- NE_SCHUR_EIG_FAIL
-
During calculation of a real Schur form, there was a failure to compute eigenvalues in a total of iterations.
- NE_SCHUR_REORDER
-
The computed Schur form could not be reordered by an internal call.
This routine returned with
.
Please contact
NAG.
- NE_SINGULAR
-
On entry, the matrix is nearly numerically singular and could not be inverted. Try perturbing the value of . Norm of matrix , Reciprocal condition number .
On entry, the matrix is numerically singular and could not be inverted. Try perturbing the value of .
- NE_SPARSE_COL
-
On entry, for , and .
Constraint: .
On entry, .
Constraint: .
On entry, and .
Constraint: .
- NE_SPARSE_ROW
-
On entry, in specification of column , and for , and .
Constraint: .
- NE_TOO_MANY_ITER
-
The maximum number of iterations has been reached.
The maximum number of iterations .
The number of converged eigenvalues .
See the function document for further details.
- NE_USER_STOP
-
User requested termination in
monit,
.
User requested termination in
option,
.
- NE_ZERO_RESID
-
7 Accuracy
The relative accuracy of a Ritz value (eigenvalue approximation),
, is considered acceptable if its Ritz estimate
. The default value for
is the
machine precision given by
nag_machine_precision (X02AJC). The Ritz estimates are available via the
monit function at each iteration in the Arnoldi process, or can be printed by setting option
to a positive value.
8 Parallelism and Performance
nag_eigen_real_gen_sparse_arnoldi (f02ekc) is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
nag_eigen_real_gen_sparse_arnoldi (f02ekc) 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 function. Please also consult the
Users' Note for your implementation for any additional implementation-specific information.
nag_eigen_real_gen_sparse_arnoldi (f02ekc) calls functions based on the ARPACK suite in
Chapter f12. These functions use an implicitly restarted Arnoldi iterative method to converge to approximations to a set of required eigenvalues (see the
f12 Chapter Introduction).
In the default mode, only matrix-vector multiplications are performed using the sparse matrix during the Arnoldi process. Each iteration is therefore cheap computationally, relative to the alternative, , 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 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, mode may still prove to be the most efficient since no inversions are required. Where smallest eigenvalues are sought and mode is not suitable, or eigenvalues close to a given real value are sought, the mode should be used.
If the
mode is used (via a call to
nag_real_sparse_eigensystem_option (f12adc) in
option) then the matrix
is used in linear system solves by the Arnoldi process. This is first factorized internally using the direct
factorization function
nag_superlu_lu_factorize (f11mec). The condition number of
is then calculated by a call to
nag_superlu_condition_number_lu (f11mgc). If the condition number is too big then the matrix is considered to be nearly singular, i.e.,
is an approximate eigenvalue of
, and the function exits with an error. In this situation it is normally sufficient to perturb
by a small amount and call nag_eigen_real_gen_sparse_arnoldi (f02ekc) again. After successful factorization, subsequent solves are performed by calls to
nag_superlu_solve_lu (f11mfc).
Finally, nag_eigen_real_gen_sparse_arnoldi (f02ekc) transforms the eigenvectors. Each eigenvector (real or complex) is normalized so that , and the element of largest absolute value is real and positive.
The monitoring function
monit provides some basic information on the convergence of the Arnoldi iterations. Much greater levels of detail on the Arnoldi process are available via option
. If this is set to a positive value then information will be printed, by default, to standard output. The
option may be used to select a monitoring
file by setting the option to a file identification (unit) number associated with
(see
nag_open_file (x04acc)).
10 Example
This example computes the four eigenvalues of the matrix
which lie closest to the value
on the real line, and their corresponding eigenvectors, where
is the tridiagonal matrix with elements
10.1 Program Text
Program Text (f02ekce.c)
10.2 Program Data
Program Data (f02ekce.d)
10.3 Program Results
Program Results (f02ekce.r)
11 Optional Arguments
Internally nag_eigen_real_gen_sparse_arnoldi (f02ekc) calls functions from the suite
nag_real_sparse_eigensystem_init (f12aac),
nag_real_sparse_eigensystem_iter (f12abc),
nag_real_sparse_eigensystem_sol (f12acc),
nag_real_sparse_eigensystem_option (f12adc) and
nag_real_sparse_eigensystem_monit (f12aec). Several optional arguments for these computational functions define choices in the problem specification or the algorithm logic. In order to reduce the number of formal arguments of nag_eigen_real_gen_sparse_arnoldi (f02ekc) these optional arguments are also used here and have associated
default values that are usually appropriate. Therefore, you need only specify those optional arguments whose values are to be different from their default values.
Optional arguments may be specified via the user-supplied function
option in the call to nag_eigen_real_gen_sparse_arnoldi (f02ekc).
option must be coded such that one call to
nag_real_sparse_eigensystem_option (f12adc) is necessary to set each optional argument. All optional arguments 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 arguments.
The following is a list of the optional arguments available. A full description of each optional argument is provided in
Section 11.1.
11.1 Description of the Optional Arguments
For each option, we give a summary line, a description of the optional argument 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 nag_machine_precision (X02AJC)).
Keywords and character values are case and white space insensitive.
Optional arguments used to specify files (e.g.,
and
) have type Integer. This Integer value corresponds with the Nag_FileID as returned by
nag_open_file (x04acc). See
Section 10 for an example of the use of this facility.
If the optional argument
is set then optional argument specifications are listed in a
file by setting the option to a file identification (unit) number associated with
messages (see
nag_open_file (x04acc)).
This special keyword may be used to reset all optional arguments to their default values.
Iteration Limit | |
Default |
The limit on the number of Arnoldi iterations that can be performed before nag_eigen_real_gen_sparse_arnoldi (f02ekc) exits with
NE_TOO_MANY_ITER.
Largest Magnitude | | Default |
The Arnoldi iterative method converges on a number of eigenvalues with given properties. The default is to compute the eigenvalues of largest magnitude using . Alternatively, eigenvalues may be chosen which have part, part, , part or part.
Note that these options select the eigenvalue properties for eigenvalues of the linear operator determined by the computational mode and problem type.
Normally each optional argument specification is not printed to
as it is supplied. Optional argument may be used to enable printing and optional argument may be used to suppress the printing.
Unless
is set to
(the default), monitoring information is output to the file associated with Nag_FileID
during the solution of each problem; this may be the same as
. The type of information produced is dependent on the value of
, see the description of the optional argument
in this section for details of the information produced. Please see
nag_open_file (x04acc) to associate a file with a given Nag_FileID (see
Section 3.2.1.1 in the Essential Introduction).
This controls the amount of printing produced by nag_eigen_real_gen_sparse_arnoldi (f02ekc) as follows.
| No output except error messages. |
| The set of selected options. |
| Problem and timing statistics when all calls to nag_real_sparse_eigensystem_iter (f12abc) have been completed. |
| A single line of summary output at each Arnoldi iteration. |
|
If
is set to a valid Nag_FileID
then at each iteration, the length and additional steps of the current Arnoldi factorization and the number of converged Ritz values; during re-orthogonalization, the norm of initial/restarted starting vector. |
| Problem and timing statistics on final exit from nag_real_sparse_eigensystem_iter (f12abc). If is set to a valid Nag_FileID then at each iteration, the number of shifts being applied, the eigenvalues and estimates of the Hessenberg matrix , the size of the Arnoldi basis, the wanted Ritz values and associated Ritz estimates and the shifts applied; vector norms prior to and following re-orthogonalization. |
| If is set to a valid Nag_FileID 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 compressed upper Hessenberg matrix ; during re-orthogonalization, the initial/restarted starting vector; during the Arnoldi iteration loop, a restart is flagged and the number of the residual requiring iterative refinement; while applying shifts, the indices of the shifts being applied. |
| If is set to a valid Nag_FileID then during the Arnoldi iteration loop, the Arnoldi 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 is set to a valid Nag_FileID then during Arnoldi iteration loop: norms of key components and the active column of , norms of residuals during iterative refinement, the final upper Hessenberg matrix ; while applying shifts: number of shifts, shift values, block indices, updated matrix ; while computing eigenvalues of : the matrix , the computed eigenvalues and Ritz estimates. |
These options define the computational mode which in turn defines the form of operation to be performed.
Given a standard eigenvalue problem in the form
then the following modes are available with the appropriate operator
.
|
|
|
where is real |
An approximate eigenvalue has deemed to have converged when the corresponding Ritz estimate is within relative to the magnitude of the eigenvalue.