arraysnumpymultidimensional-arraycontiguous

When are arrays C-contiguous and F-contiguous simultaneously?


Under what conditions can arrays be C-contiguous and F-contiguous simultaneosly?

I can think of the following:

Are there any others?


Solution

  • You got it. An array is both C and Fortran contiguous (i.e. is both row major and column major) when it has at most 1 dimension longer than 1. Basically, vectors and scalars, plus degenerate arrays with additional "unnecessary" dimensions.