[PYTHON MATRIX-SIG] Array comparisons, and determinants
tim@lassi.ece.uiuc.edu
tim@lassi.ece.uiuc.edu
Thu, 24 Oct 1996 22:29:28 -0500
>ARRAY COMPARISONS
>
>There has been quite a bit of discussion of array comparisons recently. I
>seem to have missed the early stages so perhaps this has all been dealt
>with, but just in case...
>
>
>Inequalities are often generalised to work for vectors and matrices. For
>example, x>=0 where x is a vector means x[i]>=0 for every i.
>Unfortunately M>=0 where M is a matrix sometimes means the analogous thing
>to x>=0 and sometimes means M is positive semi-definite. Either of these
>would presumably be implementable by defining suitable __cmp__ functions.
The problem is that __cmp__ can only validly return an integer. Notice
that for your first example that am array might be neither >=0 nor <0
([1,-1] comes to mind), so there's really no valid value to return.
>However, (and this is where I may be missing something obvious, or
>something that is there already and I haven't understood), has anyone
>considered adopting the Matlab convention: the result of A>=0 for any
>array would be a boolean array of the same shape as A, and this could be
>reduced to give the behaviour corresponding to x>=0 above if that is what
>is wanted.
Once again, only integers can be returned from __cmp__ (this is built
pretty solidly into the python core), so this isn't an option.
I'm working on a way to fix up __cmp__, so that a) exceptions
are handled correctly, and b) one can indicate inequality without
having to indicate ordering (i.e., [1,2,5,3] != [4,5,3,7] is
meaningful, but [1,2,5,3] < [4,5,3,7] probably isn't).
I've started to put together a description of the problem and how I'm
trying to fix it at http://dogbert.ece.uiuc.edu/~tim/cmp.html . It is
however, only about 1/3 written and probably chalk full of typos, so
be warned.
--
-tim
+--------------------------------------------------------------------+
| Tim Hochberg Ultrahigh Speed Digital Electronics Lab |
| tim@lassi.ece.uiuc.edu University of Illinois |
| http://dogbert.ece.uiuc.edu/~tim (217) 333-6014 |
+--------------------------------------------------------------------+
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================