[Numpy-discussion] Multiply along axis

2011-06-29 Thread Robert Elsner
Hello everyone, I would like to solve the following problem (preferably without reshaping / flipping the array a). Assume I have a vector v of length x and an n-dimensional array a where one dimension has length x as well. Now I would like to multiply the vector v along a given axis of a. Some

Re: [Numpy-discussion] Multiply along axis

2011-06-29 Thread Robert Elsner
Oh and I forgot to mention: I want to specify the axis so that it is possible to multiply x along an arbitrary axis of a (given that the lengths match). On 29.06.2011 16:32, Robert Elsner wrote: Hello everyone, I would like to solve the following problem (preferably without reshaping /

Re: [Numpy-discussion] Multiply along axis

2011-06-29 Thread Skipper Seabold
On Wed, Jun 29, 2011 at 10:32 AM, Robert Elsner ml...@re-factory.de wrote: Hello everyone, I would like to solve the following problem (preferably without reshaping / flipping the array a). Assume I have a vector v of length x and an n-dimensional array a where one dimension has length x

Re: [Numpy-discussion] Multiply along axis

2011-06-29 Thread Robert Elsner
Yeah great that was spot-on. And I thought I knew most of the slicing tricks. I combined it with a slice object so that idx_obj = [ None for i in xrange(a.ndim) ] idx_obj[axis] = slice(None) a * x[idx_object] works the way I want it. Suggestions are welcome but I am happy with the quick

Re: [Numpy-discussion] Multiply along axis

2011-06-29 Thread josef . pktd
On Wed, Jun 29, 2011 at 11:05 AM, Robert Elsner ml...@re-factory.de wrote: Yeah great that was spot-on. And I thought I knew most of the slicing tricks. I combined it with a slice object so that idx_obj = [ None for i in xrange(a.ndim) ] or idx_obj = [None] * a.ndim otherwise this is also