I am looking for a way to have a Matrix variable (i.e, a bunch of ordered column vectors) which is contiguous in memory, using an STL container (e.g, an std::vector). One option is this:
vector< vector<float> > mat;
mat.push_back (column1); // column1 is of type vector<float>
mat.push_back (column2); // column2 is of type vector<float>
which is not contiguous in the sense that &mat[1][0] is not equal to &mat[0][N-1] + 1, where N is the length of column1.
Another option is this:
vector< float > mat;
float f1[] = {1., 2., 3.};
float f2[] = {4., 5., 6.};
mat.insert (mat.end (), f1, f1 + 3);
mat.insert (mat.end (), f2, f2 + 3);
Which is contiguous in memory, but enforces me to use an array of floats.
EDIT
TO make it clear, I prefer an option like vector < vector<float> >, so I can access a given column as an STL vector.
I would write my own matrix class which uses a
std::vector<float>as backend for storage.