NAG CL Interface
f11dkc (real_​gen_​precon_​jacobi)

Settings help

CL Name Style:


1 Purpose

f11dkc 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 f11dkc will be used as a preconditioner for the iterative solution of real sparse systems of equations.

2 Specification

#include <nag.h>
void  f11dkc (Nag_SparseNsym_Store store, Nag_TransType trans, Nag_InitializeA init, Integer niter, Integer n, Integer nnz, const double a[], const Integer irow[], const Integer icol[], Nag_SparseNsym_CheckData check, const double b[], double x[], double diag[], NagError *fail)
The function may be called by the names: f11dkc, nag_sparse_real_gen_precon_jacobi or nag_sparse_nsym_jacobi.

3 Description

f11dkc 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.
f11dkc 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 f11dkc will be used as a preconditioner for the iterative solution of real sparse systems of equations. This may be with either the symmetric or nonsymmetric suites of functions.
For symmetric systems the suite consists of:
For nonsymmetric systems the suite consists of:

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 Nag_SparseNsym_Store 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=Nag_SparseNsym_StoreCS
The complete matrix A is stored in CS format.
store=Nag_SparseNsym_StoreSCS
The lower triangle of the symmetric matrix A is stored in SCS format.
Constraint: store=Nag_SparseNsym_StoreCS or Nag_SparseNsym_StoreSCS.
2: trans Nag_TransType Input
On entry: if store=Nag_SparseNsym_StoreCS, specifies whether the approximate solution of Ax=b or of ATx=b is required.
trans=Nag_NoTrans
The approximate solution of Ax=b is calculated.
trans=Nag_Trans
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=Nag_NoTrans for reasons of efficiency.
Constraint: trans=Nag_NoTrans or Nag_Trans.
3: init Nag_InitializeA Input
On entry: on first entry, init should be set to Nag_InitializeI, 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 Nag_InputA.
init=Nag_InputA
diag must contain the diagonal of A.
init=Nag_InitializeI
diag will store the diagonal of A on exit.
Suggested value: init=Nag_InitializeI on first entry; init=Nag_InputA, subsequently, unless diag has been overwritten.
Constraint: init=Nag_InputA or Nag_InitializeI.
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=Nag_SparseNsym_StoreCS, the number of nonzero elements in the matrix A.
If store=Nag_SparseNsym_StoreSCS, the number of nonzero elements in the lower triangle of the matrix A.
Constraints:
  • if store=Nag_SparseNsym_StoreCS, 1nnzn2;
  • if store=Nag_SparseNsym_StoreSCS, 1nnzn×(n+1)/2.
7: a[nnz] const double Input
On entry: if store=Nag_SparseNsym_StoreCS, the nonzero elements in the matrix A (CS format).
If store=Nag_SparseNsym_StoreSCS, 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 function f11zac or f11zbc may be used to reorder the elements in this way for CS and SCS storage, respectively.
8: irow[nnz] const Integer Input
9: icol[nnz] const Integer Input
On entry: if store=Nag_SparseNsym_StoreCS, the row and column indices of the nonzero elements supplied in a.
If store=Nag_SparseNsym_StoreSCS, 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=0,1,,nnz-1;
  • if store=Nag_SparseNsym_StoreCS, 1icol[i]n, for i=0,1,,nnz-1;
  • if store=Nag_SparseNsym_StoreSCS, 1icol[i]irow[i], for i=0,1,,nnz-1;
  • either irow[i-1]<irow[i] or both irow[i-1]=irow[i] and icol[i-1]<icol[i], for i=1,2,,nnz-1.
10: check Nag_SparseNsym_CheckData Input
On entry: specifies whether or not the CS or SCS representation of the matrix A should be checked.
check=Nag_SparseNsym_Check
Checks are carried out on the values of n, nnz, irow, icol; if init=Nag_InputA, diag is also checked.
check=Nag_SparseNsym_NoCheck
None of these checks are carried out.
See also Section 9.2.
Constraint: check=Nag_SparseNsym_Check or Nag_SparseNsym_NoCheck.
11: b[n] const double Input
On entry: the right-hand side vector b.
12: x[n] double Output
On exit: the approximate solution vector xniter.
13: diag[n] double Input/Output
On entry: if init=Nag_InputA, the diagonal elements of A.
On exit: if init=Nag_InputA, unchanged on exit.
If init=Nag_InitializeI, the diagonal elements of A.
14: fail NagError * Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).

6 Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 3.1.2 in the Introduction to the NAG Library CL Interface for further information.
NE_BAD_PARAM
On entry, argument value had an illegal value.
NE_INT
On entry, n=value.
Constraint: n1.
On entry, niter=value.
Constraint: niter1.
On entry, nnz=value.
Constraint: nnz1.
NE_INT_2
On entry, nnz=value and n=value.
Constraint: nnzn×(n+1)/2.
On entry, nnz=value and n=value.
Constraint: nnzn2.
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
See Section 7.5 in the Introduction to the NAG Library CL Interface for further information.
NE_INVALID_CS
On entry, I=value, icol[I-1]=value and irow[I-1]=value.
Constraint: icol[I-1]1 and icol[I-1]irow[I-1].
On entry, I=value, icol[I-1]=value and n=value.
Constraint: icol[I-1]1 and icol[I-1]n.
On entry, I=value, irow[I-1]=value and n=value.
Constraint: irow[I-1]1 and irow[I-1]n.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library CL Interface for further information.
NE_NOT_STRICTLY_INCREASING
On entry, a[i-1] is out of order: i=value.
On entry, the location (irow[I-1],icol[I-1]) is a duplicate: I=value.
NE_ZERO_DIAG_ELEM
On entry, the diagonal element of the Ith row is zero or missing: I=value.
On entry, the element diag[I-1] is zero: I=value.

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

f11dkc is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
f11dkc 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 function. 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 f11dkc is proportional to niter×nnz.

9.2 Use of check

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

10 Example

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

10.1 Program Text

Program Text (f11dkce.c)

10.2 Program Data

Program Data (f11dkce.d)

10.3 Program Results

Program Results (f11dkce.r)