From b27b26f2b74ba9ce4acbf1f72bd7cd9fed6dfd9f Mon Sep 17 00:00:00 2001 From: Sebastian Junges Date: Mon, 8 Jan 2018 15:55:27 +0100 Subject: [PATCH] row group start and row group end for iteration over matrices --- src/storage/matrix.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/storage/matrix.cpp b/src/storage/matrix.cpp index 0e09ffc..19b74d2 100644 --- a/src/storage/matrix.cpp +++ b/src/storage/matrix.cpp @@ -38,6 +38,9 @@ void define_sparse_matrix(py::module& m) { .def_property_readonly("nr_columns", &SparseMatrix::getColumnCount, "Number of columns") .def_property_readonly("nr_entries", &SparseMatrix::getEntryCount, "Number of non-zero entries") .def_property_readonly("_row_group_indices", &SparseMatrix::getRowGroupIndices, "Starting rows of row groups") + + .def("get_row_group_start", [](SparseMatrix& matrix, entry_index row) {return matrix.getRowGroupIndices()[row];}) + .def("get_row_group_end", [](SparseMatrix& matrix, entry_index row) {return matrix.getRowGroupIndices()[row+1];}) .def_property_readonly("has_trivial_row_grouping", &SparseMatrix::hasTrivialRowGrouping, "Trivial row grouping") .def("get_row", [](SparseMatrix& matrix, entry_index row) { return matrix.getRows(row, row+1); @@ -87,6 +90,8 @@ void define_sparse_matrix(py::module& m) { .def_property_readonly("nr_columns", &SparseMatrix::getColumnCount, "Number of columns") .def_property_readonly("nr_entries", &SparseMatrix::getEntryCount, "Number of non-zero entries") .def_property_readonly("_row_group_indices", &SparseMatrix::getRowGroupIndices, "Starting rows of row groups") + .def("get_row_group_start", [](SparseMatrix& matrix, entry_index row) {return matrix.getRowGroupIndices()[row];}) + .def("get_row_group_end", [](SparseMatrix& matrix, entry_index row) {return matrix.getRowGroupIndices()[row+1];}) .def_property_readonly("has_trivial_row_grouping", &SparseMatrix::hasTrivialRowGrouping, "Trivial row grouping") .def("get_row", [](SparseMatrix& matrix, entry_index row) { return matrix.getRows(row, row+1);