[PYTHON MATRIX-SIG] Re: Version 2.0

James Hugunin jjh@mama-bear.lcs.mit.edu
Wed, 13 Dec 95 12:51:32 -0500


Paul sent me this as private comments and I'm going to violate all rules of  
Netiquette by replying to the entire group.  I think that there are some  
important things in here to comment on.

> a. It seems like if I don't do the import of omath then 2.*x doesn't
> work. After a from omath import * it does. (?)

This is true.  You have to import omath somehow, or matrices do not have  
any numeric behavior (notice that if you use import Matrix, or from Matrix  
import *. this gets done for you).  Here are the reasons...

1) This makes the matrixobject code a lot smaller, and therefore likelier  
to be included in the base python distribution (fingers crossed)

2) This makes add.reduce(m) possible.

3) This makes it possible to have a vectorized_ofuncmodule (or something  
like that) that defines high performance versions of these operators for a  
particular machine, and then have them be used when you say "a+b".

> b. Matrix(1,2,3) produces a Matrix_l, or at least that is what it
>     claims it is. Should be a Matrix_i?

This will be seen as a BIG issue, and I'll write more about it later (I've  
a few other demands on my time right now).

It should either be Matrix_b (a matrix of bytes, because 1,2, and 3 can all  
be stored in a single byte) or it should be Matrix_l (a matrix of longs  
because a python integer technically holds a C long).

> c. I preferred the [1.,2.,3.] rather than the Matrix_d(...). A lot. A
> whole lot. Provide a query function for those who really want to know
> the flavor of matrix.

The printing of matrices can be GREATLY improved.  I changed the  
matrix_print function so that it goes out and calls a python routine to do  
the actual printing.  Check out the PrintMatrix function in Matrix.py.   
Currently this function just returns the string representation of the object  
(for which Matrix_d is a good choice modulo naming conventions).

Anybody who has good ideas about how to print a matrix can go in and modify  
this python function to get whatever print behavior they like.  If you come  
up with a good print function, send it to me, and I'll include the best one  
in the next release.

> d. I really like the way Matrix decides on a type.

Thanks.

> e. I like the idea that others have suggested of IntegerMatrix(...)
> instead of a constructor that takes a character to decide type. However,
> there are times when the latter is useful because you are COMPUTING the
> type (like choose a precision based on the system, for example) so I
> wouldn't get rid of the character method.
>     The fact that Matrix() does the right thing and that everything
> coerces mitigates most of this to the margins, however.

And here I decided to respond to your message in order to stay out of the  
naming issue.  I like both approaches, and I'm waiting to see what things  
look like after the dust has settled.

-Jim

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

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