[PEP draft 2] Adding new math operators

Huaiyu Zhu hzhu at localhost.localdomain
Fri Aug 11 15:26:56 EDT 2000


On 11 Aug 2000 20:51:58 +0200, Konrad Hinsen <hinsen at cnrs-orleans.fr> wrote:
>> 
>> I'm not sure I follow you here.  Let's say A is a matrix.  The expression
>> (using matrixwise notation)
>> 
>>     B = A ~- mean(A)
>
>What is mean(A) supposed to return? The average over all elements of
>A? Or the average over all columns or rows? In NumPy, if you define a
>function mean() acting on a sequence, then it will do an average along
>the first index when passed a higher-rank array, and thus return an
>array whose rank is 1 lower than that of the input array. Judging from
>your following matlab example, I suppose you expect it to return a
>scalar.

It returns a row vector consisting of means of columns, since there are only
two axes here.  If it were a scalar the issue disappears.  

>> These operations are also interchangeable as algorithms evolve.  Suppose A
>> is a collection of time series it is common to change scaling into a
>
>A collection of time series is not a matrix, but a classical
>application of NumPy-style arrays.

This is true, but the multiplication is still matrix style.  This just shows
that the objects do not possess the property of "matrixwise" or
"elementwise", but the operations do.

>Anyway, I'll have to drop out of the discussion for two weeks. Among
>other things, I'll participate in a conference where I'll talk about
>Python to people who work mainly in the PDE business. Perhaps that
>application domain will require yet another set of operators...

Good. Maybe we can have some feedback from a different crowd.  (Please do
ask them how they prefer to write Schur complement and similar things.)

Huaiyu



More information about the Python-list mailing list