[Numpy-discussion] help using np.einsum for stacked matrix multiplication

2014-10-29 Thread Andrew Nelson
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

Re: [Numpy-discussion] help using np.einsum for stacked matrix multiplication

2014-10-29 Thread Dave Hirschfeld
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

Re: [Numpy-discussion] help using np.einsum for stacked matrix multiplication

2014-10-29 Thread Eelco Hoogendoorn
You need to specify your input format. Also, if your output matrix misses the NY dimension, that implies you wish to contract (sum) over it, which contradicts your statement that the 2x2 subblocks form the matrices to multiply with. In general, I think it would help if you give a little more

Re: [Numpy-discussion] help using np.einsum for stacked matrix multiplication

2014-10-29 Thread Sebastian Berg
On Mi, 2014-10-29 at 20:39 +1100, Andrew Nelson wrote: 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

Re: [Numpy-discussion] help using np.einsum for stacked matrix multiplication

2014-10-29 Thread Sebastian Berg
On Mi, 2014-10-29 at 13:05 +0100, Sebastian Berg wrote: On Mi, 2014-10-29 at 20:39 +1100, Andrew Nelson wrote: 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

Re: [Numpy-discussion] help using np.einsum for stacked matrix multiplication

2014-10-29 Thread Andrew Nelson
On Wed, Oct 29, 2014 at 10:39 AM, Andrew Nelson andyf...@gmail.com wrote: 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

Re: [Numpy-discussion] help using np.einsum for stacked matrix multiplication

2014-10-29 Thread Alexander Belopolsky
On Wed, Oct 29, 2014 at 5:39 AM, Andrew Nelson andyf...@gmail.com wrote: 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). What you are looking for is