Matlab vs Python (was RE: Discussion: Introducing new operators f

Travis Oliphant olipt at mayo.edu
Tue Jul 18 12:08:57 EDT 2000


> Personally, I find that the matrix-orientation of Matlab makes it
> harder to get things done.  I more often have 3 or higher dimensional
> arrays than I have plain old 2D matrices, so I'd rather see the more
> general Numeric Python syntax than any over-specialized matrix code.
> 
> When you're contracting a 4-tensor with a vector, you almost need an
> index-based notation.
> 
> As it is, the only things missing from NumPy is an easy spelling of
> matrix-matrix multiplication, and if you really need that, you can
> just define your own class to do it.

I think I'll chime in here.  I have been greatly enjoying this discussion.
I have been an active participant in Numerical Python development and have
been advocating it's use over Matlab to anyone who will listen for over a
year.  This recent excitement is encouraging as I've seen the potential
for Python to replace Matlab for some time.  Before, my thesis writing
picked up I spent quite a bit of time working on improving the number of
"toolboxes" available for Python --- a project I intend to continue as
soon as my dissertation gets written since I plan on using Python in the
electrical engineering classes I teach at University this winter.

Many people would like to see Python get into the core.  Guido has (in the
past six months) expressed a willingness to do that if there is community
support (I do not know if the recent move to BeOpen has changed that -- I
would be surprised if it did).  Some of us are working right now on a
redesign of NumPy to facilitate its inclusion into the core.  It is
available at SourceForge under the module name numpy2.  The basic idea is
to move the array object from a C-type to a Python class.  This will make
it much easier to subclass the array while keeping extension module
compatibility among the subclasses (so that toolboxes can be written to
handle the data regardless of the class).  I'm very busy right now, so
progress is slow.  However, the good news is that the design is complete
but just requires some coding work to get it running.  Any helpers who
want to make sure NumPy gets into the core are more than welcome to help.

I am not opposed to adding ONE new operator like "@" to the language.  
But, from the documentation it seems that Python likes not having such
"line noise" in its syntax.  I quoted the above because it expresses my
opinion as well:  Matlab had to "retrofit" itself in a very inelegant way
to handle N-D arrays --- it still doesn't do a good job in many respects.
There was a lot of careful discussion that went in to making NumPy general
for N-D arrays and not just 2-D matrices. 

For that reason I support to a greater extent the concept of a
Matrix-syntax parser for Python and a specialized Matrix subclass.  I
think MatPy is a fantastic step in this direction.  Either a
pre-processor/modified interpreter or an evaluation module
(ala PyAlgebra.run) seem like good ideas to me.

We need to remember that 2-D Linear Algebra is just a subset of what
Matlab and Numerical Python are useful for.  Many problems are actually
better written with N-D tensors.  I'd love to find Numerical algorithms
that found N-D tensor inverses without remapping to the (arbitrary?) 2-D
domain.  Has anybody heard of such things?


Travis Oliphant


---Words without work are worthless---











More information about the Python-list mailing list