简体   繁体   English

计算 scipy.sparse 矩阵的伪逆的列子集的最快方法

[英]Fastest way to compute a subset of columns of the pseudoinverse of a scipy.sparse matrix

I am looking for the best way to compute a subset of the columns of the pseudoinverse of a sparse matrix A .我正在寻找计算稀疏矩阵A的伪逆的列子集的最佳方法。 Here are some relevant facts:以下是一些相关事实:

  1. A is a sparse NxN matrix that has a single zero eigenvalue with known eigenvector A是一个稀疏的NxN矩阵,它有一个已知特征向量的零特征值

  2. I only need M < N/2 columns of the pseudoinverse我只需要伪逆的M < N/2

  3. The pseudoinverse is a dense matrix伪逆是一个稠密矩阵

I am currently using scipy.linalg.lstsq(A,Id) (where Id is an NxM submatrix of the NxN identity matrix), but I suspect there is a better way to do this.我目前正在使用scipy.linalg.lstsq(A,Id) (其中IdNxN单位矩阵的NxM子矩阵),但我怀疑有更好的方法来做到这一点。

Any suggestions will be appreciated.任何建议将不胜感激。

Update: Since there is only one zero eigenvalue, it turns out to be faster to create an invertible augmented (N+1)x(N+1) matrix and use scipy.linalg.solve .更新:由于只有一个零特征值,结果证明创建可逆增广(N+1)x(N+1)矩阵并使用scipy.linalg.solve However, this is still not taking advantage of the sparsity of A .然而,这仍然没有利用A的稀疏性。

You are looking for scipy.sparse.linalg.svds which will “Compute the largest k singular values/vectors for a sparse matrix” (though that's a bit misleading since it'll do that for dense matrixes too!).您正在寻找scipy.sparse.linalg.svds ,它将“为稀疏矩阵计算最大的k奇异值/向量”(尽管这有点误导,因为它也会为密集矩阵这样做!)。

It uses the Arnoldi iteration as implemented in the popular Fortran77 package, ARPACK, which in turn has wrappers in most math systems (Matlab, R, etc.).它使用流行的 Fortran77 包 ARPACK 中实现的Arnoldi 迭代,而后者又在大多数数学系统(Matlab、R 等)中具有包装器。

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

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