The NumPy Fortran-ordering quiz

Travis Oliphant oliphant.travis at ieee.org
Tue Oct 17 22:15:13 EDT 2006


Charles R Harris wrote:
>
>
> On 10/17/06, *Lisandro Dalcin* <dalcinl at gmail.com 
> <mailto:dalcinl at gmail.com>> wrote:
>
>     I was surprised by this
>
>     In [14]: array([[1,2,3],[4,5,6]]).reshape((3,2),order='F')
>     Out[14]:
>     array([[1, 5],
>            [4, 3],
>            [2, 6]])
>
>
> This one still looks wrong.

Why does this look wrong.  What do you want it to be?  Perhaps you are 
thinking about the input array as C-order and the output array as 
Fortran order.   That's not what reshape does.   The order argument 
specifies how you think about both the input and output.

Thus, reshape does the equivalent of a Fortran ravel to [1,4,2,5,3,6] 
and then a Fortran-order based fill of an empty (3,2) array:  giving you 
the result.

-Travis


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642




More information about the NumPy-Discussion mailing list