def exp(self, x, u):
// TODO: Check which method is faster depending on n, k.
x_inv_u = np.linalg.solve(x, u)
if self._k > 1:
e = np.zeros(np.shape(x))
for i in range(self._k):
e[i] = sp.linalg.expm(x_inv_u[i])
else:
e = sp.linalg.expm(x_inv_u)
return multiprod(x, e)
// This alternative implementation is sometimes faster though less
// stable. It can return a matrix with small negative determinant.
// c = la.cholesky(x)
// c_inv = la.inv(c)