Discussion: Introducing new operators for matrix computation

Huaiyu Zhu hzhu at localhost.localdomain
Fri Jul 14 18:45:59 EDT 2000


John, 

Thanks for your clear description of the importance of matrix in another
post.  Are you aware of MatPy?  (http://MatPy.sourceforge.net/)

On 13 Jul 2000 21:36:02 -0500, John Lull <lull at acm.org> wrote:
>> 
>> [in octave we write]
>> > b = X\y                  # LMS solution of a linear equation y = X*b
>> > b = (X'*X)\(X'*y)        # or written out in more details
>> > b = inv(X'*X)*(X'*y)     # or in a less efficient form.
>> > 
>> > but the corresponding Python notation is horrendous:
>> > 
>> > b = matrixmultiply(inverse(matrixmultiply(transpose(X), X)), 
>> >     (matrixmultiply(transpose(X), y[:,NewAxis])))
>
>I'm don't think this is quite fair.  You could just as easily write:
>    b = rDiv(X, y)
>if you simply had an appropriate rDiv() function.  It's not nearly as
>pretty as octave's notation, but it doesn't have to be nearly as
>hideous as your example.

Well, you are right.  That quote was from a post written before MatPy
started, using NumPy which has a different idea of vectors tham matrices.
Now in MatPy these three are

solve(X,y)
solve(X.H()*X, X.H()*y)
(X.H()*X).I() * (X.H()*y)

This is almost as good or even better.

So why do we still need additional operators?  Because we are now using * as
matrixmultiply, so there need to be another operator for elementwise *.

Huaiyu




More information about the Python-list mailing list