I have an n-dimensional array with column-major order. I need to find the address of any element in this array(in memory).
On the Internet, I found only formulas for 1-,2-,3-,4- dimensional arrays here. However, even with them I can’t get the address of an element in a multi-dimensional array.
Does somebody knows formula for this?
If
anis the coordinate in dimensionnanssnis the size of dimensionnthen the element (a1,a2,…,an) has the address:For multivariable arrays column-major vs row-major doesn’t make much sence, but it should just be to swap a1,s1 with a2,s2 to make it column-major.