chkginv {lazy.mat} | R Documentation |
Check if the the second matrix is a generalized inverse of the first one, or vice versa.
chkginv(A, Ainv, eps = NULL, print = 0)
A |
matrix |
Ainv |
Possible generalized inverse of A |
eps |
criterion for zero |
print |
= 1 to print the result |
This function checks if the following four conditons are met.
g1) A - A %*% Ainv %*% A
g2) Ainv - Ainv %*% A %*% Ainv
g3) A %*% Ainv - t(A %*% Ainv)
g4) Ainv %*% A - t(Ainv %*% A)
In addition, when the input matrix is square, the following two conditons
are added.
g01) I - A %*% Ainv
g02) I - Ainv %*% A
For each condition above, the maximum of the absolute values
will be compared to eps
to see if it can be regaeded as zero.
The default value of eps
is
max(abs(c(diag(Ainv),diag(A)))) * sqrt(.Machine$double.eps)
.
A list of:
check=list(g1,g2,g3,g4,g01,g02) where g1, g2,... are either OK or NG
maxad=list(g1,g2,g3,g4,g01,g02) where g1, g2,... are the max absolute value
of each criterion.
chkginv( demomat(3,3), matSwp(demomat(3,3)) ) # called from Ginv or matSwp A=demomat(9,4)/100; A=t(A)%*%A; Ainv=Ginv(A,chkginv=2)