[PYTHON MATRIX-SIG] Final (hopefully) alpha release available
Konrad Hinsen
hinsen@ibs.ibs.fr
Wed, 23 Oct 96 10:13:11 +0100
> either. However, it seems like A == B, and A != B are perfectly valid
> matrix expressions that should evaluate to true and false respectively
> if A and B are the same shape and have equal values. In other words,
> A == B <=> A.shape == B.shape and and.reduce(equal(ravel(A), ravel(B))).
>
> Yes? No?
If you ask me, yes! And of course it is possible. Here is the
definition of __cmp__ of my tensor class, which is basically
a wrapper around a special kind of array:
def __cmp__(self, other):
if self.rank != other.rank:
return 1
else:
return not umath.logical_and.reduce(
umath.equal(self.array, other.array).flat)
In this case, self.rank completely specifies shape, so it doesn't have
to be compared separately.
Konrad.
--
-------------------------------------------------------------------------------
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
=================