rankMatrix {Matrix} | R Documentation |
Compute the rank of matrix, a well-defined functional in theory, somewhat ambigous in practice. We provide several methods, the default corresponding to Matlab's definition.
rankMatrix(x, tol = NULL, method = c("tolNorm2", "qrLINPACK", "useGrad", "maybeGrad"), sval = svd(x, 0, 0)$d)
x |
numeric matrix, of dimension n x m, say. |
tol |
nonnegative number specifying a tolerance for
“practically zero” with specific meaning depending on
|
method |
a character string specifying the computational method, can be abbreviated:
|
sval |
numeric vector of non-increasing singular values of
|
positive integer in 1:min(dim(x))
, with attributes detailing
the method used.
Martin Maechler; for the "*Grad" methods, building on suggestions by Ravi Varadhan.
rankMatrix(cbind(1, 0, 1:3)) # 2 (meths <- eval(formals(rankMatrix)$method)) ## a "border" case: H12 <- Hilbert(12) rankMatrix(H12, tol = 1e-20) # 12; but 11 with default method & tol. sapply(meths, function(.m.) rankMatrix(H12, method = .m.)) ## tolNorm2 qrLINPACK useGrad maybeGrad ## 11 12 11 11 ## "sparse" case: M15 <- kronecker(diag(x=c(100,1,10)), Hilbert(5)) sapply(meths, function(.m.) rankMatrix(M15, method = .m.)) #--> all 15, but 'useGrad' has 14.