[Numpy-discussion] einsum

Mark Wiebe mwwiebe at gmail.com
Wed Jan 26 23:06:49 EST 2011


On Wed, Jan 26, 2011 at 5:23 PM, <josef.pktd at gmail.com> wrote:

> <snip>
> 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.
>

I thought of various extensions to the notation, but the idea is tricky
enough as is I think. Decoding a regex-like syntax probably wouldn't help.

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

One possibility would be for the Python exposure to accept lists or tuples
of integers.  The subscript 'ii' could be [(0,0)], and 'ij,jk->ik' could be
[(0,1), (1,2), (0,2)].  Internally it would convert this directly to a
C-string to pass to the API function.

-Mark
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20110126/59ce9232/attachment.html>


More information about the NumPy-Discussion mailing list