Vector-transposing function
Change your column loop to use a reference.

for (const auto &amp;c : column_vec)


Without the reference, a copy will be made of each vector.  This will involve a memory allocation.  Using the reference you avoid all that, which should save a good deal of time since each c will be a single element vector.

auto r can stay since r will be a double.

Combine this with using reserve on row_vector will eliminate all but one memory allocation.