## C-style and F-style array transformations are transpose of each other ## Indexing in C-style is horizontal while Fortran-style indexing is vertical.

Recall that, a non-contiguous layout with shape (d0, d1, …, dN−1) the value in (n0, n1, …, nN−1) located in the contiguous layout with index nStyle is given by
For C-style            For F-style  such that, for dk, dk + 1, …, dm−1, dm if k > m As a consequence, in practice this means that the indexing in C-style is horizontal while indexing in F-style is vertical. #### For an index on contiguous layout where are its corresponding indices in C-style and F-style non-contiguous layout?

Let us consider the example of N = 2 dimensional array. Furthermore, let the shape for C-style non-contiguous memory layout be (d0 = 4, d1 = 3) and shape for F-style layout be (d0 = 3, d1 = 4).

For a given index (n0 = 2, n1 = 1) in the C-style non-contiguous layout, its corresponding index in contiguous layout is 7 because This index 7 in the contiguous layout corresponds to the index (n0 = 1, n1 = 2) in F-style non-contiguous layout because  Similarly, the index 10 in the contiguous layout corresponds to the index (n0 = 3, n1 = 1) in C-style since
nC = n0 d1 + n1 1 = 3 ⋅ 3 + 1 ⋅ 1 = 10
and the index (n0 = 1, n3 = 1) in F-style since
nF = n0 1 + n1 d0 = 1 ⋅ 1 + 3 ⋅ 3 = 10.

Looking at the contiguous layout, moving from index 7 to index 10 requires jumping three elements.

Since, we learned that the contiguous memory layout is mapped from non-contiguous layouts the number of elements that must be jumped from (n0 = 2, n1 = 1)C to (n0 = 3, n1 = 1)C for C-style, and (n0 = 1, n1 = 2)F to (n0 = 1, n1 = 3)F for F-style will also be three elements.

Elements that must be jumped to get from one element to another is the same.