I came across this in the header assignment.hpp:
v <<= 1,2,3;
I suggest that there might be more useful methods if you look carefully. For instance.
vector<double> a(6, 0);
a <<= 1, 2, move_to(5), 3;
: 1 2 0 0 0 3
matrix<double> A(3, 3, 0);
A <<= 1, 2, next_row(),
3, 4, begin1(), 1;
:
1 2 1
3 4 0
0 0 0
Live On Coliru
#include <boost/numeric/ublas/vector.hpp>
#include <boost/numeric/ublas/vector_expression.hpp>
#include <boost/numeric/ublas/traits/c_array.hpp>
#include <boost/numeric/ublas/assignment.hpp>
namespace ublas = boost::numeric::ublas;
int main() {
using V = ublas::c_vector<int, 3>;
V v;
v <<= 1,2,3;
for (auto i : v)
std::cout << i << " ";
}
1 2 3