naginterfaces.library.sparse.real_gen_basic_solver¶
- naginterfaces.library.sparse.real_gen_basic_solver(irevcm, u, v, comm, wgt=None)[source]¶
real_gen_basic_solver
is an iterative solver for a real general (nonsymmetric) system of simultaneous linear equations;real_gen_basic_solver
is the second in a suite of three functions, where the first function,real_gen_basic_setup()
, must be called prior toreal_gen_basic_solver
to set up the suite, and the third function in the suite,real_gen_basic_diag()
, can be used to return additional information about the computation.These functions are suitable for the solution of large sparse general (nonsymmetric) systems of equations.
For full information please refer to the NAG Library document for f11be
https://support.nag.com/numeric/nl/nagdoc_30.3/flhtml/f11/f11bef.html
- Parameters
- irevcmint
On initial entry: , otherwise an error condition will be raised.
On intermediate entry: must either be unchanged from its previous exit value, or can have one of the following values.
Tidy termination: the computation will terminate at the end of the current iteration. Further reverse communication exits may occur depending on when the termination request is issued.
real_gen_basic_solver
will then return with the termination code . Note that before callingreal_gen_basic_solver
with the calling program must have performed the tasks required by the value of returned by the previous call toreal_gen_basic_solver
, otherwise subsequently returned values may be invalid.Immediate termination:
real_gen_basic_solver
will return immediately with termination code and with any useful information available. This includes the last iterate of the solution. The residual vector is generally not available.Immediate termination may be useful, for example, when errors are detected during matrix-vector multiplication or during the solution of the preconditioning equation.
Changing to any other value between calls will result in an error.
- ufloat, ndarray, shape , modified in place
On initial entry: an initial estimate, , of the solution of the system of equations .
On intermediate entry: must remain unchanged.
On intermediate exit: the returned value of determines the contents of in the following way:
if , or , holds the vector on which the operation specified by is to be carried out;
if , holds the current iterate of the solution vector.
On final exit: if = 3 or < 0, the array is unchanged from the initial entry to
real_gen_basic_solver
.If = 1, the array is unchanged from the last entry to
real_gen_basic_solver
.Otherwise, holds the last available iterate of the solution of the system of equations, for all returned values of .
- vfloat, ndarray, shape , modified in place
On initial entry: the right-hand side of the system of equations .
On intermediate entry: the returned value of determines the contents of in the following way:
if , or , must store the vector , the result of the operation specified by the value of returned by the previous call to
real_gen_basic_solver
;if , must remain unchanged.
On intermediate exit: if , holds the current iterate of the residual vector. Note that this is an approximation to the true residual vector. Otherwise, it does not contain any useful information.
On final exit: if = 3 or < 0, the array is unchanged from the initial entry to
real_gen_basic_solver
.If = 1, the array is unchanged from the last entry to
real_gen_basic_solver
.If the function exits successfully or = 2, the array contains the true residual vector of the system of equations (see also Exceptions).
Otherwise, stores the last available iterate of the residual vector unless = 8 is returned on last entry, in which case is set to .
- commdict, communication object, modified in place
Communication structure.
This argument must have been initialized by a prior call to
real_gen_basic_setup()
.- wgtNone or float, array-like, shape , optional
The user-supplied weights, if these are to be used in the computation of the vector norms in the termination criterion (see Notes for real_gen_basic_setup and Parameters for real_gen_basic_setup).
- Returns
- irevcmint
On intermediate exit: has the following meanings.
The calling program must compute the matrix-vector product , where and are stored in and , respectively; RGMRES, CGS and BI-CGSTAB() methods return only if the matrix norm or is estimated internally using Higham’s method. This can only happen if in
real_gen_basic_setup()
.The calling program must compute the matrix-vector product , where and are stored in and , respectively.
The calling program must solve the preconditioning equation , where and are stored in and , respectively.
Monitoring step: the solution and residual at the current iteration are returned in the arrays and , respectively. No action by the calling program is required.
real_gen_basic_diag()
can be called at this step to return additional information.On final exit: :
real_gen_basic_solver
has completed its tasks. The value of determines whether the iteration has been successfully completed, errors have been detected or the calling program has requested termination.
- Raises
- NagValueError
- (errno )
On intermediate re-entry, .
Constraint: either must be unchanged from its previous exit value or or .
- (errno )
On initial entry, .
Constraint: .
- (errno )
Either
real_gen_basic_setup()
was not called before callingreal_gen_basic_solver
or it has returned an error.
- Warns
- NagAlgorithmicWarning
- (errno )
real_gen_basic_solver
has already completed its tasks. You need to set a new problem.- (errno )
The required accuracy could not be obtained. However, a reasonable accuracy may have been achieved.
- (errno )
User-requested tidy termination. The required accuracy has not been achieved. However, a reasonable accuracy may have been achieved.
- (errno )
User-requested tidy termination. The solution has not converged after iterations.
- (errno )
The solution has not converged after iterations.
- (errno )
Algorithm breakdown at iteration no. .
- (errno )
User-requested immediate termination.
- (errno )
The weights in array are all zero.
- Notes
real_gen_basic_solver
solves the general (nonsymmetric) system of linear simultaneous equations of order , where is large and the coefficient matrix is sparse, using one of four available methods: RGMRES, the preconditioned restarted generalized minimum residual method (see Saad and Schultz (1986)); CGS, the preconditioned conjugate gradient squared method (see Sonneveld (1989)); BI-CGSTAB(), the bi-conjugate gradient stabilized method of order (see Van der Vorst (1989) and Sleijpen and Fokkema (1993)); or TFQMR, the transpose-free quasi-minimal residual method (see Freund and Nachtigal (1991) and Freund (1993)).For a general description of the methods employed you are referred to Notes for real_gen_basic_setup.
real_gen_basic_solver
can solve the system after the first function in the suite,real_gen_basic_setup()
, has been called to initialize the computation and specify the method of solution. The third function in the suite,real_gen_basic_diag()
, can be used to return additional information generated by the computation, during monitoring steps and afterreal_gen_basic_solver
has completed its tasks.real_gen_basic_solver
uses reverse communication, i.e., it returns repeatedly to the calling program with the argument (see Parameters) set to specified values which require the calling program to carry out one of the following tasks:compute the matrix-vector product or (the four methods require the matrix transpose-vector product only if or is estimated internally by Higham’s method (see Higham (1988)));
solve the preconditioning equation ;
notify the completion of the computation;
allow the calling program to monitor the solution.
Through the argument the calling program can cause immediate or tidy termination of the execution. On final exit, the last iterates of the solution and of the residual vectors of the original system of equations are returned.
Reverse communication has the following advantages.
Maximum flexibility in the representation and storage of sparse matrices: all matrix operations are performed outside the solver function, thereby avoiding the need for a complicated interface with enough flexibility to cope with all types of storage schemes and sparsity patterns. This applies also to preconditioners.
Enhanced user interaction: you can closely monitor the progress of the solution and tidy or immediate termination can be requested. This is useful, for example, when alternative termination criteria are to be employed or in case of failure of the external functions used to perform matrix operations.
- References
Freund, R W, 1993, A transpose-free quasi-minimal residual algorithm for non-Hermitian linear systems, SIAM J. Sci. Comput. (14), 470–482
Freund, R W and Nachtigal, N, 1991, QMR: a Quasi-Minimal Residual Method for Non-Hermitian Linear Systems, Numer. Math. (60), 315–339
Higham, N J, 1988, FORTRAN codes for estimating the one-norm of a real or complex matrix, with applications to condition estimation, ACM Trans. Math. Software (14), 381–396
Saad, Y and Schultz, M, 1986, GMRES: a generalized minimal residual algorithm for solving nonsymmetric linear systems, SIAM J. Sci. Statist. Comput. (7), 856–869
Sleijpen, G L G and Fokkema, D R, 1993, BiCGSTAB for linear equations involving matrices with complex spectrum, ETNA (1), 11–32
Sonneveld, P, 1989, CGS, a fast Lanczos-type solver for nonsymmetric linear systems, SIAM J. Sci. Statist. Comput. (10), 36–52
Van der Vorst, H, 1989, Bi-CGSTAB, a fast and smoothly converging variant of Bi-CG for the solution of nonsymmetric linear systems, SIAM J. Sci. Statist. Comput. (13), 631–644