PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_sparse_direct_real_gen_refine (f11mh)
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, or . 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 or . The function handles each right-hand side vector (stored as a column of the matrix ) independently, so we describe the function of nag_sparse_direct_real_gen_refine (f11mh) in terms of a single right-hand side and solution .
Given a computed solution
, the function computes the
component-wise backward error
. This is the size of the smallest relative perturbation in each element of
and
such that if
is the exact solution of a perturbed system:
Then the function estimates a bound for the
component-wise forward error in the computed solution, defined by:
where
is the true solution.
The function uses the
factorization
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:
– string (length ≥ 1)
-
Specifies whether
or
is solved.
- is solved.
- is solved.
Constraint:
or .
- 2:
– int64int32nag_int array
-
The dimension of the array
icolzp
must be at least
contains the index in
of the start of a new column. See
Compressed column storage (CCS) format in the F11 Chapter Introduction.
- 3:
– int64int32nag_int array
-
The dimension of the array
irowix
must be at least
, the number of nonzeros of the sparse matrix
The row index array of sparse matrix .
- 4:
– double array
-
The dimension of the array
a
must be at least
, the number of nonzeros of the sparse matrix
The array of nonzero values in the sparse matrix .
- 5:
– int64int32nag_int array
-
The column permutation which defines
, the row permutation which defines
, plus associated data structures as computed by
nag_sparse_direct_real_gen_lu (f11me).
- 6:
– 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
as computed by
nag_sparse_direct_real_gen_lu (f11me).
- 7:
– 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
and some nonzero values of matrix
as computed by
nag_sparse_direct_real_gen_lu (f11me).
- 8:
– 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
as computed by
nag_sparse_direct_real_gen_lu (f11me).
- 9:
– 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
as computed by
nag_sparse_direct_real_gen_lu (f11me).
- 10:
– double array
-
The first dimension of the array
b must be at least
.
The second dimension of the array
b must be at least
.
The by right-hand side matrix .
- 11:
– double array
-
The first dimension of the array
x must be at least
.
The second dimension of the array
x must be at least
.
The
by
solution matrix
, as returned by
nag_sparse_direct_real_gen_solve (f11mf).
Optional Input Parameters
- 1:
– int64int32nag_int scalar
-
Default:
the first dimension of the arrays
b,
x. (An error is raised if these dimensions are not equal.)
, the order of the matrix .
Constraint:
.
- 2:
– int64int32nag_int scalar
-
Default:
the second dimension of the arrays
b,
x.
, the number of right-hand sides in .
Constraint:
.
Output Parameters
- 1:
– double array
-
The first dimension of the array
x will be
.
The second dimension of the array
x will be
.
The by improved solution matrix .
- 2:
– double array
-
contains an estimated error bound for the th solution vector, that is, the th column of , for .
- 3:
– double array
-
contains the component-wise backward error bound for the th solution vector, that is, the th column of , for .
- 4:
– int64int32nag_int scalar
unless the function detects an error (see
Error Indicators and Warnings).
Error Indicators and Warnings
Errors or warnings detected by the function:
-
-
Constraint: .
Constraint: .
Constraint: .
Constraint: .
On entry, .
Constraint: or .
-
-
Incorrect row permutations in array
iprm.
-
-
Incorrect column permutations in array
iprm.
-
An unexpected error has been triggered by this routine. Please
contact
NAG.
-
Your licence key may have expired or may not have been installed correctly.
-
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 or ;
Example
This example solves the system of equations
using iterative refinement and to compute the forward and backward error bounds, where
Here
is nonsymmetric and must first be factorized by
nag_sparse_direct_real_gen_lu (f11me).
Open in the MATLAB editor:
f11mh_example
function f11mh_example
fprintf('f11mh example results\n\n');
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];
spec = 'M';
iprm = zeros(1, 7*n, 'int64');
[iprm, ifail] = f11md( ...
spec, n, icolzp, irowix, iprm);
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);
x = b;
trans = 'N';
[x, ifail] = f11mf( ...
trans, iprm, il, lval, iu, uval, x);
[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)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015