3

I have a sparse csr matrix, sparse.csr_matrix(A), for which I would like to compute the matrix rank

There are two options that I am aware of: I could convert it to numpy matrix or array (.todense() or .toarray()) and then use np.linalg.matrix_rank(A), which defeats my purpose of using the sparse matrix format, since I have extremely large matrices. The other option is to compute a SVD decomposition (sparse matrix svd in python) for a matrix, then deduce matrix rank from this.

Are there any other options for this? Is there currently a standard, most efficient way for me to compute the rank of a sparse matrix? I am relatively new to doing linear algebra in python, so any alternatives and suggestions with that in mind would be most helpful.

bark
  • 51
  • 4
  • Try studying and proving algorithms which work for matrices in sparse form, and decide which ones are the best. – Ṃųỻịgǻňạcểơửṩ Feb 25 '19 at 01:48
  • 3
    @Ṁữŀlɪgắnậcễơưṩᛗ Thank you for taking the time to reply. This is currently what I am doing, but I am looking for some more guidance about what are the standard options available already. This is only one component of a larger problem I am working on, so I would prefer to spend less time researching and comparing algorithms, unless necessary. – bark Feb 25 '19 at 02:18
  • See [scipy.linalg.interpolative.estimate_rank](https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.interpolative.estimate_rank.html) – denis Jun 10 '19 at 17:02
  • Thank you for your reply, Denis, but I am not looking for an estimate of rank, but an exact value. I have resorted to using Linbox to resolve this issue. – bark Jun 11 '19 at 19:51

1 Answers1

2

I have been using .todense() method and using rank method of numpy to calculate the answers.

It has given me a satisfactory answer till now.

Kartikey Singh
  • 864
  • 10
  • 23