Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

Chapter Contents
Chapter Introduction
NAG Toolbox

# NAG Toolbox: nag_sparse_real_symm_precon_ichol_solve (f11jb)

## Purpose

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).

## Syntax

[x, ifail] = f11jb(a, irow, icol, ipiv, istr, check, y, 'n', n, 'la', la)
[x, ifail] = nag_sparse_real_symm_precon_ichol_solve(a, irow, icol, ipiv, istr, check, y, 'n', n, 'la', la)

## Description

nag_sparse_real_symm_precon_ichol_solve (f11jb) solves a system of linear equations
 Mx = y $Mx=y$
involving the preconditioning matrix M = PLDLTPT$M=PLD{L}^{\mathrm{T}}{P}^{\mathrm{T}}$, corresponding to an incomplete Cholesky decomposition of a sparse symmetric matrix stored in symmetric coordinate storage (SCS) format (see Section [Symmetric coordinate storage (SCS) format] in the F11 Chapter Introduction), as generated by nag_sparse_real_symm_precon_ichol (f11ja).
In the above decomposition L$L$ is a lower triangular sparse matrix with unit diagonal, D$D$ is a diagonal matrix and P$P$ is a permutation matrix. L$L$ and D$D$ are supplied to nag_sparse_real_symm_precon_ichol_solve (f11jb) through the matrix
 C = L + D − 1 − I $C=L+D-1-I$
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 P$P$ 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 Section [Direct Solution of Systems] in (f11ja)). This use of nag_sparse_real_symm_precon_ichol_solve (f11jb) is demonstrated in Section [Example].

None.

## Parameters

### Compulsory Input Parameters

1:     a(la) – double array
The values returned in the array a by a previous call to nag_sparse_real_symm_precon_ichol (f11ja).
2:     irow(la) – int64int32nag_int array
3:     icol(la) – int64int32nag_int array
4:     ipiv(n) – int64int32nag_int array
5:     istr(n + 1${\mathbf{n}}+1$) – int64int32nag_int array
The values returned in arrays irow, icol, ipiv and istr by a previous call to nag_sparse_real_symm_precon_ichol (f11ja).
6:     check – string (length ≥ 1)
Specifies whether or not the input data should be checked.
check = 'C'${\mathbf{check}}=\text{'C'}$
Checks are carried out on the values of n, irow, icol, ipiv and istr.
check = 'N'${\mathbf{check}}=\text{'N'}$
No checks are carried out.
Constraint: check = 'C'${\mathbf{check}}=\text{'C'}$ or 'N'$\text{'N'}$.
7:     y(n) – double array
n, the dimension of the array, must satisfy the constraint n1${\mathbf{n}}\ge 1$.
The right-hand side vector y$y$.

### Optional Input Parameters

1:     n – int64int32nag_int scalar
Default: The dimension of the arrays ipiv, y. (An error is raised if these dimensions are not equal.)
n$n$, the order of the matrix M$M$. This must be the same value as was supplied in the preceding call to nag_sparse_real_symm_precon_ichol (f11ja).
Constraint: n1${\mathbf{n}}\ge 1$.
2:     la – int64int32nag_int scalar
Default: The dimension of the arrays a, irow, icol. (An error is raised if these dimensions are not equal.)
The dimension of the arrays a, irow and icol as declared in the (sub)program from which nag_sparse_real_symm_precon_ichol_solve (f11jb) is called. This must be the same value returned by the preceding call to nag_sparse_real_symm_precon_ichol (f11ja).

None.

### Output Parameters

1:     x(n) – double array
The solution vector x$x$.
2:     ifail – int64int32nag_int scalar
${\mathrm{ifail}}={\mathbf{0}}$ unless the function detects an error (see [Error Indicators and Warnings]).

## Error Indicators and Warnings

Errors or warnings detected by the function:
ifail = 1${\mathbf{ifail}}=1$
 On entry, check ≠ 'C'${\mathbf{check}}\ne \text{'C'}$ or 'N'$\text{'N'}$.
ifail = 2${\mathbf{ifail}}=2$
 On entry, n < 1${\mathbf{n}}<1$.
ifail = 3${\mathbf{ifail}}=3$
On entry, the SCS representation of the preconditioning matrix M$M$ is invalid. Further details are given in the error message. Check that the call to nag_sparse_real_symm_precon_ichol_solve (f11jb) has been preceded by a valid call to nag_sparse_real_symm_precon_ichol (f11ja) and that the arrays a, irow, icol, ipiv and istr have not been corrupted between the two calls.

## Accuracy

The computed solution x$x$ is the exact solution of a perturbed system of equations (M + δM)x = y$\left(M+\delta M\right)x=y$, where
 |δM| ≤ c(n)εP|L||D||LT|PT, $|δM|≤c(n)εP|L||D||LT|PT,$
c(n)$c\left(n\right)$ is a modest linear function of n$n$, and ε$\epsilon$ is the machine precision.

### Timing

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).

### Use of check

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 M$M$. In the interests of both reliability and efficiency, you are recommended to set check = 'C'${\mathbf{check}}=\text{'C'}$ for the first of such calls, and to set check = 'N'${\mathbf{check}}=\text{'N'}$ for all subsequent calls.

## Example

```function nag_sparse_real_symm_precon_ichol_solve_example
nz = int64(23);
a = zeros(3*nz, 1);
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 = zeros(3*nz, 1, 'int64');
irow(1:nz) = [int64(1); 2; 2; 3; 3; 4; 5; 5; 6; 6; 6; 7; 7; 7; 7; 8; ...
8; 8; 9; 9; 9; 9; 9];
icol = zeros(3*nz, 1, 'int64');
icol(1:nz) = [int64(1); 1; 2; 2; 3; 4; 1; 5; 3; 4; 6; 2; 5; 6; 7; 4; ...
6; 8; 1; 5; 6; 8; 9];
ipiv = zeros(9, 1, 'int64');
lfill = int64(-1);
dtol = 0;
mic = 'N';
dscale = 0;
pstrat = 'M';
check = 'C';
y = [4.1; -2.94; 1.41; 2.53; 4.35; 1.29; 5.01; 0.52; 4.57];
% Calculate incomplete Cholesky factorization
[a, irow, icol, ipiv, istr, nnzc, npivm, ifail] = ...
nag_sparse_real_symm_precon_ichol(nz, a, irow, icol, lfill, dtol, mic, ...
dscale, ipiv);

if npivm ~= 0
fprintf('\nFactorization is not complete.\n');
else
% Solve P L D L^T P^T x = y
[x, ifail] = nag_sparse_real_symm_precon_ichol_solve(a, irow, icol, ipiv, ...
istr, check, y);

fprintf('\nSolution of linear system:\n');
disp(x);
end
```
```

Solution of linear system:
0.7000
0.1600
0.5200
0.7700
0.2800
0.2100
0.9300
0.2000
0.9000

```
```function f11jb_example
nz = int64(23);
a = zeros(3*nz, 1);
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 = zeros(3*nz, 1, 'int64');
irow(1:nz) = [int64(1); 2; 2; 3; 3; 4; 5; 5; 6; 6; 6; 7; 7; 7; 7; 8; ...
8; 8; 9; 9; 9; 9; 9];
icol = zeros(3*nz, 1, 'int64');
icol(1:nz) = [int64(1); 1; 2; 2; 3; 4; 1; 5; 3; 4; 6; 2; 5; 6; 7; 4; ...
6; 8; 1; 5; 6; 8; 9];
ipiv = zeros(9, 1, 'int64');
lfill = int64(-1);
dtol = 0;
mic = 'N';
dscale = 0;
pstrat = 'M';
check = 'C';
y = [4.1; -2.94; 1.41; 2.53; 4.35; 1.29; 5.01; 0.52; 4.57];
% Calculate incomplete Cholesky factorization
[a, irow, icol, ipiv, istr, nnzc, npivm, ifail] = ...
f11ja(nz, a, irow, icol, lfill, dtol, mic, dscale, ipiv);

if npivm ~= 0
fprintf('\nFactorization is not complete.\n');
else
% Solve P L D L^T P^T x = y
[x, ifail] = f11jb(a, irow, icol, ipiv, istr, check, y);

fprintf('\nSolution of linear system:\n');
disp(x);
end
```
```

Solution of linear system:
0.7000
0.1600
0.5200
0.7700
0.2800
0.2100
0.9300
0.2000
0.9000

```