[SciPy-User] [SciPy-user] Matrix Exponentials For Very Large Sparse Matrices

Joshua Stults joshua.stults@gmail....
Mon Jan 25 16:18:20 CST 2010

On Mon, Jan 25, 2010 at 5:04 PM, Dylan Gorman <dgorman@berkeley.edu> wrote:
> Joshua,
> Thanks for the expokit suggestion. I seem to have gotten it installed
> on my Mac OS X Leopard system. The presentation you linked indicated
> that I need to change the call to matvec in expokit.f to include n, so
> I first replaced all instances of 'call matvec(' in expokit.f with
> 'call matvec(n,', but I'm not sure exactly when this should be done. I
> then executed:
> f2py -m expokit -h expokit.pyf expokit.f
> f2py -c expokit.pyf expokit.f --link-lapack-opt
> which produced the expokit.so file.
> However, now I'm trying to reproduce the example given in the
> presentation you linked, and the call to dmexpv() does not seem to
> work. It wants a lot of arguments:
>  >>> from scipy import *
>  >>> from expokit import dmexpv
>  >>> dmexpv()
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> TypeError: expokit.dmexpv() takes at least 11 arguments (0 given)
> The most confusing thing it wants me to pass is matvec, which is
> apparently an external matrix-vector multiplication function. I can't
> seem to figure out how to get this function to work. Tthe presentation
> uses a much simpler call:
> dmexpv(m, t, v, wsp, iwsp, A)
> Can you offer any insight into this problem?

Maybe a little, the Krylov methods will require a function that gives
the action of your matrix on a vector, just like a Krylov method for
solving a linear system would.  F2py usually does a pretty good job of
generating doc strings that give all the arguments and their
dimensions, have you taken a look at

print dmexpv.__doc__


> Thank you,
> Dylan
> On Jan 22, 2010, at 6:47 PM, Joshua Stults wrote:
>> On Fri, Jan 22, 2010 at 8:58 PM, Burak1327
>> <burak.o.cankurtaran@alumni.uts.edu.au> wrote:
>>> The most simple approximations are polynomial expansions.
>>> Chebychev polynomials are GREAT, even a 2nd order
>>> Taylor expansion is good enough in a lot of cases, specific to
>>> your type of problem.
>>> Which leads to actual scipy discussion. I'm no scipy expert, but
>>> the above mentioned methods are probably in the library.
>> Here's an example of using f2py to compile expokit (see slides 15 -
>> 21):
>> http://sf.anu.edu.au/~mhk900/Python_Workshop/short.pdf
>> Expokit website: http://www.maths.uq.edu.au/expokit/
>> Uses Krylov methods for sparse matrices; these will use more memory
>> than the polynomial expansion methods that Burak mentioned.

Joshua Stults
Website: http://j-stults.blogspot.com

More information about the SciPy-User mailing list