简体   繁体   English

稀疏矩阵Python的等级

[英]Rank of Sparse matrix Python

I have a sparse csr matrix, sparse.csr_matrix(A), for which I would like to compute the matrix rank 我有一个稀疏的csr矩阵sparse.csr_matrix(A),我想为其计算矩阵等级

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. 我知道两个选项:我可以将其转换为numpy矩阵或数组(.todense()或.toarray()),然后使用np.linalg.matrix_rank(A),这违反了我使用稀疏模型的目的矩阵格式,因为我有非常大的矩阵。 The other option is to compute a SVD decomposition ( sparse matrix svd in python ) for a matrix, then deduce matrix rank from this. 另一个选择是计算矩阵的SVD分解( 在python中稀疏矩阵svd ),然后从中推导出矩阵等级。

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. 我在python中做线性代数相对较新,因此考虑到这一点的任何替代方法和建议将是最有帮助的。

I have been using .todense() method and using rank method of numpy to calculate the answers. 我一直在使用.todense()方法和rank method of numpy来计算答案。

It has given me a satisfactory answer till now. 到目前为止,它给了我令人满意的答复。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM