F11DKF (PDF version)
F11 Chapter Contents
F11 Chapter Introduction
NAG Library Manual

NAG Library Routine Document

F11DKF

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

+ Contents

    1  Purpose
    7  Accuracy

1  Purpose

F11DKF computes the approximate solution of a real, symmetric or nonsymmetric, sparse system of linear equations applying a number of Jacobi iterations. It is expected that F11DKF will be used as a preconditioner for the iterative solution of real sparse systems of equations.

2  Specification

SUBROUTINE F11DKF ( STORE, TRANS, INIT, NITER, N, NNZ, A, IROW, ICOL, CHECK, B, X, DIAG, WORK, IFAIL)
INTEGER  NITER, N, NNZ, IROW(NNZ), ICOL(NNZ), IFAIL
REAL (KIND=nag_wp)  A(NNZ), B(N), X(N), DIAG(N), WORK(N)
CHARACTER(1)  STORE, TRANS, INIT, CHECK

3  Description

F11DKF computes the approximate solution of the real sparse system of linear equations Ax=b using NITER iterations of the Jacobi algorithm (see also Golub and Van Loan (1996) and Young (1971)):
xk+1=xk+D-1b-Axk (1)
where k=1,2,,NITER and x0=0.
F11DKF can be used both for nonsymmetric and symmetric systems of equations. For symmetric matrices, either all nonzero elements of the matrix A can be supplied using coordinate storage (CS), or only the nonzero elements of the lower triangle of A, using symmetric coordinate storage (SCS) (see the F11 Chapter Introduction).
It is expected that F11DKF will be used as a preconditioner for the iterative solution of real sparse systems of equations, using either the suite comprising the routines F11GDF, F11GEF and F11GFF, for symmetric systems, or the suite comprising the routines F11BDF, F11BEF and F11BFF, for nonsymmetric systems of equations.

4  References

Golub G H and Van Loan C F (1996) Matrix Computations (3rd Edition) Johns Hopkins University Press, Baltimore
Young D (1971) Iterative Solution of Large Linear Systems Academic Press, New York

5  Parameters

1:     STORE – CHARACTER(1)Input
On entry: specifies whether the matrix A is stored using symmetric coordinate storage (SCS) (applicable only to a symmetric matrix A) or coordinate storage (CS) (applicable to both symmetric and nonsymmetric matrices).
STORE='N'
The complete matrix A is stored in CS format.
STORE='S'
The lower triangle of the symmetric matrix A is stored in SCS format.
Constraint: STORE='N' or 'S'.
2:     TRANS – CHARACTER(1)Input
On entry: if STORE='N', specifies whether the approximate solution of Ax=b or of ATx=b is required.
TRANS='N'
The approximate solution of Ax=b is calculated.
TRANS='T'
The approximate solution of ATx=b is calculated.
Suggested value: if the matrix A is symmetric and stored in CS format, it is recommended that TRANS='N' for reasons of efficiency.
Constraint: TRANS='N' or 'T'.
3:     INIT – CHARACTER(1)Input
On entry: on first entry, INIT should be set to 'I', unless the diagonal elements of A are already stored in the array DIAG. If DIAG already contains the diagonal of A, it must be set to 'N'.
INIT='N'
DIAG must contain the diagonal of A.
INIT='I'
DIAG will store the diagonal of A on exit.
Suggested value: INIT='I' on first entry; INIT='N', subsequently, unless DIAG has been overwritten.
Constraint: INIT='N' or 'I'.
4:     NITER – INTEGERInput
On entry: the number of Jacobi iterations requested.
Constraint: NITER1.
5:     N – INTEGERInput
On entry: n, the order of the matrix A.
Constraint: N1.
6:     NNZ – INTEGERInput
On entry: if STORE='N', the number of nonzero elements in the matrix A.
If STORE='S', the number of nonzero elements in the lower triangle of the matrix A.
Constraints:
  • if STORE='N', 1NNZN2;
  • if STORE='S', 1NNZN×N+1/2.
7:     A(NNZ) – REAL (KIND=nag_wp) arrayInput
On entry: if STORE='N', the nonzero elements in the matrix A (CS format).
If STORE='S', the nonzero elements in the lower triangle of the matrix A (SCS format).
In both cases, the elements of either A or of its lower triangle must be ordered by increasing row index and by increasing column index within each row. Multiple entries for the same row and columns indices are not permitted. The routine F11ZAF or F11ZBF may be used to reorder the elements in this way for CS and SCS storage, respectively.
8:     IROW(NNZ) – INTEGER arrayInput
9:     ICOL(NNZ) – INTEGER arrayInput
On entry: if STORE='N', the row and column indices of the nonzero elements supplied in A.
If STORE='S', the row and column indices of the nonzero elements of the lower triangle of the matrix A supplied in A.
Constraints:
  • 1IROWiN, for i=1,2,,NNZ;
  • if STORE='N', 1ICOLiN, for i=1,2,,NNZ;
  • if STORE='S', 1ICOLiIROWi, for i=1,2,,NNZ;
  • either IROWi-1<IROWi or both IROWi-1=IROWi and ICOLi-1<ICOLi, for i=2,3,,NNZ.
10:   CHECK – CHARACTER(1)Input
On entry: specifies whether or not the CS or SCS representation of the matrix A should be checked.
CHECK='C'
Checks are carried out on the values of N, NNZ, IROW, ICOL; if INIT='N', DIAG is also checked.
CHECK='N'
None of these checks are carried out.
See also Section 8.2.
Constraint: CHECK='C' or 'N'.
11:   B(N) – REAL (KIND=nag_wp) arrayInput
On entry: the right-hand side vector b.
12:   X(N) – REAL (KIND=nag_wp) arrayOutput
On exit: the approximate solution vector xNITER.
13:   DIAG(N) – REAL (KIND=nag_wp) arrayInput/Output
On entry: if INIT='N', the diagonal elements of A.
On exit: if INIT='N', unchanged on exit.
If INIT='I', the diagonal elements of A.
14:   WORK(N) – REAL (KIND=nag_wp) arrayWorkspace
15:   IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to 0, -1​ or ​1. If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction 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 parameter, 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
On entry,STORE'N' or 'S',
orTRANS'N' or 'T',
orINIT'N' or 'I',
orCHECK'C' or 'N',
orNITER0.
IFAIL=2
On entry,N<1,
orNNZ<1,
orNNZ>N2, if STORE='N',
or1NNZNN+1/2, if STORE='S'.
IFAIL=3
On entry, the arrays IROW and ICOL fail to satisfy the following constraints:
  • 1IROWiN and
    • if STORE='N' then 1ICOLiN, or
    • if STORE='S' then 1ICOLiIROWi, for i=1,2,,NNZ.
  • IROWi-1<IROWi or IROWi-1=IROWi and ICOLi-1<ICOLi, for i=2,3,,NNZ.
Therefore a nonzero element has been supplied which does not lie within the matrix A, is out of order, or has duplicate row and column indices. Call either F11ZAF or F11ZBF to reorder and sum or remove duplicates when STORE='N' or STORE='S', respectively.
IFAIL=4
On entry, INIT='N' and some diagonal elements of A stored in DIAG are zero.
IFAIL=5
On entry, INIT='I' and some diagonal elements of A are zero.

7  Accuracy

In general, the Jacobi method cannot be used on its own to solve systems of linear equations. The rate of convergence is bound by its spectral properties (see, for example, Golub and Van Loan (1996)) and as a solver, the Jacobi method can only be applied to a limited set of matrices. One condition that guarantees convergence is strict diagonal dominance.
However, the Jacobi method can be used successfully as a preconditioner to a wider class of systems of equations. The Jacobi method has good vector/parallel properties, hence it can be applied very efficiently. Unfortunately, it is not possible to provide criteria which define the applicability of the Jacobi method as a preconditioner, and its usefulness must be judged for each case.

8  Further Comments

8.1  Timing

The time taken for a call to F11DKF is proportional to NITER×NNZ.

8.2  Use of CHECK

It is expected that a common use of F11DKF will be as preconditioner for the iterative solution of real, symmetric or nonsymmetric, linear systems. In this situation, F11DKF is likely to be called many times. In the interests of both reliability and efficiency, you are recommended to set CHECK='C' for the first of such calls, and to set CHECK='N' for all subsequent calls.

9  Example

This example solves the real sparse nonsymmetric system of equations Ax=b iteratively using F11DKF as a preconditioner.

9.1  Program Text

Program Text (f11dkfe.f90)

9.2  Program Data

Program Data (f11dkfe.d)

9.3  Program Results

Program Results (f11dkfe.r)


F11DKF (PDF version)
F11 Chapter Contents
F11 Chapter Introduction
NAG Library Manual

© The Numerical Algorithms Group Ltd, Oxford, UK. 2012