Skip to content

rank of a matrix

4 messages · mingan, Spencer Graves, Uwe Ligges +1 more

#
how do I check the rank of a matrix ?

say

A=  1   0   0
     0   1   0

then rank(A)=2

what is this function?

thanks


  I did try help.search("rank"), but all the returned help information 
seem irrelevant to what I want.

  I would like to know how people search for help information like this.






rank(base)              Sample Ranks
SignRank(stats)         Distribution of the Wilcoxon Signed Rank
                        Statistic
Wilcoxon(stats)         Distribution of the Wilcoxon Rank Sum
                        Statistic
friedman.test(stats)    Friedman Rank Sum Test
kruskal.test(stats)     Kruskal-Wallis Rank Sum Test
pairwise.wilcox.test(stats)
                        Pairwise Wilcoxon rank sum tests
wilcox.test(stats)      Wilcoxon Rank Sum and Signed Rank Tests
#
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:

            
#
mingan wrote:

            
Well, calculating the rank is from the computational point of view a 
very hard problem.
See ?qr

Uwe Ligges
#
mingan wrote on 5/4/2005 8:54 AM:
See ?qr or ?svd.

tol <- 1e-7
qr(A, tol)$rank
sum(svd(A)$d > tol)

--sundar