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

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

# NAG Toolbox: nag_sparse_real_gen_precon_ilu_solve (f11db)

## Purpose

nag_sparse_real_gen_precon_ilu_solve (f11db) solves a system of linear equations involving the incomplete LU$LU$ preconditioning matrix generated by nag_sparse_real_gen_precon_ilu (f11da).

## Syntax

[x, ifail] = f11db(trans, a, irow, icol, ipivp, ipivq, istr, idiag, check, y, 'n', n, 'la', la)
[x, ifail] = nag_sparse_real_gen_precon_ilu_solve(trans, a, irow, icol, ipivp, ipivq, istr, idiag, check, y, 'n', n, 'la', la)

## Description

nag_sparse_real_gen_precon_ilu_solve (f11db) solves a system of linear equations
 Mx = y, or MTx = y,
$Mx=y, or MTx=y,$
according to the value of the parameter trans, where the matrix M = PLDUQ$M=PLDUQ$, corresponds to an incomplete LU$LU$ decomposition of a sparse matrix stored in coordinate storage (CS) format (see Section [Coordinate storage (CS) format] in the F11 Chapter Introduction), as generated by nag_sparse_real_gen_precon_ilu (f11da).
In the above decomposition L$L$ is a lower triangular sparse matrix with unit diagonal elements, D$D$ is a diagonal matrix, U$U$ is an upper triangular sparse matrix with unit diagonal elements and, P$P$ and Q$Q$ are permutation matrices. L$L$, D$D$ and U$U$ are supplied to nag_sparse_real_gen_precon_ilu_solve (f11db) through the matrix
 C = L + D − 1 + U − 2I $C=L+D-1+U-2I$
which is an n by n sparse matrix, stored in CS format, as returned by nag_sparse_real_gen_precon_ilu (f11da). The permutation matrices P$P$ and Q$Q$ are returned from nag_sparse_real_gen_precon_ilu (f11da) via the arrays ipivp and ipivq.
It is envisaged that a common use of nag_sparse_real_gen_precon_ilu_solve (f11db) will be to carry out the preconditioning step required in the application of nag_sparse_real_gen_basic_solver (f11be) to sparse linear systems. nag_sparse_real_gen_precon_ilu_solve (f11db) is used for this purpose by the Black Box function nag_sparse_real_gen_solve_ilu (f11dc).
nag_sparse_real_gen_precon_ilu_solve (f11db) may also be used in combination with nag_sparse_real_gen_precon_ilu (f11da) to solve a sparse system of linear equations directly (see Section [Direct Solution of Sparse Linear Systems] in (f11da)). This use of nag_sparse_real_gen_precon_ilu_solve (f11db) is demonstrated in Section [Example].

None.

## Parameters

### Compulsory Input Parameters

1:     trans – string (length ≥ 1)
Specifies whether or not the matrix M$M$ is transposed.
trans = 'N'${\mathbf{trans}}=\text{'N'}$
Mx = y$Mx=y$ is solved.
trans = 'T'${\mathbf{trans}}=\text{'T'}$
MTx = y${M}^{\mathrm{T}}x=y$ is solved.
Constraint: trans = 'N'${\mathbf{trans}}=\text{'N'}$ or 'T'$\text{'T'}$.
2:     a(la) – double array
The values returned in the array a by a previous call to nag_sparse_real_gen_precon_ilu (f11da).
3:     irow(la) – int64int32nag_int array
4:     icol(la) – int64int32nag_int array
5:     ipivp(n) – int64int32nag_int array
6:     ipivq(n) – int64int32nag_int array
7:     istr(n + 1${\mathbf{n}}+1$) – int64int32nag_int array
8:     idiag(n) – int64int32nag_int array
The values returned in arrays irow, icol, ipivp, ipivq, istr and idiag by a previous call to nag_sparse_real_gen_precon_ilu (f11da).
9:     check – string (length ≥ 1)
Specifies whether or not the CS representation of the matrix M$M$ should be checked.
check = 'C'${\mathbf{check}}=\text{'C'}$
Checks are carried on the values of n, irow, icol, ipivp, ipivq, istr and idiag.
check = 'N'${\mathbf{check}}=\text{'N'}$
None of these checks are carried out.
Constraint: check = 'C'${\mathbf{check}}=\text{'C'}$ or 'N'$\text{'N'}$.
10:   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 ipivp, ipivq, istr, idiag, 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_gen_precon_ilu (f11da).
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_gen_precon_ilu_solve (f11db) is called. This must be the same value returned by the preceding call to nag_sparse_real_gen_precon_ilu (f11da).

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, trans ≠ 'N'${\mathbf{trans}}\ne \text{'N'}$ or 'T'$\text{'T'}$, or 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 CS 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_gen_precon_ilu_solve (f11db) has been preceded by a valid call to nag_sparse_real_gen_precon_ilu (f11da) and that the arrays a, irow, icol, ipivp, ipivq, istr and idiag have not been corrupted between the two calls.

## Accuracy

If trans = 'N'${\mathbf{trans}}=\text{'N'}$ 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||U|Q, $|δM|≤c(n)εP|L||D||U|Q,$
c(n)$c\left(n\right)$ is a modest linear function of n$n$, and ε$\epsilon$ is the machine precision. An equivalent result holds when trans = 'T'${\mathbf{trans}}=\text{'T'}$.

### Timing

The time taken for a call to nag_sparse_real_gen_precon_ilu_solve (f11db) is proportional to the value of nnzc returned from nag_sparse_real_gen_precon_ilu (f11da).

### Use of check

It is expected that a common use of nag_sparse_real_gen_precon_ilu_solve (f11db) 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_ilu_solve (f11db) 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 for all subsequent calls set check = 'N'${\mathbf{check}}=\text{'N'}$.

## Example

function nag_sparse_real_gen_precon_ilu_solve_example
nz = int64(11);
a = zeros(2*nz, 1);
a(1:nz) = [1; 1; -1; 2; 2; 3; -2; 1; -2; 1; 1];
irow = zeros(2*nz, 1, 'int64');
irow(1:nz) = [1; 1; 2; 2; 2; 3; 3; 4; 4; 4; 4];
icol = zeros(2*nz, 1, 'int64');
icol(1:nz) = [2; 3; 1; 3; 4; 1; 4; 1; 2; 3; 4];
lfill = int64(-1);
dtol = 0;
pstrat = 'C';
milu = 'N';
ipivp = zeros(4, 1, 'int64');
ipivq = zeros(4, 1, 'int64');
check = 'C';
trans = 'N';
y = [5; 13; -5; 4];
% Calculate LU factorization
[a, irow, icol, ipivp, ipivq, istr, idiag, nnzc, npivm, ifail] = ...
nag_sparse_real_gen_precon_ilu(nz, a, irow, icol, lfill, dtol, milu, ...
ipivp, ipivq);

if npivm > 0
fprintf('\nFactorization is not complete.\n');
else
% Solve P L D U x = y
[x, ifail] = nag_sparse_real_gen_precon_ilu_solve(trans, a, irow, icol, ...
ipivp, ipivq, istr, idiag, check, y)
end

x =

1
2
3
4

ifail =

0

function f11db_example
nz = int64(11);
a = zeros(2*nz, 1);
a(1:nz) = [1; 1; -1; 2; 2; 3; -2; 1; -2; 1; 1];
irow = zeros(2*nz, 1, 'int64');
irow(1:nz) = [1; 1; 2; 2; 2; 3; 3; 4; 4; 4; 4];
icol = zeros(2*nz, 1, 'int64');
icol(1:nz) = [2; 3; 1; 3; 4; 1; 4; 1; 2; 3; 4];
lfill = int64(-1);
dtol = 0;
pstrat = 'C';
milu = 'N';
ipivp = zeros(4, 1, 'int64');
ipivq = zeros(4, 1, 'int64');
check = 'C';
trans = 'N';
y = [5; 13; -5; 4];
% Calculate LU factorization
[a, irow, icol, ipivp, ipivq, istr, idiag, nnzc, npivm, ifail] = ...
f11da(nz, a, irow, icol, lfill, dtol, milu, ipivp, ipivq);

if npivm > 0
fprintf('\nFactorization is not complete.\n');
else
% Solve P L D U x = y
[x, ifail] = f11db(trans, a, irow, icol, ipivp, ipivq, istr, idiag, check, y)
end

x =

1
2
3
4

ifail =

0

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2013