Operators for matrix: current choices (Was Matlab vs Python ...)

Gregory Lielens gregory.lielens at fft.be
Wed Jul 19 05:03:39 EDT 2000


Paul Prescod wrote:
> 
> Tim Hochberg wrote:
> >
> > Similarly:
> >
> > dot((A,B), C) -> A(B)(C)
> > dot(A, dot(B,C) -> A(B(C))
> >
> > which looks pretty good to me. And it's arguably closer to paper
> > linear algebra notation than A*B is.
> 
> Another good idea! You can even make it look like the new-syntax
> proposal:
> 
> A()*B()*C
> A()+B()+C
> A()-B()-C

Wow...Personally, I do not like it too mush...to say the least! I found
it really confusing, because
there is no way to visually tell if you are calling a function or
performing matrix multiplication, which is
not a good thing as these two operation are likely to appear at the same
time on many lines of codes involving linear algebra...This is
particularly confusing for A(B), and slightly better for A()*B()*C...but
again, A could be a function with no arguments!

On the other hand, the JNumeric "symmetric" notation looks already
better, even "sexy":
(A)(B), yeah!

but I see 2 problems:

-the parentheses around A are important because they are a visual hint
to indicate that this is not a function call,
but a matrix multiply (or more generally, an inner product for Nd
numeric arrays). But internally, (A)(B) is the same as A(B) (I think it
is the case, please correct me if  I am wrong), so we have to count on
the good will of people to avoid the A(B) thing, and to avoid to write
(f)(A) when f is a function. The last case is not likely, but if f is an
array of functions, (f[i])(A) could happen (and have a totally different
meaning if f is an array of Numeric arrays). This problem comes only
from "look", but it is important imho, I really fear to see A(B)!
 
-it gives one more operator only, the multiplication...This is the more
important, I agree, especially if (A.inv)(B) can be evaluated at the
same cost as Matlab's A\B, but it rules out the distinction one could
want to make regarding other operations.


Greg.



More information about the Python-list mailing list