[SciPy-User] iterative matrix methods seem slow
Richard Sharp
richsharp at stanford.edu
Fri Jun 24 14:58:25 EDT 2011
Thanks Pauli,
> I don't see you passing in a preconditioner here -- it goes in via
> the M= parameter of gmres.
Right, I had one in there to begin with, but removed it later since it
seemed to slow down the convergence.
> On preconditioners: If you want "automatic" preconditioners, you can
> try the following:
>
> http://docs.scipy.org/doc/scipy/reference/sparse.linalg.html#scipy.sparse.linalg.spilu
Thanks for this. Using the incomplete as follows LU I was able to cut
the iterative runtimes from 1700s to 30s
P = scipy.sparse.linalg.spilu(matrix, drop_tol=1e-5)
M_x = lambda x: P.solve(x)
M = scipy.sparse.linalg.LinearOperator((n * m, n * m), M_x)
result = scipy.sparse.linalg.lgmres(matrix, b, tol=1e-4, M=M)[0]
But the spilu factors in about 3s, solves in 0.1s and seems to give a
result that's very close to my continuous solution, so I'm using that
now with no memory or runtime problems:
P = scipy.sparse.linalg.spilu(matrix, drop_tol=1e-5)
result = P.solve(b)
Thanks for the guidance and help!
Rich
More information about the SciPy-User
mailing list