PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_matop_real_gen_pseudinv (f01bl)
Purpose
nag_matop_real_gen_pseudinv (f01bl) calculates the rank and pseudo-inverse of an by real matrix, , using a factorization with column interchanges.
Syntax
Note: the interface to this routine has changed since earlier releases of the toolbox:
At Mark 22: |
m was made optional |
Description
Householder's factorization with column interchanges is used in the decomposition
, where
is
with its columns permuted,
is the first
columns of an
by
orthogonal matrix and
is an
by
upper-trapezoidal matrix of rank
. The pseudo-inverse of
is given by
where
If the matrix is found to be of maximum rank,
,
is a nonsingular
by
upper-triangular matrix and the pseudo-inverse of
simplifies to
. The transpose of the pseudo-inverse of
is overwritten on
.
References
Peters G and Wilkinson J H (1970) The least squares problem and pseudo-inverses Comput. J. 13 309–316
Wilkinson J H and Reinsch C (1971) Handbook for Automatic Computation II, Linear Algebra Springer–Verlag
Parameters
Compulsory Input Parameters
- 1:
– double scalar
-
The tolerance used to decide when elements can be regarded as zero (see
Further Comments).
- 2:
– double array
-
lda, the first dimension of the array, must satisfy the constraint
.
The by rectangular matrix .
Optional Input Parameters
- 1:
– int64int32nag_int scalar
- 2:
– int64int32nag_int scalar
-
Default:
For
m, the first dimension of the array
a. the second dimension of the array
a.
and , the number of rows and columns in the matrix .
Constraint:
.
Output Parameters
- 1:
– double array
-
The transpose of the pseudo-inverse of .
- 2:
– double array
-
contains the element of largest modulus in the reduced matrix at the
th stage. If
, then only the first
elements of
aijmax have values assigned to them; the remaining elements are unused. The ratio
usually gives an indication of the condition number of the original matrix (see
Further Comments).
- 3:
– int64int32nag_int scalar
-
, the rank of
as determined using the tolerance
t.
- 4:
– int64int32nag_int array
-
The record of the column interchanges in the Householder factorization.
- 5:
– 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:
-
-
Inverse not found, due to an incorrect determination of
irank (see
Further Comments).
-
-
Invalid tolerance, due to
(i) |
t is negative, ; |
(ii) |
t too large, ; |
(iii) |
t too small, . |
-
-
-
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
For most matrices the pseudo-inverse is the best possible having regard to the condition of
and the choice of
t. Note that only the singular value decomposition method can be relied upon to give maximum accuracy for the precision of computation used and correct determination of the condition of a matrix (see
Wilkinson and Reinsch (1971)).
The computed factors
and
satisfy the relation
where
in which
is a modest function of
and
,
is the value of
t, and
is the
machine precision.
Further Comments
The time taken by nag_matop_real_gen_pseudinv (f01bl) is approximately proportional to .
The most difficult practical problem is the determination of the rank of the matrix (see pages 314–315 of
Peters and Wilkinson (1970)); only the singular value decomposition method gives a reliable indication of rank deficiency (see pages 134–151 of
Wilkinson and Reinsch (1971) and
nag_lapack_dgesvd (f08kb)). In
nag_matop_real_gen_pseudinv (f01bl) a tolerance,
t, is used to recognize ‘zero’ elements in the remaining matrix at each step in the factorization. The value of
t should be set at
times the bound on possible errors in individual elements of the original matrix. If the elements of
vary widely in their orders of magnitude, of course this presents severe difficulties. Sound decisions can only be made by somebody who appreciates the underlying physical problem.
If the condition number of is we expect to get figures wrong in the pseudo-inverse. An estimate of the condition number is usually given by .
Example
A complete program follows which outputs the maximum of the moduli of the ‘remaining’ elements at each step in the factorization, the rank, as determined by the given value of
t, and the transposed pseudo-inverse. Data and results are given for an example which is a
by
matrix of deficient rank in which the last column is a linear combination of the other four. Setting
t to
times the norm of the matrix, the rank is correctly determined as
and the pseudo-inverse is computed to full implementation accuracy.
Open in the MATLAB editor:
f01bl_example
function f01bl_example
fprintf('f01bl example results\n\n');
t = 2.99772935794301e-15;
a = [ 7, -2, 4, 9, 1.8;
3, 8, -4, 6, 1.3;
9, 6, 1, 5, 2.1;
-8, 7, 5, 2, 0.6;
4, -1, 2, 8, 1.3;
1, 6, 3, -5, 0.5];
anorm = norm(a);
t = anorm*eps('double');
[ainv, aijmax, irank, inc, ifail] = f01bl(t, a);
fprintf('Maximum element in reduced matrix at Kth stages\n');
fprintf(' K Modulus\n');
ind = [1:double(irank)+1];
fprintf('%4d %12.4e\n',[ind ; aijmax']);
fprintf('\nRank = %5d\n\n', irank);
fprintf('Pseudo-inverse\n');
disp(ainv');
f01bl example results
Maximum element in reduced matrix at Kth stages
K Modulus
1 9.0000e+00
2 9.3101e+00
3 8.7461e+00
4 5.6832e+00
5 2.8449e-16
Rank = 4
Pseudo-inverse
0.0178 -0.0118 0.0472 -0.0566 -0.0037 0.0384
-0.0216 0.0434 0.0294 0.0291 -0.0138 0.0343
0.0520 -0.0813 0.0139 0.0474 0.0166 0.0576
0.0237 0.0357 -0.0138 0.0305 0.0357 -0.0571
0.0072 -0.0014 0.0077 0.0050 0.0035 0.0073
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015