# [PYTHON MATRIX-SIG] Matrix multiplies and syntactic nits

James Hugunin jjh@mama-bear.lcs.mit.edu
Mon, 13 Nov 95 15:05:10 -0500

```I'm working on putting out the 0.2 version of my matrix object, and I'm
having a surprisingly hard time resolving some very silly naming issues.

1) There is a single python file currently called Matrix.py which imports
everything you could ever want for basic functions on matrix objects.  This
module has a similar role as Tkinter does in the Tk module system.  It
defines functions and a number of useful constants.  Should I rename this
module to Mx.py, or something similar so that people will be more inclined
to use "import Mx" rather than "from Matrix import *" (which is what I use
all the time).  This idea comes directly from Tkinter related discussions on
the main list.

2) I have two possible ways to implement matrix multiplies:

a) a % b

I personally never need the modulo operator for matrices, and it does have
enough of a resemblence to X to be reasonably mnemonic.  However, this
breaks the current conceptual elegance of the system where every operator
works on matrices (more or less) exactly the way it works on python scalars.

b) a.matrixMultiply(b)

This is the obvious solution, however it does make matrix equations
extremely ugly to type.  Possibly an abbreviation is called for in this
particular case?

Any opinions?

Note: There seem to be enough people with very reasonable objections to the
idea of controlling "*" with a global variable that I don't consider this
one of the possible solutions.

3) String representations of matrices

I'm not talking about the normally printed representation here, that's a
major issue, not a nit.  I'm trying to decide between two string
representations and again I just wanted some feedback.

The following are 2x3 matrices of integers.

a) Matrix_i((1,2,3),(4,5,6))

b) matrix([[1,2,3],[4,5,6]], 'i')

Opinions on which you should get with str(M)?

Thanks for the feedback - Jim

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

send messages to: matrix-sig@python.org