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