From a34037bff4746eb45fde093847e03b7a7f5fbb8f Mon Sep 17 00:00:00 2001 From: Tim Quatmann Date: Fri, 10 May 2019 10:04:16 +0200 Subject: [PATCH] Added utility function for rounding. --- src/storm/utility/constants.cpp | 17 +++++++++++++++++ src/storm/utility/constants.h | 3 +++ 2 files changed, 20 insertions(+) diff --git a/src/storm/utility/constants.cpp b/src/storm/utility/constants.cpp index b1944c267..fdaa62a51 100644 --- a/src/storm/utility/constants.cpp +++ b/src/storm/utility/constants.cpp @@ -256,6 +256,11 @@ namespace storm { return std::ceil(number); } + template + ValueType round(ValueType const& number) { + return std::round(number); + } + template ValueType log(ValueType const& number) { return std::log(number); @@ -417,6 +422,11 @@ namespace storm { return carl::ceil(number); } + template<> + ClnRationalNumber round(storm::ClnRationalNumber const& number) { + return carl::round(number); + } + template<> ClnRationalNumber log(ClnRationalNumber const& number) { return carl::log(number); @@ -610,6 +620,11 @@ namespace storm { return carl::ceil(number); } + template<> + GmpRationalNumber round(storm::GmpRationalNumber const& number) { + return carl::round(number); + } + template<> GmpRationalNumber log(GmpRationalNumber const& number) { return carl::log(number); @@ -886,6 +901,7 @@ namespace storm { template double abs(double const& number); template double floor(double const& number); template double ceil(double const& number); + template double round(double const& number); template double log(double const& number); template double log10(double const& number); template typename NumberTraits::IntegerType trunc(double const& number); @@ -918,6 +934,7 @@ namespace storm { template float abs(float const& number); template float floor(float const& number); template float ceil(float const& number); + template float round(float const& number); template float log(float const& number); template std::string to_string(float const& value); diff --git a/src/storm/utility/constants.h b/src/storm/utility/constants.h index 80e1ef336..ddd125edb 100644 --- a/src/storm/utility/constants.h +++ b/src/storm/utility/constants.h @@ -155,6 +155,9 @@ namespace storm { template ValueType ceil(ValueType const& number); + template + ValueType round(ValueType const& number); + template ValueType log(ValueType const& number);