[Matrix-SIG] Question for the NumPy gurus

Konrad Hinsen hinsen@cnrs-orleans.fr
Wed, 11 Aug 1999 22:12:08 +0200


   I have two arrays with in1.shape = (N,M,P) and in2.shape = (N,P)

   Is there a fast way (no Python for loop) to perform
   an innerproduct element-wise along the first dimension to 
   return an array of shape (N,M)?  I was hoping for the equivalent of

Not with dot(), but it's easy enough to do it in two steps:

   out = add.reduce(in1*in2[:,Numeric.NewAxis,:], 1)

(not tested, of course, after all I am on vacation!)
-- 
-------------------------------------------------------------------------------
Konrad Hinsen                            | E-Mail: hinsen@cnrs-orleans.fr
Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.55.69
Rue Charles Sadron                       | Fax:  +33-2.38.63.15.17
45071 Orleans Cedex 2                    | Deutsch/Esperanto/English/
France                                   | Nederlands/Francais
-------------------------------------------------------------------------------