2
votes

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.

1
Try studying and proving algorithms which work for matrices in sparse form, and decide which ones are the best. - Ṃųỻịgǻňạcểơửṩ
@Ṁữŀ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
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

1 Answers

1
votes

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.