[Numpy-discussion] einsum

josef.pktd at gmail.com josef.pktd at gmail.com
Wed Jan 26 20:23:01 EST 2011

On Wed, Jan 26, 2011 at 7:35 PM, Benjamin Root <ben.root at ou.edu> wrote:
> On Wednesday, January 26, 2011, Gael Varoquaux
> <gael.varoquaux at normalesup.org> wrote:
>> On Thu, Jan 27, 2011 at 12:18:30AM +0100, Hanno Klemm wrote:
>>> 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)
>> In my experience, Einstein summation conventions are quite
>> incomprehensible for people who haven't studies relativity (they aren't
>> used much outside some narrow fields of physics). If you start adding
>> metrics, you'll make it even harder for people to follow.
>> My 2 cents,
>> Gaël
> Just to dispel the notion that Einstein notation is only used in the
> study of relativity, I can personally attest that Einstein notation is
> used in the field of fluid dynamics and some aspects of meteorology.
> This is really a neat idea and I support the idea of packaging it as a
> separate module.

So, if I read the examples correctly we finally get dot along an axis

np.einsum('ijk,ji->', a, b)
np.einsum('ijk,jik->k', a, b)

or something like this.

the notation might require getting used to but it doesn't look worse
than figuring out what tensordot does.

The only disadvantage I see, is that choosing the axes to operate on
in a program or function requires string manipulation.


> Ben Root
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion

More information about the NumPy-Discussion mailing list