This is the 3D version of an existing question.
A 3D array M[x,y,z]
of shape (n,n,n)
should be mapped to a flat vector containing only the elements with x<=y<=z in order to save space. So what I need is an expression similar to the 2D case (index := x + (y+1)*y/2
). I tried to derive some formulas but just can't get it right. Note that the element order inside the vector doesn't matter.