[Numpy-discussion] Generalised inner product

Charles R Harris charlesr.harris at gmail.com
Mon May 19 09:03:09 EDT 2008


On Mon, May 19, 2008 at 4:23 AM, Peter Creasey <
p.e.creasey.00 at googlemail.com> wrote:

> Hi,
>
> Does numpy have some sort of generalised inner product? For example I have
> arrays
>
> a.shape = (5,6,7)
> b.shape = (8,7,9,10)
>
> and I want to perform a product over the 3rd axis of a and the 2nd of b,
> i.e.
>
> c[i,j,k,l,m] = sum (over x) of a[i,j,x] * b[k,x,l,m]
>
> I guess I could do it with swapaxes and numpy.dot or numpy.inner but I
> wondered if there was a general function.
>

Try tensordot.

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20080519/fde3ea7f/attachment.html>


More information about the NumPy-Discussion mailing list