NAG Library Routine Document

f11dxf (complex_gen_precon_jacobi)


    1  Purpose
    7  Accuracy


f11dxf computes the approximate solution of a complex, Hermitian or non-Hermitian, sparse system of linear equations applying a number of Jacobi iterations. It is expected that f11dxf will be used as a preconditioner for the iterative solution of complex sparse systems of equations.


Fortran Interface
Subroutine f11dxf ( 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
Complex (Kind=nag_wp), Intent (In):: a(nnz), b(n)
Complex (Kind=nag_wp), Intent (Inout):: diag(n)
Complex (Kind=nag_wp), Intent (Out):: x(n), work(n)
Character (1), Intent (In):: store, trans, init, check
C Header Interface
#include nagmk26.h
void  f11dxf_ (const char *store, const char *trans, const char *init, const Integer *niter, const Integer *n, const Integer *nnz, const Complex a[], const Integer irow[], const Integer icol[], const char *check, const Complex b[], Complex x[], Complex diag[], Complex work[], Integer *ifail, const Charlen length_store, const Charlen length_trans, const Charlen length_init, const Charlen length_check)


f11dxf computes the approximate solution of the complex 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.
f11dxf can be used both for non-Hermitian and Hermitian systems of equations. For Hermitian 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 f11dxf will be used as a preconditioner for the iterative solution of complex sparse systems of equations, using either the suite comprising the routines f11grf, f11gsf and f11gtf, for Hermitian systems, or the suite comprising the routines f11brf, f11bsf and f11btf, for non-Hermitian systems of equations.


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


1:     store – Character(1)Input
On entry: specifies whether the matrix A is stored using symmetric coordinate storage (SCS) (applicable only to a Hermitian matrix A) or coordinate storage (CS) (applicable to both Hermitian and non-Hermitian matrices).
The complete matrix A is stored in CS format.
The lower triangle of the Hermitian 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 AHx=b is required.
The approximate solution of Ax=b is calculated.
The approximate solution of AHx=b is calculated.
Suggested value: if the matrix A is Hermitian 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'.
diag must contain the diagonal of A.
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.
  • if store='N', 1nnzn2;
  • if store='S', 1nnzn×n+1/2.
7:     annz – Complex (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 f11znf or f11zpf may be used to reorder the elements in this way for CS and SCS storage, respectively.
8:     irownnz – Integer arrayInput
9:     icolnnz – 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.
  • 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.
Checks are carried out on the values of n, nnz, irow, icol; if init='N', diag is also checked.
None of these checks are carried out.
See also Section 9.2.
Constraint: check='C' or 'N'.
11:   bn – Complex (Kind=nag_wp) arrayInput
On entry: the right-hand side vector b.
12:   xn – Complex (Kind=nag_wp) arrayOutput
On exit: the approximate solution vector xniter.
13:   diagn – Complex (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:   workn – Complex (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 argument you should refer to Section 3.4 in How to Use the NAG Library and its Documentation 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).

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:
On entry,store'N' or 'S',
ortrans'N' or 'T',
orinit'N' or 'I',
orcheck'C' or 'N',
On entry,n<1,
ornnz>n2, if store='N',
or1nnznn+1/2, if store='S'.
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.
On entry, init='N' and some diagonal elements of A stored in diag are zero.
On entry, init='I' and some diagonal elements of A are zero.
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 3.9 in How to Use the NAG Library and its Documentation for further information.
Your licence key may have expired or may not have been installed correctly.
See Section 3.8 in How to Use the NAG Library and its Documentation for further information.
Dynamic memory allocation failed.
See Section 3.7 in How to Use the NAG Library and its Documentation for further information.


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.

Parallelism and Performance

f11dxf is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
f11dxf 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.

Further Comments


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

Use of check

It is expected that a common use of f11dxf will be as preconditioner for the iterative solution of complex, Hermitian or non-Hermitian, linear systems. In this situation, f11dxf 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.


This example solves the complex sparse non-Hermitian system of equations Ax=b iteratively using f11dxf as a preconditioner.

Program Text

Program Text (f11dxfe.f90)

Program Data

Program Data (f11dxfe.d)

Program Results

Program Results (f11dxfe.r)

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