hide long namesshow long names
hide short namesshow short names
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_solve_ilu (f11dc)

Purpose

nag_sparse_real_gen_solve_ilu (f11dc) solves a real sparse nonsymmetric system of linear equations, represented in coordinate storage format, using a restarted generalized minimal residual (RGMRES), conjugate gradient squared (CGS), stabilized bi-conjugate gradient (Bi-CGSTAB), or transpose-free quasi-minimal residual (TFQMR) method, with incomplete LULU preconditioning.

Syntax

[x, rnorm, itn, ifail] = f11dc(method, nnz, a, irow, icol, ipivp, ipivq, istr, idiag, b, m, tol, maxitn, x, 'n', n, 'la', la)
[x, rnorm, itn, ifail] = nag_sparse_real_gen_solve_ilu(method, nnz, a, irow, icol, ipivp, ipivq, istr, idiag, b, m, tol, maxitn, x, 'n', n, 'la', la)

Description

nag_sparse_real_gen_solve_ilu (f11dc) solves a real sparse nonsymmetric linear system of equations:
Ax = b,
Ax=b,
using a preconditioned RGMRES (see Saad and Schultz (1986)), CGS (see Sonneveld (1989)), Bi-CGSTAB() (see Van der Vorst (1989) and Sleijpen and Fokkema (1993)), or TFQMR (see Freund and Nachtigal (1991) and Freund (1993)) method.
nag_sparse_real_gen_solve_ilu (f11dc) uses the incomplete LULU factorization determined by nag_sparse_real_gen_precon_ilu (f11da) as the preconditioning matrix. A call to nag_sparse_real_gen_solve_ilu (f11dc) must always be preceded by a call to nag_sparse_real_gen_precon_ilu (f11da). Alternative preconditioners for the same storage scheme are available by calling nag_sparse_real_gen_solve_jacssor (f11de).
The matrix AA, and the preconditioning matrix MM, are represented in coordinate storage (CS) format (see Section [Coordinate storage (CS) format] in the F11 Chapter Introduction) in the arrays a, irow and icol, as returned from nag_sparse_real_gen_precon_ilu (f11da). The array a holds the nonzero entries in these matrices, while irow and icol hold the corresponding row and column indices.
nag_sparse_real_gen_solve_ilu (f11dc) is a Black Box function which calls nag_sparse_real_gen_basic_setup (f11bd), nag_sparse_real_gen_basic_solver (f11be) and nag_sparse_real_gen_basic_diag (f11bf). If you wish to use an alternative storage scheme, preconditioner, or termination criterion, or require additional diagnostic information, you should call these underlying functions directly.

References

Freund R W (1993) A transpose-free quasi-minimal residual algorithm for non-Hermitian linear systems SIAM J. Sci. Comput. 14 470–482
Freund R W and Nachtigal N (1991) QMR: a Quasi-Minimal Residual Method for Non-Hermitian Linear Systems Numer. Math. 60 315–339
Saad Y and Schultz M (1986) GMRES: a generalized minimal residual algorithm for solving nonsymmetric linear systems SIAM J. Sci. Statist. Comput. 7 856–869
Salvini S A and Shaw G J (1996) An evaluation of new NAG Library solvers for large sparse unsymmetric linear systems NAG Technical Report TR2/96
Sleijpen G L G and Fokkema D R (1993) BiCGSTAB()() for linear equations involving matrices with complex spectrum ETNA 1 11–32
Sonneveld P (1989) CGS, a fast Lanczos-type solver for nonsymmetric linear systems SIAM J. Sci. Statist. Comput. 10 36–52
Van der Vorst H (1989) Bi-CGSTAB, a fast and smoothly converging variant of Bi-CG for the solution of nonsymmetric linear systems SIAM J. Sci. Statist. Comput. 13 631–644

Parameters

Compulsory Input Parameters

1:     method – string
Specifies the iterative method to be used.
method = 'RGMRES'method='RGMRES'
Restarted generalized minimum residual method.
method = 'CGS'method='CGS'
Conjugate gradient squared method.
method = 'BICGSTAB'method='BICGSTAB'
Bi-conjugate gradient stabilized () method.
method = 'TFQMR'method='TFQMR'
Transpose-free quasi-minimal residual method.
Constraint: method = 'RGMRES'method='RGMRES', 'CGS''CGS', 'BICGSTAB''BICGSTAB' or 'TFQMR''TFQMR'.
2:     nnz – int64int32nag_int scalar
The number of nonzero elements in the matrix AA. This must be the same value as was supplied in the preceding call to nag_sparse_real_gen_precon_ilu (f11da).
Constraint: 1nnzn21nnzn2.
3:     a(la) – double array
la, the dimension of the array, must satisfy the constraint la2 × nnzla2×nnz.
The values returned in the array a by a previous call to nag_sparse_real_gen_precon_ilu (f11da).
4:     irow(la) – int64int32nag_int array
5:     icol(la) – int64int32nag_int array
6:     ipivp(n) – int64int32nag_int array
7:     ipivq(n) – int64int32nag_int array
8:     istr(n + 1n+1) – int64int32nag_int array
9:     idiag(n) – int64int32nag_int array
la, the dimension of the array, must satisfy the constraint la2 × nnzla2×nnz.
The values returned in arrays irow, icol, ipivp, ipivq, istr and idiag by a previous call to nag_sparse_real_gen_precon_ilu (f11da).
ipivp and ipivq are restored on exit.
10:   b(n) – double array
n, the dimension of the array, must satisfy the constraint n1n1.
The right-hand side vector bb.
11:   m – int64int32nag_int scalar
If method = 'RGMRES'method='RGMRES', m is the dimension of the restart subspace.
If method = 'BICGSTAB'method='BICGSTAB', m is the order  of the polynomial Bi-CGSTAB method; otherwise, m is not referenced.
Constraints:
  • if method = 'RGMRES'method='RGMRES', 0 < mmin (n,50)0<mmin(n,50);
  • if method = 'BICGSTAB'method='BICGSTAB', 0 < mmin (n,10)0<mmin(n,10).
12:   tol – double scalar
The required tolerance. Let xkxk denote the approximate solution at iteration kk, and rkrk the corresponding residual. The algorithm is considered to have converged at iteration kk if
rkτ × (b + Axk).
rkτ×(b+Axk).
If tol0.0tol0.0, τ = max (sqrt(ε),sqrt(n)ε)τ=max(ε,nε) is used, where εε is the machine precision. Otherwise τ = max (tol,10ε,sqrt(n)ε)τ=max(tol,10ε,nε) is used.
Constraint: tol < 1.0tol<1.0.
13:   maxitn – int64int32nag_int scalar
The maximum number of iterations allowed.
Constraint: maxitn1maxitn1.
14:   x(n) – double array
n, the dimension of the array, must satisfy the constraint n1n1.
An initial approximation to the solution vector xx.

Optional Input Parameters

1:     n – int64int32nag_int scalar
Default: The dimension of the arrays ipivp, ipivq, idiag, b, x. (An error is raised if these dimensions are not equal.)
nn, the order of the matrix AA. This must be the same value as was supplied in the preceding call to nag_sparse_real_gen_precon_ilu (f11da).
Constraint: n1n1.
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_solve_ilu (f11dc) is called. This must be the same value as was supplied in the preceding call to nag_sparse_real_gen_precon_ilu (f11da).
Constraint: la2 × nnzla2×nnz.

Input Parameters Omitted from the MATLAB Interface

work lwork

Output Parameters

1:     x(n) – double array
An improved approximation to the solution vector xx.
2:     rnorm – double scalar
The final value of the residual norm rkrk, where kk is the output value of itn.
3:     itn – int64int32nag_int scalar
The number of iterations carried out.
4:     ifail – int64int32nag_int scalar
ifail = 0ifail=0 unless the function detects an error (see [Error Indicators and Warnings]).

Error Indicators and Warnings

Errors or warnings detected by the function:

Cases prefixed with W are classified as warnings and do not generate an error of type NAG:error_n. See nag_issue_warnings.

  ifail = 1ifail=1
On entry,method'RGMRES','CGS','BICGSTAB'method'RGMRES','CGS','BICGSTAB', or 'TFQMR',
orn < 1n<1,
ornnz < 1nnz<1,
ornnz > n2nnz>n2,
orla < 2 × nnzla<2×nnz,
orm < 1m<1 and method = 'RGMRES'method='RGMRES' or method = 'BICGSTAB'method='BICGSTAB',
orm > min (n,50)m>min(n,50), with method = 'RGMRES'method='RGMRES',
orm > min (n,10)m>min(n,10), with method = 'BICGSTAB'method='BICGSTAB',
ortol1.0tol1.0,
ormaxitn < 1maxitn<1,
orlwork too small.
  ifail = 2ifail=2
On entry, the CS representation of AA is invalid. Further details are given in the error message. Check that the call to nag_sparse_real_gen_solve_ilu (f11dc) has been preceded by a valid call to nag_sparse_real_gen_precon_ilu (f11da), and that the arrays a, irow, and icol have not been corrupted between the two calls.
  ifail = 3ifail=3
On entry, the CS representation of the preconditioning matrix MM is invalid. Further details are given in the error message. Check that the call to nag_sparse_real_gen_solve_ilu (f11dc) 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.
W ifail = 4ifail=4
The required accuracy could not be obtained. However, a reasonable accuracy may have been obtained, and further iterations could not improve the result. You should check the output value of rnorm for acceptability. This error code usually implies that your problem has been fully and satisfactorily solved to within or close to the accuracy available on your system. Further iterations are unlikely to improve on this situation.
  ifail = 5ifail=5
Required accuracy not obtained in maxitn iterations.
  ifail = 6ifail=6
Algorithmic breakdown. A solution is returned, although it is possible that it is completely inaccurate.
  ifail = 7ifail=7 (nag_sparse_real_gen_basic_setup (f11bd), nag_sparse_real_gen_basic_solver (f11be) or nag_sparse_real_gen_basic_diag (f11bf))
A serious error has occurred in an internal call to one of the specified functions. Check all function calls and array sizes. Seek expert help.

Accuracy

On successful termination, the final residual rk = bAxkrk=b-Axk, where k = itnk=itn, satisfies the termination criterion
rkτ × (b + Axk).
rkτ×(b+Axk).
The value of the final residual norm is returned in rnorm.

Further Comments

The time taken by nag_sparse_real_gen_solve_ilu (f11dc) for each iteration is roughly proportional to the value of nnzc returned from the preceding call to nag_sparse_real_gen_precon_ilu (f11da).
The number of iterations required to achieve a prescribed accuracy cannot be easily determined a priori, as it can depend dramatically on the conditioning and spectrum of the preconditioned coefficient matrix A = m1AA-=m-1A.
Some illustrations of the application of nag_sparse_real_gen_solve_ilu (f11dc) to linear systems arising from the discretization of two-dimensional elliptic partial differential equations, and to random-valued randomly structured linear systems, can be found in Salvini and Shaw (1996).

Example

function nag_sparse_real_gen_solve_ilu_example
m = int64(4);
nz = int64(24);
method = 'CGS';
lfill = int64(0);
dtol = 0;
pstrat = 'C';
milu = 'N';
tol = 1e-10;
maxitn = int64(100);
a = zeros(3*nz, 1);
a(1:nz) = [2; -1; 1; 4; -3; 2; -7; 2; 3; -4; 5; 5; -1; 8; -3; -6; 5; 2; -5; ...
            -1; 6; -1; 2; 3];
irow = zeros(3*nz, 1, 'int64');
irow(1:nz) = [1; 1; 1; 2; 2; 2; 3; 3; 4; 4; 4; 4; 5; 5; 5; 6; 6; 6; ...
               7; 7; 7; 8; 8; 8];
icol = zeros(3*nz, 1, 'int64');
icol(1:nz) = [1; 4; 8; 1; 2; 5; 3; 6; 1; 3; 4; 7; 2; 5; 7; 1; 3; 6; ...
               3; 5; 7; 2; 6; 8];
ipivp = zeros(8, 1, 'int64');
ipivq = zeros(8, 1, 'int64');
b = [6;  8; -9; 46; 17; 21; 22; 34];
x = zeros(8, 1);
% Calculate incomplete 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);

% Solve Ax = b
[x, rnorm, itn, ifail] = nag_sparse_real_gen_solve_ilu(method, nz, a, irow, ...
                               icol, ipivp, ipivq, ...
                               istr, idiag, b, m, tol, maxitn, x)
 

x =

    1.0000
    2.0000
    3.0000
    4.0000
    5.0000
    6.0000
    7.0000
    8.0000


rnorm =

   1.3500e-13


itn =

                    4


ifail =

                    0


function f11dc_example
m = int64(4);
nz = int64(24);
method = 'CGS';
lfill = int64(0);
dtol = 0;
pstrat = 'C';
milu = 'N';
tol = 1e-10;
maxitn = int64(100);
a = zeros(3*nz, 1);
a(1:nz) = [2; -1; 1; 4; -3; 2; -7; 2; 3; -4; 5; 5; -1; 8; -3; -6; 5; 2; -5; ...
            -1; 6; -1; 2; 3];
irow = zeros(3*nz, 1, 'int64');
irow(1:nz) = [1; 1; 1; 2; 2; 2; 3; 3; 4; 4; 4; 4; 5; 5; 5; 6; 6; 6; ...
               7; 7; 7; 8; 8; 8];
icol = zeros(3*nz, 1, 'int64');
icol(1:nz) = [1; 4; 8; 1; 2; 5; 3; 6; 1; 3; 4; 7; 2; 5; 7; 1; 3; 6; ...
               3; 5; 7; 2; 6; 8];
ipivp = zeros(8, 1, 'int64');
ipivq = zeros(8, 1, 'int64');
b = [6;  8; -9; 46; 17; 21; 22; 34];
x = zeros(8, 1);
% Calculate incomplete LU factorization
[a, irow, icol, ipivp, ipivq, istr, idiag, nnzc, npivm, ifail] = ...
    f11da(nz, a, irow, icol, lfill, dtol, milu, ipivp, ipivq);

% Solve Ax = b
[x, rnorm, itn, ifail] = f11dc(method, nz, a, irow, icol, ipivp, ipivq, ...
                               istr, idiag, b, m, tol, maxitn, x)
 

x =

    1.0000
    2.0000
    3.0000
    4.0000
    5.0000
    6.0000
    7.0000
    8.0000


rnorm =

   4.5078e-09


itn =

                    3


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