PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_sparse_real_symm_solve_jacssor (f11je)
Purpose
nag_sparse_real_symm_solve_jacssor (f11je) solves a real sparse symmetric system of linear equations, represented in symmetric coordinate storage format, using a conjugate gradient or Lanczos method, without preconditioning, with Jacobi or with SSOR preconditioning.
Syntax
[
x,
rnorm,
itn,
ifail] = f11je(
method,
precon,
a,
irow,
icol,
omega,
b,
tol,
maxitn,
x, 'n',
n, 'nz',
nz)
[
x,
rnorm,
itn,
ifail] = nag_sparse_real_symm_solve_jacssor(
method,
precon,
a,
irow,
icol,
omega,
b,
tol,
maxitn,
x, 'n',
n, 'nz',
nz)
Description
nag_sparse_real_symm_solve_jacssor (f11je) solves a real sparse symmetric linear system of equations
using a preconditioned conjugate gradient method (see
Barrett et al. (1994)), or a preconditioned Lanczos method based on the algorithm SYMMLQ (see
Paige and Saunders (1975)). The conjugate gradient method is more efficient if
is positive definite, but may fail to converge for indefinite matrices. In this case the Lanczos method should be used instead. For further details see
Barrett et al. (1994).
The function allows the following choices for the preconditioner:
- no preconditioning;
- Jacobi preconditioning (see Young (1971));
- symmetric successive-over-relaxation (SSOR) preconditioning (see Young (1971)).
For incomplete Cholesky (IC) preconditioning see
nag_sparse_real_symm_solve_ichol (f11jc).
The matrix
is represented in symmetric coordinate storage (SCS) format (see
Symmetric coordinate storage (SCS) format in the F11 Chapter Introduction) in the arrays
a,
irow and
icol. The array
a holds the nonzero entries in the lower triangular part of the matrix, while
irow and
icol hold the corresponding row and column indices.
References
Barrett R, Berry M, Chan T F, Demmel J, Donato J, Dongarra J, Eijkhout V, Pozo R, Romine C and Van der Vorst H (1994) Templates for the Solution of Linear Systems: Building Blocks for Iterative Methods SIAM, Philadelphia
Paige C C and Saunders M A (1975) Solution of sparse indefinite systems of linear equations SIAM J. Numer. Anal. 12 617–629
Young D (1971) Iterative Solution of Large Linear Systems Academic Press, New York
Parameters
Compulsory Input Parameters
- 1:
– string
-
Specifies the iterative method to be used.
- Conjugate gradient method.
- Lanczos method (SYMMLQ).
Constraint:
or .
- 2:
– string (length ≥ 1)
-
Specifies the type of preconditioning to be used.
- No preconditioning.
- Jacobi.
- Symmetric successive-over-relaxation (SSOR).
Constraint:
, or .
- 3:
– double array
-
The nonzero elements of the lower triangular part of the matrix
, ordered by increasing row index, and by increasing column index within each row. Multiple entries for the same row and column indices are not permitted. The function
nag_sparse_real_symm_sort (f11zb) may be used to order the elements in this way.
- 4:
– int64int32nag_int array
- 5:
– int64int32nag_int array
-
The row and column indices of the nonzero elements supplied in array
a.
Constraints:
irow and
icol must satisfy these constraints (which may be imposed by a call to
nag_sparse_real_symm_sort (f11zb)):
- and , for ;
- or and , for .
- 6:
– double scalar
-
If
,
omega is the relaxation parameter
to be used in the SSOR method. Otherwise
omega need not be initialized.
Constraint:
.
- 7:
– double array
-
The right-hand side vector .
- 8:
– double scalar
-
The required tolerance. Let
denote the approximate solution at iteration
, and
the corresponding residual. The algorithm is considered to have converged at iteration
if
If
,
is used, where
is the
machine precision. Otherwise
is used.
Constraint:
.
- 9:
– int64int32nag_int scalar
-
The maximum number of iterations allowed.
Constraint:
.
- 10:
– double array
-
An initial approximation to the solution vector .
Optional Input Parameters
- 1:
– int64int32nag_int scalar
-
Default:
the dimension of the arrays
b,
x. (An error is raised if these dimensions are not equal.)
, the order of the matrix .
Constraint:
.
- 2:
– int64int32nag_int scalar
-
Default:
the dimension of the arrays
a,
irow,
icol. (An error is raised if these dimensions are not equal.)
The number of nonzero elements in the lower triangular part of the matrix .
Constraint:
.
Output Parameters
- 1:
– double array
-
An improved approximation to the solution vector .
- 2:
– double scalar
-
The final value of the residual norm
, where
is the output value of
itn.
- 3:
– int64int32nag_int scalar
-
The number of iterations carried out.
- 4:
– int64int32nag_int scalar
unless the function detects an error (see
Error Indicators and Warnings).
Error Indicators and Warnings
Errors or warnings detected by the function:
-
-
On entry, | or , |
or | , or , |
or | , |
or | , |
or | , |
or | omega lies outside the interval , |
or | , |
or | , |
or | lwork too small. |
-
-
On entry, the arrays
irow and
icol fail to satisfy the following constraints:
- and , for ;
- , or and , for .
Therefore a nonzero element has been supplied which does not lie in the lower triangular part of
, is out of order, or has duplicate row and column indices. Call
nag_sparse_real_symm_sort (f11zb) to reorder and sum or remove duplicates.
-
-
On entry, the matrix has a zero diagonal element. Jacobi and SSOR preconditioners are not appropriate for this problem.
-
-
The required accuracy could not be obtained. However, a reasonable accuracy has been obtained and further iterations could not improve the result.
-
-
Required accuracy not obtained in
maxitn iterations.
-
-
The preconditioner appears not to be positive definite.
-
-
The matrix of the coefficients appears not to be positive definite (conjugate gradient method only).
- (nag_sparse_real_symm_basic_setup (f11gd), nag_sparse_real_symm_basic_solver (f11ge) or nag_sparse_real_symm_basic_diag (f11gf))
-
A serious error has occurred in an internal call to one of the specified functions. Check all function calls and array sizes. Seek expert help.
-
An unexpected error has been triggered by this routine. Please
contact
NAG.
-
Your licence key may have expired or may not have been installed correctly.
-
Dynamic memory allocation failed.
Accuracy
On successful termination, the final residual
, where
, satisfies the termination criterion
The value of the final residual norm is returned in
rnorm.
Further Comments
The time taken by
nag_sparse_real_symm_solve_jacssor (f11je) for each iteration is roughly proportional to
nz. One iteration with the Lanczos method (SYMMLQ) requires a slightly larger number of operations than one iteration with the conjugate gradient method.
The number of iterations required to achieve a prescribed accuracy cannot be easily determined a priori, as it can depend dramatically on the conditioning and spectrum of the preconditioned matrix of the coefficients .
Example
This example solves a symmetric positive definite system of equations using the conjugate gradient method, with SSOR preconditioning.
Open in the MATLAB editor:
f11je_example
function f11je_example
fprintf('f11je example results\n\n');
n = int64(7);
nz = int64(16);
irow = zeros(nz,1,'int64');
icol = irow;
a(1:16) = [4 1 5 2 2 3 -1 1 4 1 -2 3 2 -1 -2 5];
irow(1:16) = [1 2 2 3 4 4 5 5 5 6 6 6 7 7 7 7];
icol(1:16) = [1 1 2 3 2 4 1 4 5 2 5 6 1 2 3 7];
b = [15 18 -8 21 11 10 29];
x = zeros(n,1);
method = 'CG';
precon = 'S';
omega = 1.1;
tol = 1e-06;
maxitn = int64(100);
[x, rnorm, itn, ifail] = ...
f11je( ...
method, precon, a, irow, icol, omega, b, tol, maxitn, x);
fprintf('Converged in %d iterations\n', itn);
fprintf('Final redidual norm = %16.3d\n\n', rnorm);
disp('Solution');
disp(x);
f11je example results
Converged in 6 iterations
Final redidual norm = 5.026e-06
Solution
1.0000
2.0000
3.0000
4.0000
5.0000
6.0000
7.0000
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015