Discussion: new operators for numerical computation
Travis Oliphant
olipt at mayo.edu
Thu Jul 20 14:05:54 EDT 2000
> We are planning to use Numeric (or its future equivalent) heavily for
> our software. One thing we would strongly object to is making
> matrix operators the default. The vast majority of our manipulations
> (on images and spectra) involve elementwise operations. This would be
> consistent with what most astronomers would expect (and how IDL--currently
> the most commonly used array-based language in the astronomical community
> by far--handles it).
I also take this view. Definining * to be matrixwise should be handled by
subclassing the generic array (which will be much easier to do
without breaking compatibility with compiled extension modules in the
future Numeric).
>
> Use of parentheses for matrix operators that Konrad Hinsen proposed
> appears to be the best solution I've seen so far.
I agree. I'm glad Konrad is still with actively with us. His ideas were
also pivotal in getting Numeric into its current useful state. I do like
Tim Hochberg's suggestion of (|) as matsolve.
The only question is can the (*) be implemented in the current grammar?
I don't think we should start introducing [*] {*} variants. That would
likely weaken our case in the PEP.
I like:
(*) outer product
(.) inner product
(|) matrix solve
(**) matrix power
(^) is better but only if ^ is power (which is not likely!)
I'm not sure we should blow our chance to get some useful operators into
Python by over-reaching... Also, unless you've used Numeric with Python
for a while, it's easy to over-value the use of the infix notation.
This really bugged me when I first started using Numeric Python as
well, but it doesn't bother me anymore. The syntax does not have
to be as bad as Huaiyu demonstrates.
-Travis
More information about the Python-list
mailing list