I am looking for a way to define a nxm matrix from a given 1xm vector in boost::ublas. I try the following code
boost::numeric::ublas::vector<double> v(100);
boost::numeric::ublas::matrix<double> m(10, 100);
std::copy(v.begin(), v.end(), m.begin2());
but this will only copy the vector to the first row of the matrix. What I want is to duplicate v to rows so each row of M identical to a v. So besides looping each row and run copy 10 times, is that any better way to do so? Thanks.
Short of looping, you may do it like this:
although it's probably not the most optimal, performance-wise.