[Numpy-discussion] Compute multiple outer products without a loop?

Ken Basye kbasye1@jhu....
Mon Feb 16 17:06:46 CST 2009


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 :->.
   Thanks,
       Ken
 


More information about the Numpy-discussion mailing list