[SciPy-user] In-place matrix reordering

Robert Kern robert.kern@gmail....
Wed Feb 25 02:14:33 CST 2009

On Wed, Feb 25, 2009 at 02:12, Antonino Ingargiola <tritemio@gmail.com> wrote:
> 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?

No, sorry. numpy's memory model does not allow arbitrary views like this.

Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
  -- Umberto Eco

More information about the SciPy-user mailing list