Recommended direct solver for sparse positive definite linear system in scipy? -
i'm sorry if explained in scipy.sparse documentation.
when using scipy, function recommend using solve sparse positive definite linear system of equations? want use direct method, , want columns reordered preserve sparsity as possible in cholesky factorization of coefficient matrix. ideally i'd able experiment various options reordering.
does direct solver sparse positive definite systems exist in scipy.sparse? scikit.sparse way go?
scipy.sparse.linalg.spsolve clear enough, seems speed must
pip install
scikit-umfpack
or else
- build umfpack , amd suitesparse
- then rebuild scipy source,
[umfpack] umfpack_libs = ...
in site.cfg .
otherwise scipy.sparse.linalg defaults slower superlu.
is scikit.sparse way go?
compared what, criteria ? if c / c++ enough you, use suitesparse directly. tool depends on you're comfortable with, , on users: one, two, many. maybe better visualization project more faster spsolve.
some pretty obvious pluses , minuses of scipy.sparse:
+ python fast development, data input -- matrices -- visualize
+ several packages have built on scipy.sparse; ask around in application area (which ?)
- rough edges (matrices pain), afaik no wiki collect hints , code snippets
- layers upon layers, scipy.sparse -- suitesparse -- ... blas ... make timing , debugging tough.
fwiw, solver times vary lot on imac. these default args, without umfpack.
(this not realistic testcase; satisficing enough.)
x = sparse.rand( m, n, dens, format="csr" ) = 1e-6 * sparse.eye(m) + x * x.t linalg solvers( a, b ) (5000, 5000) density 0.42 % -- 51 msec spsolve 5 msec bicg 3 msec bicgstab 2 msec cg 4 msec cgs 3 msec gmres 4 msec lgmres 1 msec minres 6 msec qmr 5 msec lsmr (5000, 5000) density 0.84 % -- 428 msec spsolve 12 msec bicg 7 msec bicgstab 5 msec cg 10 msec cgs 6 msec gmres 8 msec lgmres 2 msec minres 13 msec qmr 12 msec lsmr (5000, 5000) density 1.3 % -- 1462 msec spsolve 16 msec bicg 9 msec bicgstab 7 msec cg 11 msec cgs 7 msec gmres 10 msec lgmres 1 msec minres 18 msec qmr 14 msec lsmr
Comments
Post a Comment