问题
I have a scipy.sparse.csc_matrix
sparse matrix A
of shape (N, N)
where N
is about 15000
. A
has less than 1 %
non-zero elements.
I need to solve for Ax=b
as time efficient as possible.
Using scipy.sparse.linalg.spsolve
takes about 350 ms
using scikit-umfpack
.
scipy.sparse.linalg.gmres
is with 50 ms
significantly faster when using an ILU
preconditioner. Without preconditioner it takes more than a minute.
However, creating the preconditioner takes about 1.5 s
. Given that, it would be more efficient to just use scipy.sparse.linalg.spsolve
.
I'm creating the preconditioner M
with
from scipy.sparse.linalg import LinearOperator, spilu
ilu = spilu(A)
Mx = lambda x: ilu.solve(x)
M = LinearOperator((N, N), Mx)
Is there a more efficient way of doing this, such that using scipy.sparse.linalg.gmres
would be more profitable?
来源:https://stackoverflow.com/questions/46876951/sparse-matrix-solver-with-preconditioner