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_direct_real_gen_refine (f11mh)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

Purpose

nag_sparse_direct_real_gen_refine (f11mh) returns error bounds for the solution of a real sparse system of linear equations with multiple right-hand sides, AX=B or ATX=B. It improves the solution by iterative refinement in standard precision, in order to reduce the backward error as much as possible.

Syntax

[x, ferr, berr, ifail] = f11mh(trans, icolzp, irowix, a, iprm, il, lval, iu, uval, b, x, 'n', n, 'nrhs_p', nrhs_p)
[x, ferr, berr, ifail] = nag_sparse_direct_real_gen_refine(trans, icolzp, irowix, a, iprm, il, lval, iu, uval, b, x, 'n', n, 'nrhs_p', nrhs_p)

Description

nag_sparse_direct_real_gen_refine (f11mh) returns the backward errors and estimated bounds on the forward errors for the solution of a real system of linear equations with multiple right-hand sides AX=B or ATX=B. The function handles each right-hand side vector (stored as a column of the matrix B) independently, so we describe the function of nag_sparse_direct_real_gen_refine (f11mh) in terms of a single right-hand side b and solution x.
Given a computed solution x, the function computes the component-wise backward error β. This is the size of the smallest relative perturbation in each element of A and b such that if x is the exact solution of a perturbed system:
A+δA x = b + δ b then   δaij β aij   and   δbi β bi .  
Then the function estimates a bound for the component-wise forward error in the computed solution, defined by:
maxi xi - x^i / maxi xi  
where x^ is the true solution.
The function uses the LU  factorization Pr A Pc = LU  computed by nag_sparse_direct_real_gen_lu (f11me) and the solution computed by nag_sparse_direct_real_gen_solve (f11mf).

References

Golub G H and Van Loan C F (1996) Matrix Computations (3rd Edition) Johns Hopkins University Press, Baltimore

Parameters

Compulsory Input Parameters

1:     trans – string (length ≥ 1)
Specifies whether AX=B or ATX=B is solved.
trans='N'
AX=B is solved.
trans='T'
ATX=B is solved.
Constraint: trans='N' or 'T'.
2:     icolzp: int64int32nag_int array
The dimension of the array icolzp must be at least n+1
icolzpi contains the index in A of the start of a new column. See Compressed column storage (CCS) format in the F11 Chapter Introduction.
3:     irowix: int64int32nag_int array
The dimension of the array irowix must be at least icolzpn+1-1, the number of nonzeros of the sparse matrix A
The row index array of sparse matrix A.
4:     a: – double array
The dimension of the array a must be at least icolzpn+1-1, the number of nonzeros of the sparse matrix A
The array of nonzero values in the sparse matrix A.
5:     iprm7×n int64int32nag_int array
The column permutation which defines Pc, the row permutation which defines Pr, plus associated data structures as computed by nag_sparse_direct_real_gen_lu (f11me).
6:     il: int64int32nag_int array
The dimension of the array il must be at least as large as the dimension of the array of the same name in nag_sparse_direct_real_gen_lu (f11me)
Records the sparsity pattern of matrix L as computed by nag_sparse_direct_real_gen_lu (f11me).
7:     lval: – double array
The dimension of the array lval must be at least as large as the dimension of the array of the same name in nag_sparse_direct_real_gen_lu (f11me)
Records the nonzero values of matrix L and some nonzero values of matrix U as computed by nag_sparse_direct_real_gen_lu (f11me).
8:     iu: int64int32nag_int array
The dimension of the array iu must be at least as large as the dimension of the array of the same name in nag_sparse_direct_real_gen_lu (f11me)
Records the sparsity pattern of matrix U as computed by nag_sparse_direct_real_gen_lu (f11me).
9:     uval: – double array
The dimension of the array uval must be at least as large as the dimension of the array of the same name in nag_sparse_direct_real_gen_lu (f11me)
Records some nonzero values of matrix U as computed by nag_sparse_direct_real_gen_lu (f11me).
10:   bldb: – double array
The first dimension of the array b must be at least max1,n.
The second dimension of the array b must be at least max1,nrhs_p.
The n by nrhs right-hand side matrix B.
11:   xldx: – double array
The first dimension of the array x must be at least max1,n.
The second dimension of the array x must be at least max1,nrhs_p.
The n by nrhs solution matrix X, as returned by nag_sparse_direct_real_gen_solve (f11mf).

Optional Input Parameters

1:     n int64int32nag_int scalar
Default: the first dimension of the arrays b, x. (An error is raised if these dimensions are not equal.)
n, the order of the matrix A.
Constraint: n0.
2:     nrhs_p int64int32nag_int scalar
Default: the second dimension of the arrays b, x.
nrhs, the number of right-hand sides in B.
Constraint: nrhs_p0.

Output Parameters

1:     xldx: – double array
The first dimension of the array x will be max1,n.
The second dimension of the array x will be max1,nrhs_p.
The n by nrhs improved solution matrix X.
2:     ferrnrhs_p – double array
ferrj contains an estimated error bound for the jth solution vector, that is, the jth column of X, for j=1,2,,nrhs.
3:     berrnrhs_p – double array
berrj contains the component-wise backward error bound β for the jth solution vector, that is, the jth column of X, for j=1,2,,nrhs.
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:
   ifail=1
Constraint: ldbmax1,n.
Constraint: ldxmax1,n.
Constraint: n0.
Constraint: nrhs_p0.
On entry, trans=_.
Constraint: trans='N' or 'T'.
   ifail=2
Incorrect row permutations in array iprm.
   ifail=3
Incorrect column permutations in array iprm.
   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

The bounds returned in ferr are not rigorous, because they are estimated, not computed exactly; but in practice they almost always overestimate the actual error.

Further Comments

At most five steps of iterative refinement are performed, but usually only one or two steps are required.
Estimating the forward error involves solving a number of systems of linear equations of the form Ax=b or ATx=b;

Example

This example solves the system of equations AX=B using iterative refinement and to compute the forward and backward error bounds, where
A= 2.00 1.00 0 0 0 0 0 1.00 -1.00 0 4.00 0 1.00 0 1.00 0 0 0 1.00 2.00 0 -2.00 0 0 3.00   and  B= 1.56 3.12 -0.25 -0.50 3.60 7.20 1.33 2.66 0.52 1.04 .  
Here A is nonsymmetric and must first be factorized by nag_sparse_direct_real_gen_lu (f11me).
function f11mh_example


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

% Solve AX=B for sparse A

% A and B 
n      = int64(5);
nz     = int64(11);
icolzp = [int64(1); 3; 5;  7; 9; 12];
irowix = [int64(1); 3; 1;  5; 2;  3;  2; 4; 3; 4; 5];
a      = [        2;  4; 1; -2; 1;  1; -1; 1; 1; 2; 3];
b = [  1.56,  3.12;
      -0.25, -0.50;
       3.60,  7.20;
       1.33,  2.66;
       0.52,  1.04];

% Calculate COLAMD permutation
spec = 'M';
iprm = zeros(1, 7*n, 'int64');

[iprm, ifail] = f11md( ...
                       spec, n, icolzp, irowix, iprm);

% Factorise
thresh = 1;
nzlmx  = int64(8*nz);
nzlumx = int64(8*nz);
nzumx  = int64(8*nz);

[iprm, nzlumx, il, lval, iu, uval, nnzl, nnzu, flop, ifail] = ...
  f11me( ...
         n, irowix, a, iprm, thresh, nzlmx, nzlumx, nzumx);

% Compute solution in x
x     = b;
trans = 'N';

[x, ifail] = f11mf( ...
                    trans, iprm, il, lval, iu, uval, x);

% Improve solution, and compute backward errors and estimated
% bounds on the forward errors
[x, ferr, berr, ifail] = ...
  f11mh( ...
         trans, icolzp, irowix, a, iprm, il, lval, iu, uval, b, x);

fprintf('Solutions:\n');
disp(x);
fprintf('Estmated Forward Error:\n');
fprintf('%8.1e\n', ferr);
fprintf('\nEstmated Backward Error:\n');
fprintf('%8.1e\n', berr);


f11mh example results

Solutions:
    0.7000    1.4000
    0.1600    0.3200
    0.5200    1.0400
    0.7700    1.5400
    0.2800    0.5600

Estmated Forward Error:
 5.0e-15
 5.0e-15

Estmated Backward Error:
 3.6e-17
 3.6e-17

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