[Numpy-discussion] Matrix dot product over an axis(for a 3d array/list of matrices)
Emmanuel Bengio
bengioe@gmail....
Thu Jul 15 13:30:44 CDT 2010
I get about 60% of the original execution times for about any size of stack.
On 15 July 2010 14:09, Charles R Harris <charlesr.harris@gmail.com> wrote:
>
>
> On Thu, Jul 15, 2010 at 12:00 PM, Emmanuel Bengio <bengioe@gmail.com>wrote:
>
>> Ok I get it. Thanks!
>>
>> Numpy syntax that works for me:
>> numpy.sum(a[:,:,:,numpy.newaxis]*b[:,numpy.newaxis,:,:],axis=-2)
>>
>>
> The leading "..." gives the same thing, but iterates over all the leading
> indicies in case you want multidimensional arrays of matrices ;) You can
> also use the sum method which might be a bit more economical:
>
> (a[:,:,:,numpy.newaxis]*b[:,numpy.newaxis,:,:]).sum(axis=-2)
>
> How do the execution times compare?
>
> <snip>
>
> Chuck
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>
--
Emmanuel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20100715/5a44a6a6/attachment.html
More information about the NumPy-Discussion
mailing list