[PYTHON MATRIX-SIG] First experiences
James Hugunin
jjh@Goldilocks.LCS.MIT.EDU
Tue, 30 Jan 96 14:50:41 EST
From: hinsenk@ERE.UMontreal.CA (Hinsen Konrad)
You are right. I had forgotten that returning a pointer or returning
a copy makes a real difference here; I am probably too much infected
by J, in which arrays are immutable objects. And the more I think
about it, the more I like immutable arrays! But that's another point.
I rather like immutable arrays myself, but I was convinced that
mutable arrays were the right choice sometime in the middle of this
project, and I'm unlikely to change again.
current array module. Some operations are functions (e.g. reshape()),
others are methods (like concat()), but that seems to be completely
arbitrary.
Actually, reshape is now an array method, and the old reshape function
is only around for "historical reasons". I should probably remove it.
That's just a matter of efficiency and has to be tried. In my APL code
this function is used a lot, and often on small arrays.
Again, what would you call this new method?
Ehh... Which one? Concatenation? Well, I still hope to find
a solution that incorporates all applications into one, which
can then be called concat(). We should try to keep the number
of functions/methods to a minimum. So how about this:
function concat((a,b,c...), n=0)
concatenates arrays a,b,c,... along the nth axis and returns
the result. The shape along the other axes must agree.
This doesn't take care of new axes, but they can be added
easily with the pseudo index.
This can easily be added to the standard set of functions and
implemented on top of the existing transpose and concat methods. You
might want to do this as an exercise ;).
I was actually asking for a new name for the method that will do a
reshape allowing you to make copies of the array in the process. I'm
fairly convinced that I don't want this to be the default behavior of
the reshape method.
-Jim
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================