Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Boost vectors versus STL vectors

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 STL 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?

like image 602
Rafael S. Calsaverini Avatar asked Jun 09 '11 14:06

Rafael S. Calsaverini


Video Answer


1 Answers

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.

like image 112
ildjarn Avatar answered Sep 28 '22 07:09

ildjarn