PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_lapack_dgetri (f07aj)
Purpose
nag_lapack_dgetri (f07aj) computes the inverse of a real matrix
, where
has been factorized by
nag_lapack_dgetrf (f07ad).
Syntax
Description
nag_lapack_dgetri (f07aj) is used to compute the inverse of a real matrix
, the function must be preceded by a call to
nag_lapack_dgetrf (f07ad), which computes the
factorization of
as
. The inverse of
is computed by forming
and then solving the equation
for
.
References
Du Croz J J and Higham N J (1992) Stability of methods for matrix inversion IMA J. Numer. Anal. 12 1–19
Parameters
Compulsory Input Parameters
- 1:
– 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
factorization of
, as returned by
nag_lapack_dgetrf (f07ad).
- 2:
– int64int32nag_int array
-
The dimension of the array
ipiv
must be at least
The pivot indices, as returned by
nag_lapack_dgetrf (f07ad).
Optional Input Parameters
- 1:
– int64int32nag_int scalar
-
Default:
the first dimension of the array
a and the second dimension of the arrays
a,
ipiv.
, the order 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
.
The factorization stores the by matrix .
- 2:
– 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 zero.
is singular, and the inverse of cannot be computed.
Accuracy
The computed inverse
satisfies a bound of the form:
where
is a modest linear function of
, and
is the
machine precision.
Note that a similar bound for
cannot be guaranteed, although it is almost always satisfied. See
Du Croz and Higham (1992).
Further Comments
The total number of floating-point operations is approximately .
The complex analogue of this function is
nag_lapack_zgetri (f07aw).
Example
This example computes the inverse of the matrix
, where
Here
is nonsymmetric and must first be factorized by
nag_lapack_dgetrf (f07ad).
Open in the MATLAB editor:
f07aj_example
function f07aj_example
fprintf('f07aj example results\n\n');
a = [ 1.80, 2.88, 2.05, -0.89;
5.25, -2.95, -0.95, -3.80;
1.58, -2.69, -2.90, -1.04;
-1.11, -0.66, -0.59, 0.80];
[af, ipiv, info] = f07ad(a);
[ainv, info] = f07aj(af, ipiv);
[ifail] = x04ca( ...
'General', ' ', ainv, 'Inverse');
f07aj example results
Inverse
1 2 3 4
1 1.7720 0.5757 0.0843 4.8155
2 -0.1175 -0.4456 0.4114 -1.7126
3 0.1799 0.4527 -0.6676 1.4824
4 2.4944 0.7650 -0.0360 7.6119
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015