Reputation: 308
If I have n vectors of length m and want to join them to create an mxn matrix, what is the most efficient way to do this in C++ using Boost uBLAS?
Obviously, I can just loop though them and assign each matrix element with the corresponding vector value, but I feel like there is a better way to do this I am unaware of.
Upvotes: 4
Views: 878
Reputation: 54178
Rather than iterating the entire list of vectors element-wise, I would try assigning each of your vectors directly into the corresponding matrix column.
template<class AE >
BOOST_UBLAS_INLINE matrix_column & operator= (const vector_expression< AE > &ae)
You have to copy each element at some point, but this should be faster than a nested loop (or a perf bug in Boost.uBlas, if not).
Upvotes: 2