PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_sparse_real_gen_basic_setup (f11bd)
Purpose
nag_sparse_real_gen_basic_setup (f11bd) is a setup function, the first in a suite of three functions for the iterative solution of a real general (nonsymmetric) system of simultaneous linear equations.
nag_sparse_real_gen_basic_setup (f11bd) must be called before
nag_sparse_real_gen_basic_solver (f11be), the iterative solver. The third function in the suite,
nag_sparse_real_gen_basic_diag (f11bf), can be used to return additional information about the computation.
These three functions are suitable for the solution of large sparse general (nonsymmetric) systems of equations.
Syntax
[
lwreq,
work,
ifail] = f11bd(
method,
precon,
n,
m,
tol,
maxitn,
anorm,
sigmax,
monit,
lwork, 'norm_p',
norm_p, 'weight',
weight, 'iterm',
iterm)
[
lwreq,
work,
ifail] = nag_sparse_real_gen_basic_setup(
method,
precon,
n,
m,
tol,
maxitn,
anorm,
sigmax,
monit,
lwork, 'norm_p',
norm_p, 'weight',
weight, 'iterm',
iterm)
Description
The suite consisting of the functions
nag_sparse_real_gen_basic_setup (f11bd),
nag_sparse_real_gen_basic_solver (f11be) and
nag_sparse_real_gen_basic_diag (f11bf) is designed to solve the general (nonsymmetric) system of simultaneous linear equations
of order
, where
is large and the coefficient matrix
is sparse.
nag_sparse_real_gen_basic_setup (f11bd) is a setup function which must be called before
nag_sparse_real_gen_basic_solver (f11be), the iterative solver. The third function in the suite,
nag_sparse_real_gen_basic_diag (f11bf), can be used to return additional information about the computation. A choice of methods is available:
- restarted generalized minimum residual method (RGMRES);
- conjugate gradient squared method (CGS);
- bi-conjugate gradient stabilized () method (Bi-CGSTAB());
- transpose-free quasi-minimal residual method (TFQMR).
Restarted Generalized Minimum Residual Method (RGMRES)
The restarted generalized minimum residual method (RGMRES) (see
Saad and Schultz (1986),
Barrett et al. (1994) and
Dias da Cunha and Hopkins (1994)) starts from the residual
, where
is an initial estimate for the solution (often
). An orthogonal basis for the Krylov subspace
, for
, is generated explicitly: this is referred to as Arnoldi's method (see
Arnoldi (1951)). The solution is then expanded onto the orthogonal basis so as to minimize the residual norm
. The lack of symmetry of
implies that the orthogonal basis is generated by applying a ‘long’ recurrence relation, whose length increases linearly with the iteration count. For all but the most trivial problems, computational and storage costs can quickly become prohibitive as the iteration count increases. RGMRES limits these costs by employing a restart strategy: every
iterations at most, the Arnoldi process is restarted from
, where the subscript
denotes the last available iterate. Each group of
iterations is referred to as a ‘super-iteration’. The value of
is chosen in advance and is fixed throughout the computation. Unfortunately, an optimum value of
cannot easily be predicted.
Conjugate Gradient Squared Method (CGS)
The conjugate gradient squared method (CGS) (see
Sonneveld (1989),
Barrett et al. (1994) and
Dias da Cunha and Hopkins (1994)) is a development of the bi-conjugate gradient method where the nonsymmetric Lanczos method is applied to reduce the coefficients matrix to real tridiagonal form: two bi-orthogonal sequences of vectors are generated starting from the residual
, where
is an initial estimate for the solution (often
) and from the
shadow residual corresponding to the arbitrary problem
, where
can be any vector, but in practice is chosen so that
. In the course of the iteration, the residual and shadow residual
and
are generated,
where
is a polynomial of order
, and bi-orthogonality is exploited by computing the vector product
. Applying the ‘contraction’ operator
twice, the iteration coefficients can still be recovered without advancing the solution of the shadow problem, which is of no interest. The CGS method often provides fast convergence; however, there is no reason why the contraction operator should also reduce the once reduced vector
: this may well lead to a highly irregular convergence which may result in large cancellation errors.
Bi-Conjugate Gradient Stabilized (ℓ) Method (Bi-CGSTAB(ℓ))
The bi-conjugate gradient stabilized (
) method (Bi-CGSTAB(
)) (see
Van der Vorst (1989),
Sleijpen and Fokkema (1993) and
Dias da Cunha and Hopkins (1994)) is similar to the CGS method above. However, instead of generating the sequence
, it generates the sequence
, where the
are polynomials chosen to minimize the residual
after the application of the contraction operator
. Two main steps can be identified for each iteration: an OR (Orthogonal Residuals) step where a basis of order
is generated by a Bi-CG iteration and an MR (Minimum Residuals) step where the residual is minimized over the basis generated, by a method akin to GMRES. For
, the method corresponds to the Bi-CGSTAB method of
Van der Vorst (1989). For
, more information about complex eigenvalues of the iteration matrix can be taken into account, and this may lead to improved convergence and robustness. However, as
increases, numerical instabilities may arise. For this reason, a maximum value of
is imposed, but probably
is sufficient in most cases.
Transpose-free Quasi-minimal Residual Method (TFQMR)
The transpose-free quasi-minimal residual method (TFQMR) (see
Freund and Nachtigal (1991) and
Freund (1993)) is conceptually derived from the CGS method. The residual is minimized over the space of the residual vectors generated by the CGS iterations under the simplifying assumption that residuals are almost orthogonal. In practice, this is not the case but theoretical analysis has proved the validity of the method. This has the effect of remedying the rather irregular convergence behaviour with wild oscillations in the residual norm that can degrade the numerical performance and robustness of the CGS method. In general, the TFQMR method can be expected to converge at least as fast as the CGS method, in terms of number of iterations, although each iteration involves a higher operation count. When the CGS method exhibits irregular convergence, the TFQMR method can produce much smoother, almost monotonic convergence curves. However, the close relationship between the CGS and TFQMR method implies that the
overall speed of convergence is similar for both methods. In some cases, the TFQMR method may converge faster than the CGS method.
General Considerations
For each method, a sequence of solution iterates is generated such that, hopefully, the sequence of the residual norms converges to a required tolerance. Note that, in general, convergence, when it occurs, is not monotonic.
In the RGMRES and Bi-CGSTAB(
) methods above, your program must provide the
maximum number of basis vectors used,
or
, respectively; however, a
smaller number of basis vectors may be generated and used when the stability of the solution process requires this (see
Further Comments).
Faster convergence can be achieved using a
preconditioner (see
Golub and Van Loan (1996) and
Barrett et al. (1994)). A preconditioner maps the original system of equations onto a different system, say
with, hopefully, better characteristics with respect to its speed of convergence: for example, the condition number of the coefficients matrix can be improved or eigenvalues in its spectrum can be made to coalesce. An orthogonal basis for the Krylov subspace
, for
, is generated and the solution proceeds as outlined above. The algorithms used are such that the solution and residual iterates of the original system are produced, not their preconditioned counterparts. Note that an unsuitable preconditioner or no preconditioning at all may result in a very slow rate, or lack, of convergence. However, preconditioning involves a trade-off between the reduction in the number of iterations required for convergence and the additional computational costs per iteration. Also, setting up a preconditioner may involve non-negligible overheads.
A
left preconditioner
can be used by the RGMRES, CGS and TFQMR methods, such that
in
(1), where
is the identity matrix of order
; a
right preconditioner
can be used by the Bi-CGSTAB(
) method, such that
. These are formal definitions, used only in the design of the algorithms; in practice, only the means to compute the matrix–vector products
and
(the latter only being required when an estimate of
or
is computed internally), and to solve the preconditioning equations
are required, i.e., explicit information about
, or its inverse is not required at any stage.
The first termination criterion
is available for all four methods. In
(2),
,
and
denotes a user-specified tolerance subject to
,
, where
is the
machine precision. Facilities are provided for the estimation of the norm of the coefficients matrix
or
, when this is not known in advance, by applying Higham's method (see
Higham (1988)). Note that
cannot be estimated internally. This criterion uses an error bound derived from
backward error analysis to ensure that the computed solution is the exact solution of a problem as close to the original as the termination tolerance requires. Termination criteria employing bounds derived from
forward error analysis are not used because any such criteria would require information about the condition number
which is not easily obtainable.
The second termination criterion
is available for all methods except TFQMR. In
(3),
is the largest singular value of the (preconditioned) iteration matrix
. This termination criterion monitors the progress of the solution of the preconditioned system of equations and is less expensive to apply than criterion
(2) for the Bi-CGSTAB(
) method with
. Only the RGMRES method provides facilities to estimate
internally, when this is not supplied (see
Further Comments).
Termination criterion
(2) is the recommended choice, despite its additional costs per iteration when using the Bi-CGSTAB(
) method with
. Also, if the norm of the initial estimate is much larger than the norm of the solution, that is, if
, a dramatic loss of significant digits could result in complete lack of convergence. The use of criterion
(2) will enable the detection of such a situation, and the iteration will be restarted at a suitable point. No such restart facilities are provided for criterion
(3).
Optionally, a vector
of user-specified weights can be used in the computation of the vector norms in termination criterion
(2), i.e.,
, where
, for
. Note that the use of weights increases the computational costs.
The sequence of calls to the functions comprising the suite is enforced: first, the setup function
nag_sparse_real_gen_basic_setup (f11bd) must be called, followed by the solver
nag_sparse_real_gen_basic_solver (f11be).
nag_sparse_real_gen_basic_diag (f11bf) can be called either when
nag_sparse_real_gen_basic_solver (f11be) is carrying out a monitoring step or after
nag_sparse_real_gen_basic_solver (f11be) has completed its tasks. Incorrect sequencing will raise an error condition.
In general, it is not possible to recommend one method in preference to another. RGMRES is often used in the solution of systems arising from PDEs. On the other hand, it can easily stagnate when the size
of the orthogonal basis is too small, or the preconditioner is not good enough. CGS can be the fastest method, but the computed residuals can exhibit instability which may greatly affect the convergence and quality of the solution. Bi-CGSTAB(
) seems robust and reliable, but it can be slower than the other methods: if a preconditioner is used and
, Bi-CGSTAB(
) computes the solution of the preconditioned system
: the preconditioning equations must be solved to obtain the required solution. The algorithm employed limits to
or less, when no intermediate monitoring is requested, the number of times the preconditioner has to be thus applied compared with the total number of applications of the preconditioner. TFQMR can be viewed as a more robust variant of the CGS method: it shares the CGS method speed but avoids the CGS fluctuations in the residual, which may give rise to instability. Also, when the termination criterion
(2) is used, the CGS, Bi-CGSTAB(
) and TFQMR methods will restart the iteration automatically when necessary in order to solve the given problem.
References
Arnoldi W (1951) The principle of minimized iterations in the solution of the matrix eigenvalue problem Quart. Appl. Math. 9 17–29
Barrett R, Berry M, Chan T F, Demmel J, Donato J, Dongarra J, Eijkhout V, Pozo R, Romine C and Van der Vorst H (1994) Templates for the Solution of Linear Systems: Building Blocks for Iterative Methods SIAM, Philadelphia
Dias da Cunha R and Hopkins T (1994) PIM 1.1 — the parallel iterative method package for systems of linear equations user's guide — Fortran 77 version Technical Report Computing Laboratory, University of Kent at Canterbury, Kent, UK
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
Golub G H and Van Loan C F (1996) Matrix Computations (3rd Edition) Johns Hopkins University Press, Baltimore
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
Parameters
Compulsory Input Parameters
- 1:
– string
-
The iterative method to be used.
- Restarted generalized minimum residual method.
- Conjugate gradient squared method.
- Bi-conjugate gradient stabilized () method.
- Transpose-free quasi-minimal residual method.
Constraint:
, , or .
- 2:
– string (length ≥ 1)
-
Determines whether preconditioning is used.
- No preconditioning.
- Preconditioning.
Constraint:
or .
- 3:
– int64int32nag_int scalar
-
, the order of the matrix .
Constraint:
.
- 4:
– int64int32nag_int scalar
-
If
,
m is the dimension
of the restart subspace.
If
,
m is the order
of the polynomial Bi-CGSTAB method.
Otherwise,
m is not referenced.
Constraints:
- if , ;
- if , .
- 5:
– double scalar
-
The tolerance
for the termination criterion. If
is used, where
is the
machine precision. Otherwise
is used.
Constraint:
.
- 6:
– int64int32nag_int scalar
-
The maximum number of iterations.
Constraint:
.
- 7:
– double scalar
-
If
, the value of
to be used in the termination criterion
(2) (
).
If
,
and
or
, then
is estimated internally by
nag_sparse_real_gen_basic_solver (f11be).
If
,
anorm is not referenced.
Constraint:
if and , .
- 8:
– double scalar
-
If
, the largest singular value
of the preconditioned iteration matrix; otherwise,
sigmax is not referenced.
If , and , then the value of will be estimated internally.
Constraint:
if or and , .
- 9:
– int64int32nag_int scalar
-
If
, the frequency at which a monitoring step is executed by
nag_sparse_real_gen_basic_solver (f11be): if
or
, a monitoring step is executed every
monit iterations; otherwise, a monitoring step is executed every
monit super-iterations (groups of up to
or
iterations for RGMRES or Bi-CGSTAB(
), respectively).
There are some additional computational costs involved in monitoring the solution and residual vectors when the Bi-CGSTAB() method is used with .
Constraint:
.
- 10:
– int64int32nag_int scalar
-
The dimension of the array
work.
Constraint:
.
Note: although the minimum value of
lwork ensures the correct functioning of
nag_sparse_real_gen_basic_setup (f11bd), a larger value is required by the other functions in the suite, namely
nag_sparse_real_gen_basic_solver (f11be) and
nag_sparse_real_gen_basic_diag (f11bf). The required value is as follows:
Method |
Requirements |
RGMRES |
, where is the dimension of the basis. |
CGS |
. |
Bi-CGSTAB() |
, where is the order of the method. |
TFQMR |
, |
where
|
if and was supplied. |
|
if and a preconditioner is used or was supplied. |
|
otherwise. |
Optional Input Parameters
- 1:
– string (length ≥ 1)
Suggested value:
- if , ;
- if , .
Default:
- if , ;
- otherwise .
Defines the matrix and vector norm to be used in the termination criteria.
- norm.
- norm.
- norm.
Constraints:
- if , , or ;
- if , .
- 2:
– string (length ≥ 1)
Default:
Specifies whether a vector
of user-supplied weights is to be used in the computation of the vector norms required in termination criterion
(2) (
):
, where
, for
. The suffix
denotes the vector norm used, as specified by the argument
norm_p. Note that weights cannot be used when
, i.e., when criterion
(3) is used.
- User-supplied weights are to be used and must be supplied on initial entry to nag_sparse_real_gen_basic_solver (f11be).
- All weights are implicitly set equal to one. Weights do not need to be supplied on initial entry to nag_sparse_real_gen_basic_solver (f11be).
Constraints:
- if , or ;
- if , .
- 3:
– int64int32nag_int scalar
Default:
Defines the termination criterion to be used.
- Use the termination criterion defined in (2).
- Use the termination criterion defined in (3).
Constraints:
- if or or , ;
- otherwise or .
Note: is only appropriate for a restricted set of choices for
method,
norm_p and
weight; that is
,
and
.
Output Parameters
- 1:
– int64int32nag_int scalar
-
The minimum amount of workspace required by
nag_sparse_real_gen_basic_solver (f11be). (See also
Arguments in
nag_sparse_real_gen_basic_solver (f11be).)
- 2:
– double array
-
The array
work is initialized by
nag_sparse_real_gen_basic_setup (f11bd). It must
not be modified before calling the next function in the suite, namely
nag_sparse_real_gen_basic_solver (f11be).
- 3:
– int64int32nag_int scalar
unless the function detects an error (see
Error Indicators and Warnings).
Error Indicators and Warnings
Errors or warnings detected by the function:
-
-
nag_sparse_real_gen_basic_setup (f11bd) has been called out of sequence: either
nag_sparse_real_gen_basic_setup (f11bd) has been called twice or
nag_sparse_real_gen_basic_solver (f11be) has not terminated its current task.
-
-
On entry, .
Constraint: , , or .
-
-
On entry, .
Constraint: or .
-
-
On entry, .
Constraint: , or .
-
-
On entry, .
Constraint: or .
-
-
Constraint: or .
On entry, and .
Constraint: if , .
On entry, and .
Constraint: if , .
On entry, and .
Constraint: if , .
-
-
Constraint: .
-
-
Constraint: if , . If , .
Constraint: if or , .
-
-
Constraint: .
-
-
Constraint: .
-
-
Constraint: if and , .
-
-
Constraint: if and or , .
-
-
Constraint: .
-
-
Constraint: .
-
An unexpected error has been triggered by this routine. Please
contact
NAG.
-
Your licence key may have expired or may not have been installed correctly.
-
Dynamic memory allocation failed.
Accuracy
Not applicable.
Further Comments
RGMRES can estimate internally the maximum singular value of the iteration matrix, using , where is the upper triangular matrix obtained by factorization of the upper Hessenberg matrix generated by the Arnoldi process. The computational costs of this computation are negligible when compared to the overall costs.
Loss of orthogonality in the RGMRES method, or of bi-orthogonality in the Bi-CGSTAB(
) method may degrade the solution and speed of convergence. For both methods, the algorithms employed include checks on the basis vectors so that the number of basis vectors used for a given super-iteration may be less than the value specified in the input argument
m. Also, if termination criterion
(2) is used the CGS, Bi-CGSTAB(
) and TFQMR methods will restart automatically the computation from the last available iterates, when the stability of the solution process requires it.
Termination criterion
(3), when available, involves only the residual (or norm of the residual) produced directly by the iteration process: this may differ from the norm of the true residual
, particularly when the norm of the residual is very small. Also, if the norm of the initial estimate of the solution is much larger than the norm of the exact solution, convergence can be achieved despite very large errors in the solution. On the other hand, termination criterion
(3) is cheaper to use and inspects the progress of the actual iteration. Termination criterion
(2) should be preferred in most cases, despite its slightly larger costs.
Example
This example solves an
nonsymmetric system of simultaneous linear equations using the bi-conjugate gradient stabilized method of order
, where the coefficients matrix
has a random sparsity pattern. An incomplete
preconditioner is used (routines
nag_sparse_real_gen_precon_ilu (f11da) and
nag_sparse_real_gen_precon_ilu_solve (f11db)).
Open in the MATLAB editor:
f11bd_example
function f11bd_example
fprintf('f11bd example results\n\n');
n = int64(8);
nz = int64(24);
a = zeros(3*nz, 1);
irow = zeros(3*nz, 1, 'int64');
icol = irow;
irow(1:nz) = int64(...
[1; 1; 1; 2; 2; 2; 3; 3; 4; 4; 4; 4;
5; 5; 5; 6; 6; 6; 7; 7; 7; 8; 8; 8]);
icol(1:nz) = int64(...
[1; 4; 8; 1; 2; 5; 3; 6; 1; 3; 4; 7;
2; 5; 7; 1; 3; 6; 3; 5; 7; 2; 6; 8]);
a(1:nz) = [2;-1; 1; 4;-3; 2;-7; 2; 3;-4; 5; 5;
-1; 8;-3;-6; 5; 2;-5;-1; 6;-1; 2; 3];
b = [6; 8;-9;46;17;21;22;34];
lfill = int64(0);
dtol = 0;
milu = 'No modification';
ipivp = zeros(n, 1, 'int64');
ipivq = zeros(n, 1, 'int64');
[a, irow, icol, ipivp, ipivq, istr, idiag, nnzc, npivm, ifail] = ...
f11da(...
nz, a, irow, icol, lfill, dtol, milu, ipivp, ipivq);
method = 'BICGSTAB';
precon = 'Preconditioned';
lpoly = int64(1);
tol = sqrt(x02aj);
maxitn = int64(20);
anorm = 0;
sigmax = 0;
monit = int64(1);
lwork = int64(6000);
[lwreq, work, ifail] = ...
f11bd(...
method, precon, n, lpoly, tol, maxitn, anorm, sigmax, ...
monit, lwork, 'norm_p', '1');
irevcm = int64(0);
u = zeros(8, 1);
v = b;
wgt = zeros(8, 1);
while (irevcm ~= 4)
[irevcm, u, v, work, ifail] = f11be(...
irevcm, u, v, wgt, work);
if (irevcm == -1)
[v, ifail] = f11xa(...
'T', a(1:nz), irow(1:nz), icol(1:nz), 'N', u);
elseif (irevcm == 1)
[v, ifail] = f11xa(...
'N', a(1:nz), irow(1:nz), icol(1:nz), 'N', u);
elseif (irevcm == 2)
[v, ifail] = f11db('N', a, irow, icol, ipivp, ipivq, istr, idiag, 'N', u);
if (ifail ~= 0)
irevcm = 6;
end
elseif (irevcm == 3)
[itn, stplhs, stprhs, anorm, sigmax, ifail] = ...
f11bf(work);
fprintf('\nMonitoring at iteration number %2d\n',itn);
fprintf('residual norm: %14.4e\n', stplhs);
fprintf('\n Solution Vector Residual Vector\n');
for i = 1:n
fprintf('%16.4f %16.2e\n', u(i), v(i));
end
end
end
[itn, stplhs, stprhs, anorm, sigmax, ifail] = ...
f11bf(work);
fprintf('\nNumber of iterations for convergence: %4d\n', itn);
fprintf('Residual norm: %14.4e\n', stplhs);
fprintf('Right-hand side of termination criteria: %14.4e\n', stprhs);
fprintf('i-norm of matrix a: %14.4e\n', anorm);
fprintf('\n Solution Vector Residual Vector\n');
for i = 1:n
fprintf('%16.4f %16.2e\n', u(i), v(i));
end
f11bd example results
Monitoring at iteration number 1
residual norm: 1.4059e+02
Solution Vector Residual Vector
-4.5858 1.53e+01
1.0154 2.66e+01
-2.2234 -8.75e+00
6.0097 1.86e+01
1.3827 8.28e+00
-7.9070 2.04e+01
0.4427 9.61e+00
5.9248 3.31e+01
Monitoring at iteration number 2
residual norm: 3.2742e+01
Solution Vector Residual Vector
4.1642 -2.96e+00
4.9370 -5.55e+00
4.8101 8.21e-01
5.4324 -1.68e+01
5.8531 5.60e-01
11.9250 -1.91e+00
8.4826 1.01e+00
6.0625 -3.10e+00
Number of iterations for convergence: 3
Residual norm: 1.0373e-08
Right-hand side of termination criteria: 5.8900e-06
i-norm of matrix a: 1.1000e+01
Solution Vector Residual Vector
1.0000 -1.36e-09
2.0000 -2.61e-09
3.0000 2.25e-10
4.0000 -3.22e-09
5.0000 6.30e-10
6.0000 -5.24e-10
7.0000 9.58e-10
8.0000 -8.49e-10
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015