PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_sparse_real_gen_precon_ssor_solve (f11dd)
Purpose
nag_sparse_real_gen_precon_ssor_solve (f11dd) solves a system of linear equations involving the preconditioning matrix corresponding to SSOR applied to a real sparse nonsymmetric matrix, represented in coordinate storage format.
Syntax
[
x,
ifail] = f11dd(
trans,
a,
irow,
icol,
rdiag,
omega,
check,
y, 'n',
n, 'nz',
nz)
[
x,
ifail] = nag_sparse_real_gen_precon_ssor_solve(
trans,
a,
irow,
icol,
rdiag,
omega,
check,
y, 'n',
n, 'nz',
nz)
Description
nag_sparse_real_gen_precon_ssor_solve (f11dd) solves a system of linear equations
according to the value of the argument
trans, where the matrix
corresponds to symmetric successive-over-relaxation (SSOR) (see
Young (1971)) applied to a linear system
, where
is a real sparse nonsymmetric matrix stored in coordinate storage (CS) format (see
Coordinate storage (CS) format in the F11 Chapter Introduction).
In the definition of given above is the diagonal part of , is the strictly lower triangular part of , is the strictly upper triangular part of , and is a user-defined relaxation parameter.
It is envisaged that a common use of
nag_sparse_real_gen_precon_ssor_solve (f11dd) will be to carry out the preconditioning step required in the application of
nag_sparse_real_gen_basic_solver (f11be) to sparse linear systems. For an illustration of this use of
nag_sparse_real_gen_precon_ssor_solve (f11dd) see the example program given in
Example.
nag_sparse_real_gen_precon_ssor_solve (f11dd) is also used for this purpose by the Black Box function
nag_sparse_real_gen_solve_jacssor (f11de).
References
Young D (1971) Iterative Solution of Large Linear Systems Academic Press, New York
Parameters
Compulsory Input Parameters
- 1:
– string (length ≥ 1)
-
Specifies whether or not the matrix
is transposed.
- is solved.
- is solved.
Constraint:
or .
- 2:
– double array
-
The nonzero elements in 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_gen_sort (f11za) may be used to order the elements in this way.
- 3:
– int64int32nag_int array
- 4:
– int64int32nag_int array
-
The row and column indices of the nonzero elements supplied in array
a.
Constraints:
irow and
icol must satisfy the following constraints (which may be imposed by a call to
nag_sparse_real_gen_sort (f11za)):
- and , for ;
- either or both and , for .
- 5:
– double array
-
The elements of the diagonal matrix , where is the diagonal part of .
- 6:
– double scalar
-
The relaxation parameter .
Constraint:
.
- 7:
– string (length ≥ 1)
-
Specifies whether or not the CS representation of the matrix
should be checked.
- Checks are carried on the values of n, nz, irow, icol and omega.
- None of these checks are carried out.
Constraint:
or .
- 8:
– double array
-
The right-hand side vector .
Optional Input Parameters
- 1:
– int64int32nag_int scalar
-
Default:
the dimension of the arrays
rdiag,
y. (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 matrix .
Constraint:
.
Output Parameters
- 1:
– double array
-
The solution vector .
- 2:
– 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 . |
-
-
On entry, | , |
or | , |
or | , |
or | omega lies outside the interval , |
-
-
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 matrix
, is out of order, or has duplicate row and column indices. Call
nag_sparse_real_gen_sort (f11za) to reorder and sum or remove duplicates.
-
-
On entry, the matrix has a zero diagonal element. The SSOR preconditioner is not appropriate for this problem.
-
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
If
the computed solution
is the exact solution of a perturbed system of equations
, where
is a modest linear function of
, and
is the
machine precision. An equivalent result holds when
.
Further Comments
Timing
The time taken for a call to
nag_sparse_real_gen_precon_ssor_solve (f11dd) is proportional to
nz.
Use of check
It is expected that a common use of
nag_sparse_real_gen_precon_ssor_solve (f11dd) will be to carry out the preconditioning step required in the application of
nag_sparse_real_gen_basic_solver (f11be) to sparse linear systems. In this situation
nag_sparse_real_gen_precon_ssor_solve (f11dd) is likely to be called many times with the same matrix
. In the interests of both reliability and efficiency, you are recommended to set
for the first of such calls, and for all subsequent calls set
.
Example
This example solves a sparse linear system of equations:
using RGMRES with SSOR preconditioning.
The RGMRES algorithm itself is implemented by the reverse communication function
nag_sparse_real_gen_basic_solver (f11be), which returns repeatedly to the calling program with various values of the argument
irevcm. This argument indicates the action to be taken by the calling program.
- If , a matrix-vector product is required. This is implemented by a call to nag_sparse_real_gen_matvec (f11xa).
- If , a transposed matrix-vector product is required in the estimation of the norm of . This is implemented by a call to nag_sparse_real_gen_matvec (f11xa).
- If , a solution of the preconditioning equation is required. This is achieved by a call to nag_sparse_real_gen_precon_ssor_solve (f11dd).
- If , nag_sparse_real_gen_basic_solver (f11be) has completed its tasks. Either the iteration has terminated, or an error condition has arisen.
For further details see the function document for
nag_sparse_real_gen_basic_solver (f11be).
Open in the MATLAB editor:
f11dd_example
function f11dd_example
fprintf('f11dd example results\n\n');
n = int64(5);
m = int64(2);
nz = int64(16);
a = zeros(3*nz, 1);
irow = zeros(3*nz, 1, 'int64');
icol = irow;
a(1:nz) = [2; 1;-1;-3;-2; 1; 1; 5; 3; 1;-2;-3;-1; 4;-2;-6];
irow(1:nz) = [1; 1; 1; 2; 2; 2; 3; 3; 3; 3; 4; 4; 4; 5; 5; 5];
icol(1:nz) = [1; 2; 4; 2; 3; 5; 1; 3; 4; 5; 1; 4; 5; 2; 3; 5];
method = 'rgmres';
precon = 'P';
tol = 1e-10;
maxitn = int64(1000);
anorm = 0;
sigmax = 0;
monit = int64(0);
lwork = max([n*(m+3)+m*(m+5)+101,7*n+100,(2*n+m)*(m+2)+n+100,10*n+100]);
[lwreq, work, ifail] = ...
f11bd( ...
method, precon, n, m, tol, maxitn, anorm, sigmax, monit, lwork, ...
'norm_p', 'I');
b = [0; -7; 33; -19; -28];
x = zeros(n, 1);
rdiag = zeros(n, 1);
if strcmpi(precon, 'P')
dcount = zeros(n, 1, 'int64');
for i = 1:nz
if irow(i) == icol(i)
dcount(irow(i)) = dcount(irow(i)) + 1;
if a(i) ~= 0
rdiag(irow(i)) = 1/a(i);
else
error('Matrix has a zero diagonal element');
end
end
end
for i = 1:n
if dcount(i) == 0
error('Matrix has a missing diagonal element');
elseif dcount(i) >= 2
error('Matrix has a multiple diagonal element');
end
end
end
trans = 'N';
omega = 1.1;
ckddf = 'C';
irevcm = int64(0);
wgt = zeros(n, 1);
ckxaf = 'C';
while irevcm ~= 4
[irevcm, x, b, work, ifail] = f11be( ...
irevcm, x, b, wgt, work);
if (irevcm == -1)
[b, ifail] = f11xa( ...
'T', a(1:nz), irow(1:nz), icol(1:nz), ckxaf, x);
ckxaf = 'N';
elseif (irevcm == 1)
[b, ifail] = f11xa( ...
'N', a(1:nz), irow(1:nz), icol(1:nz), ckxaf, x);
ckxaf = 'N';
elseif (irevcm == 2)
[b, ifail] = f11dd( ...
trans, a(1:nz), irow(1:nz), icol(1:nz), rdiag,...
omega, ckddf, x);
ckddf = 'N';
end
end
[itn, stplhs, stprhs, anorm, sigmax, ifail] = ...
f11bf(work);
fprintf('\nConverged in %d iterations\n', itn);
fprintf('Matrix norm = %16.3e\n', anorm);
fprintf('Final residual norm = %16.3e\n\n', stplhs);
disp('Solution');
disp(x);
f11dd example results
Converged in 12 iterations
Matrix norm = 1.200e+01
Final residual norm = 3.841e-09
Solution
1.0000
2.0000
3.0000
4.0000
5.0000
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015