[PYTHON MATRIX-SIG] Bug in matrixMultiply, and once more names

Hinsen Konrad hinsenk@ere.umontreal.ca
Mon, 29 Jan 1996 14:49:21 -0500


Here's a bug (or two) that I just found:

>>> from Numeric import *
>>> x = array([1,2,3.])
>>> add.reduce(x*x)
14.0
>>> x.matrixMultiply(x)
array(14.0, 'd')
>>> 2.*x.matrixMultiply(x)
Segmentation fault

The segmentation fault is the obvious bug, but I am also surprised
that x.matrixMultiply(x) returns an array of rank 0 instead of a
scalar.

This raises the question of how rank-0 arrays are treated in
general. Although it may seem reasonable to convert them to scalars,
it also makes sense to keep them as arrays if they have one of the new
types (e.g. C float).


About names:

>From the recent discussion I remember that there are supposed to be
two array types: a low-level type "array" and a high-level type
"Array". The latter may have become unnecessary now that "array"s have
automatic coercion again. But should the remaining one be called
"array" or "Array"? I don't really care, but certainly we should have
either "array" and "matrix" or "Array" and "Matrix", not "array" and
"Matrix" as it is now.

Also, I have some more objections against the name of the module
UserArray. I don't like the "UserXxx" names at all (because they don't
relate to the user any more than any other module), but that's not my
point now. UserList is a Python class that is equivalent to the
built-in list type, UserDict similarly wraps dictionaries.  So one
should conclude that UserArray is an analogous wrapping of the old
array type, but that is not true. The new arrays have different
functionality, so they should have another name. One possibility would
be "NumericArray", since the main new feature is numerical
operations. On the other hand, there are no numerical operations on
e.g. character arrays. Maybe someone else finds a better name.

And now back to testing...

-------------------------------------------------------------------------------
Konrad Hinsen                     | E-Mail: hinsenk@ere.umontreal.ca
Departement de chimie             | Tel.: +1-514-343-6111 ext. 3953
Universite de Montreal            | Fax:  +1-514-343-7586
C.P. 6128, succ. Centre-Ville     | Deutsch/Esperanto/English/Nederlands/
Montreal (QC) H3C 3J7             | Francais (phase experimentale)
-------------------------------------------------------------------------------

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

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