Den 07.07.2011 15:24, skrev Yoshi Rokuko:
> thank you for pointing that out!
>
> so how do you change your numpy related c code now, would you like to share?
>

Regardless or memory layout, we can always access element array[i,j,k] 
like this:

const int s0 = array->strides[0];
const int s1 = array->strides[1];
const int s2 = array->strides[2];
char *const data = array->data;

dtype *element = (dtype*)(data + i*s0 + j*s1 + k*s2);

To force a particular layout, I usually call "np.ascontiguousarray" or 
"np.asfortranarray" in Python or Cython before calling into C or 
Fortran. These functions will do nothing if the layout is already correct.

Sturla








_______________________________________________
NumPy-Discussion mailing list
[email protected]
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to