21 #ifndef __UBLAS_EXTRA_HPP__ 22 #define __UBLAS_EXTRA_HPP__ 25 #include <boost/numeric/ublas/vector.hpp> 32 template<
class V,
class D>
33 void append(V& vect, D element)
35 typedef typename V::value_type VD;
36 assert(
typeid(VD) ==
typeid(D));
39 const size_t size = vect.size();
40 vect.resize(size+1,
true);
44 template<
class V,
class I>
45 void erase(V& vect, I begin)
47 typedef typename V::iterator VI;
48 assert(
typeid(VI) ==
typeid(I));
50 for(VI it = begin; it != vect.end()-1; ++it)
54 vect.resize(vect.size()-1);
58 void erase_column(M& mat,
size_t pos)
60 for(
size_t i = pos; i < mat.size2()-1; ++i)
62 column(mat,i) = column(mat,i+1);
64 mat.resize(mat.size1(),mat.size2()-1);
67 template<
class M,
class V>
68 void add_to_diagonal(M& mat,
const V& vec)
70 assert(mat.size1()==mat.size2());
71 assert(mat.size1()==vec.size());
72 const size_t ll = vec.size();
73 for(
size_t ii = 0; ii < ll; ++ii)
75 mat(ii,ii) += vec(ii);
79 boost::numeric::ublas::vector<double> array2vector(
const double array[],
Namespace of the library interface.