Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can solve the problem in at least two ways, depending on your preferences. First of all - you don't need the Boost library, and you can do it yourself.</p> <pre><code>class array{ unsigned int dimNumber; vector&lt;unsigned int&gt; dimSizes; float *array; array(const unsigned int dimNumber, ...){ va_list arguments; va_start(arguments,dimNumber); this-&gt;dimNumber = dimNumber; unsigned int totalSize = 1; for(unsigned int i=0;i&lt;dimNumber;i++) { dimSizes.push_back(va_arg(arguments,double)); totalSize *= dimSizes[dimSizes.size()-1]; } va_end(arguments); array = new float[totalSize]; }; float getElement(unsigned int dimNumber, ...){ va_list arguments; va_start(arguments,dimNumber); unsgned int elementPos = 0, dimAdd = 1; for(unsigned int i=0;i&lt;dimNumber;i++) { unsigned int val = va_arg(arguments,double); elementPos += dimAdd * val; dimAdd *= dimsizes[i]; } return array[elementPos] }; }; </code></pre> <p>Setting an element value would be the same, you will just have to specify the new value. Of course you can use any type you want, not just float... and of course remember to <code>delete[]</code> the array in the destructor.</p> <p>I haven't tested the code (just wrote it straight down here from memory), so there can be some problems with calculating the position, but I'm sure you'll fix them if you encounter them. This code should give you the general idea.</p> <p>The second way would be to create a <code>dimension</code> class, which would store a <code>vector&lt;dimension*&gt;</code> which would store sub-dimensions. But that's a bit complicated and too long to write down here.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload