PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_linsys_real_sparse_fac_solve (f04ax)
Purpose
nag_linsys_real_sparse_fac_solve (f04ax) calculates the approximate solution of a set of real sparse linear equations with a single right-hand side,
or
, where
has been factorized by
nag_matop_real_gen_sparse_lu (f01br) or
nag_matop_real_gen_sparse_lu_reuse (f01bs).
Syntax
[
rhs,
resid] = f04ax(
a,
icn,
ikeep,
rhs,
mtype,
idisp, 'n',
n, 'licn',
licn)
[
rhs,
resid] = nag_linsys_real_sparse_fac_solve(
a,
icn,
ikeep,
rhs,
mtype,
idisp, 'n',
n, 'licn',
licn)
Description
To solve a system of real linear equations
or
, where
is a general sparse matrix,
must first be factorized by
nag_matop_real_gen_sparse_lu (f01br) or
nag_matop_real_gen_sparse_lu_reuse (f01bs).
nag_linsys_real_sparse_fac_solve (f04ax) then computes
by block forward or backward substitution using simple forward and backward substitution within each diagonal block.
The method is fully described in
Duff (1977).
A more recent method is available through solver function
nag_sparse_direct_real_gen_solve (f11mf) and factorization function
nag_sparse_direct_real_gen_lu (f11me).
References
Duff I S (1977) MA28 – a set of Fortran subroutines for sparse unsymmetric linear equations AERE Report R8730 HMSO
Parameters
Compulsory Input Parameters
- 1:
– double array
-
The nonzero elements in the factorization of the matrix
, as returned by
nag_matop_real_gen_sparse_lu (f01br) or
nag_matop_real_gen_sparse_lu_reuse (f01bs).
- 2:
– int64int32nag_int array
-
The column indices of the nonzero elements of the factorization, as returned by
nag_matop_real_gen_sparse_lu (f01br) or
nag_matop_real_gen_sparse_lu_reuse (f01bs).
- 3:
– int64int32nag_int array
-
ikeep provides, on entry, indexing information about the factorization, as returned by
nag_matop_real_gen_sparse_lu (f01br) or
nag_matop_real_gen_sparse_lu_reuse (f01bs). Used as internal workspace prior to being restored and hence is unchanged.
- 4:
– double array
-
The right-hand side vector .
- 5:
– int64int32nag_int scalar
-
mtype specifies the task to be performed.
- Solve .
- Solve .
- 6:
– int64int32nag_int array
-
Optional Input Parameters
- 1:
– int64int32nag_int scalar
-
Default:
the dimension of the array
rhs.
, the order of the matrix .
Constraint:
.
- 2:
– int64int32nag_int scalar
-
Default:
the dimension of the arrays
a,
icn. (An error is raised if these dimensions are not equal.)
The dimension of the arrays
a and
icn.
Output Parameters
- 1:
– double array
-
rhs stores the solution vector
.
- 2:
– double scalar
-
The value of the maximum residual,
, over all the unsatisfied equations, in case
nag_matop_real_gen_sparse_lu (f01br) or
nag_matop_real_gen_sparse_lu_reuse (f01bs) has been used to factorize a singular or rectangular matrix.
Error Indicators and Warnings
None.
Accuracy
The accuracy of the computed solution depends on the conditioning of the original matrix. Since
nag_linsys_real_sparse_fac_solve (f04ax) is always used with either
nag_matop_real_gen_sparse_lu (f01br) or
nag_matop_real_gen_sparse_lu_reuse (f01bs), you are recommended to set
on entry to these functions and to examine the value of
on exit (see
nag_matop_real_gen_sparse_lu (f01br) and
nag_matop_real_gen_sparse_lu_reuse (f01bs)). For a detailed error analysis see page 17 of
Duff (1977).
If storage for the original matrix is available then the error can be estimated by calculating the residual
and calling
nag_linsys_real_sparse_fac_solve (f04ax) again to find a correction
for
by solving
Further Comments
If the factorized form contains nonzeros () then the time taken is very approximately times longer than the inner loop of full matrix code. Some advantage is taken of zeros in the right-hand side when solving ().
Example
This example solves the set of linear equations
where
The nonzero elements of
and indexing information are read in by the program, as described in the document for
nag_matop_real_gen_sparse_lu (f01br).
Open in the MATLAB editor:
f04ax_example
function f04ax_example
fprintf('f04ax example results\n\n');
n = int64(6);
nz = int64(15);
a = zeros(150,1);
a(1:15) = [ 5;
2; -1; 2;
3;
-2; 1; 1;
-1; -1; 2; -3;
-1; -1; 6];
irn = zeros(75,1,'int64');
icn = zeros(150,1,'int64');
irn(1:15) = [int64(1);
2; 2; 2;
3;
4; 4; 4;
5; 5; 5; 5;
6; 6; 6];
icn(1:15) = [int64(1);
2; 3; 4;
3;
1; 4; 5;
1; 4; 5; 6;
1; 2; 6];
b = [15;
12;
18;
3;
-6;
0];
abort = [true; true; false; true];
[a, irn, icn, ikeep, w, idisp, ifail] = ...
f01br( ...
n, nz, a, irn, icn, abort);
mtype = int64(1);
[x, resid] = f04ax( ...
a, icn, ikeep, b, mtype, idisp);
disp('Solution');
disp(x);
f04ax example results
Solution
3
3
6
6
3
1
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015