[SciPy-User] faster expm

Pauli Virtanen pav@iki...
Sat Oct 30 09:24:01 CDT 2010

Sat, 30 Oct 2010 10:02:57 -0400, Craig Jones wrote:
> I have been using scipy etc for just over a year now and am now
> exclusively using it.  One application I have been doing requires a
> matrix exponential (in lieu of integration).  In Matlab it was very fast
> but using scipy.linalg.expm it is quite slow (as the actual algorithm is
> implemented in python).  In fact about 50% of the code is spent in expm.
>  My matrix is typically 9x9 to 12x12 and is about 50% zeros (most
> nonzero are along the diagonal and just off diagonal).

Well, it's also quite possible the difference is just that the algorithm 
in Scipy is not optimal and does more matrix products than necessary, 
rather than the problem being in Python overhead. Would require 
benchmarking of the expm code. Moreover, Scipy's expm always uses a fixed 
degree for the Pade approximant, which might not be the optimal choice.

Pauli Virtanen

More information about the SciPy-User mailing list