I have a scenario in my c++ project which necessitates the use of a dynamically expanding array within a for loop and it is not conducive or highly inefficient to preallocate. Simply put, after each iteration of the loop the array is appended by a sub-array of length that is different from the previous iteration. One possible solution is std::vector::push_back. But, currently I rely heavily on the armadillo library. My questions are as follows,
Is a push_back like operation possible with armadillo armadillo Col, Colvec or mat data structures?
If (1) is not possible, Is it easy/efficient to switch back and forth between std::vector and armadillo vectors?
Is the use of arma::fields an efficient alternative? The idea is to allocate a field of size equal to the range of the loop.
Copy vectors into the field elements during each iteration of the for loop and once the loop is exited, consolidate the field elements into a single vector.