cube structure

P

Philipp Kraus

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
 
M

Marcel Müller

Philipp said:
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
 
R

red floyd

Philipp Kraus wrote:

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

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

Marcel Müller

red said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top