|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
||||
|
||||
|
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? 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
|
|||
|
|||
|
float matrix[50][50][50];
|
|
#3
|
||||
|
||||
|
hm, that was too simple for me to think out I guess.
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
|
||||
|
||||
|
Quote:
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
|
|||
|
|||
|
You can use dinamic mammory as
X[][] is pointer X** x[][][] is pointer X*** and so on. |
|
#6
|
||||
|
||||
|
Thanks a lot
That really solves me a lot of unneccessary work. You are the best 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 Best greets MArek |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > C Programming > Multidimensional data matrices under c++ |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|