| Language Reference |
computes the generalized inverse
b=ginv(x)*y;
This solution has minimum Projection matrices can be formed by specifying
GINV
(row space) or
GINV
(column space).
The following program demonstrates some common uses of the GINV function:
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 };
/* find generalized inverse */
Ainv = ginv(A);
/* find LS solution: min |Ax-b|^2 */
b = { 3, 2, 4, 2, 1, 3 };
x = Ainv*b;
/* form projection matrix onto row space.
Note P = P` and P*P = P */
P = Ainv*A;
/* find numerical rank of A */
rankA = round(trace(P));
reset fuzz;
print Ainv, rankA, x, P;
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
RANKA
4
X
2
1
1
0
2
P
0.8 -0.2 0.2 0.2 0.2
-0.2 0.8 0.2 0.2 0.2
0.2 0.2 0.8 -0.2 -0.2
0.2 0.2 -0.2 0.8 -0.2
0.2 0.2 -0.2 -0.2 0.8
If
is an
matrix, then,
in addition to the memory allocated for the return matrix, the GINV function
temporarily allocates an
array for performing its computation.
Copyright © 2009 by SAS Institute Inc., Cary, NC, USA. All rights reserved.