diff --git a/src/adapters/GmmxxAdapter.h b/src/adapters/GmmxxAdapter.h index 3fd990a46..482b8a16a 100644 --- a/src/adapters/GmmxxAdapter.h +++ b/src/adapters/GmmxxAdapter.h @@ -31,15 +31,16 @@ public: LOG4CPLUS_DEBUG(logger, "Converting matrix with " << realNonZeros << " non-zeros to gmm++ format."); // Prepare the resulting matrix. - gmm::csr_matrix* result = new gmm::csr_matrix(matrix.rowCount, matrix.rowCount); + gmm::csr_matrix* result = new gmm::csr_matrix(matrix.rowCount, matrix.colCount); // Copy Row Indications - std::copy(matrix.rowIndications.begin(), matrix.rowIndications.end(), std::back_inserter(result->jc)); + std::copy(matrix.rowIndications.begin(), matrix.rowIndications.end(), result->jc.begin()); // Copy Columns Indications result->ir.resize(realNonZeros); - std::copy(matrix.columnIndications.begin(), matrix.columnIndications.end(), std::back_inserter(result->ir)); + std::copy(matrix.columnIndications.begin(), matrix.columnIndications.end(), result->ir.begin()); // And do the same thing with the actual values. - std::copy(matrix.valueStorage.begin(), matrix.valueStorage.end(), std::back_inserter(result->pr)); + result->pr.resize(realNonZeros); + std::copy(matrix.valueStorage.begin(), matrix.valueStorage.end(), result->pr.begin()); LOG4CPLUS_DEBUG(logger, "Done converting matrix to gmm++ format."); diff --git a/src/storage/SparseMatrix.h b/src/storage/SparseMatrix.h index 977c6f67a..3d8009733 100644 --- a/src/storage/SparseMatrix.h +++ b/src/storage/SparseMatrix.h @@ -887,29 +887,16 @@ public: return result; } - void repeatedMultiply(std::vector* vector, uint_fast64_t multiplications) { - std::vector* originalVector = vector; - std::vector* swap = nullptr; - std::vector* temporaryResult = new std::vector(vector->size()); - for (uint_fast64_t iter = 0; iter < multiplications; ++iter) { - for (uint_fast64_t row = 0; row < rowCount; ++row) { - (*temporaryResult)[row] = 0; - for (uint_fast64_t col = columnIndications[row]; col < columnIndications[row + 1]; ++col) { - (*temporaryResult)[row] += valueStorage[col] * (*vector)[row]; - } - } - - swap = temporaryResult; - temporaryResult = vector; - vector = swap; - } - - if (multiplications % 2 == 1) { - *originalVector = *temporaryResult; - delete vector; - } else { - delete temporaryResult; + T getRowVectorProduct(uint_fast64_t row, std::vector& vector) { + T result = storm::utility::constGetZero();; + auto valueIterator = valueStorage.begin() + rowIndications[row]; + const auto valueIteratorEnd = valueStorage.begin() + rowIndications[row + 1]; + auto columnIterator = columnIndications.begin() + rowIndications[row]; + const auto columnIteratorEnd = columnIndications.begin() + rowIndications[row + 1]; + for (; valueIterator != valueIteratorEnd; ++valueIterator, ++columnIterator) { + result += *valueIterator * vector[*columnIterator]; } + return result; } /*! @@ -1008,11 +995,7 @@ public: std::cout << "entries in (" << rowCount << "x" << colCount << " matrix):" << std::endl; std::cout << rowIndications << std::endl; std::cout << columnIndications << std::endl; - for (uint_fast64_t i = 0; i < rowCount; ++i) { - for (uint_fast64_t j = rowIndications[i]; j < rowIndications[i + 1]; ++j) { - std::cout << "(" << i << "," << columnIndications[j] << ") = " << valueStorage[j] << std::endl; - } - } + std::cout << valueStorage << std::endl; } private: