I have a 2D-matrix whose column size increases after every iteration but the row size remains fixed. For each iteration, a function returns a matrix which I would like to stack horizontally. Following is the code I tried but I think I am doing something wrong in the big_mat[ii].insert part. But I looked around and found codes for vertical stacking where you can start from big_mat.end() and perform insert. But I want the row size to remain fixed. Can you please help me with this ? Also the maximum final size would be of the order 1,000,000 times 5,000.
std::vector<std::vector<float> > big_mat;
big_mat.reserve(fixed_row_dim);
std::vector<std::vector<float> > small_mat;
for (some condition){
// small_mat is always fixed_row_dim x some_dim
small_mat = GetMat(params,fixed_row_dim);
for (int ii = 0; ii < fixed_row_dim; ii++){
big_mat[ii].insert(big_mat[ii].end(),small_mat[ii].begin(),small_mat[ii].end());
}
}