Numpy: Multiplying arrays of matrices

Robert Kern robert.kern at gmail.com
Wed Sep 15 17:47:02 EDT 2010


On 9/15/10 11:36 AM, Colin J. Williams wrote:
> On 14-Sep-10 19:54 PM, Gregory Ewing wrote:
>> Suppose I have two N+2 dimensional arrays, representing
>> N-d arrays of 2-d matrices. I want to perform matrix
>> multiplication between corresponding matrices in these
>> arrays.
>>
>> I had thought that dot() might do this, but it appears
>> not, because e.g. applying it to two 3-d arrays gives
>> a 4-d array, not another 3-d array.
>>
>> I'd also like to be able to find the inverse of each
>> matrix in one of these arrays, but again, inv() doesn't
>> do what I want -- it only works on 2-d arrays.
>>
>> Any thoughts on how to achieve these things using numpy
>> functions?
>
> There is a Matrix sub-class which permit you to do that sort of thimg.

No, it doesn't.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco




More information about the Python-list mailing list