[SciPy-user] fsolve with sparse matrices
Fri Apr 17 10:53:58 CDT 2009
2009/4/17 Jan Wicijowski <email@example.com>:
> Hi all!
> I would like to ask you, if anyone was ever confronted with solving
> nonlinear system with scipy.optimize.fsolve, with huge no. of equations,
> say 10000.
> The usual approach fails, because the size of jacobian matrix is
> proportional to the square of equations number. The paging kills my OS.
> In my problem, which is solving a nonlinear electrical circuit, the matrix
> is mostly zeros, which has immediately led me to trying sparse matrices.
> The first obstacle was numpy.atleast_1d contained in
> scipy.optimize.minpack.check_func - instead of preserving sparse matrix as
> is, it has a suprising behaviour of boxing the matrix in a list. This may
> be a bug, but I may post it elsewhere.
> Injecting custom function instead of scipy.optimize.minpack.check_func
> didn't work as well with fsolve. This wasn't surprising, as I guessed,
> that FORTRAN hybrj won't be able to deal with interfacing with scipy
> So, am I left with rewriting the original FORTRAN hybrj source to python,
> or is there somebody, who dealt with such problem?
> Jan Wicijowski
I was working on a similar problem (large sparse matrix, solving
optical Bloch-equations), and been planning to check out interfacing
with Fortran. The idea was, that I know the NAG library  works very
well for these kinds of calculations, just have to get the interface
between the sparse matrices and Fortran working. I checked it now, and
they have some documents showing how to use the NAG with F2PY .
Though they only use numpy, so no mention of sparse matrices, but NAG
This supposed to be just a heads up, need to check it out. Though in
my experience even the NAG people can be contacted, and they helped to
resolve issues (or extend functionality) before.
More information about the SciPy-user