#1
  1. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Location
    currently Lisbone, Portugal
    Posts
    154
    Rep Power
    12

    Lightbulb 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. #2
  3. No Profile Picture
    Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Feb 2001
    Posts
    1,474
    Rep Power
    15
    float matrix[50][50][50];
  4. #3
  5. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Location
    currently Lisbone, Portugal
    Posts
    154
    Rep Power
    12
    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
  6. #4
  7. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,091
    Rep Power
    2222
    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.
  8. #5
  9. 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.
  10. #6
  11. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Location
    currently Lisbone, Portugal
    Posts
    154
    Rep Power
    12
    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
  12. #7
  13. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Location
    currently Lisbone, Portugal
    Posts
    154
    Rep Power
    12
    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

IMN logo majestic logo threadwatch logo seochat tools logo