[PYTHON MATRIX-SIG] Re: take() again

Carlos Fonseca fonseca@gaivota.demon.co.uk
Wed, 21 Aug 1996 22:46:12 +0100 (BST)


On Tue, 20 Aug 1996, Konrad Hinsen wrote:

> You would be welcome in the J development team, because what you have
> just described is exactly how J behaves with a modified rank for its
> left argument (i.e. the indices). I agree that this is very useful,
> but modifying the access to the other argument is also useful.
> Obviously the best way out is to have two axis argument, then we
> would almost have the full J functionality. But I am not sure whether
> that is a realistic proposal.

I am not familiar with J, but from what I've read in this list, it would
seem to have very complete multidimensional array handling. Why would
"full" functionality not be realistic? Too complex, perhaps?

> > If indices is 2d and we want the current behaviour, then take([a],indices)
> > will do it. In this way, the rank of the result will only increase if we
> > explicitly want it to.
> 
> Yes, but what if we want the current behaviour with an arbitrary axis
> specification? That would be lost.
> 

One could always write take(a,[indices]) to get the current behaviour with
axis=2, if indices is 1d. More generally, one could write

take( a[(ni-1)*(NewAxis,)],indices[(Ellipses,)+ax*(NewAxis,)+(All,)] )

where ni is the number of dimensions in indices, and ax is the desired
axis in a. Many other combinations would also be possible, of course.

The above may not look nice, but it would work for *all* cases, and the
default values should cover *most* cases. Currently, take()'s
functionality is still incomplete, as I hope to have convinced everybody
by now. 

What else can we do about take, so that it works for at least the two
of us? ;-)

Carlos



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

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