PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_sparse_complex_gen_precon_jacobi (f11dx)
Purpose
nag_sparse_complex_gen_precon_jacobi (f11dx) 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 nag_sparse_complex_gen_precon_jacobi (f11dx) will be used as a preconditioner for the iterative solution of complex sparse systems of equations.
Syntax
[
x,
diag,
ifail] = f11dx(
store,
trans,
init,
niter,
a,
irow,
icol,
check,
b,
diag, 'n',
n, 'nz',
nz)
[
x,
diag,
ifail] = nag_sparse_complex_gen_precon_jacobi(
store,
trans,
init,
niter,
a,
irow,
icol,
check,
b,
diag, 'n',
n, 'nz',
nz)
Description
nag_sparse_complex_gen_precon_jacobi (f11dx) computes the
approximate solution of the complex 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_complex_gen_precon_jacobi (f11dx) can be used both for non-Hermitian and Hermitian systems of equations. For Hermitian 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_complex_gen_precon_jacobi (f11dx) will be used as a preconditioner for the iterative solution of complex sparse systems of equations, using either the suite comprising the functions
nag_sparse_complex_herm_basic_setup (f11gr),
nag_sparse_complex_herm_basic_solver (f11gs) and
nag_sparse_complex_herm_basic_diag (f11gt), for Hermitian systems, or the suite comprising the functions
nag_sparse_complex_gen_basic_setup (f11br),
nag_sparse_complex_gen_basic_solver (f11bs) and
nag_sparse_complex_gen_basic_diag (f11bt), for non-Hermitian systems of equations.
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
Parameters
Compulsory Input Parameters
- 1:
– string (length ≥ 1)
-
Specifies whether the matrix
is stored using symmetric coordinate storage (SCS) (applicable only to a Hermitian matrix
) or coordinate storage (CS) (applicable to both Hermitian and non-Hermitian matrices).
- The complete matrix is stored in CS format.
- The lower triangle of the Hermitian matrix is stored in SCS format.
Constraint:
or .
- 2:
– string (length ≥ 1)
Suggested value:
if the matrix is Hermitian and stored in CS format, it is recommended that for reasons of efficiency.
If
, specifies whether the approximate solution of
or of
is required.
- The approximate solution of is calculated.
- The approximate solution of is calculated.
Constraint:
or .
- 3:
– string (length ≥ 1)
Suggested value:
on first entry;
, subsequently, unless
diag has been overwritten.
On first entry,
init should be set to 'I', unless the diagonal elements of
are already stored in the array
diag. If
diag already contains the diagonal of
, it must be set to 'N'.
- diag must contain the diagonal of .
- diag will store the diagonal of on exit.
Constraint:
or .
- 4:
– int64int32nag_int scalar
-
The number of Jacobi iterations requested.
Constraint:
.
- 5:
– complex array
-
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_complex_gen_sort (f11zn) or
nag_sparse_complex_herm_sort (f11zp) may be used to reorder the elements in this way for CS and SCS storage, respectively.
- 6:
– int64int32nag_int array
- 7:
– int64int32nag_int array
-
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 .
- 8:
– string (length ≥ 1)
-
Specifies whether or not the CS or SCS representation of the matrix
should be checked.
- Checks are carried out on the values of n, nz, irow, icol; if , diag is also checked.
- None of these checks are carried out.
Constraint:
or .
- 9:
– complex array
-
The right-hand side vector .
- 10:
– complex array
-
If , the diagonal elements of .
Optional Input Parameters
- 1:
– int64int32nag_int scalar
-
Default:
the dimension of the arrays
b,
diag. (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.)
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 , .
Output Parameters
- 1:
– complex array
-
The approximate solution vector .
- 2:
– complex array
-
If
, unchanged on exit.
If , the diagonal elements of .
- 3:
– 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 , |
or | . |
-
-
On entry, | , |
or | , |
or | , if , |
or | , if . |
-
-
On entry, the arrays
irow and
icol fail to satisfy the following constraints:
- and
- if then , or
- if then , for .
- or and , for .
Therefore a nonzero element has been supplied which does not lie within the matrix
, is out of order, or has duplicate row and column indices. Call either
nag_sparse_real_gen_sort (f11za) or
nag_sparse_real_symm_sort (f11zb) to reorder and sum or remove duplicates when
or
, respectively.
-
-
On entry,
and some diagonal elements of
stored in
diag are zero.
-
-
On entry, and some diagonal elements of are zero.
-
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
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.
Further Comments
Timing
The time taken for a call to nag_sparse_complex_gen_precon_jacobi (f11dx) is proportional to .
Use of check
It is expected that a common use of nag_sparse_complex_gen_precon_jacobi (f11dx) will be as preconditioner for the iterative solution of complex, Hermitian or non-Hermitian, linear systems. In this situation, nag_sparse_complex_gen_precon_jacobi (f11dx) 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.
Example
This example solves the complex sparse non-Hermitian system of equations iteratively using nag_sparse_complex_gen_precon_jacobi (f11dx) as a preconditioner.
Open in the MATLAB editor:
f11dx_example
function f11dx_example
fprintf('f11dx example results\n\n');
nz = int64(24);
n = int64(8);
a = [ 2 + 1i, -1 + 1i, 1 - 3i, 4 + 7i, -3 + 0i, 2 + 4i, ...
-7 - 5i, 2 + 1i, 3 + 2i, -4 + 2i, 0 + 1i, 5 - 3i, ...
-1 + 2i, 8 + 6i, -3 - 4i, -6 - 2i, 5 - 2i, 2 + 0i, ...
0 - 5i, -1 + 5i, 6 + 2i, -1 + 4i, 2 + 0i, 3 + 3i];
b = [ 7 + 11i;
1 + 24i;
-13 - 18i;
-10 + 3i;
23 + 14i;
17 - 7i;
15 - 3i;
-3 + 20i];
irow = int64(...
[1; 1; 1; 2; 2; 2; 3; 3; 4; 4; 4; 4;
5; 5; 5; 6; 6; 6; 7; 7; 7; 8; 8; 8]);
icol = int64(...
[1; 4; 8; 1; 2; 5; 3; 6; 1; 3; 4; 7;
2; 5; 7; 1; 3; 6; 3; 5; 7; 2; 6; 8]);
b = [ 7 + 11i;
1 + 24i;
-13 - 18i;
-10 + 3i;
23 + 14i;
17 - 7i;
15 - 3i;
-3 + 20i];
method = 'TFQMR';
precon = 'p';
m = int64(2);
tol = 1e-6;
maxitn = int64(20);
anorm = 0;
sigmax = 0;
monit = int64(1);
lwork = int64(300);
[lwreq, work, ifail] = f11br( ...
method, precon, n, m, tol, maxitn, anorm, ...
sigmax, monit, lwork, 'norm_p', '1');
irevcm = int64(0);
x = complex(zeros(n, 1));
wgt= zeros(n, 1);
store = 'Non Hermitian';
trans = 'N';
init = 'I';
niter = int64(2);
check = 'Check';
diag = complex(zeros(n, 1));
while (irevcm ~= 4)
[irevcm, x, b, work, ifail] = f11bs( ...
irevcm, x, b, wgt, work);
if (irevcm == -1)
[b, ifail] = f11xn('T', a, irow, icol, 'N', x);
elseif (irevcm == 1)
[b, ifail] = f11xn('N', a, irow, icol, 'N', x);
elseif (irevcm == 2)
[b, diag, ifail] = f11dx( ...
store, trans, init, niter, ...
a, irow, icol, check, x, diag);
elseif (irevcm == 3)
[itn, stplhs, stprhs, anorm, sigmax, work, ifail] = ...
f11bt(work);
fprintf('\nMonitoring at iteration number %d\n', itn);
fprintf('residual norm: %14.4e\n', stplhs);
end
end
[itn, stplhs, stprhs, anorm, sigmax, work, ifail] = ...
f11bt(work);
fprintf('\nNumber of iterations for convergence: %d\n', itn);
fprintf('Residual norm: %14.4e\n', stplhs);
fprintf('Right-hand side of termination criteria: %14.4e\n', stprhs);
fprintf('i-norm of matrix a: %14.4e\n', anorm);
fprintf('\n Solution Vector\n');
disp(x);
fprintf('\n Residual Vector\n');
disp(b);
f11dx example results
Monitoring at iteration number 1
residual norm: 1.5062e+02
Monitoring at iteration number 2
residual norm: 1.5704e+02
Monitoring at iteration number 3
residual norm: 1.4803e+02
Monitoring at iteration number 4
residual norm: 8.5215e+01
Monitoring at iteration number 5
residual norm: 4.2951e+01
Monitoring at iteration number 6
residual norm: 2.5055e+01
Monitoring at iteration number 7
residual norm: 1.9090e-01
Number of iterations for convergence: 8
Residual norm: 9.5485e-08
Right-hand side of termination criteria: 8.9100e-04
i-norm of matrix a: 2.7000e+01
Solution Vector
1.0000 + 1.0000i
2.0000 - 1.0000i
3.0000 + 1.0000i
4.0000 - 1.0000i
3.0000 - 1.0000i
2.0000 + 1.0000i
1.0000 - 1.0000i
0.0000 + 3.0000i
Residual Vector
1.0e-07 *
0.0471 - 0.0394i
0.0877 - 0.0981i
-0.0287 + 0.0416i
0.0358 - 0.1112i
-0.0692 - 0.0869i
-0.0225 + 0.0849i
0.0052 - 0.0334i
-0.0558 - 0.1073i
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015