Matrix in Python .

Travis Oliphant oliphant at ee.byu.edu
Wed Nov 14 14:22:25 EST 2001


> On Fri, 09 Nov 2001 12:50:32 +0200, Amit Weisman <weismann at netvision.net.il>
> wrote:
> >Is there a module for dealing with Matrix ?
>
> Assuming you mean matrix in the mathematical sense, instead of whatever the
> film or video that others are joking about, then:
>
> There is the Numeric package.  Search for either "numeric python" or "numpy"
> on Google.  I think it is numpy.sf.net
>
> If you want a more Matlab like syntax, I have a wrapper package MatPy around
> NumPy, also on sourceforge.  Haven't updated it for quite some time, though.


The latest version of NumPy has an expanded Matrix Package that borrows
from the ideas of Huaiyu's work.

If you have NumPy installed, and import Matrix

then Matrix.Matrix()

generates a matrix where the * acts as matrix multiplication instead of
element by element multiplication (to get that you have to get the array
out and use it)

There are attributes .T and .H to get the transpose and .A to get the
array out

Also Matrix.Matrix('[1,2,3;4,5,6;7,8,9]')  Let's you use Matlab-style
semicolon separation to separate the rows.


-Travis






More information about the Python-list mailing list