[MATRIX-SIG] reverse of take?
Konrad Hinsen
hinsen@ibs.ibs.fr
Tue, 1 Jul 1997 17:02:31 +0200
> Can you index a multi-dimensional array with a one-dimensional array? In
> other words does arraytype[range(10)] refer to the first 10 elements of
> the array? I think this would be doable using other more verbose methods,
> but this is a simple way to spell this.
This issue is already settled. Obviously, array[range(10)] should be
the same as array[:10], right? And that expression is equivalent to
array[:10, ...].
To get the first ten elements, use ravel(array)[:10].
> Can you index a one-dimensional array with a multi-dimensional array? In
> languages which provide this, this usually returns a value with the same
> shape as the matrix and the values corresponding to the value in the vector
> with that index. This is really nice for image processing - for example
> palette remapping. You can get this by applying a function, but that is
> usually a lot slower.
I see no reason why this shouldn't be allowed in NumPy.
> 1. A function which returns the permutation which would put the elements of
> a 1-d array in order. In APL this is called 'upgrade' and in S it is called
> 'order'. A quick illustration of the use of this is computing the ranks
And in NumPy it's called argsort!
--
-------------------------------------------------------------------------------
Konrad Hinsen | E-Mail: hinsen@ibs.ibs.fr
Laboratoire de Dynamique Moleculaire | Tel.: +33-4.76.88.99.28
Institut de Biologie Structurale | Fax: +33-4.76.88.54.94
41, av. des Martyrs | Deutsch/Esperanto/English/
38027 Grenoble Cedex 1, France | Nederlands/Francais
-------------------------------------------------------------------------------
_______________
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
_______________