I am trying to figure out the fastest method to find the determinant of sparse symmetric and real matrices in python. using scipy sparse
module but really surprised that there is no determinant function. I am aware I could use LU factorization to compute determinant but don't see a easy way to do it because the return of scipy.sparse.linalg.splu
is an object and instantiating a dense L and U matrix is not worth it - I may as well do sp.linalg.det(A.todense())
where A
is my scipy sparse matrix.
I am also a bit surprised why others have not faced the problem of efficient determinant computation within scipy. How would one use splu
to compute determinant?
I looked into pySparse
and scikits.sparse.chlmod
. The latter is not practical right now for me - needs package installations and also not sure sure how fast the code is before I go into all the trouble.
Any solutions? Thanks in advance.
eigs(A, 1, which="SM", return_eigenvectors=False)
orsvds(A, 1, which="SM", return_singular_vectors=False)
may be a good indicator of whether or not your matrix is singular. I'm reluctant to say that it will always work though... – IanHpySparce
, it has asuperlu
interface, which implements LU-factorisation via partial pivoting, why does it not feet your needs? – alko