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_complex_herm_precon_ilu_solve (f11jp)

## Purpose

nag_sparse_complex_herm_precon_ilu_solve (f11jp) solves a system of complex linear equations involving the incomplete Cholesky preconditioning matrix generated by nag_sparse_complex_herm_precon_ilu (f11jn).

## Syntax

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

## Description

nag_sparse_complex_herm_precon_ilu_solve (f11jp) solves a system of linear equations
 Mx = y $Mx=y$
involving the preconditioning matrix M = PLDLHPT$M=PLD{L}^{\mathrm{H}}{P}^{\mathrm{T}}$, corresponding to an incomplete Cholesky decomposition of a complex sparse Hermitian 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_complex_herm_precon_ilu (f11jn).
In the above decomposition L$L$ is a complex lower triangular sparse matrix with unit diagonal, D$D$ is a real diagonal matrix and P$P$ is a permutation matrix. L$L$ and D$D$ are supplied to nag_sparse_complex_herm_precon_ilu_solve (f11jp) through the matrix
 C = L + D − 1 − I $C=L+D-1-I$
which is a lower triangular n$n$ by n$n$ complex sparse matrix, stored in SCS format, as returned by nag_sparse_complex_herm_precon_ilu (f11jn). The permutation matrix P$P$ is returned from nag_sparse_complex_herm_precon_ilu (f11jn) via the array ipiv.
nag_sparse_complex_herm_precon_ilu_solve (f11jp) may also be used in combination with nag_sparse_complex_herm_precon_ilu (f11jn) to solve a sparse complex Hermitian positive definite system of linear equations directly (see nag_sparse_complex_herm_precon_ilu (f11jn)). This is illustrated in Section [Example].

None.

## Parameters

### Compulsory Input Parameters

1:     a(la) – complex array
The values returned in the array a by a previous call to nag_sparse_complex_herm_precon_ilu (f11jn).
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_complex_herm_precon_ilu (f11jn).
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'}$
None of these checks are carried out.
Constraint: check = 'C'${\mathbf{check}}=\text{'C'}$ or 'N'$\text{'N'}$.
7:     y(n) – complex 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_complex_herm_precon_ilu (f11jn).
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_complex_herm_precon_ilu_solve (f11jp) is called. This must be the same value supplied in the preceding call to nag_sparse_complex_herm_precon_ilu (f11jn).

None.

### Output Parameters

1:     x(n) – complex 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_complex_herm_precon_ilu_solve (f11jp) has been preceded by a valid call to nag_sparse_complex_herm_precon_ilu (f11jn) 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||LH|PT, $|δM|≤c(n)εP|L||D||LH|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_complex_herm_precon_ilu_solve (f11jp) is proportional to the value of nnzc returned from nag_sparse_complex_herm_precon_ilu (f11jn).

## Example

```function nag_sparse_complex_herm_precon_ilu_solve_example
nz = int64(23);
a = zeros(3*nz, 1);
a(1:nz) = [6 + 0i; -1 + 1i; 6 + 0i; 0 + 1i; 5 + 0i; 5 + 0i; 2 - 2i; ...
4 + 0i; 1 + 1i; 2 + 0i; 6 + 0i; -4 + 3i; 0 + 1i; -1 + 0i; ...
6 + 0i; -1 - 1i; 0 - 1i; 9 + 0i; 1 + 3i; 1 + 2i; -1 + 0i; ...
1 + 4i; 9 + 0i];
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');
check = 'C';
y = [ 8 + 54i; -10 - 92i; 25 + 27i; 26 - 28i; 54 + 12i; ...
26 - 22i; 47 + 65i; 71 - 57i; 60 + 70i];
lfill = int64(-1);
dtol = 0;
mic = 'N';
dscale = 0;
pstrat = 'M';
[a, irow, icol, ipiv, istr, nnzc, npivm, ifail] = ...
nag_sparse_complex_herm_precon_ilu(nz, a, irow, icol, lfill, dtol, mic, ...
dscale, ipiv);

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

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

Solution of linear system:
1.0000 + 9.0000i
2.0000 - 8.0000i
3.0000 + 7.0000i
4.0000 - 6.0000i
5.0000 + 5.0000i
6.0000 - 4.0000i
7.0000 + 3.0000i
8.0000 - 2.0000i
9.0000 + 1.0000i

```
```function f11jp_example
nz = int64(23);
a = zeros(3*nz, 1);
a(1:nz) = [6 + 0i; -1 + 1i; 6 + 0i; 0 + 1i; 5 + 0i; 5 + 0i; 2 - 2i; ...
4 + 0i; 1 + 1i; 2 + 0i; 6 + 0i; -4 + 3i; 0 + 1i; -1 + 0i; ...
6 + 0i; -1 - 1i; 0 - 1i; 9 + 0i; 1 + 3i; 1 + 2i; -1 + 0i; ...
1 + 4i; 9 + 0i];
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');
check = 'C';
y = [ 8 + 54i; -10 - 92i; 25 + 27i; 26 - 28i; 54 + 12i; ...
26 - 22i; 47 + 65i; 71 - 57i; 60 + 70i];
lfill = int64(-1);
dtol = 0;
mic = 'N';
dscale = 0;
pstrat = 'M';
[a, irow, icol, ipiv, istr, nnzc, npivm, ifail] = ...
f11jn(nz, a, irow, icol, lfill, dtol, mic, dscale, ipiv);

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

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

Solution of linear system:
1.0000 + 9.0000i
2.0000 - 8.0000i
3.0000 + 7.0000i
4.0000 - 6.0000i
5.0000 + 5.0000i
6.0000 - 4.0000i
7.0000 + 3.0000i
8.0000 - 2.0000i
9.0000 + 1.0000i

```