Note that there are some explanatory texts on larger screens.

plurals
  1. POMultidimensional fixed-size arrays using boost
    primarykey
    data
    text
    <p>I would like to <code>typedef</code> a multi-dimensional array using the boost library. The matrix is rectangular and the dimension and lengths in each dimension should be fixed within the <code>typedef</code>. In case of a vector this was exactly what is solved by the <code>boost::array</code> template class:</p> <pre><code>typedef boost::array&lt;int, 3&gt; vec3_t; </code></pre> <p>For multi-dimensional arrays I could repeat this construction</p> <pre><code>typedef boost::array&lt;boost::array&lt;int, 2&gt; ,3&gt; mat2x3_t </code></pre> <p>and it allows me to also initialize my matrix quite nicely (although I'm not sure if this behavior is guaranteed...):</p> <pre><code>Mat2x3_t m = { 11, 12, 13, 21, 22, 23}; </code></pre> <p>However, from a performance standpoint I am unsure whether this is to way to go. My understanding of memory management is very limited but the way I imagine this in the computer memory is, that the inner-most array (<code>boost::array&lt;int, 2&gt;</code> in the above example) is guaranteed to allocate a contiguous block of memory, whereas, for the "higher levels" of arrays I'n not sure.</p> <p>I also looked at the <code>boost::multi_array</code> class, where, to my understanding, the whole matrix will take up a contiguous block of memory and is quite ideal for my "rectangular" matrices that I'm interested in. It further supplies some neat member functions (which are not crucial for my implementation but are a nice addition nonetheless). The deal breaker for this class seems to be, however, that I cannot <code>typedef</code> the length in each dimension but only the number of dimensions.</p> <p><em>So my question is:</em> Does the the construction in terms of multiple arrays result in performance issues when I have to iterate through it a lot (~10^7 times)? In my example I used a 2x3 int matrix but my use-case would be a higher-dimensional 64x4x2 matrix with complex numbers. And, is the initialization in terms of the curly braces guaranteed by the implementation? If there are issues with the arrays, is there a way to typedef a fixed size multi_array? Or are the other alternatives I am missing?</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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