matrix_1 = matrix_2 * matrix_3

Fernando Pérez fperez528 at
Mon Aug 26 19:25:43 CEST 2002

Anton Vredegoor wrote:

> From this it seems that redefining the star operator to do what is
> called matrixmultiply here could cause problems. But maybe not. Could
> someone please inform me whether it would be possible to adapt numeric
> to use the star operator for matrixmultiply.

In [1]: from Matrix import Matrix

In [2]: A=Matrix([[1,2],[3,4]])

In [3]: B=Matrix([[0,1],[1,0]])

In [4]: A*B
Matrix([[2, 1],
       [4, 3]])

Matrix comes with Numeric, no need to redefine anything. Numeric implements 
element-wise operations, Matrix implements regular Linear-algebra type 



More information about the Python-list mailing list