NAG Library Function Document

nag_sparse_nsym_jacobi (f11dkc)

 Contents

    1  Purpose
    7  Accuracy

1
Purpose

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

2
Specification

#include <nag.h>
#include <nagf11.h>
void  nag_sparse_nsym_jacobi (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)

3
Description

nag_sparse_nsym_jacobi (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-1b-Axk (1)
where k=1,2,,niter and x0=0.
nag_sparse_nsym_jacobi (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 nag_sparse_nsym_jacobi (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_StoreInput
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_TransTypeInput
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_InitializeAInput
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 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=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 doubleInput
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 nag_sparse_nsym_sort (f11zac) or nag_sparse_sym_sort (f11zbc) may be used to reorder the elements in this way for CS and SCS storage, respectively.
8:     irow[nnz] const IntegerInput
9:     icol[nnz] const IntegerInput
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_CheckDataInput
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 doubleInput
On entry: the right-hand side vector b.
12:   x[n] doubleOutput
On exit: the approximate solution vector xniter.
13:   diag[n] doubleInput/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 3.7 in How to Use the NAG Library and its Documentation).

6
Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 2.3.1.2 in How to Use the NAG Library and its Documentation 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 2.7.6 in How to Use the NAG Library and its Documentation 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 2.7.5 in How to Use the NAG Library and its Documentation 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

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

9.2
Use of check

It is expected that a common use of nag_sparse_nsym_jacobi (f11dkc) will be as preconditioner for the iterative solution of real, symmetric or nonsymmetric, linear systems. In this situation, nag_sparse_nsym_jacobi (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 nag_sparse_nsym_jacobi (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)

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