开发者

Creating a matrix from vectors in C++ with 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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜