[Numpy-discussion] Matlab/Numpy index order

brechmos craig@brechmos....
Tue May 12 15:02:00 CDT 2009


Ah, hah.  

In [3]: c = b.reshape((256,256,150), order='F')

Ok, I needed more coffee.

If I do it this way (without the transpose), it should be as fast as
c=b.reshape((150,256,256)), right?  It is just changing the stride (or
something like that)?  Or is it going to be faster without changing the
order?

Thanks for the help.


Ryan May-3 wrote:
> 
> On Tue, May 12, 2009 at 2:51 PM, brechmos <craig@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
> 
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
> 
> 

-- 
View this message in context: http://www.nabble.com/Matlab-Numpy-index-order-tp23509178p23509345.html
Sent from the Numpy-discussion mailing list archive at Nabble.com.



More information about the Numpy-discussion mailing list