Storm 1.11.1.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
GmmxxAdapter.cpp
Go to the documentation of this file.
2
3#include <algorithm>
4
8
9namespace storm {
10namespace adapters {
11
12#ifdef STORM_HAVE_GMM
13template<typename T>
14std::unique_ptr<gmm::csr_matrix<T>> GmmxxAdapter<T>::toGmmxxSparseMatrix(storm::storage::SparseMatrix<T> const& matrix) {
15 uint_fast64_t realNonZeros = matrix.getEntryCount();
16 STORM_LOG_TRACE("Converting " << matrix.getRowCount() << "x" << matrix.getColumnCount() << " matrix with " << realNonZeros
17 << " non-zeros to gmm++ format.");
18
19 // Prepare the resulting matrix.
20 std::unique_ptr<gmm::csr_matrix<T>> result(new gmm::csr_matrix<T>(matrix.getRowCount(), matrix.getColumnCount()));
21
22 // Copy Row Indications
23 std::copy(matrix.rowIndications.begin(), matrix.rowIndications.end(), result->jc.begin());
24
25 // Copy columns and values.
26 std::vector<T> values;
27 values.reserve(matrix.getEntryCount());
28
29 // To match the correct vector type for gmm, we create the vector with the exact same type.
30 decltype(result->ir) columns;
31 columns.reserve(matrix.getEntryCount());
32
33 for (auto const& entry : matrix) {
34 columns.emplace_back(entry.getColumn());
35 values.emplace_back(entry.getValue());
36 }
37
38 std::swap(result->ir, columns);
39 std::swap(result->pr, values);
40
41 STORM_LOG_TRACE("Done converting matrix to gmm++ format.");
42
43 return result;
44}
45
46template class GmmxxAdapter<double>;
47template class GmmxxAdapter<storm::RationalNumber>;
48template class GmmxxAdapter<storm::RationalFunction>;
49#endif
50
51} // namespace adapters
52} // namespace storm
A class that holds a possibly non-square matrix in the compressed row storage format.
index_type getEntryCount() const
Returns the number of entries in the matrix.
index_type getColumnCount() const
Returns the number of columns of the matrix.
index_type getRowCount() const
Returns the number of rows of the matrix.
#define STORM_LOG_TRACE(message)
Definition logging.h:12