Storm 1.14.0.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
BeliefNumerics.cpp
Go to the documentation of this file.
2
3#include <cmath>
7
8namespace storm::pomdp::beliefs {
9
10namespace detail {
17constexpr double NumericPrecisionFactor = 1e14;
18
19double reprValue(double const& val) {
20 return round(val * NumericPrecisionFactor);
21}
22
23storm::RationalNumber reprValue(storm::RationalNumber const& val) {
24 return val;
25}
26} // namespace detail
27
28template<typename ValueType>
29bool BeliefNumerics<ValueType>::lessOrEqual(ValueType const& lhs, ValueType const& rhs) {
30 return detail::reprValue(lhs) <= detail::reprValue(rhs);
31}
32
33template<typename ValueType>
34bool BeliefNumerics<ValueType>::equal(ValueType const& lhs, ValueType const& rhs) {
35 return detail::reprValue(lhs) == detail::reprValue(rhs);
36}
37
38template<typename ValueType>
42
43template<typename ValueType>
47
48template<typename ValueType>
49ValueType BeliefNumerics<ValueType>::valueForHash(const ValueType& val) {
50 return detail::reprValue(val);
51}
52
53template struct BeliefNumerics<double>;
55
56} // namespace storm::pomdp::beliefs
double round(double val, int precision)
constexpr double NumericPrecisionFactor
Used to decide whether two belief values are equal.
double reprValue(double const &val)
ValueType zero()
Definition constants.cpp:26
ValueType one()
Definition constants.cpp:21
Numeric predicates used when comparing and hashing beliefs.
static bool isZero(ValueType const &val)
static ValueType valueForHash(ValueType const &val)
static bool equal(ValueType const &lhs, ValueType const &rhs)
static bool isOne(ValueType const &val)
static bool lessOrEqual(ValueType const &lhs, ValueType const &rhs)