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_jacssor (f11de)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

Purpose

nag_sparse_real_gen_solve_jacssor (f11de) 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, without preconditioning, with Jacobi, or with SSOR preconditioning.

Syntax

[x, rnorm, itn, ifail] = f11de(method, precon, a, irow, icol, omega, b, m, tol, maxitn, x, 'n', n, 'nz', nz)
[x, rnorm, itn, ifail] = nag_sparse_real_gen_solve_jacssor(method, precon, a, irow, icol, omega, b, m, tol, maxitn, x, 'n', n, 'nz', nz)

Description

nag_sparse_real_gen_solve_jacssor (f11de) solves a real sparse nonsymmetric system of linear equations
Ax=b,  
using an 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.
The function allows the following choices for the preconditioner:
For incomplete LU (ILU) preconditioning see nag_sparse_real_gen_solve_ilu (f11dc).
The matrix A is represented in coordinate storage (CS) format (see Coordinate storage (CS) format in the F11 Chapter Introduction) in the arrays a, irow and icol. The array a holds the nonzero entries in the matrix, while irow and icol hold the corresponding row and column indices.
nag_sparse_real_gen_solve_jacssor (f11de) 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
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
Young D (1971) Iterative Solution of Large Linear Systems Academic Press, New York

Parameters

Compulsory Input Parameters

1:     method – string
The iterative method to be used.
method='RGMRES'
Restarted generalized minimum residual method.
method='CGS'
Conjugate gradient squared method.
method='BICGSTAB'
Bi-conjugate gradient stabilized () method.
method='TFQMR'
Transpose-free quasi-minimal residual method.
Constraint: method='RGMRES', 'CGS', 'BICGSTAB' or 'TFQMR'.
2:     precon – string (length ≥ 1)
Specifies the type of preconditioning to be used.
precon='N'
No preconditioning.
precon='J'
Jacobi.
precon='S'
Symmetric successive-over-relaxation.
Constraint: precon='N', 'J' or 'S'.
3:     anz – double array
The nonzero elements of the matrix A, ordered by increasing row index, and by increasing column index within each row. Multiple entries for the same row and column indices are not permitted. The function nag_sparse_real_gen_sort (f11za) may be used to order the elements in this way.
4:     irownz int64int32nag_int array
5:     icolnz int64int32nag_int array
The row and column indices of the nonzero elements supplied in a.
Constraints:
irow and icol must satisfy the following constraints (which may be imposed by a call to nag_sparse_real_gen_sort (f11za)):
  • 1irowin and 1icolin, for i=1,2,,nz;
  • irowi-1<irowi or irowi-1=irowi and icoli-1<icoli, for i=2,3,,nz.
6:     omega – double scalar
If precon='S', omega is the relaxation parameter ω to be used in the SSOR method. Otherwise omega need not be initialized and is not referenced.
Constraint: 0.0<omega<2.0.
7:     bn – double array
The right-hand side vector b.
8:     m int64int32nag_int scalar
If method='RGMRES', m is the dimension of the restart subspace.
If method='BICGSTAB', m is the order  of the polynomial Bi-CGSTAB method.
Otherwise, m is not referenced.
Constraints:
  • if method='RGMRES', 0<mminn,50;
  • if method='BICGSTAB', 0<mminn,10.
9:     tol – double scalar
The required tolerance. Let xk denote the approximate solution at iteration k, and rk the corresponding residual. The algorithm is considered to have converged at iteration k if
rkτ×b+Axk.  
If tol0.0, τ=maxε,10ε,nε is used, where ε is the machine precision. Otherwise τ=maxtol,10ε,nε is used.
Constraint: tol<1.0.
10:   maxitn int64int32nag_int scalar
The maximum number of iterations allowed.
Constraint: maxitn1.
11:   xn – double array
An initial approximation to the solution vector x.

Optional Input Parameters

1:     n int64int32nag_int scalar
Default: the dimension of the arrays b, x. (An error is raised if these dimensions are not equal.)
n, the order of the matrix A.
Constraint: n1.
2:     nz int64int32nag_int scalar
Default: the dimension of the arrays a, irow, icol. (An error is raised if these dimensions are not equal.)
The number of nonzero elements in the matrix A.
Constraint: 1nzn2.

Output Parameters

1:     xn – double array
An improved approximation to the solution vector x.
2:     rnorm – double scalar
The final value of the residual norm rk, where k is the output value of itn.
3:     itn int64int32nag_int scalar
The number of iterations carried out.
4:     ifail int64int32nag_int scalar
ifail=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=1
On entry,method'RGMRES','CGS','BICGSTAB', or 'TFQMR',
orprecon'N', 'J' or 'S',
orn<1,
ornz<1,
ornz>n2,
orprecon='S' and omega lies outside the interval 0.0,2.0,
orm<1,
orm>minn,50, with method='RGMRES',
orm>minn,10, with method='BICGSTAB',
ortol1.0,
ormaxitn<1,
orlwork too small.
   ifail=2
On entry, the arrays irow and icol fail to satisfy the following constraints:
  • 1irowin and 1icolin, for i=1,2,,nz;
  • irowi-1<irowi, or irowi-1=irowi and icoli-1<icoli, for i=2,3,,nz.
Therefore a nonzero element has been supplied which does not lie within the matrix A, is out of order, or has duplicate row and column indices. Call nag_sparse_real_gen_sort (f11za) to reorder and sum or remove duplicates.
   ifail=3
On entry, the matrix A has a zero diagonal element. Jacobi and SSOR preconditioners are not appropriate for this problem.
W  ifail=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=5
Required accuracy not obtained in maxitn iterations.
   ifail=6
Algorithmic breakdown. A solution is returned, although it is possible that it is completely inaccurate.
   ifail=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.
   ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
   ifail=-399
Your licence key may have expired or may not have been installed correctly.
   ifail=-999
Dynamic memory allocation failed.

Accuracy

On successful termination, the final residual rk=b-Axk, where k=itn, satisfies the termination criterion
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_jacssor (f11de) for each iteration is roughly proportional to nz.
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-=m-1A.

Example

This example solves a sparse nonsymmetric system of equations using the RGMRES method, with SSOR preconditioning.
function f11de_example


fprintf('f11de example results\n\n');

% Sparse matrix A
a    = [        2;  1;-1;-3;-2; 1; 1; 5; 3; 1;-2;-3;-1; 4;-2;-6];
irow = [int64(1); 1; 1; 2; 2; 2; 3; 3; 3; 3; 4; 4; 4; 5; 5; 5];
icol = [int64(1); 2; 4; 2; 3; 5; 1; 3; 4; 5; 1; 4; 5; 2; 3; 5];

% RHS b and initial guess x
b = [0; -7; 33; -19; -28];
x = zeros(5, 1);

% Use RGMRES with SSOR preconditioning
method = 'RGMRES';
precon = 'S';

% Input argument initializations
m      = int64(1);
omega  = 1.05;
tol    = 1e-10;
maxitn = int64(1000);

% Solve Ax = b
[x, rnorm, itn, ifail] = ...
f11de( ...
       method, precon, a, irow, icol, omega, b, m, tol, maxitn, x);

fprintf('Converged in %d iterations\n', itn);
fprintf('Final residual norm = %16.1e\n\n', rnorm);
disp('Solution');
disp(x);


f11de example results

Converged in 13 iterations
Final residual norm =          5.1e-09

Solution
    1.0000
    2.0000
    3.0000
    4.0000
    5.0000


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–2015