PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_lapack_dgesvx (f07ab)
Purpose
nag_lapack_dgesvx (f07ab) uses the
factorization to compute the solution to a real system of linear equations
where
is an
by
matrix and
and
are
by
matrices. Error bounds on the solution and a condition estimate are also provided.
Syntax
[
a,
af,
ipiv,
equed,
r,
c,
b,
x,
rcond,
ferr,
berr,
work,
info] = f07ab(
fact,
trans,
a,
af,
ipiv,
equed,
r,
c,
b, 'n',
n, 'nrhs_p',
nrhs_p)
[
a,
af,
ipiv,
equed,
r,
c,
b,
x,
rcond,
ferr,
berr,
work,
info] = nag_lapack_dgesvx(
fact,
trans,
a,
af,
ipiv,
equed,
r,
c,
b, 'n',
n, 'nrhs_p',
nrhs_p)
Description
nag_lapack_dgesvx (f07ab) performs the following steps:
1. |
Equilibration
The linear system to be solved may be badly scaled. However, the system can be equilibrated as a first stage by setting . In this case, real scaling factors are computed and these factors then determine whether the system is to be equilibrated. Equilibrated forms of the systems and are
and
respectively, where and are diagonal matrices, with positive diagonal elements, formed from the computed scaling factors.
When equilibration is used, will be overwritten by and will be overwritten by (or when the solution of is sought). |
2. |
Factorization
The matrix , or its scaled form, is copied and factored using the decomposition
where is a permutation matrix, is a unit lower triangular matrix, and is upper triangular.
This stage can be by-passed when a factored matrix (with scaled matrices and scaling factors) are supplied; for example, as provided by a previous call to nag_lapack_dgesvx (f07ab) with the same matrix . |
3. |
Condition Number Estimation
The factorization of determines whether a solution to the linear system exists. If some diagonal element of is zero, then is exactly singular, no solution exists and the function returns with a failure. Otherwise the factorized form of is used to estimate the condition number of the matrix . If the reciprocal of the condition number is less than machine precision then a warning code is returned on final exit. |
4. |
Solution
The (equilibrated) system is solved for ( or ) using the factored form of (). |
5. |
Iterative Refinement
Iterative refinement is applied to improve the computed solution matrix and to calculate error bounds and backward error estimates for the computed solution. |
6. |
Construct Solution Matrix
If equilibration was used, the matrix is premultiplied by (if ) or (if or ) so that it solves the original system before equilibration. |
References
Anderson E, Bai Z, Bischof C, Blackford S, Demmel J, Dongarra J J, Du Croz J J, Greenbaum A, Hammarling S, McKenney A and Sorensen D (1999)
LAPACK Users' Guide (3rd Edition) SIAM, Philadelphia
http://www.netlib.org/lapack/lug
Golub G H and Van Loan C F (1996) Matrix Computations (3rd Edition) Johns Hopkins University Press, Baltimore
Higham N J (2002) Accuracy and Stability of Numerical Algorithms (2nd Edition) SIAM, Philadelphia
Parameters
Compulsory Input Parameters
- 1:
– string (length ≥ 1)
-
Specifies whether or not the factorized form of the matrix
is supplied on entry, and if not, whether the matrix
should be equilibrated before it is factorized.
- af and ipiv contain the factorized form of . If , the matrix has been equilibrated with scaling factors given by r and c. a, af and ipiv are not modified.
- The matrix will be copied to af and factorized.
- The matrix will be equilibrated if necessary, then copied to af and factorized.
Constraint:
, or .
- 2:
– string (length ≥ 1)
-
Specifies the form of the system of equations.
- (No transpose).
- or
- (Transpose).
Constraint:
, or .
- 3:
– double array
-
The first dimension of the array
a must be at least
.
The second dimension of the array
a must be at least
.
The
by
matrix
.
If
and
,
a must have been equilibrated by the scaling factors in
r and/or
c.
- 4:
– double array
-
The first dimension of the array
af must be at least
.
The second dimension of the array
af must be at least
.
If
,
af contains the factors
and
from the factorization
as computed by
nag_lapack_dgetrf (f07ad). If
,
af is the factorized form of the equilibrated matrix
.
If
or
,
af need not be set.
- 5:
– int64int32nag_int array
-
The dimension of the array
ipiv
must be at least
If
,
ipiv contains the pivot indices from the factorization
as computed by
nag_lapack_dgetrf (f07ad); at the
th step row
of the matrix was interchanged with row
.
indicates a row interchange was not required.
If
or
,
ipiv need not be set.
- 6:
– string (length ≥ 1)
-
If
or
,
equed need not be set.
If
,
equed must specify the form of the equilibration that was performed as follows:
- if , no equilibration;
- if , row equilibration, i.e., has been premultiplied by ;
- if , column equilibration, i.e., has been postmultiplied by ;
- if , both row and column equilibration, i.e., has been replaced by .
Constraint:
if , , , or .
- 7:
– double array
-
The dimension of the array
r
must be at least
If
or
,
r need not be set.
If
and
or
,
r must contain the row scale factors for
,
; each element of
r must be positive.
- 8:
– double array
-
The dimension of the array
c
must be at least
If
or
,
c need not be set.
If
or
or
,
c must contain the column scale factors for
,
; each element of
c must be positive.
- 9:
– 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 .
Optional Input Parameters
- 1:
– int64int32nag_int scalar
-
Default:
the first dimension of the arrays
a,
af,
b and the second dimension of the arrays
a,
af,
ipiv,
r,
c.
, the number of linear equations, i.e., the order of the matrix .
Constraint:
.
- 2:
– int64int32nag_int scalar
-
Default:
the second dimension of the array
b.
, the number of right-hand sides, i.e., the number of columns of the matrix .
Constraint:
.
Output Parameters
- 1:
– double array
-
The first dimension of the array
a will be
.
The second dimension of the array
a will be
.
If
or
, or if
and
,
a is not modified.
If
or
,
is scaled as follows:
- if , ;
- if , ;
- if , .
- 2:
– double array
-
The first dimension of the array
af will be
.
The second dimension of the array
af will be
.
If
,
af returns the factors
and
from the factorization
of the original matrix
.
If
,
af returns the factors
and
from the factorization
of the equilibrated matrix
(see the description of
a for the form of the equilibrated matrix).
If
,
af is unchanged from entry.
- 3:
– int64int32nag_int array
-
The dimension of the array
ipiv will be
If
,
ipiv contains the pivot indices from the factorization
of the original matrix
.
If
,
ipiv contains the pivot indices from the factorization
of the equilibrated matrix
.
If
,
ipiv is unchanged from entry.
- 4:
– string (length ≥ 1)
-
If
,
equed is unchanged from entry.
Otherwise, if no constraints are violated,
equed specifies the form of equilibration that was performed as specified above.
- 5:
– double array
-
The dimension of the array
r will be
If
,
r is unchanged from entry.
Otherwise, if no constraints are violated and
or
,
r contains the row scale factors for
,
, such that
is multiplied on the left by
; each element of
r is positive.
- 6:
– double array
-
The dimension of the array
c will be
If
,
c is unchanged from entry.
Otherwise, if no constraints are violated and
or
,
c contains the row scale factors for
,
; each element of
c is positive.
- 7:
– double array
-
The first dimension of the array
b will be
.
The second dimension of the array
b will be
.
If
,
b is not modified.
If
and
or
,
b stores
.
If
or
and
or
,
b stores
.
- 8:
– double array
-
The first dimension of the array
x will be
.
The second dimension of the array
x will be
.
If or , the by solution matrix to the original system of equations. Note that the arrays and are modified on exit if , and the solution to the equilibrated system is if and or , or if or and or .
- 9:
– double scalar
-
If no constraints are violated, an estimate of the reciprocal condition number of the matrix (after equilibration if that is performed), computed as .
- 10:
– double array
-
If
or
, an estimate of the forward error bound for each computed solution vector, such that
where
is the
th column of the computed solution returned in the array
x and
is the corresponding column of the exact solution
. The estimate is as reliable as the estimate for
rcond, and is almost always a slight overestimate of the true error.
- 11:
– double array
-
If or , an estimate of the component-wise relative backward error of each computed solution vector (i.e., the smallest relative change in any element of or that makes an exact solution).
- 12:
– double array
-
contains the reciprocal pivot growth factor
. The ‘max absolute element’ norm is used. If
is much less than
, then the stability of the
factorization of the (equilibrated) matrix
could be poor. This also means that the solution
x, condition estimate
rcond, and forward error bound
ferr could be unreliable. If the factorization fails with
, then
contains the reciprocal pivot growth factor for the leading
info columns of
.
- 13:
– int64int32nag_int scalar
unless the function detects an error (see
Error Indicators and Warnings).
Error Indicators and Warnings
Cases prefixed with W are classified as warnings and
do not generate an error of type NAG:error_n. See nag_issue_warnings.
-
If , argument had an illegal value. An explanatory message is output, and execution of the program is terminated.
- W
-
Element of the diagonal is exactly zero.
The factorization has been completed, but the factor is exactly singular, so the solution and error bounds could not be computed.
is returned.
- W
-
is nonsingular, but
rcond is less than
machine precision, meaning that the matrix is singular to working precision.
Nevertheless, the solution and error bounds are computed because there
are a number of situations where the computed solution can be more accurate
than the value of
rcond would suggest.
Accuracy
For each right-hand side vector
, the computed solution
is the exact solution of a perturbed system of equations
, where
is a modest linear function of
, and
is the
machine precision. See Section 9.3 of
Higham (2002) for further details.
If
is the true solution, then the computed solution
satisfies a forward error bound of the form
where
.
If
is the
th column of
, then
is returned in
and a bound on
is returned in
. See Section 4.4 of
Anderson et al. (1999) for further details.
Further Comments
The factorization of requires approximately floating-point operations.
Estimating the forward error involves solving a number of systems of linear equations of the form or ; the number is usually or and never more than . Each solution involves approximately operations.
In practice the condition number estimator is very reliable, but it can underestimate the true condition number; see Section 15.3 of
Higham (2002) for further details.
The complex analogue of this function is
nag_lapack_zgesvx (f07ap).
Example
This example solves the equations
where
is the general matrix
and
Error estimates for the solutions, information on scaling, an estimate of the reciprocal of the condition number of the scaled matrix and an estimate of the reciprocal of the pivot growth factor for the factorization of are also output.
Open in the MATLAB editor:
f07ab_example
function f07ab_example
fprintf('f07ab example results\n\n');
n = 4;
nrhs = 2;
a = [ 1.80, 2.88, 2.05, -0.89;
525.00, -295.00, -95.00, -380.00;
1.58, -2.69, -2.90, -1.04;
-1.11, -0.66, -0.59, 0.80];
b = [ 9.52, 18.47;
2435.00, 225.00;
0.77, -13.28;
-6.22, -6.21];
fact = 'Equilibration';
trans = 'No transpose';
equed = 'N';
af = zeros(n, n);
ipiv = zeros(n, 1, 'int64');
r = zeros(n, 1);
c = zeros(n, 1);
[a, af, ipiv, equed, r, c, b, x, rcond, ferr, berr, work, info] = ...
f07ab(...
fact, trans, a, af, ipiv, equed, r, c, b);
fprintf('Solution is x:\n');
disp(x);
fprintf('\nApproximate condition number = %8.3f\n',1/rcond);
fprintf('Approximate forward errors :\n');
fprintf(' %11.3e\n',ferr);
fprintf('Approximate backward errors :\n')
fprintf(' %11.3e\n',berr);
f07ab example results
Solution is x:
1.0000 3.0000
-1.0000 2.0000
3.0000 4.0000
-5.0000 1.0000
Approximate condition number = 54.967
Approximate forward errors :
2.384e-14
3.301e-14
Approximate backward errors :
6.800e-17
8.040e-17
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015