From 76c01de25c3f1dbc4452c4c4732d24d029b971d2 Mon Sep 17 00:00:00 2001 From: TimQu Date: Fri, 1 Sep 2017 14:11:05 +0200 Subject: [PATCH] use utility::vector::max_if to compute the maximum exit rate in an MA --- src/storm/models/sparse/MarkovAutomaton.cpp | 6 +----- src/storm/utility/vector.h | 8 ++------ 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/src/storm/models/sparse/MarkovAutomaton.cpp b/src/storm/models/sparse/MarkovAutomaton.cpp index 485aa8a64..568775727 100644 --- a/src/storm/models/sparse/MarkovAutomaton.cpp +++ b/src/storm/models/sparse/MarkovAutomaton.cpp @@ -93,11 +93,7 @@ namespace storm { template ValueType MarkovAutomaton::getMaximalExitRate() const { - ValueType result = storm::utility::zero(); - for (auto markovianState : this->markovianStates) { - result = std::max(result, this->exitRates[markovianState]); - } - return result; + return storm::utility::vector::max_if(this->exitRates, this->markovianStates); } template diff --git a/src/storm/utility/vector.h b/src/storm/utility/vector.h index 828ef1ed5..889561c2b 100644 --- a/src/storm/utility/vector.h +++ b/src/storm/utility/vector.h @@ -563,9 +563,7 @@ namespace storm { ++it; for (; it != ite; ++it) { - if (values[*it] > current) { - current = values[*it]; - } + current = std::max(values[*it], current); } return current; } @@ -588,9 +586,7 @@ namespace storm { ++it; for (; it != ite; ++it) { - if (values[*it] < current) { - current = values[*it]; - } + current = std::min(values[*it], current); } return current; }