NAG FL Interface
f11dkf (real_​gen_​precon_​jacobi)

Settings help

FL Name Style:


FL Specification Language:


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

Fortran Interface
Subroutine f11dkf ( store, trans, init, niter, n, nnz, a, irow, icol, check, b, x, diag, work, ifail)
Integer, Intent (In) :: niter, n, nnz, irow(nnz), icol(nnz)
Integer, Intent (Inout) :: ifail
Real (Kind=nag_wp), Intent (In) :: a(nnz), b(n)
Real (Kind=nag_wp), Intent (Inout) :: diag(n)
Real (Kind=nag_wp), Intent (Out) :: x(n), work(n)
Character (1), Intent (In) :: store, trans, init, check
C Header Interface
#include <nag.h>
void  f11dkf_ (const char *store, const char *trans, const char *init, const Integer *niter, const Integer *n, const Integer *nnz, const double a[], const Integer irow[], const Integer icol[], const char *check, const double b[], double x[], double diag[], double work[], Integer *ifail, const Charlen length_store, const Charlen length_trans, const Charlen length_init, const Charlen length_check)
The routine may be called by the names f11dkf or nagf_sparse_real_gen_precon_jacobi.

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-1(b-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 Arguments

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 non-symmetric 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 Integer Input
On entry: the number of Jacobi iterations requested.
Constraint: niter1.
5: n Integer Input
On entry: n, the order of the matrix A.
Constraint: n1.
6: nnz Integer Input
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) array Input
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 array Input
9: icol(nnz) Integer array Input
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:
  • 1irow(i)n, for i=1,2,,nnz;
  • if store='N', 1icol(i)n, for i=1,2,,nnz;
  • if store='S', 1icol(i)irow(i), for i=1,2,,nnz;
  • either irow(i-1)<irow(i) or both irow(i-1)=irow(i) and icol(i-1)<icol(i), 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 9.2.
Constraint: check='C' or 'N'.
11: b(n) Real (Kind=nag_wp) array Input
On entry: the right-hand side vector b.
12: x(n) Real (Kind=nag_wp) array Output
On exit: the approximate solution vector xniter.
13: diag(n) Real (Kind=nag_wp) array Input/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) array Workspace
15: ifail Integer Input/Output
On entry: ifail must be set to 0, −1 or 1 to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of 0 causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of −1 means that an error message is printed while a value of 1 means that it is not.
If halting is not appropriate, the value −1 or 1 is recommended. If message printing is undesirable, then the value 1 is recommended. Otherwise, the value 0 is recommended. 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, check=value.
Constraint: check='N' or 'C'.
On entry, init=value.
Constraint: init='N' or 'I'.
On entry, niter=value.
Constraint: niter1.
On entry, store=value.
Constraint: store='N' or 'S'.
On entry, trans=value.
Constraint: trans='N' or 'T'.
ifail=2
On entry, n=value.
Constraint: n1.
On entry, nnz=value.
Constraint: nnz1.
On entry, nnz=value and n=value.
Constraint: nnzn×(n+1)/2.
On entry, nnz=value and n=value.
Constraint: nnzn2.
ifail=3
On entry, a(i) is out of order: i=value.
On entry, I=value, icol(I)=value and irow(I)=value.
Constraint: icol(I)1 and icol(I)irow(I).
On entry, I=value, icol(I)=value and n=value.
Constraint: icol(I)1 and icol(I)n.
On entry, I=value, irow(I)=value and n=value.
Constraint: irow(I)1 and irow(I)n.
On entry, the location (irow(I),icol(I)) is a duplicate: I=value.
ifail=4
On entry, the element diag(I) is zero: I=value.
ifail=5
On entry, the diagonal element of the Ith row is zero or missing: I=value.
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

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 Parallelism and Performance

Background information to multithreading can be found in the Multithreading documentation.
f11dkf is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
f11dkf 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 routine. Please also consult the Users' Note for your implementation for any additional implementation-specific information.

9 Further Comments

9.1 Timing

The time taken for a call to f11dkf is proportional to niter×nnz.

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

10 Example

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

10.1 Program Text

Program Text (f11dkfe.f90)

10.2 Program Data

Program Data (f11dkfe.d)

10.3 Program Results

Program Results (f11dkfe.r)