cube structure

Discussion in 'C++' started by Philipp Kraus, Apr 21, 2010.

  1. Hello,

    I need y n-dimensional cube structur. Is there a solution in the STL or Boost?
    The datatypes of the cube must be variable. I think an array is like
    this structure
    but I need a dynamic allocation:

    read(i)
    cube c<int>(i, 10) //this declare a cube with 10^i elements

    Thanks for help

    Phil
     
    Philipp Kraus, Apr 21, 2010
    #1
    1. Advertising

  2. Philipp Kraus

    John H. Guest

    On Apr 21, 4:16 pm, Philipp Kraus <> wrote:
    > I need y n-dimensional cube structur.


    You should try writing your own, it can be fun.

    >Is there a solution in the STL or Boost?


    After you wrote your own, throw it away and look at boost's
    Multidimensional Array Library:
    http://www.boost.org/doc/libs/1_42_0/libs/multi_array/doc/index.html
     
    John H., Apr 21, 2010
    #2
    1. Advertising

  3. Philipp Kraus wrote:
    > I need y n-dimensional cube structur. Is there a solution in the STL or
    > Boost?


    Directly: no.

    But feel free to setup a nested structure. However, you have to take
    care of the vector size if you need to synchronize that in the deeper
    levels. It depends a bit on what you call 'dynamic allocation'. If the
    size is a lifetime constant of the objects, it is quite easy to handle.

    > read(i)
    > cube c<int>(i, 10) //this declare a cube with 10^i elements


    Here you have another implicit constraint. All dimensions are the same.
    Is this always true?

    Furthermore think about the memory complexity. You have exponential
    complexity here. Is this really what you need? Your memory footprint
    will literally explode with i. Are all values in the tensor distinct or
    are many of them zero? In the latter case you should prefer some sparse
    tensor implementation. Also a Perl like create on demand solution might
    be sufficient where non-existing elements are zero by definition.

    Whatever you do, do not allocate a single chunk of memory and index it
    by x,y,z etc. This may cause unwanted memory fragmentation. And, of
    course, reallocations are extremely expensive.


    Marcel
     
    Marcel Müller, Apr 21, 2010
    #3
  4. Philipp Kraus

    red floyd Guest

    On Apr 21, 3:11 pm, Marcel Müller <>
    wrote:
    > Philipp Kraus wrote:


    > > read(i)
    > > cube c<int>(i, 10) //this declare a cube with 10^i elements

    >
    > Here you have another implicit constraint. All dimensions are the same.
    > Is this always true?
    >


    Kind of implied by the problem statemtn -- "cube".
     
    red floyd, Apr 22, 2010
    #4
  5. red floyd wrote:
    >> Here you have another implicit constraint. All dimensions are the same.
    >> Is this always true?

    >
    > Kind of implied by the problem statemtn -- "cube".


    Well, from mathematical point of view, yes. In context of database and
    BI applications cube is used for multi dimensional data containers in
    general.


    Marcel
     
    Marcel Müller, Apr 24, 2010
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. mrwoopey
    Replies:
    3
    Views:
    2,291
    pipodyer
    May 9, 2006
  2. Joel Leong
    Replies:
    3
    Views:
    3,177
    Scott Allen
    Apr 19, 2005
  3. sarah28
    Replies:
    3
    Views:
    1,008
    sarah28
    Jun 26, 2003
  4. Cube root computation

    , Jan 16, 2006, in forum: C Programming
    Replies:
    2
    Views:
    583
    Randy Poe
    Jan 16, 2006
  5. Replies:
    4
    Views:
    1,027
Loading...

Share This Page