Moore-Penrose Generalized Inverse of Sparse Matrix

Is there any package that provides a function to calculate a generalized inverse of a sparse matrix? I know the LinearAlgebra package provides pinv and the SparseArrays provides capabilities for the creation of sparse matrices but have not been able to find any the calculate the psuedo-inverse of a sparse matrix

The pseudo-inverse of a sparse matrix would almost always be dense, wouldn’t it? Given that, it seems like it doesn’t make too much sense to have a sparse pinv—or if one does it would be equivalent to converting to sense first.


You almost never compute the inverse (pseudo or otherwise) of a sparse matrix because the inverse is generally dense.

On the other hand, you do compute the application of the inverse to a vector, and you often precompute factorizations that let you apply the inverse more quickly.

In the case of the ordinary inverse, you can apply a sparse inverse with A \ b and compute the factorization with lu(A) etcetera. In the case of the pseudoinverse, applying it computes the least-squares solution, and the corresponding factorization is usually qr.