F11 Chapter Contents
F11 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentF11DXF

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.

## 1  Purpose

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.

## 2  Specification

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

## 3  Description

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,\dots ,{\mathbf{NITER}}$ and ${x}_{0}=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

## 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 Hermitian matrix $A$) or coordinate storage (CS) (applicable to both Hermitian and non-Hermitian matrices).
${\mathbf{STORE}}=\text{'N'}$
The complete matrix $A$ is stored in CS format.
${\mathbf{STORE}}=\text{'S'}$
The lower triangle of the Hermitian matrix $A$ is stored in SCS format.
Constraint: ${\mathbf{STORE}}=\text{'N'}$ or $\text{'S'}$.
2:     TRANS – CHARACTER(1)Input
On entry: if ${\mathbf{STORE}}=\text{'N'}$, specifies whether the approximate solution of $Ax=b$ or of ${A}^{\mathrm{T}}x=b$ is required.
${\mathbf{TRANS}}=\text{'N'}$
The approximate solution of $Ax=b$ is calculated.
${\mathbf{TRANS}}=\text{'T'}$
The approximate solution of ${A}^{\mathrm{T}}x=b$ is calculated.
Suggested value: if the matrix $A$ is Hermitian and stored in CS format, it is recommended that ${\mathbf{TRANS}}=\text{'N'}$ for reasons of efficiency.
Constraint: ${\mathbf{TRANS}}=\text{'N'}$ or $\text{'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'.
${\mathbf{INIT}}=\text{'N'}$
DIAG must contain the diagonal of $A$.
${\mathbf{INIT}}=\text{'I'}$
DIAG will store the diagonal of $A$ on exit.
Suggested value: ${\mathbf{INIT}}=\text{'I'}$ on first entry; ${\mathbf{INIT}}=\text{'N'}$, subsequently, unless DIAG has been overwritten.
Constraint: ${\mathbf{INIT}}=\text{'N'}$ or $\text{'I'}$.
4:     NITER – INTEGERInput
On entry: the number of Jacobi iterations requested.
Constraint: ${\mathbf{NITER}}\ge 1$.
5:     N – INTEGERInput
On entry: $n$, the order of the matrix $A$.
Constraint: ${\mathbf{N}}\ge 1$.
6:     NNZ – INTEGERInput
On entry: if ${\mathbf{STORE}}=\text{'N'}$, the number of nonzero elements in the matrix $A$.
If ${\mathbf{STORE}}=\text{'S'}$, the number of nonzero elements in the lower triangle of the matrix $A$.
Constraints:
• if ${\mathbf{STORE}}=\text{'N'}$, $1\le {\mathbf{NNZ}}\le {{\mathbf{N}}}^{2}$;
• if ${\mathbf{STORE}}=\text{'S'}$, $1\le {\mathbf{NNZ}}\le {\mathbf{N}}×\left({\mathbf{N}}+1\right)/2$.
7:     A(NNZ) – COMPLEX (KIND=nag_wp) arrayInput
On entry: if ${\mathbf{STORE}}=\text{'N'}$, the nonzero elements in the matrix $A$ (CS format).
If ${\mathbf{STORE}}=\text{'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:     IROW(NNZ) – INTEGER arrayInput
9:     ICOL(NNZ) – INTEGER arrayInput
On entry: if ${\mathbf{STORE}}=\text{'N'}$, the row and column indices of the nonzero elements supplied in A.
If ${\mathbf{STORE}}=\text{'S'}$, the row and column indices of the nonzero elements of the lower triangle of the matrix $A$ supplied in A.
Constraints:
• $1\le {\mathbf{IROW}}\left(\mathit{i}\right)\le {\mathbf{N}}$, for $\mathit{i}=1,2,\dots ,{\mathbf{NNZ}}$;
• if ${\mathbf{STORE}}=\text{'N'}$, $1\le {\mathbf{ICOL}}\left(\mathit{i}\right)\le {\mathbf{N}}$, for $\mathit{i}=1,2,\dots ,{\mathbf{NNZ}}$;
• if ${\mathbf{STORE}}=\text{'S'}$, $1\le {\mathbf{ICOL}}\left(\mathit{i}\right)\le {\mathbf{IROW}}\left(\mathit{i}\right)$, for $\mathit{i}=1,2,\dots ,{\mathbf{NNZ}}$;
• either ${\mathbf{IROW}}\left(\mathit{i}-1\right)<{\mathbf{IROW}}\left(\mathit{i}\right)$ or both ${\mathbf{IROW}}\left(\mathit{i}-1\right)={\mathbf{IROW}}\left(\mathit{i}\right)$ and ${\mathbf{ICOL}}\left(\mathit{i}-1\right)<{\mathbf{ICOL}}\left(\mathit{i}\right)$, for $\mathit{i}=2,3,\dots ,{\mathbf{NNZ}}$.
10:   CHECK – CHARACTER(1)Input
On entry: specifies whether or not the CS or SCS representation of the matrix $A$ should be checked.
${\mathbf{CHECK}}=\text{'C'}$
Checks are carried out on the values of N, NNZ, IROW, ICOL; if ${\mathbf{INIT}}=\text{'N'}$, DIAG is also checked.
${\mathbf{CHECK}}=\text{'N'}$
None of these checks are carried out.
Constraint: ${\mathbf{CHECK}}=\text{'C'}$ or $\text{'N'}$.
11:   B(N) – COMPLEX (KIND=nag_wp) arrayInput
On entry: the right-hand side vector $b$.
12:   X(N) – COMPLEX (KIND=nag_wp) arrayOutput
On exit: the approximate solution vector ${x}_{{\mathbf{NITER}}}$.
13:   DIAG(N) – COMPLEX (KIND=nag_wp) arrayInput/Output
On entry: if ${\mathbf{INIT}}=\text{'N'}$, the diagonal elements of $A$.
On exit: if ${\mathbf{INIT}}=\text{'N'}$, unchanged on exit.
If ${\mathbf{INIT}}=\text{'I'}$, the diagonal elements of $A$.
14:   WORK(N) – COMPLEX (KIND=nag_wp) arrayWorkspace
15:   IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to $0$, $-1\text{​ 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\text{​ 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 $-\mathbf{1}\text{​ or ​}\mathbf{1}$ is used it is essential to test the value of IFAIL on exit.
On exit: ${\mathbf{IFAIL}}={\mathbf{0}}$ unless the routine detects an error or a warning has been flagged (see Section 6).

## 6  Error Indicators and Warnings

If on entry ${\mathbf{IFAIL}}={\mathbf{0}}$ or $-{\mathbf{1}}$, explanatory error messages are output on the current error message unit (as defined by X04AAF).
Errors or warnings detected by the routine:
${\mathbf{IFAIL}}=1$
 On entry, ${\mathbf{STORE}}\ne \text{'N'}$ or $\text{'S'}$, or ${\mathbf{TRANS}}\ne \text{'N'}$ or $\text{'T'}$, or ${\mathbf{INIT}}\ne \text{'N'}$ or $\text{'I'}$, or ${\mathbf{CHECK}}\ne \text{'C'}$ or $\text{'N'}$, or ${\mathbf{NITER}}\le 0$.
${\mathbf{IFAIL}}=2$
 On entry, ${\mathbf{N}}<1$, or ${\mathbf{NNZ}}<1$, or ${\mathbf{NNZ}}>{{\mathbf{N}}}^{2}$, if ${\mathbf{STORE}}=\text{'N'}$, or $1\le {\mathbf{NNZ}}\le \left[{\mathbf{N}}\left({\mathbf{N}}+1\right)\right]/2$, if ${\mathbf{STORE}}=\text{'S'}$.
${\mathbf{IFAIL}}=3$
On entry, the arrays IROW and ICOL fail to satisfy the following constraints:
• $1\le {\mathbf{IROW}}\left(i\right)\le {\mathbf{N}}$ and
• if ${\mathbf{STORE}}=\text{'N'}$ then $1\le {\mathbf{ICOL}}\left(i\right)\le {\mathbf{N}}$, or
• if ${\mathbf{STORE}}=\text{'S'}$ then $1\le {\mathbf{ICOL}}\left(\mathit{i}\right)\le {\mathbf{IROW}}\left(\mathit{i}\right)$, for $\mathit{i}=1,2,\dots ,{\mathbf{NNZ}}$.
• ${\mathbf{IROW}}\left(\mathit{i}-1\right)<{\mathbf{IROW}}\left(\mathit{i}\right)$ or ${\mathbf{IROW}}\left(\mathit{i}-1\right)={\mathbf{IROW}}\left(\mathit{i}\right)$ and ${\mathbf{ICOL}}\left(\mathit{i}-1\right)<{\mathbf{ICOL}}\left(\mathit{i}\right)$, for $\mathit{i}=2,3,\dots ,{\mathbf{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 ${\mathbf{STORE}}=\text{'N'}$ or ${\mathbf{STORE}}=\text{'S'}$, respectively.
${\mathbf{IFAIL}}=4$
On entry, ${\mathbf{INIT}}=\text{'N'}$ and some diagonal elements of $A$ stored in DIAG are zero.
${\mathbf{IFAIL}}=5$
On entry, ${\mathbf{INIT}}=\text{'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.1  Timing

The time taken for a call to F11DXF is proportional to ${\mathbf{NITER}}×{\mathbf{NNZ}}$.

### 8.2  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 ${\mathbf{CHECK}}=\text{'C'}$ for the first of such calls, and to set ${\mathbf{CHECK}}=\text{'N'}$ for all subsequent calls.

## 9  Example

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

### 9.1  Program Text

Program Text (f11dxfe.f90)

### 9.2  Program Data

Program Data (f11dxfe.d)

### 9.3  Program Results

Program Results (f11dxfe.r)