[SciPy-user] In-place matrix reordering

Antonino Ingargiola tritemio@gmail....
Wed Feb 25 02:12:37 CST 2009


Hi to the list,

I have to "reorder" the columns of a big 2D array (a matrix) but
without doing a temp copy of the whole matrix (since it is 1.5GB).

Basically I would need something like this:

a = arange(12).reshape(4,3)
b = a[:,(2,0,1)]

but without the array copy triggered by the advanced indexing. Let the
(2,0,1) tuple be an arbitrary sequence previously computed.

The .take method seems to do a copy too:

b = a.take((2,0,1), axis=1)

What I need is a "view" of "a" with an arbitrary column order.

Is there a way to accomplish this task?


Ciao,
    ~ Antonio


More information about the SciPy-user mailing list