PDA

View Full Version : n-dimensional data type


liorean
03-11-2005, 05:48 PM
I'm trying to design a data type that is essentially a frame in n dimensions, where you can look up an entry in any given axis and be given a result that is an n-1 dimension frame of the same type, so that the relative cost of looking up in the different axes is not dramatically increased the more dimensions it has and the higher the number of the axis asked for.

Pseudocode e.g:frame threedimframe=new frame(3,4,5);
// Creates a frame with 3 cells in the first axis, four in the second,
// five in the third.

frame planeoffirstaxis=threedimframe.axis(0).cell(1);
// Returns a frame with 4 cells in the first axis, 5 in the second,
// corresponding to the plane of the second cell of the first axis
// of threedimframe

frame planeofsecondaxis=threedimframe.axis(1).cell(3);
// Returns a frame with 3 cells in the first axis, 5 in the second,
// corresponding to the plane of the fourth cell of the second axis
// of threedimframe

frame planeofthirdaxis=threedimframe.axis(2).cell(0);
// Returns a frame with 3 cells in the first axis, 4 in the second,
// corresponding to the plane of the fourth cell of the second axis
// of threedimframeThis in such a way that getting planeofthirdaxis doesn't require much more computation than getting planeoffirstaxis.

Anyone have an idea?

liorean
03-11-2005, 07:05 PM
Hmm, to clarify what I meant a bit, this is something similar to multidimensional arrays. An example using pseudo array notation style:threedimframe=[
[[0,1],
[2,3]],
[[4,5],
[6,7]]];

planeoffirstaxis=threedimframe[1][][];
/* Contains
[[4,5],
[6,7]]
*/

planeofsecondaxis=threedimframe[][0][];
/* Contains
[[0,1],
[4,5]]
*/

planeofthirdaxis=threedimframe[][][1];
/* Contains
[[1,3],
[5,7]]
*/

Unit
03-11-2005, 09:21 PM
It is my understanding that the one dimensional nature of our memory systems makes it computationally intensive to represent n-dimensional structures. Adding more dimensions results in even more computations. If we were to have a two dimensional memory, accessing an element in a two dimensional structure would not require any multiplication at all.

In essence, I think there is no way to make the cost of accessing a particular frame remain constant. You may reduce the access cost by using seperate index tables along the higher dimension axis(performance at the cost of memory and upfront computation).

Note that I treat the memory as one dimensional because there is no way to address a particular bit in a byte to access it.

This n-dimensional stuff still makes my brain twist and turn
:eek: