Browse Source

Catching empty selection in getSubmatrix pointed out by Timo Gros

tempestpy_adaptions
dehnert 7 years ago
parent
commit
0d78367b9a
  1. 1
      src/storm/storage/SparseMatrix.cpp
  2. 8
      src/test/storm/storage/SparseMatrixTest.cpp

1
src/storm/storage/SparseMatrix.cpp

@ -892,6 +892,7 @@ namespace storm {
template<typename ValueType>
SparseMatrix<ValueType> SparseMatrix<ValueType>::getSubmatrix(storm::storage::BitVector const& rowGroupConstraint, storm::storage::BitVector const& columnConstraint, std::vector<index_type> const& rowGroupIndices, bool insertDiagonalEntries) const {
STORM_LOG_THROW(!rowGroupConstraint.empty() && !columnConstraint.empty(), storm::exceptions::InvalidArgumentException, "Cannot build empty submatrix.");
uint_fast64_t submatrixColumnCount = columnConstraint.getNumberOfSetBits();
// Start by creating a temporary vector that stores for each index whose bit is set to true the number of

8
src/test/storm/storage/SparseMatrixTest.cpp

@ -331,13 +331,15 @@ TEST(SparseMatrix, Submatrix) {
storm::storage::SparseMatrix<double> matrix;
ASSERT_NO_THROW(matrix = matrixBuilder.build());
storm::storage::BitVector rowGroupConstraint(4);
storm::storage::BitVector columnConstraint(4);
ASSERT_THROW(matrix.getSubmatrix(true, rowGroupConstraint, columnConstraint), storm::exceptions::InvalidArgumentException);
std::vector<uint_fast64_t> rowGroupIndices = {0, 1, 2, 4, 5};
storm::storage::BitVector rowGroupConstraint(4);
rowGroupConstraint.set(2);
rowGroupConstraint.set(3);
storm::storage::BitVector columnConstraint(4);
columnConstraint.set(0);
columnConstraint.set(3);

Loading…
Cancel
Save