开发者

Creating a matrix from vectors in C++ with uBLAS

开发者 https://www.devze.com 2023-03-14 13:12 出处:网络
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?

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.


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).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号