I simply want to traverse a matrix from start to finish touching upon every element. However, I see that there is no one iterator for boost matrix, rather there are two iterators, and I haven't been able to figure out how to make them work so that you can traverse the entire matrix
typedef boost::numeric::ublas::matrix<float> matrix;
matrix m1(3, 7);
for (auto i = 0; i < m1.size1(); i++)
{
for (auto j = 0; j < m1.size2(); j++)
{
m1(i, j) = i + 1 + 0.1*j;
}
}
for (auto itr1 = m1.begin1(); itr1!= m1.end1(); ++itr1)
{
for (auto itr2 = m1.begin2(); itr2 != m1.end2(); itr2++)
{
//std::cout << *itr2 << " ";
//std::cout << *itr1 << " ";
}
}
This code of mine, prints only row1 of matrix using itr1 and only column1 of the matrix using itr2. What can be done to instead access all rows and columns?