On Wed, Jan 26, 2011 at 3:18 PM, Hanno Klemm <klemm@phys.ethz.ch> wrote:
Mark,
interesting idea. Given the fact that in 2-d euclidean metric, the
Einstein summation conventions are only a way to write out
conventional matrix multiplications, do you consider at some point to
include a non-euclidean metric in this thing? (As you have in special
relativity, for example)
Something along the lines:
eta = np.diag(-1,1,1,1)
a = np.array(1,2,3,4)
b = np.array(1,1,1,1)
such that
einsum('i,i', a,b, metric=eta) = -1 + 2 + 3 + 4
This particular example is already doable as follows:
>>> eta = np.diag([-1,1,1,1])
>>> eta
array([[-1, 0, 0, 0],
[ 0, 1, 0, 0],
[ 0, 0, 1, 0],
[ 0, 0, 0, 1]])
>>> a = np.array([1,2,3,4])
>>> b = np.array([1,1,1,1])
>>> np.einsum('i,j,ij', a, b, eta)
8
I think that's right, did I understand you correctly?
Cheers,
Mark