What does Fortran order mean?

Stefan van der Walt stefan at sun.ac.za
Tue Oct 17 03:46:57 CDT 2006


On Mon, Oct 16, 2006 at 02:20:04PM -0600, Charles R Harris wrote:
> Travis,
> 
> I note that
> 
> >>> a = arange(6).reshape(2,3,order='F')
> >>> a
> array([[0, 1, 2],
>        [3, 4, 5]])
> 
> Shouldn't that be 3x2? Or maybe [[0,2,4],[1,3,5]]? Reshape is making a copy,
> but flat, flatten, and tostring all show the elements in 'C' order. I ask
> because I wonder if changing the order can be used to prepare arrays for input
> into the LaPack routines.

I think that the calculation of 'a' above is correct, but that the
memory representation is incorrect.  For example (see attached script
-- which is overkill, I know), these commands:

x = N.arange(6,dtype=float).reshape((2,3),order='F')
catmem(x)

x = N.array([[0,1,2],[3,4,5]],order='F',dtype=float)
catmem(x)

x = N.array(N.arange(6,dtype=float).reshape((2,3)),order='F')
catmem(x)

x = N.asfortranarray(N.arange(6,dtype=float).reshape((2,3)))
catmem(x)

yield the following results:

0.000000 1.000000 2.000000 3.000000 4.000000 5.000000 
0.000000 3.000000 1.000000 4.000000 2.000000 5.000000 
0.000000 3.000000 1.000000 4.000000 2.000000 5.000000 
0.000000 3.000000 1.000000 4.000000 2.000000 5.000000 

Regards
Stéfan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: catmem.c
Type: text/x-csrc
Size: 134 bytes
Desc: not available
Url : http://projects.scipy.org/pipermail/numpy-discussion/attachments/20061017/5d254168/attachment-0001.bin 
-------------- next part --------------
from glob import glob

env = Environment()
env.Replace(CCFLAGS=['-O2','-Wall','-ansi','-pedantic'])
env.SharedLibrary('catmem', ['catmem.c'])
-------------- next part --------------
A non-text attachment was scrubbed...
Name: catmem.py
Type: text/x-python
Size: 628 bytes
Desc: not available
Url : http://projects.scipy.org/pipermail/numpy-discussion/attachments/20061017/5d254168/attachment-0001.py 
-------------- next part --------------
-------------------------------------------------------------------------
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
-------------- next part --------------
_______________________________________________
Numpy-discussion mailing list
Numpy-discussion at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


More information about the Numpy-discussion mailing list