rankMM function

Simple Matrix Rank

Simple Matrix Rank

Compute the rank of a matrix A in simple way, based on the SVD, svd(), and the same as Matlab .

rankMM(A, tol = NULL, sv = svd(A, 0, 0)$d)

Arguments

  • A: a numerical matrix, maybe non-square. When sv is specified, only dim(A) is made use of.
  • tol: numerical tolerance (compared to singular values). By default, when NULL, the tolerance is determined from the maximal value of sv and the computer epsilon.
  • sv: vector of non-increasing singular values of A, (to be passed if already known).

See Also

There are more sophisticated proposals for computing the rank of a matrix; for a couple of those, see rankMatrix in the list("Matrix") package.

Returns

an integer from the set 0:min(dim(A)).

Author(s)

Martin Maechler, Date: 7 Apr 2007

Examples

rankMM # - note the simple function definition hilbert <- function(n) { i <- seq_len(n); 1/outer(i - 1L, i, "+") } hilbert(4) H12 <- hilbert(12) rankMM(H12) # 11 - numerically more realistic rankMM(H12, tol=0) # -> 12 ## explanation : round(log10(svd(H12, 0,0)$d), 1)