#define BOOST_UBLAS_NO_ELEMENT_PROXIES #include #include using std::cout; using std::endl; int main() { boost::numeric::ublas::coordinate_matrix matrix_mask(3, 3, 2); cout << "Setting matrix(1,1) = 2.1" << endl; matrix_mask(1,1) = 2.1; cout << "Displaying matrix(1,1)" << endl; std::cout << matrix_mask(1,1) << std::endl; cout << "Displaying indices1, indices2, and values_data. Why are there 3? May be a red herring" << endl; std::copy( matrix_mask.index1_data().begin(), matrix_mask.index1_data().end(), std::ostream_iterator(std::cout, ",")); std::cout << std::endl; std::copy(matrix_mask.index2_data().begin(), matrix_mask.index2_data().end(), std::ostream_iterator(std::cout, ",")); std::cout << std::endl; std::copy(matrix_mask.value_data().begin(), matrix_mask.value_data().end(), std::ostream_iterator(std::cout, ",")); std::cout << std::endl; cout << "Setting matrix(0,1) = 1.1" << endl; matrix_mask(0, 1) = 1.1; cout << "Displaying indices1, indices2, and values_data. Looks OK to me." << endl; std::copy( matrix_mask.index1_data().begin(), matrix_mask.index1_data().end(), std::ostream_iterator(std::cout, ",")); std::cout << std::endl; std::copy(matrix_mask.index2_data().begin(), matrix_mask.index2_data().end(), std::ostream_iterator(std::cout, ",")); std::cout << std::endl; std::copy(matrix_mask.value_data().begin(), matrix_mask.value_data().end(), std::ostream_iterator(std::cout, ",")); std::cout << std::endl; cout << "Sorting the matrix, which would be triggered pre-lookup." << endl; matrix_mask.sort(); // std::cout << matrix_mask(1,1) << std::endl; cout << "Displaying indices1, indices2, and values_data. Messed up now after the read." << endl; std::copy( matrix_mask.index1_data().begin(), matrix_mask.index1_data().end(), std::ostream_iterator(std::cout, ",")); std::cout << std::endl; std::copy(matrix_mask.index2_data().begin(), matrix_mask.index2_data().end(), std::ostream_iterator(std::cout, ",")); std::cout << std::endl; std::copy(matrix_mask.value_data().begin(), matrix_mask.value_data().end(), std::ostream_iterator(std::cout, ",")); std::cout << std::endl; cout << "Displaying matrix(1,1). This might be doing a sort that breaks the values?" << endl; std::cout << matrix_mask(1,1) << std::endl; cout << "Displaying indices1, indices2, and values_data. Messed up now after the read." << endl; std::copy( matrix_mask.index1_data().begin(), matrix_mask.index1_data().end(), std::ostream_iterator(std::cout, ",")); std::cout << std::endl; std::copy(matrix_mask.index2_data().begin(), matrix_mask.index2_data().end(), std::ostream_iterator(std::cout, ",")); std::cout << std::endl; std::copy(matrix_mask.value_data().begin(), matrix_mask.value_data().end(), std::ostream_iterator(std::cout, ",")); std::cout << std::endl; }