2

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

I can think of the following:

  • The 1D case that is trivially C- and F-contiguous.
  • Similarly, multi-dimensional arrays where all dimensions are singleton dimensions except for one.

Are there any others?

ARF
  • 7,420
  • 8
  • 45
  • 72

1 Answers1

1

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.

John Zwinck
  • 239,568
  • 38
  • 324
  • 436