void checkDenseMatrixEqual(M1 const& m1, M2 const& m2){ BOOST_REQUIRE_EQUAL(m1.size1(),m2.size1()); BOOST_REQUIRE_EQUAL(m1.size2(),m2.size2()); //indexed access for(std::size_t i = 0; i != m2.size1(); ++i){ for(std::size_t j = 0; j != m2.size2(); ++j){ BOOST_CHECK_EQUAL(m1(i,j),m2(i,j)); } } //iterator access rows for(std::size_t i = 0; i != m2.size1(); ++i){ typedef typename M1::const_row_iterator Iter; BOOST_REQUIRE_EQUAL(m1.row_end(i)-m1.row_begin(i), m1.size2()); std::size_t k = 0; for(Iter it = m1.row_begin(i); it != m1.row_end(i); ++it,++k){ BOOST_CHECK_EQUAL(k,it.index()); BOOST_CHECK_EQUAL(*it,m2(i,k)); } //test that the actual iterated length equals the number of elements BOOST_CHECK_EQUAL(k, m1.size2()); } //iterator access columns for(std::size_t i = 0; i != m2.size2(); ++i){ typedef typename M1::const_column_iterator Iter; BOOST_REQUIRE_EQUAL(m1.column_end(i)-m1.column_begin(i), m1.size1()); std::size_t k = 0; for(Iter it = m1.column_begin(i); it != m1.column_end(i); ++it,++k){ BOOST_CHECK_EQUAL(k,it.index()); BOOST_CHECK_EQUAL(*it,m2(k,i)); } //test that the actual iterated length equals the number of elements BOOST_CHECK_EQUAL(k, m1.size1()); } }