[PYTHON MATRIX-SIG] ARRAY COMPARISONS
Konrad Hinsen
hinsen@ibs.ibs.fr
Fri, 25 Oct 96 13:55:38 +0100
> That is not a problem. The answer to "is [1,-1]>=0" is "no" so you return
> 0, as you do for the comparisons [1,-1]<=0, [1,-1]>0 and [1,-1]<0. These
But that's not how Python does comparisons. An expression like "a<b"
is turned into "cmp(a,b)==-1", and only the function cmp() is
implemented for each data type. Mathematically that means assuming an
ordering relation with the usual properties for all types.
Of course the best solution would be to give up this strategy and
implement all the comparison operators independently. With some
effort that could even be done in a backwards compatible way (i.e.
using the old strategy for types defining cmp()). But that is far
from a trivial change.
> It seems to me that one of the reasons APL never made it was that it
> insisted on talking its own language which was internally self-consistent
> but had little to do with any language talked by others. Conversely,
> Matlab, with its horrid "bad Fortran" syntax, is very popular in part
I suppose APL's main problem was the use of a special character set.
Even modern GUIs don't solve all the difficulties associated with
it. Look at comp.lang.apl to see what people are doing to publish
APL code on Usenet - it's a mess!
> because it never strays really far from standard notation. If we are to
> sell NumPy to users, shouldn't we try to make the operators mean what
> typical users will expect them to mean, or will learn that they mean in
> mathematics courses, rather than defining them to be something completely
> different?
I agree, but there's no way to do that with Python 1.4. And perhaps
not even with Python 1.5 or whatever comes next.
--
-------------------------------------------------------------------------------
Konrad Hinsen | E-Mail: hinsen@ibs.ibs.fr
Laboratoire de Dynamique Moleculaire | Tel.: +33-76.88.99.28
Institut de Biologie Structurale | Fax: +33-76.88.54.94
41, av. des Martyrs | Deutsch/Esperanto/English/
38027 Grenoble Cedex 1, France | Nederlands/Francais
-------------------------------------------------------------------------------
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================