[SciPy-user] Dot in greater than 2D

josef.pktd@gmai... josef.pktd@gmai...
Mon Jun 15 13:14:13 CDT 2009

```On Mon, Jun 15, 2009 at 1:52 PM, Brian Lewis<brian.lewis17@gmail.com> wrote:
> How is dot defined for matrices with dimension greater than 2?  The
> docstring says:
>
>     dot(a,b)
>     Returns the dot product of a and b for arrays of floating point types.
>     Like the generic numpy equivalent the product sum is over
>     the last dimension of a and the second-to-last dimension of b.
>     NB: The first argument is not conjugated.

What dot does this refer to? a namespace would be useful information

>>> np.dot(np.ones((5,3,2)),np.ones((10,2,20))).shape
(5, 3, 10, 20)

Josef

>
> which seemed a bit cryptic to me.  Is there any documentation on this with
> an example using arrays with greater than 2 dimensions? On first read, it
> seemed like only the summed dimensions needed to agree.  So,
>
> a.shape == (5,3,2)
> b.shape == (10,2,20)
>
> but I get that the objects are not aligned.  On second read, it seemed like
> maybe dot would apply itself recursively.  So maybe
>
> a.shape == (5,3,2)
> b.shape == (3,2,5)
>
> would work since a[:,:,i] has shape (5,3) and is compatible (via dot) with
> b[:,i,:] whose shape is (3,5). Not so surprisingly, the objects are also not
> aligned.
>
> Apologies for my naivety.
>
> _______________________________________________
> SciPy-user mailing list
> SciPy-user@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
>
```