[PYTHON MATRIX-SIG] First experiences
Hinsen Konrad
hinsenk@ere.umontreal.ca
Tue, 30 Jan 1996 14:33:41 -0500
It could still return a new pointer if the size is the same,
and make a copy only if the size changes. Personally I don't care
This I REALLY don't want. I firmly believe that whether a function
returns a pointer or a copy should not be dependent on its arguments.
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.
Well, you should use c = array([a, b]) for that. This seems fairly
clean to me, and will run quite efficiently if a and b are already
arrays of the same type.
I didn't know this was possible (of course I should have tried...).
But still that is a solution only if I want to create a new first
axis. What if I don't want a new axis, or if the new axis is not
the first one?
What do you mean by non-destructive? a.concat(b) does not modify a,
but instead returns a new array that is b concatenated with a. This
is almost exactly equivalent to a+b if a and b were lists.
OK, I misunderstood this.
One argument could be a tuple of all arrays to be concatenated.
This doesn't work nicely if you only have one array.
Not as long as it is a method. But concat() could be made a normal
function. Actually, that is another slightly unclear point in the
current array module. Some operations are functions (e.g. reshape()),
others are methods (like concat()), but that seems to be completely
arbitrary.
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.
-------------------------------------------------------------------------------
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
=================