NAG FL Interface
f11brf (complex_​gen_​basic_​setup)

1 Purpose

f11brf is a setup routine, the first in a suite of three routines for the iterative solution of a complex general (non-Hermitian) system of simultaneous linear equations. f11brf must be called before f11bsf, the iterative solver. The third routine in the suite, f11btf, can be used to return additional information about the computation.
These three routines are suitable for the solution of large sparse general (non-Hermitian) systems of equations.

2 Specification

Fortran Interface
Subroutine f11brf ( method, precon, norm, weight, iterm, n, m, tol, maxitn, anorm, sigmax, monit, lwreq, work, lwork, ifail)
Integer, Intent (In) :: iterm, n, m, maxitn, monit, lwork
Integer, Intent (Inout) :: ifail
Integer, Intent (Out) :: lwreq
Real (Kind=nag_wp), Intent (In) :: tol, anorm, sigmax
Complex (Kind=nag_wp), Intent (Out) :: work(lwork)
Character (*), Intent (In) :: method
Character (1), Intent (In) :: precon, norm, weight
C Header Interface
#include <nag.h>
void  f11brf_ (const char *method, const char *precon, const char *norm, const char *weight, const Integer *iterm, const Integer *n, const Integer *m, const double *tol, const Integer *maxitn, const double *anorm, const double *sigmax, const Integer *monit, Integer *lwreq, Complex work[], const Integer *lwork, Integer *ifail, const Charlen length_method, const Charlen length_precon, const Charlen length_norm, const Charlen length_weight)
The routine may be called by the names f11brf or nagf_sparse_complex_gen_basic_setup.

3 Description

The suite consisting of the routines f11brf, f11bsf and f11btf is designed to solve the general (non-Hermitian) system of simultaneous linear equations Ax=b of order n, where n is large and the coefficient matrix A is sparse.
f11brf is a setup routine which must be called before f11bsf, the iterative solver. The third routine in the suite, f11btf, can be used to return additional information about the computation. A choice of methods is available:

3.1 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 r0=b-Ax0, where x0 is an initial estimate for the solution (often x0=0). An orthogonal basis for the Krylov subspace spanAkr0, for k=0,1,, 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 b-Ax2. The lack of symmetry of A 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 m iterations at most, the Arnoldi process is restarted from rl=b-Axl, where the subscript l denotes the last available iterate. Each group of m iterations is referred to as a ‘super-iteration’. The value of m is chosen in advance and is fixed throughout the computation. Unfortunately, an optimum value of m cannot easily be predicted.

3.2 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 tridiagonal form: two bi-orthogonal sequences of vectors are generated starting from the residual r0=b-Ax0, where x0 is an initial estimate for the solution (often x0=0) and from the shadow residual r^0 corresponding to the arbitrary problem AHx^=b^, where b^ can be any vector, but in practice is chosen so that r0=r^0. In the course of the iteration, the residual and shadow residual ri=PiA r0 and r^i=PiAHr^0 are generated, where Pi is a polynomial of order i, and bi-orthogonality is exploited by computing the vector product ρi=r^i,ri=PiAHr^0, PiA r0=r^0,Pi2Ar0. Applying the ‘contraction’ operator PiA 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 PiAr0: this may well lead to a highly irregular convergence which may result in large cancellation errors.

3.3 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 Pi2 Ar0, it generates the sequence QiA PiA r0, where the QiA are polynomials chosen to minimize the residual after the application of the contraction operator PiA. 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 =1, the method corresponds to the Bi-CGSTAB method of Van der Vorst (1989). For >1, 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 =10 is imposed, but probably =4 is sufficient in most cases.

3.4 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.

3.5 General Considerations

For each method, a sequence of solution iterates xi is generated such that, hopefully, the sequence of the residual norms ri 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, m or , respectively; however, a smaller number of basis vectors may be generated and used when the stability of the solution process requires this (see Section 9).
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
A¯x¯=b¯, (1)
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 spanA¯kr¯0, for k=0,1,, 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 M-1 can be used by the RGMRES, CGS and TFQMR methods, such that A¯=M-1AIn in (1), where In is the identity matrix of order n; a right preconditioner M-1 can be used by the Bi-CGSTAB() method, such that A¯=AM-1In. These are formal definitions, used only in the design of the algorithms; in practice, only the means to compute the matrix–vector products v=Au and v=AHu (the latter only being required when an estimate of A1 or A is computed internally), and to solve the preconditioning equations Mv=u are required, i.e., explicit information about M, or its inverse is not required at any stage.
The first termination criterion
rkp τ bp + Ap × xkp (2)
is available for all four methods. In (2), p=1, ​ or ​2 and τ denotes a user-specified tolerance subject to max10,n, ετ<1, where ε is the machine precision. Facilities are provided for the estimation of the norm of the coefficients matrix A1 or A, when this is not known in advance, by applying Higham's method (see Higham (1988)). Note that A2 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 κA which is not easily obtainable.
The second termination criterion
r¯k2 τ r¯02 + σ1 A¯ × Δx¯k2 (3)
is available for all methods except TFQMR. In (3), σ1A¯=A¯2 is the largest singular value of the (preconditioned) iteration matrix A¯. 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 >1. Only the RGMRES method provides facilities to estimate σ1A¯ internally, when this is not supplied (see Section 9).
Termination criterion (2) is the recommended choice, despite its additional costs per iteration when using the Bi-CGSTAB() method with >1. Also, if the norm of the initial estimate is much larger than the norm of the solution, that is, if x0x, 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 w of user-specified weights can be used in the computation of the vector norms in termination criterion (2), i.e., vpw=v w p, where v w i=wi vi, for i=1,2,,n. Note that the use of weights increases the computational costs.
The sequence of calls to the routines comprising the suite is enforced: first, the setup routine f11brf must be called, followed by the solver f11bsf. f11btf can be called either when f11bsf is carrying out a monitoring step or after f11bsf 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 m 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 >1, Bi-CGSTAB() computes the solution of the preconditioned system x¯k=Mxk: the preconditioning equations must be solved to obtain the required solution. The algorithm employed limits to 10% 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.

4 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

5 Arguments

1: method Character(*) Input
On entry: the iterative method to be used.
method='RGMRES'
Restarted generalized minimum residual method.
method='CGS'
Conjugate gradient squared method.
method='BICGSTAB'
Bi-conjugate gradient stabilized () method.
method='TFQMR'
Transpose-free quasi-minimal residual method.
Constraint: method='RGMRES', 'CGS', 'BICGSTAB' or 'TFQMR'.
2: precon Character(1) Input
On entry: determines whether preconditioning is used.
precon='N'
No preconditioning.
precon='P'
Preconditioning.
Constraint: precon='N' or 'P'.
3: norm Character(1) Input
On entry: defines the matrix and vector norm to be used in the termination criteria.
norm='1'
l1 norm.
norm='I'
l norm.
norm='2'
l2 norm.
Suggested values:
  • if iterm=1, norm='I';
  • if iterm=2, norm='2'.
Constraints:
  • if iterm=1, norm='1', 'I' or '2';
  • if iterm=2, norm='2'.
4: weight Character(1) Input
On entry: specifies whether a vector w of user-supplied weights is to be used in the computation of the vector norms required in termination criterion (2) (iterm=1): vpw=v w p, where vi w =wi vi, for i=1,2,,n. The suffix p=1,2, denotes the vector norm used, as specified by the argument norm. Note that weights cannot be used when iterm=2, i.e., when criterion (3) is used.
weight='W'
User-supplied weights are to be used and must be supplied on initial entry to f11bsf.
weight='N'
All weights are implicitly set equal to one. Weights do not need to be supplied on initial entry to f11bsf.
Suggested value: weight='N'.
Constraints:
  • if iterm=1, weight='W' or 'N';
  • if iterm=2, weight='N'.
5: iterm Integer Input
On entry: defines the termination criterion to be used.
iterm=1
Use the termination criterion defined in (2).
iterm=2
Use the termination criterion defined in (3).
Suggested value: iterm=1.
Constraints:
  • if method='TFQMR' or weight='W' or norm'2', iterm=1;
  • otherwise iterm=1 or 2.
Note: iterm=2 is only appropriate for a restricted set of choices for method, norm and weight; that is norm='2', weight='N' and method'TFQMR'.
6: n Integer Input
On entry: n, the order of the matrix A.
Constraint: n>0.
7: m Integer Input
On entry: if method='RGMRES', m is the dimension m of the restart subspace.
If method='BICGSTAB', m is the order of the polynomial Bi-CGSTAB method.
Otherwise, m is not referenced.
Constraints:
  • if method='RGMRES', 0<mminn,50;
  • if method='BICGSTAB', 0<mminn,10.
8: tol Real (Kind=nag_wp) Input
On entry: the tolerance τ for the termination criterion. If tol0.0,τ=maxε,nε is used, where ε is the machine precision. Otherwise τ=maxtol,10ε,nε is used.
Constraint: tol<1.0.
9: maxitn Integer Input
On entry: the maximum number of iterations.
Constraint: maxitn>0.
10: anorm Real (Kind=nag_wp) Input
On entry: if anorm>0.0, the value of Ap to be used in the termination criterion (2) (iterm=1).
If anorm0.0, iterm=1 and norm='1' or 'I', then A1=A is estimated internally by f11bsf.
If iterm=2, anorm is not referenced.
Constraint: if iterm=1 and norm='2', anorm>0.0.
11: sigmax Real (Kind=nag_wp) Input
On entry: if iterm=2, the largest singular value σ1 of the preconditioned iteration matrix; otherwise, sigmax is not referenced.
If sigmax0.0, iterm=2 and method='RGMRES', the value of σ1 will be estimated internally.
Constraint: if method='CGS' or 'BICGSTAB' and iterm=2, sigmax>0.0.
12: monit Integer Input
On entry: if monit>0, the frequency at which a monitoring step is executed by f11bsf: if method='CGS' or 'TFQMR', a monitoring step is executed every monit iterations; otherwise, a monitoring step is executed every monit super-iterations (groups of up to m 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 >1.
Constraint: monitmaxitn.
13: lwreq Integer Output
On exit: the minimum amount of workspace required by f11bsf. (See also Section 5 in f11bsf.)
14: worklwork Complex (Kind=nag_wp) array Communication Array
On exit: the array work is initialized by f11brf. It must not be modified before calling the next routine in the suite, namely f11bsf.
15: lwork Integer Input
On entry: the dimension of the array work as declared in the (sub)program from which f11brf is called.
Constraint: lwork120.
Note:  although the minimum value of lwork ensures the correct functioning of f11brf, a larger value is required by the other routines in the suite, namely f11bsf and f11btf. The required value is as follows:
Method Requirements
RGMRES lwork=120+nm+3+mm+5+1, where m is the dimension of the basis.
CGS lwork=120+7n.
Bi-CGSTAB() lwork=120+2n++2+p, where is the order of the method.
TFQMR lwork=120+10n,
where
p=2n if >1 and iterm=2 was supplied.
p=n if >1 and a preconditioner is used or iterm=2 was supplied.
p=0 otherwise.
16: ifail Integer Input/Output
On entry: ifail must be set to 0, -1 or 1. If you are unfamiliar with this argument you should refer to Section 4 in the Introduction to the NAG Library FL Interface for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value -1 or 1 is recommended. If the output of error messages is undesirable, then the value 1 is recommended. Otherwise, if you are not familiar with this argument, the recommended value is 0. When the value -1 or 1 is used it is essential to test the value of ifail on exit.
On exit: ifail=0 unless the routine detects an error or a warning has been flagged (see Section 6).

6 Error Indicators and Warnings

If on entry ifail=0 or -1, explanatory error messages are output on the current error message unit (as defined by x04aaf).
Errors or warnings detected by the routine:
ifail=1
f11brf has been called out of sequence: either f11brf has been called twice or f11bsf has not terminated its current task.
ifail=-1
On entry, method=value.
Constraint: method='RGMRES', 'CGS', 'BICGSTAB' or 'TFQMR'.
ifail=-2
On entry, precon=value.
Constraint: precon='N' or 'P'.
ifail=-3
On entry, norm=value.
Constraint: norm='1', 'I' or '2'.
ifail=-4
On entry, weight=value.
Constraint: weight='N' or 'W'.
ifail=-5
On entry, iterm=value.
Constraint: iterm=1 or 2.
On entry, iterm=2 and method='TFQMR'.
Constraint: if iterm=2, method'TFQMR'.
On entry, iterm=2 and norm=value.
Constraint: if iterm=2, norm='2'.
On entry, iterm=2 and weight=value.
Constraint: if iterm=2, weight='N'.
ifail=-6
On entry, n=value.
Constraint: n>0.
ifail=-7
On entry, m=value, n=value and method=value.
Constraint: if method='RGMRES', mminn,50. If method='BICGSTAB', mminn,10.
On entry, m=value and method=value.
Constraint: if method='RGMRES' or 'BICGSTAB', m>0.
ifail=-8
On entry, tol=value.
Constraint: tol<1.0.
ifail=-9
On entry, maxitn=value.
Constraint: maxitn>0.
ifail=-10
On entry, iterm=1, norm='2' and anorm=value.
Constraint: if iterm=1 and norm='2', anorm>0.0.
ifail=-11
On entry, iterm=2, method=value and sigmax=value.
Constraint: if iterm=2 and method='CGS' or 'BICGSTAB', sigmax>0.0.
ifail=-12
On entry, monit=value and maxitn=value.
Constraint: monitmaxitn.
ifail=-15
On entry, lwork=value.
Constraint: lwork120.
ifail=-99
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.
ifail=-399
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.
ifail=-999
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.

7 Accuracy

Not applicable.

8 Parallelism and Performance

f11brf is not threaded in any implementation.

9 Further Comments

RGMRES can estimate internally the maximum singular value σ1 of the iteration matrix, using σ1T1, where T is the upper triangular matrix obtained by QR 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 r~k=b-Axk, 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.

10 Example

This example solves an 8×8 non-Hermitian system of simultaneous linear equations using the TFQMR method where the coefficients matrix A has a random sparsity pattern. An incomplete LU preconditioner is used (routines f11dnf and f11dpf).

10.1 Program Text

Program Text (f11brfe.f90)

10.2 Program Data

Program Data (f11brfe.d)

10.3 Program Results

Program Results (f11brfe.r)