NAG C Library Function Document
nag_sparse_nsym_jacobi (f11dkc)
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
using
niter iterations of the Jacobi algorithm (see also
Golub and Van Loan (1996) and
Young (1971)):
where
and
.
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
can be supplied using coordinate storage (CS), or only the nonzero elements of the lower triangle of
, 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:
– Nag_SparseNsym_StoreInput
-
On entry: specifies whether the matrix
is stored using symmetric coordinate storage (SCS) (applicable only to a symmetric matrix
) or coordinate storage (CS) (applicable to both symmetric and non-symmetric matrices).
- The complete matrix is stored in CS format.
- The lower triangle of the symmetric matrix is stored in SCS format.
Constraint:
or .
- 2:
– Nag_TransTypeInput
-
On entry: if
, specifies whether the approximate solution of
or of
is required.
- The approximate solution of is calculated.
- The approximate solution of is calculated.
Suggested value:
if the matrix is symmetric and stored in CS format, it is recommended that for reasons of efficiency.
Constraint:
or .
- 3:
– Nag_InitializeAInput
-
On entry: on first entry,
init should be set to
, unless the diagonal elements of
are already stored in the array
diag. If
diag already contains the diagonal of
, it must be set to
.
- diag must contain the diagonal of .
- diag will store the diagonal of on exit.
Suggested value:
on first entry;
, subsequently, unless
diag has been overwritten.
Constraint:
or .
- 4:
– IntegerInput
-
On entry: the number of Jacobi iterations requested.
Constraint:
.
- 5:
– IntegerInput
-
On entry: , the order of the matrix .
Constraint:
.
- 6:
– IntegerInput
-
On entry: if
, the number of nonzero elements in the matrix
.
If , the number of nonzero elements in the lower triangle of the matrix .
Constraints:
- if , ;
- if , .
- 7:
– const doubleInput
-
On entry: if
, the nonzero elements in the matrix
(CS format).
If , the nonzero elements in the lower triangle of the matrix (SCS format).
In both cases, the elements of either
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:
– const IntegerInput
- 9:
– const IntegerInput
-
On entry: if
, the row and column indices of the nonzero elements supplied in
a.
If
, the row and column indices of the nonzero elements of the lower triangle of the matrix
supplied in
a.
Constraints:
- , for ;
- if , , for ;
- if , , for ;
- either or both and , for .
- 10:
– Nag_SparseNsym_CheckDataInput
-
On entry: specifies whether or not the CS or SCS representation of the matrix
should be checked.
- Checks are carried out on the values of n, nnz, irow, icol; if , diag is also checked.
- None of these checks are carried out.
Constraint:
or .
- 11:
– const doubleInput
-
On entry: the right-hand side vector .
- 12:
– doubleOutput
-
On exit: the approximate solution vector .
- 13:
– doubleInput/Output
-
On entry: if , the diagonal elements of .
On exit: if
, unchanged on exit.
If , the diagonal elements of .
- 14:
– 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 had an illegal value.
- NE_INT
-
On entry, .
Constraint: .
On entry, .
Constraint: .
On entry, .
Constraint: .
- NE_INT_2
-
On entry, and .
Constraint: .
On entry, and .
Constraint: .
- 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, , and .
Constraint: and .
On entry, , and .
Constraint: and .
On entry, , and .
Constraint: and .
- 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, is out of order: .
On entry, the location () is a duplicate: .
- NE_ZERO_DIAG_ELEM
-
On entry, the diagonal element of the th row is zero or missing: .
On entry, the element is 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
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.
The time taken for a call to nag_sparse_nsym_jacobi (f11dkc) is proportional to .
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 for the first of such calls, and to set for all subsequent calls.
10
Example
This example solves the real sparse nonsymmetric system of equations 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)