[Numpy-discussion] arrays : c aligmen to fortran and back

Stéfan van der Walt stefan at sun.ac.za
Mon Aug 4 04:41:07 EDT 2008


Hi Thomas

2008/8/4 Thomas Hrabe <thrabe at burnham.org>:
> I need to convert a 3d array from c alingment to fortran and was wandering
> for the simplest code available.
> Its all about python and an interfaced C++ program, which, however,
> processes fortran aligned arrays.
>
> Is there a simple code from converting an array
> arr = numpy.array((30,20,10))
>
> to an array arr2 with the same shape
> (arr.shape == arr2.shape)  = true
> where the data is aligned in fortran style.

Does

xf = np.asfortranarray(x)

do what you want?

Stéfan



More information about the NumPy-Discussion mailing list