Re: [Numpy-discussion] Matrix dot product over an axis(for a 3d array/list of matrices)

2010-07-15 Thread Charles R Harris
On Thu, Jul 15, 2010 at 4:28 PM, David Warde-Farley wrote: > On 2010-07-15, at 4:31 PM, David Warde-Farley wrote: > > > If you need/want more speed than the solution Chuck proposed, you should > check out Cython and Tokyo. Cython lets you write loops that execute at C > speed, whereas Tokyo provid

Re: [Numpy-discussion] Matrix dot product over an axis(for a 3d array/list of matrices)

2010-07-15 Thread David Warde-Farley
On 2010-07-15, at 4:31 PM, David Warde-Farley wrote: > If you need/want more speed than the solution Chuck proposed, you should > check out Cython and Tokyo. Cython lets you write loops that execute at C > speed, whereas Tokyo provides a Cython level wrapper for BLAS (no need to go > through Py

Re: [Numpy-discussion] Matrix dot product over an axis(for a 3d array/list of matrices)

2010-07-15 Thread David Warde-Farley
On 2010-07-15, at 12:38 PM, Emmanuel Bengio wrote: > Hello, > > I have a list of 4x4 transformation matrices, that I want to "dot with" > another list of the same size (elementwise). > Making a for loop that calculates the dot product of each is extremely slow, > I thought that maybe it's due

Re: [Numpy-discussion] Matrix dot product over an axis(for a 3d array/list of matrices)

2010-07-15 Thread Emmanuel Bengio
I get about 60% of the original execution times for about any size of stack. On 15 July 2010 14:09, Charles R Harris wrote: > > > On Thu, Jul 15, 2010 at 12:00 PM, Emmanuel Bengio wrote: > >> Ok I get it. Thanks! >> >> Numpy syntax that works for me: >> numpy.sum(a[:,:,:,numpy.newaxis]*b[:,numpy

Re: [Numpy-discussion] Matrix dot product over an axis(for a 3d array/list of matrices)

2010-07-15 Thread Charles R Harris
On Thu, Jul 15, 2010 at 12:00 PM, Emmanuel Bengio 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 multidimen

Re: [Numpy-discussion] Matrix dot product over an axis(for a 3d array/list of matrices)

2010-07-15 Thread Emmanuel Bengio
Ok I get it. Thanks! Numpy syntax that works for me: numpy.sum(a[:,:,:,numpy.newaxis]*b[:,numpy.newaxis,:,:],axis=-2) On 15 July 2010 13:46, Charles R Harris wrote: > > > On Thu, Jul 15, 2010 at 11:32 AM, Emmanuel Bengio wrote: > >> >Could you place all Rot's into the same array and all the Tra

Re: [Numpy-discussion] Matrix dot product over an axis(for a 3d array/list of matrices)

2010-07-15 Thread Charles R Harris
On Thu, Jul 15, 2010 at 11:32 AM, Emmanuel Bengio wrote: > >Could you place all Rot's into the same array and all the Trans's into the > same array? > Well I guess since they're all the same size. I would just have to do > array(a). But the result of the dot product of two 3d arrays is most > une

Re: [Numpy-discussion] Matrix dot product over an axis(for a 3d array/list of matrices)

2010-07-15 Thread Emmanuel Bengio
>Could you place all Rot's into the same array and all the Trans's into the same array? Well I guess since they're all the same size. I would just have to do array(a). But the result of the dot product of two 3d arrays is most unexpected: >>> a = numpy.ones((4,5,6)) >>> a = numpy.ones((10,4,4)) >>>

Re: [Numpy-discussion] Matrix dot product over an axis(for a 3d array/list of matrices)

2010-07-15 Thread Charles R Harris
On Thu, Jul 15, 2010 at 10:38 AM, Emmanuel Bengio wrote: > Hello, > > I have a list of 4x4 transformation matrices, that I want to "dot with" > another list of the same size (elementwise). > Making a for loop that calculates the dot product of each is extremely > slow, > I thought that maybe it's

Re: [Numpy-discussion] Matrix dot product over an axis(for a 3d array/list of matrices)

2010-07-15 Thread Keith Goodman
On Thu, Jul 15, 2010 at 9:45 AM, Keith Goodman wrote: > On Thu, Jul 15, 2010 at 9:38 AM, Emmanuel Bengio wrote: >> >> Hello, >> >> I have a list of 4x4 transformation matrices, that I want to "dot with" >> another list of the same size (elementwise). >> Making a for loop that calculates the dot

Re: [Numpy-discussion] Matrix dot product over an axis(for a 3d array/list of matrices)

2010-07-15 Thread Keith Goodman
On Thu, Jul 15, 2010 at 9:38 AM, Emmanuel Bengio wrote: > > Hello, > > I have a list of 4x4 transformation matrices, that I want to "dot with" > another list of the same size (elementwise). > Making a for loop that calculates the dot product of each is extremely slow, > I thought that maybe it's

Re: [Numpy-discussion] Matrix dot product over an axis(for a 3d array/list of matrices)

2010-07-15 Thread John Salvatier
Could you place all Rot's into the same array and all the Trans's into the same array? If you have the first index of each array refer to which array it is numpy.dot should work fine, since numpy.dot just does the dot product over the second to last and last indexes. http://docs.scipy.org/doc/numpy

[Numpy-discussion] Matrix dot product over an axis(for a 3d array/list of matrices)

2010-07-15 Thread Emmanuel Bengio
Hello, I have a list of 4x4 transformation matrices, that I want to "dot with" another list of the same size (elementwise). Making a for loop that calculates the dot product of each is extremely slow, I thought that maybe it's due to the fact that I have thousands of matrices and it's a python fo