Browse Source

fixed an issue with getSubmatrix

Former-commit-id: f4f8fb2f61
tempestpy_adaptions
dehnert 9 years ago
parent
commit
44a9636f69
  1. 22
      src/storage/SparseMatrix.cpp
  2. 3
      src/storage/SparseMatrix.h

22
src/storage/SparseMatrix.cpp

@ -525,7 +525,25 @@ namespace storm {
*it = i;
}
auto res = getSubmatrix(rowConstraint, columnConstraint, fakeRowGroupIndices, insertDiagonalElements);
res.rowGroupIndices = this->rowGroupIndices;
// Create a new row grouping that reflects the new sizes of the row groups.
std::vector<uint_fast64_t> newRowGroupIndices;
newRowGroupIndices.push_back(0);
auto selectedRowIt = rowConstraint.begin();
// For this, we need to count how many rows were preserved in every group.
for (uint_fast64_t group = 0; group < this->getRowGroupCount(); ++group) {
uint_fast64_t newRowCount = 0;
while (*selectedRowIt < this->getRowGroupIndices()[group + 1]) {
++selectedRowIt;
++newRowCount;
}
if (newRowCount > 0) {
newRowGroupIndices.push_back(newRowGroupIndices.back() + newRowCount);
}
}
res.rowGroupIndices = newRowGroupIndices;
return res;
}
}
@ -641,8 +659,6 @@ namespace storm {
SparseMatrix<ValueType> res(getSubmatrix(false, rowsToKeep, storm::storage::BitVector(getColumnCount(), true), false));
assert(res.getRowCount() == rowsToKeep.getNumberOfSetBits());
assert(res.getColumnCount() == getColumnCount());
std::cout << getRowGroupCount() << std::endl;
std::cout << res.getRowGroupCount() << std::endl;
assert(getRowGroupCount() == res.getRowGroupCount());
return res;
}

3
src/storage/SparseMatrix.h

@ -603,6 +603,9 @@ namespace storm {
* set to one in the given bit vector.
*
* @param useGroups If set to true, the constraint for the rows is interpreted as selecting whole row groups.
* If it is not set, the row constraint is interpreted over the actual rows. Note that empty row groups will
* be dropped altogether. That is, if no row of a row group is selected *or* the row group is alread empty,
* the submatrix will not have this row group.
* @param constraint A bit vector indicating which rows to keep.
* @param columnConstraint A bit vector indicating which columns to keep.
* @param insertDiagonalEntries If set to true, the resulting matrix will have zero entries in column i for

Loading…
Cancel
Save