| Language Reference |
provides complete orthogonal decomposition by Householder transformations
The GINV function computes the Moore-Penrose inverse
by using the singular value decomposition of
.
Using complete orthogonal decomposition to compute
usually requires far fewer floating-point operations.
However, it can be slightly more sensitive to rounding
errors, which can disturb the detection of the true
rank of
, than singular value decomposition.
The following example demonstrates the use of the APPCORT subroutine, as well as the resulting output:
/* Only four linearly independent columns */
A = {1 0 1 0 0,
1 0 0 1 0,
1 0 0 0 1,
0 1 1 0 0,
0 1 0 1 0,
0 1 0 0 1 };
m = nrow(A);
n = ncol(A);
call comport(q,r,p,piv,lindep,A);
fullR = r // j(m-n, n, 0);
perm = i(n);
perm[piv,] = i(n);
/* recover A from factorization */
A2 = q*fullR*p`*perm`;
reset fuzz;
print A2;
/* compute Moore-Penrose generalized inverse */
rankA = n - lindep;
subR = R[1:rankA, 1:rankA];
fullRinv = j(n, n, 0);
fullRinv[1:rankA, 1:rankA] = inv(subR);
Ainv = perm*p*fullRinv*q[,1:n]`;
print Ainv;
/* verify generalized inverse */
eps = 1e-12;
if any(A*Ainv*A-A > eps) |
any(Ainv*A*Ainv-Ainv > eps) |
any((A*Ainv)`-A*Ainv > eps) |
any((Ainv*A)`-Ainv*A > eps) then
print "Pseudoinverse conditions not satisfied";
else
print "Pseudoinverse conditions satisfied";
A2
1 0 1 0 0
1 0 0 1 0
1 0 0 0 1
0 1 1 0 0
0 1 0 1 0
0 1 0 0 1
AINV
0.2666667 0.2666667 0.2666667 -0.066667 -0.066667 -0.066667
-0.066667 -0.066667 -0.066667 0.2666667 0.2666667 0.2666667
0.4 -0.1 -0.1 0.4 -0.1 -0.1
-0.1 0.4 -0.1 -0.1 0.4 -0.1
-0.1 -0.1 0.4 -0.1 -0.1 0.4
Pseudoinverse conditions satisfied
Copyright © 2009 by SAS Institute Inc., Cary, NC, USA. All rights reserved.