From b3507b8f969ec9790ca6d3694afd53ef78249c5a Mon Sep 17 00:00:00 2001 From: TimQu Date: Tue, 15 Aug 2017 17:40:07 +0200 Subject: [PATCH] fixed 'toIntegralVector' method --- src/storm/utility/vector.h | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/storm/utility/vector.h b/src/storm/utility/vector.h index b8f305a1c..cb5789852 100644 --- a/src/storm/utility/vector.h +++ b/src/storm/utility/vector.h @@ -872,7 +872,7 @@ namespace storm { } template - typename std::enable_if::value, std::pair, ValueType>>::type + typename std::enable_if::value, std::pair, ValueType>>::type toIntegralVector(std::vector const& vec) { // Collect the numbers occurring in the input vector @@ -910,7 +910,7 @@ namespace storm { // Build the result std::vector result; - result.resize(vec.size()); + result.reserve(vec.size()); for (auto const& v : vec) { result.push_back(storm::utility::convertNumber(v / factor)); STORM_LOG_ASSERT(storm::utility::isInteger(result.back()), "Resulting number '" << result.back() << "' is not integral."); @@ -920,10 +920,13 @@ namespace storm { } template - typename std::enable_if::value, std::pair, ValueType>>::type + typename std::enable_if::value, std::pair, ValueType>>::type toIntegralVector(std::vector const& vec) { - STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "Functionality not implemented."); - return std::pair, ValueType>(); + // TODO: avoid converting back and forth + auto rationalNumberVec = convertNumericVector(vec); + auto rationalNumberResult = toIntegralVector(rationalNumberVec); + + return std::make_pair(std::move(rationalNumberResult.first), storm::utility::convertNumber(rationalNumberResult.second)); } template