diff --git a/src/utility/constants.cpp b/src/utility/constants.cpp index 5b5a68348..64f522539 100644 --- a/src/utility/constants.cpp +++ b/src/utility/constants.cpp @@ -25,7 +25,52 @@ namespace storm { return std::numeric_limits::infinity(); } + template + bool isOne(ValueType const& a) { + return a == one(); + } + + template + bool isZero(ValueType const& a) { + return a == zero(); + } + + template + bool isConstant(ValueType const& a) { + return true; + } + #ifdef STORM_HAVE_CARL + template<> + bool isOne(storm::RationalFunction const& a) { + return a.isOne(); + } + + template<> + bool isZero(storm::RationalFunction const& a) { + return a.isZero(); + } + + template<> + bool isConstant(storm::RationalFunction const& a) { + return a.isConstant(); + } + + template<> + bool isOne(storm::Polynomial const& a) { + return a.isOne(); + } + + template<> + bool isZero(storm::Polynomial const& a) { + return a.isZero(); + } + + template<> + bool isConstant(storm::Polynomial const& a) { + return a.isConstant(); + } + template<> storm::RationalFunction infinity() { // FIXME: this does not work. @@ -110,40 +155,17 @@ namespace storm { template<> RationalFunction&& simplify(RationalFunction&& value); - template<> - class ConstantsComparator { - public: - bool isOne(storm::RationalFunction const& value) const; - - bool isZero(storm::RationalFunction const& value) const; - - bool isEqual(storm::RationalFunction const& value1, storm::RationalFunction const& value2) const; - - bool isConstant(storm::RationalFunction const& value) const; - }; - - template<> - class ConstantsComparator { - public: - bool isOne(storm::Polynomial const& value) const; - - bool isZero(storm::Polynomial const& value) const; - - bool isEqual(storm::Polynomial const& value1, storm::Polynomial const& value2) const; - - bool isConstant(storm::Polynomial const& value) const; - }; #endif template bool ConstantsComparator::isOne(ValueType const& value) const { - return value == one(); + return isOne(value); } template bool ConstantsComparator::isZero(ValueType const& value) const { - return value == zero(); + return isZero(value); } template @@ -151,6 +173,12 @@ namespace storm { return value1 == value2; } + template + bool ConstantsComparator::isConstant(T const& value) const { + return isConstant(value); + } + + ConstantsComparator::ConstantsComparator() : precision(static_cast(storm::settings::generalSettings().getPrecision())) { // Intentionally left empty. } @@ -226,40 +254,9 @@ namespace storm { value.simplify(); return std::move(value); } +#endif - bool ConstantsComparator::isOne(storm::RationalFunction const& value) const { - return value.isOne(); - } - - bool ConstantsComparator::isZero(storm::RationalFunction const& value) const { - return value.isZero(); - } - bool ConstantsComparator::isEqual(storm::RationalFunction const& value1, storm::RationalFunction const& value2) const { - return value1 == value2; - } - - bool ConstantsComparator::isConstant(storm::RationalFunction const& value) const { - return value.isConstant(); - } - - bool ConstantsComparator::isOne(storm::Polynomial const& value) const { - return value.isOne(); - } - - bool ConstantsComparator::isZero(storm::Polynomial const& value) const { - return value.isZero(); - } - - bool ConstantsComparator::isEqual(storm::Polynomial const& value1, storm::Polynomial const& value2) const { - return value1 == value2; - } - - bool ConstantsComparator::isConstant(storm::Polynomial const& value) const { - return value.isConstant(); - } -#endif - template storm::storage::MatrixEntry simplify(storm::storage::MatrixEntry matrixEntry) { simplify(matrixEntry.getValue()); @@ -327,6 +324,7 @@ namespace storm { #ifdef STORM_HAVE_CARL template class ConstantsComparator; template class ConstantsComparator; + template class ConstantsComparator; template RationalFunction one(); template RationalFunction zero(); diff --git a/src/utility/constants.h b/src/utility/constants.h index 2e5206711..cae1a7a5d 100644 --- a/src/utility/constants.h +++ b/src/utility/constants.h @@ -30,6 +30,16 @@ namespace storm { template ValueType infinity(); + + template + bool isOne(ValueType const& a); + + template + bool isZero(ValueType const& a); + + template + bool isConstant(ValueType const& a); + template