I did not try it, but I assume that you can build a stack of diagonal matrices 
as a MxNxN array and use tensordot with the matrix v (and it's inverse). The 
trivial way to accelerate the loop is to calculate in inverse of v before the 
loop.

   Nadav
________________________________________
From: [email protected] [[email protected]] 
on behalf of Till Stensitzki [[email protected]]
Sent: 28 January 2013 18:31
To: [email protected]
Subject: [Numpy-discussion] Matrix Expontial for differenr t.

Hi group,
is there a faster way to calculate the
matrix exponential for different t's
than this:

def sol_matexp(A, tlist, y0):
    w, v = np.linalg.eig(A)
    out = np.zeros((tlist.size, y0.size))
    for i, t in enumerate(tlist):
        sol_t = np.dot(v,np.diag(np.exp(-w*t))).dot(np.linalg.inv(v)).dot(y0)
        out[i, :] =  sol_t
    return out

This is the calculates exp(-Kt).dot(y0) for a list a ts.

greetings
Till

_______________________________________________
NumPy-Discussion mailing list
[email protected]
http://mail.scipy.org/mailman/listinfo/numpy-discussion


_______________________________________________
NumPy-Discussion mailing list
[email protected]
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to