matSwp {lazy.irtx} | R Documentation |
Matrix Sweep Operator
matSwp(A, loc = c(1:nrow(A)), eps = 1e-08, nopermute = 0, chkginv = 0, debug = 0, history = 0)
A |
a matrix to be sweeped. |
loc |
vector consisting of the pivot locations. |
eps |
small value to check if the pivot is 0. |
nopermute |
=1 to avoid permuting rows/cols when inverting A. |
chkginv |
= 1 to check if the resulting g-inverse is genuin. |
debug |
= 1 to print intermediate result. |
history |
= 1 to return the permutation matrix D |
By default, inv(A) will be calculated by permuting colums of A
in order to avoid zero pivots as much as possible.
In this case, if P is the permutation matrix,
inv(A) = P' inv(A P)
If history=1 is given, a list of A=matSwp(A) and P=Pmatrix will be
returned.
Can be used with a character matrix.
A matrix swept or a list of A matrix swept and permutation matrix.
Goodnight, J.H. (1979) Tutorial on the SWEEP operator.
The Amarican Statistician, 33, 3, 149-158.
Dempster,A.P. (1969) Elements of Continuous Multivariate Analysis.
Addison- Wesley Publishing Co.,Inc.
M <- matrix(c(1,2,3,3,2,1,4,5,2),3) Minv <- matSwp(M) Minv-matSwp(M,1:3) Minv-matSwp(M,c(3,1,2)) M-matSwp( matSwp(M,1), 1 ) matSwp(demomat(3,3),chkginv=1)