nag_sparse_real_symm_precon_ichol_solve (f11jb) solves a system of linear equations involving the incomplete Cholesky preconditioning matrix generated by
nag_sparse_real_symm_precon_ichol (f11ja).
nag_sparse_real_symm_precon_ichol_solve (f11jb) solves a system of linear equations
involving the preconditioning matrix
, corresponding to an incomplete Cholesky decomposition of a sparse symmetric matrix stored in symmetric coordinate storage (SCS) format (see
Symmetric coordinate storage (SCS) format in the F11 Chapter Introduction), as generated by
nag_sparse_real_symm_precon_ichol (f11ja).
In the above decomposition
is a lower triangular sparse matrix with unit diagonal,
is a diagonal matrix and
is a permutation matrix.
and
are supplied to
nag_sparse_real_symm_precon_ichol_solve (f11jb) through the matrix
which is a lower triangular
n by
n sparse matrix, stored in SCS format, as returned by
nag_sparse_real_symm_precon_ichol (f11ja). The permutation matrix
is returned from
nag_sparse_real_symm_precon_ichol (f11ja) via the array
ipiv.
It is envisaged that a common use of
nag_sparse_real_symm_precon_ichol_solve (f11jb) will be to carry out the preconditioning step required in the application of
nag_sparse_real_symm_basic_solver (f11ge) to sparse symmetric linear systems.
nag_sparse_real_symm_precon_ichol_solve (f11jb) is used for this purpose by the Black Box function
nag_sparse_real_symm_solve_ichol (f11jc).
nag_sparse_real_symm_precon_ichol_solve (f11jb) may also be used in combination with
nag_sparse_real_symm_precon_ichol (f11ja) to solve a sparse symmetric positive definite system of linear equations directly (see
Direct Solution of Systems in
nag_sparse_real_symm_precon_ichol (f11ja)). This use of
nag_sparse_real_symm_precon_ichol_solve (f11jb) is demonstrated in
Example.
None.
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.
The time taken for a call to
nag_sparse_real_symm_precon_ichol_solve (f11jb) is proportional to the value of
nnzc returned from
nag_sparse_real_symm_precon_ichol (f11ja).
It is expected that a common use of
nag_sparse_real_symm_precon_ichol_solve (f11jb) will be to carry out the preconditioning step required in the application of
nag_sparse_real_symm_basic_solver (f11ge) to sparse symmetric linear systems. In this situation
nag_sparse_real_symm_precon_ichol_solve (f11jb) 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 to set
for all subsequent calls.
This example reads in a symmetric positive definite sparse matrix
and a vector
. It then calls
nag_sparse_real_symm_precon_ichol (f11ja), with
and
, to compute the
complete Cholesky decomposition of
:
Then it calls
nag_sparse_real_symm_precon_ichol_solve (f11jb) to solve the system
It then repeats the exercise for the same matrix permuted with the bandwidth-reducing Reverse Cuthill–McKee permutation, calculated with
nag_sparse_sym_rcm (f11ye).
function f11jb_example
fprintf('f11jb example results\n\n');
n = int64(9);
nz = int64(23);
a = zeros(3*nz,1);
irow = zeros(3*nz,1,'int64');
icol = irow;
a(1:nz) = [ 4 -1 6 1 2 3 2 4 ...
1 2 6 -4 1 -1 6 -1 ...
-1 3 1 1 -1 1 4 ];
irow(1:nz) = [ 1 2 2 3 3 4 5 5 ...
6 6 6 7 7 7 7 8 ...
8 8 9 9 9 9 9 ];
icol(1:nz) = [ 1 1 2 2 3 4 1 5 ...
3 4 6 2 5 6 7 4 ...
6 8 1 5 6 8 9 ];
b = [4.10 -2.94 1.41 ...
2.53 4.35 1.29 ...
5.01 0.52 4.57];
lfill = int64(-1);
dtol = 0;
mic = 'N';
dscale = 0;
ipiv = zeros(n, 1, 'int64');
[a, irow, icol, ipiv, istr, nnzc, npivm, ifail] = ...
f11ja(...
nz, a, irow, icol, lfill, dtol, mic, dscale, ipiv);
[x, ifail] = f11jb(...
a, irow, icol, ipiv, istr, 'C', b);
fprintf('\n Solution of linear System\n');
fprintf('%16.4f\n', x);
[irow,icol,a,perm_fwd,perm_inv] = do_rcm(n,nz,irow,icol,a);
[a, irow, icol, ipiv, istr, nnzc, npivm, ifail] = ...
f11ja(...
nz, a, irow, icol, lfill, dtol, mic, dscale, ipiv);
y = b(perm_fwd(:));
[u, ifail] = f11jb(...
a, irow, icol, ipiv, istr, 'C', y);
x = u(perm_inv(:));
fprintf('\n Solution of linear System with reverse Cuthill-McKee\n');
fprintf('%16.4f\n', x);
function [irow_out,icol_out,a_out,perm_fwd,perm_inv] = ...
do_rcm(n,nz,irow,icol,a)
irow(nz+1:2*nz) = icol(1:nz);
icol(nz+1:2*nz) = irow(1:nz);
a(nz+1:2*nz) = a(1:nz);
nnz = nz + nz;
[nnz,a,icol,irow,istr,ifail] = f11za(n,nnz,a,icol,irow,'R','F');
lopts(1:5) = [false false true true true];
mask = zeros(n,1,'int64');
[perm_fwd, info, ifail] = f11ye(istr, irow, lopts, mask,'n',n);
perm_inv(perm_fwd(1:n)) = [1:n];
icol(1:nnz) = perm_inv(icol(1:nnz));
irow(1:nnz) = perm_inv(irow(1:nnz));
j = 0;
for i=1:nnz
if icol(i)<=irow(i)
j = j + 1;
a(j) = a(i);
irow(j) = irow(i);
icol(j) = icol(i);
end
end
nnz = int64(j);
[nnz, a, irow, icol, istr, ifail] = ...
f11zb(...
n, nnz, a, irow, icol, 'S', 'K');
a_out = zeros(3*nz,1);
irow_out = zeros(3*nz,1,'int64');
icol_out = irow_out;
a_out(1:nnz) = a(1:nnz);
irow_out(1:nnz) = irow(1:nnz);
icol_out(1:nnz) = icol(1:nnz);