[PYTHON MATRIX-SIG] Time for recap?

Guido van Rossum guido@CNRI.Reston.VA.US
Fri, 29 Sep 1995 08:21:01 -0400

I'll try to be short.

I like the general idea of going with APL/J style multidimensional

I liked Konrad's sample implementation even though I agree an actual
implementation would have to have a contiguous representation.

I'm not sure about Konrad's particular notation for changing the rank
of an operator (though it is very cool that that is possible in
Python!).  More thought needs to go in details like this.

I think the best way to proceed is to use the built-in operators for
APL/J style elementwise operations and to have the specific 2D linear
algebra operations as methods.

Likewise, instead of my earlier wild ideas about multidimensional
slices, I propose to use a slice() method that can produce arbitrary
slices; e.g. a[k][i:j] would be equivalent to a.slice(k, (i,j)).

I'm not against dropping the parentheses in a[(i,j)] but I'm not sure
if I can give it the proper thought and testing before October 13, the
scheduled release of Python 1.3 (at 13:13:13 hours :-).  We can work
on a standard patch shortly after that date though.

- - -

I have one idea I would like to float by this group.  How about
separating out the representation and the structure?

I believe I've seen C/Fortran matrix packages that made quite good use
of this.  The representation would be a simple 1-dimensional sequence.
You'd normally not see or use this, but it would be there if you
needed access to it (e.g. for passing to C/Fortran code).

There's a simple way to map an index in an N-dim array into an index
in the 1-dim representation array (Fortran compilers use it all the
time :-).

To make efficient use of this, I propose that slicing and indexing, as
long as they return an object of rank >= 1, return an object that
points into the same representation sequence.

I propose one additional feature (which I believe I saw in Algol-68;
some matrix packages may also use it): add a "stride" to each
dimension (including the last).  This makes it possible to have slices
reference discontiguous parts of the underlying representation, and
even to represent a transposed version!

If we do things just right, it may be possible to pass in the sequence
to be used as the representation -- it could be a Python list, tuple
or array (from the array module).

Again, all this can be prototyped in Python!

I would give an example, but I have to run.

--Guido van Rossum <guido@CNRI.Reston.VA.US>
URL: <http://www.python.org/~guido/>

MATRIX-SIG  - SIG on Matrix Math for Python

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