Skip to content
Prev 69144 / 398502 Next

rank of a matrix

Have you considered something like the following:

matrix.rank <- function(A, eps=sqrt(.Machine$double.eps)){
	sv. <- abs(svd(A)$d)
	sum((sv./max(sv.))>eps)
}

matrix.rank(A=diag(3))
#[1] 3
A <- array(c(1,1,0,0), dim=c(2,2))
matrix.rank(A)
#[1] 1
mingan wrote: