+ 1
Efficiency of multi-dimensional arrays
I don't really understand 4d or 5d arrays and I can't imagine what I could use them for. But I want to know anyway: or multi-dimensional arrays even efficient or am I going to kill my CPU those?
2 Respostas
+ 6
Your CPU can probably handle those without issues. The problem is that there usually isn't much data which has to be represented using dimensions higher than 3 (or 4). As such, if you find yourself doing 4D or 5D arrays, something is most probably wrong with the understanding of the task at hand.
That said, data represented in 4D or 5D or above can be easily visualized. 2D arrays can be visualized as objects arranged in rows and columns (e,g, a flat map, the Cartesian plane). 3D arrays can be visualized as objects arranged in rows, columns and elevation (e.g. a multi-storey building). When it comes to n-dimension arrays where n > 3, just imagine multiple 3D arrays arranged in n-3 order. For example, 4D arrays are multiple 3D arrays arranged in a single row (e.g. Multiple multi-storey buildings). 5D arrays are 3D arrays arranged in rows and columns (e.g. A city with multiple multi-storey buildings).
object[0][1][3][2][0] can refer to the multi-storey building at coordinates (0,1), and (3,2,0) can be the x-y-z coordinates of a specific object in that particular building at (0,1).
0
Thanks a lot. I think I got it now...
Fermi and 6D is like the city bending scene from inception ;)