Browse Source

Explicitly set initialization order for SparseMatrix to avoid nasty segfaults

tempestpy_adaptions
Matthias Volk 5 years ago
parent
commit
325b700c62
  1. 7
      src/storm/storage/SparseMatrix.cpp

7
src/storm/storage/SparseMatrix.cpp

@ -406,7 +406,12 @@ namespace storm {
} }
template<typename ValueType> template<typename ValueType>
SparseMatrix<ValueType>::SparseMatrix(index_type columnCount, std::vector<index_type>&& rowIndications, std::vector<MatrixEntry<index_type, ValueType>>&& columnsAndValues, boost::optional<std::vector<index_type>>&& rowGroupIndices) : rowCount(rowIndications.size() - 1), columnCount(columnCount), entryCount(columnsAndValues.size()), nonzeroEntryCount(0), columnsAndValues(std::move(columnsAndValues)), rowIndications(std::move(rowIndications)), trivialRowGrouping(!rowGroupIndices), rowGroupIndices(std::move(rowGroupIndices)) {
SparseMatrix<ValueType>::SparseMatrix(index_type columnCount, std::vector<index_type>&& rowIndications, std::vector<MatrixEntry<index_type, ValueType>>&& columnsAndValues, boost::optional<std::vector<index_type>>&& rowGroupIndices) : columnCount(columnCount), nonzeroEntryCount(0), columnsAndValues(std::move(columnsAndValues)), rowIndications(std::move(rowIndications)), rowGroupIndices(std::move(rowGroupIndices)) {
// Initialize some variables here which depend on other variables
// This way we are more robust against different initialization orders
this->rowCount = this->rowIndications.size() - 1;
this->entryCount = this->columnsAndValues.size();
this->trivialRowGrouping = !this->rowGroupIndices;
this->updateNonzeroEntryCount(); this->updateNonzeroEntryCount();
} }

Loading…
Cancel
Save