[Python-Dev] Re: [Fwd: Discussion: Introducing new operators formatrix computation]

Huaiyu Zhu huaiyu_zhu@yahoo.com
Fri, 14 Jul 2000 10:11:29 -0700 (PDT)


On Fri, 14 Jul 2000, Ka-Ping Yee wrote:
> > You are almost there.  :-) The current MatPy expression is
> > 	solve (X.H() * X, X.H() * y)
> 
> I was about to suggest something similar, but you beat me to it.
> 
> I think that expression looks great.  If you can say it that
> concisely, i don't think you need to throw in extra operators
> at all (let alone a half-dozen of them that are incomprehensible
> to anyone outside of the Matlab community).

Well, the Matlab community includes most scientists and enginears and
educators and students of science and engineering who can afford Matlab, or
who has enough computer literacy to know how to install Octave (or to
install Linux so that Octave comes with it).  Many are learning Linux just
for this purpose alone.  At least several of my former students did.

Back to topic.  Here's the quote from my c.l.py post:

This is not a call for a special language for matrix only.  But we do need
enough binary operators to override with.  The additional operators might be
useful at other places as well.

In matlab the following operations are all different from each other

a+b        a.+b  
a-b        a.-b
a*b        a.*b
a/b        a./b
a\b        a.\b
a^b        a.^b

What python operators can we override for them all? Just one additional
symbol for so many new binary operators is a good bargain, IMO.

I think cleanness is one of the main virtue of python, but it is lacking in
numerical computation.  To give an example of the difference it makes, I'll
quote from my original post asking for matrix in python (with corrections)

[example of matlab and python codes you've seen. end quote]

So why do we need new operators?  Because we are using * as matrixmultiply
so we need .* as elementwise multiply.