### Thread: Multidimensional data matrices under c++

1. #### Multidimensional data matrices under c++

Hello,
I was happily writing in c++ today when I came across a problem. I need a 3D float number matrix to store results of calculations. So far I know of 1D and 2D matrices. Is there any way of creating a 3D one, for storing (xyz) coordinates for example? :confused:
I can think of one way but is requires recalculation of parameters and a lot of computation time to decode.
I am open to all suggestions
Thanks for all posts
Best greets
MArek
2. No Profile Picture
Contributing User
Devshed Beginner (1000 - 1499 posts)

Join Date
Feb 2001
Posts
1,481
Rep Power
15
float matrix[50][50][50];
3. hm, that was too simple for me to think out I guess. :eek:
Now a stupid question, does this work for float matrix [x][x][x][x] as well??
So far I have been decoding addresses into such a fashion:
x^3*firstadress+x^2*secondadress+x*thirdadress+fourthadress, where x is the maximal dimension of the matrix. This also works though I have to operate on one hell-of-a-long matrix and there is always much more operations with decodning addresses correctly.
Thanks for posts
Best greets
MArek
4. Originally posted by marek_haj
Now a stupid question, does this work for float matrix [x][x][x][x] as well??
Yes, of course it does in just that fashion. I believe that you can go up to seven dimensions -- but check your compiler's documentation first.
5. No Profile Picture
Junior Member
Devshed Newbie (0 - 499 posts)

Join Date
Mar 2003
Posts
11
Rep Power
0
You can use dinamic mammory as

X[][] is pointer X**
x[][][] is pointer X***
and so on.
6. Thanks a lot :D
That really solves me a lot of unneccessary work.
You are the best :cool:
Best greets & thanks for all posts
MArek
7. and works really fine.
Now the program runs like gold and there are no problems with excessive position decoding. Thanks a lot guys :D
Best greets
MArek