[Numpy-discussion] help using np.einsum for stacked matrix multiplication
Dave Hirschfeld
dave.hirschfeld at gmail.com
Wed Oct 29 06:18:55 EDT 2014
Andrew Nelson writes:
>
> Dear list,I have a 4D array, A, that has the shape (NX, NY, 2, 2). I
wish to perform matrix multiplication of the 'NY' 2x2 matrices, resulting
in the matrix B. B would have shape (NX, 2, 2). I believe that np.einsum
would be up to the task, but I'm not quite sure of the subscripts I would
need to achieve this.
>
> Can anyone help, please?
>
> cheers,
> Andrew.
Sorry, I'm a little unclear on what is supposed to be multiplied with
what. You've got (NX x NY) 2x2 matricies, how do you end up with NX 2x2
matricies?
Perhaps if you show the code using loops with `np.dot` it will be clearer
how to translate to using `np.einsum`
-Dave
More information about the NumPy-Discussion
mailing list