[PYTHON MATRIX-SIG] Array comparisons, and determinants

Alistair Mees alistair@maths.uwa.edu.au
Fri, 25 Oct 1996 10:08:43 +0800


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.

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.



DETERMINANTS

There are much faster ways of calculating a determinant than taking the
product of its eigenvalues, for example by doing a single LR decomposition
or a single QR decomposition and then taking the products of the diagonal
elements of the triangular matrices.  (Eigenvalue extraction routines
perform many QR decompositions.)  Somewhere in LAPACK there are probably
at least half a dozen ways already programmed.  If you use a QR
decomposition you do have to check that the Q matrix is constructed in
such a way as to have determinant +1.  I apologise for merely pointing
this out and not volunteering to fix it.  Still, the number of times one
wants a determinant is actually quite small so I don't think the
inefficiency matters very much.



Alistair Mees


P.S.  

=================
MATRIX-SIG  - SIG on Matrix Math for Python

send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================