Suppose I require an undetermined number of 3-by-4 matrices. (Or a sequence of any other fixed m-by-n-dimensional matrices.) My first thought is to store these matrices in a std::vector
, where each matrix is itself a std::vector<std::vector<double> >
. How can I use std::vector::reserve()
to preallocate space for a number, say x
, of these matrices? Because I know two of the dimensions, I ought (or I'd like) to be able to x
times the size of these blocks.
I know how to implement this object in a 1D std::vector
, but I'd like to know how to do it in a 3D std::vector
, if for no other reason than to better learn how to use the std::vector
class.