void test(Matrix& matrix, const char* name) { cout << "\n" << name << "\n"; using mtl::matrix::inserter; using mtl::element_array; typedef typename mtl::Collection<Matrix>::value_type value_type; mtl::dense2D<double> m1(2, 2); m1[0][0]= 1.0; m1[0][1]= 2.0; m1[1][0]= 3.0; m1[1][1]= 4.0; std::vector<int> row1, col1; row1.push_back(1); row1.push_back(2); col1.push_back(0); col1.push_back(2); double a2[2][2]= {{11., 12.},{13., 14.}}; std::vector<int> ind2; ind2.push_back(2); ind2.push_back(4); std::vector<int> ind3; ind3.push_back(3); ind3.push_back(1); set_to_zero(matrix); // dense matrices are not automatically set to zero { inserter<Matrix, mtl::operations::update_plus<value_type> > ins(matrix); ins << element_matrix(m1, row1, col1) << element_array(a2, ind2); ins << element_array(a2, ind3); } cout << "Filled matrix:\n" << matrix << "\n"; MTL_THROW_IF(matrix[0][0] != 0.0, mtl::runtime_error("wrong zero-element")); MTL_THROW_IF(matrix[1][0] != 1.0, mtl::runtime_error("wrong insertion (single value)")); MTL_THROW_IF(matrix[2][2] != 15.0, mtl::runtime_error("wrong summation")); MTL_THROW_IF(matrix[1][1] != 14.0, mtl::runtime_error("wrong insertion (single value)")); }