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 STORM_LOG_TRACE("Converting " << matrix.getRowCount() << "x" << matrix.getColumnCount() << " matrix with " << matrix.getEntryCount()
16 << " non-zeros to gmm++ format.");
17
18 // Prepare the resulting matrix.
19 std::unique_ptr<gmm::csr_matrix<T>> result(new gmm::csr_matrix<T>(matrix.getRowCount(), matrix.getColumnCount()));
20
21 // Copy Row Indications
22 std::copy(matrix.rowIndications.begin(), matrix.rowIndications.end(), result->jc.begin());
23
24 // Copy columns and values.
25 std::vector<T> values;
26 values.reserve(matrix.getEntryCount());
27
28 // To match the correct vector type for gmm, we create the vector with the exact same type.
29 decltype(result->ir) columns;
30 columns.reserve(matrix.getEntryCount());
31
32 for (auto const& entry : matrix) {
33 columns.emplace_back(entry.getColumn());
34 values.emplace_back(entry.getValue());
35 }
36
37 std::swap(result->ir, columns);
38 std::swap(result->pr, values);
39
40 STORM_LOG_TRACE("Done converting matrix to gmm++ format.");
41
42 return result;
43}
44
45template class GmmxxAdapter<double>;
46template class GmmxxAdapter<storm::RationalNumber>;
47template class GmmxxAdapter<storm::RationalFunction>;
48#endif
49
50} // namespace adapters
51} // 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