linear simulation of multidimensional array

后端 未结 2 1652
暗喜
暗喜 2020-12-09 21:27

I know how to simulate a 2d array in a linear array using [x + y * width] as a linear index.

I can extend this to 3d arrays: [x + y * width + z *

2条回答
  •  时光取名叫无心
    2020-12-09 22:07

    Sure. Just extending your example gives x + y*width + z*width*height + w*width*height*depth + ...

    In other words, dim1 + dim2*size1 + dim3*size1*size2 + dim4*size1*size2*size3 + ...

提交回复
热议问题