[Numpy-discussion] Compute multiple outer products without a loop?
Charles R Harris
Mon Feb 16 17:16:03 CST 2009
On Mon, Feb 16, 2009 at 4:06 PM, Ken Basye <firstname.lastname@example.org> wrote:
> Hi List,
> I need to compute multiple outer products from 2-d data in the
> following way:
> Given a and b with shape, e.g, (10, 4), compute the 10 outer products
> of shape (4, 4) and get them into an array of shape (10, 4, 4).
> Currently I do this with a loop, but I'd really like some way to do it
> without looping. I read that outer(a, b) is just syntactic sugar for
> a.ravel()[:, newaxis] * b.ravel()[newaxis,:] but unfortunately this
> didn't give me any bright ideas :->.
I think you can do what you want with newaxis and broadcasting, but I'm not
sure what you want ;) Could you post your current code and a small example?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Numpy-discussion