开发者

Boost vectors versus STL vectors

开发者 https://www.devze.com 2023-03-11 22:53 出处:网络
How do boost::numeric::ublas::vector and std::vector compare in runtime efficiency? Is it safe to assume that I can convert an entire program from using std::vector to use boost::numeric::ublas::vect

How do boost::numeric::ublas::vector and std::vector compare in runtime efficiency?

Is it safe to assume that I can convert an entire program from using std::vector to use boost::numeric::ublas::vector just by writing:

#include <boost/numeric/ublas/vector.hpp>
using namespace boost::numeric::ublas;

instead of #include<vector>? Can I just use boost vectors as if they were ST开发者_Python百科L vectors in all aspects?

Do functions from <algorithm> work with boost vectors? Do they use the same iterators?

Do they work in C++0x? Do they work for range based loops?


These are completely orthogonal data types: the former represents the algebraic definition of 'vector' (a one-dimensional matrix), while the latter represents the computer science definition of 'vector' (a one-dimensional array).

They don't compare.


You should only use ublas::vector if you want to do linear algebra operations, such as matrix vector multiplication etc. They do not provide the same functionality nor the same interface as std::vector. In terms of run-time efficiency, there is nothing, that I know of, that beats std::vector.

0

精彩评论

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