[Numpy-discussion] fortran representation
Stefan van der Walt
stefan at sun.ac.za
Thu May 31 06:54:05 EDT 2007
On Thu, May 31, 2007 at 12:07:09PM +0200, lorenzo bolla wrote:
> If I have an array1D (obtained reading a stream of numbers with numpy.fromfile)
> like that:
>
> In [150]: data
> Out[150]: array([ 2., 3., 4., 3., 4., 5., 4., 5., 6., 5., 6., 7.],
> dtype=float32)
>
> I want it to be considered as "Fortran ordered", so that when I do:
>
> In [151]: data.shape = (3,4)
>
> I want to get:
>
> array([[ 2., 3., 4., 5.],
> [ 3., 4., 5., 6.],
> [ 4., 5., 6., 7.]], dtype=float32)
In [42]: x = N.array([2., 3., 4., 3., 4., 5., 4., 5., 6., 5., 6., 7.])
In [43]: x.reshape((3,4),order='F')
Out[43]:
array([[ 2., 3., 4., 5.],
[ 3., 4., 5., 6.],
[ 4., 5., 6., 7.]])
Cheers
Stéfan
More information about the NumPy-Discussion
mailing list