[Numpy-discussion] Matlab/Numpy index order

Ryan May rmay31 at gmail.com
Tue May 12 15:55:16 EDT 2009


On Tue, May 12, 2009 at 2:51 PM, brechmos <craig at brechmos.org> wrote:

> So, in Numpy I have to reshape it so the "slices" are in the first
> dimension.  Obviously, I can do a b.transpose( (1,2,0) ) to get it to look
> like Matlab, but...
>
> I don't understand why the index ordering is different between Matlab and
> Numpy.  (It isn't a C/Fortran ordering thing, I don' think).


Actually, that's precisely the reason.


> Is the data access faster if I have b without the tranpose, or can I
> transpose it so it "looks" like Matlab without taking a hit when I do
> imshow( b[:,:,0] ).
>

It's going to be faster to do it without the transpose.  Besides, for numpy,
that imshow becomes:

    imshow(b[0])

Which, IMHO, looks better than Matlab.

Ryan

-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20090512/9a01b7cc/attachment.html>


More information about the NumPy-Discussion mailing list