Precondition Matrix Solver

I have a scipy.sparse.csc_matrixsparse Aform matrix (N, N), where Nabout 15000. Ahas fewer 1 %nonzero elements.

I need to decide for the Ax=bmost effective time.

Using scipy.sparse.linalg.spsolvetakes about 350 msusing scikit-umfpack. scipy.sparse.linalg.gmresWorks 50 msmuch faster when using a preconditioner ILU. Without a precondition, this takes more than a minute.

However, creating a preconditioner takes about 1.5 s. Given this, it would be more efficient to use scipy.sparse.linalg.spsolve.

I am creating a preconditioner Musing

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 to do this, so that use scipy.sparse.linalg.gmreswould be more profitable?

+4
source share

Source: https://habr.com/ru/post/1687982/


All Articles