# [Numpy-discussion] Matrix Expontial for differenr t.

Nadav Horesh nadavh@visionsense....
Mon Jan 28 10:48:27 CST 2013

```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: numpy-discussion-bounces@scipy.org [numpy-discussion-bounces@scipy.org] on behalf of Till Stensitzki [mail.till@gmx.de]
Sent: 28 January 2013 18:31
To: numpy-discussion@scipy.org
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
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

```

More information about the NumPy-Discussion mailing list