title: Multi-dimensional datasets in C++: cleanest approach to go from a std::vector of 2D data, to a 2D grid of std::vectors?
body: <p><strong>Context:</strong>
  I've been processing scientific satellite images, currently keeping the individual end results at each timestamp as <code>cv::Mat_&lt;double&gt;</code>, which can for instance be stored in a std::container of images, such as a <code>std::vector&lt;cv::Mat_&lt;double&gt;&gt;</code>.</p>
  
  <p><strong>The issue:</strong>
  I would now like to study the physical properties of each individual pixel over time. For that, it would be far preferable if I could look at the data along the time dimension and work with a 2D table of vectors instead. In other words: to have a <code>std::vector&lt;double&gt;</code> associated to each pixel on the 2D grid that is common to all images. </p>
  
  <p>A reason for that is that the type of calculations (computing percentiles, curve fitting, etc) will rely on <code>std::algorithms</code> and libraries which expect to be fed with <code>std::vectors</code> and the like. For a given pixel the data is definitely not contiguous in memory along the time dimension though.</p>
  
  <p><strong>Can/Should I really avoid copying the data in such a case?</strong> If yes, what would be the best approach, then? By best I mean efficient yet as 'clean'/'clear' as possible.</p>
  
  <p>I thought of <code>std::reference_wrapper</code> to store the addresses in a <code>std::vector</code>; it's simple and works but each entry takes as much memory as if I had simply duplicated the data in a <code>std::vector&lt;double&gt;</code>. Each data point is just a double after all.</p>
  
  <p>NB:
  I've stumbled upon Boost MultiArray, but I'd like to avoid having to add a Boost dependency.</p>
  
  <p>Many thanks in advance for your time/input.</p>