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|
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 . Furthermore, let the shape for C-style non-contiguous memory layout be and shape for F-style layout be .
For a given indexin the C-style non-contiguous layout, its corresponding index in because
Looking at the contiguous layout, moving fromto requires .
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.