Menu
  • HOME
  • TAGS

How to insert an element into ublas matrix with dynamic size

c++,boost-ublas

As you have noticed yourself, boost::numeric::ublas::matrix doesn't resize itself automatically, like std::vector. You have to do the resizing manually before calling operator(), or write a function template that does the resizing for you as shown here: namespace ublas = boost::numeric::ublas; //just a friendly alias! template<typename T, typename U> void assign(ublas::matrix<T>&...

boost::ublas how to get determinant of int matrix?

c++,math,boost-ublas

Of course this is not a bug, since checks like this one is all over uBLAS. I guess this is because most of its operations would make no sense for non-float types. You can disable type checks using #define BOOST_UBLAS_TYPE_CHECK 0 before includes. But think twice! Take a look at...

How to create a nonempty boost ublas::vector inside an initializer list?

c++,boost,vector,constructor,boost-ublas

You may change the default storage type of an ublas/vector from unbounded_array to std::vector to get initializer_list support or introduce a helper function to initialize the member: #include <iostream> #include <boost/numeric/ublas/vector.hpp> using namespace boost::numeric::ublas; template <typename T> unbounded_array<T> make_unbounded_array(std::initializer_list<T> list) { unbounded_array<T> result(list.size()); for(unsigned i = 0; i < list.size();...