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

Tim Hochberg tim.hochberg at ieee.org
Wed Jul 19 11:06:13 EDT 2000


Gregory Lielens <gregory.lielens at fft.be> writes:

[SNIP]

> 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),

This is indeed the case.

> 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)!

This (obviously) doesn't bother me as much as it bothers you. In part
because it's common to see indistinguishable notation for
multiplication and functions "on paper". Although I will admit that
A(B) is the the one permutation that rarely means multiplication. On
the other hand, you almost never see matrix multiplication represented
using the same symbol as scalar multiplication as is being proposed with *.

> -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.

I'm not super enamored of these other operations. Plus I've been
around CLP for a long time, and its been my experience that the odds
of a big pile of new operators will make it into the core in less than
several years is very low. Therefore, I'm primarily thinking of what
can be done within the current syntax.


-tim




More information about the Python-list mailing list