[SciPy-user] multiplying matrices

Travis Oliphant oliphant at ee.byu.edu
Fri Oct 15 10:49:41 EDT 2004


Alan G Isaac wrote:

>On Wed, 22 Sep 2004, David Grant apparently wrote:
>  
>
>>Is there any way to multiple a whole bunch of matrices
>>together easily?  Ideally, the * operator would be for
>>matrix multiplication as opposed to element-by-element
>>multiplication.  I've been doing this:
>>listofmatricies = [blah, blah, blah, ....]
>>return reduce(matrixmultiply,listofmatricies)
>>Seems to work, but it would nice to be able to do it in
>>one line as in matlab.
>>    
>>
>
>  
>
Note that scipy has the easy-to-type commands

mat and bmat

mat will take a string like '1,2;3,4'  to build a matrix and

bmat takes 2-d matrices and builds other 2-d matrices with them.

Once  you get matrices you can use * for matrix multiplication and use 
the special methods

.H   Hermitian transpose
.T    transpose
.I    inverse
.A   (return the equivalent 2-d array)  (i.e. for element-by-element 
multiplying)

-Travis .




More information about the SciPy-User mailing list