Browse Source

Use carl hashing functions

tempestpy_adaptions
Matthias Volk 5 years ago
parent
commit
30565e4d0c
  1. 2
      resources/3rdparty/sylvan/src/storm_wrapper.cpp
  2. 11
      src/storm/adapters/RationalFunctionAdapter.h

2
resources/3rdparty/sylvan/src/storm_wrapper.cpp

@ -481,7 +481,7 @@ uint64_t storm_rational_function_hash(storm_rational_function_ptr const a, uint6
storm::RationalFunction const& srf_a = *(storm::RationalFunction const*)a; storm::RationalFunction const& srf_a = *(storm::RationalFunction const*)a;
// Taken from boost::hash_combine that we do not call here for the lack of boost headers. // Taken from boost::hash_combine that we do not call here for the lack of boost headers.
return seed ^ (carl::hash_value(srf_a) + 0x9e3779b9 + (seed<<6) + (seed>>2));
return seed ^ (std::hash<storm::RationalFunction>()(srf_a) + 0x9e3779b9 + (seed<<6) + (seed>>2));
} }
double storm_rational_function_get_value_double(storm_rational_function_ptr a) { double storm_rational_function_get_value_double(storm_rational_function_ptr a) {

11
src/storm/adapters/RationalFunctionAdapter.h

@ -11,6 +11,7 @@
namespace carl { namespace carl {
// Define hash values for all polynomials and rational function. // Define hash values for all polynomials and rational function.
// Needed for boost::hash_combine() and other functions
template<typename C, typename O, typename P> template<typename C, typename O, typename P>
inline size_t hash_value(carl::MultivariatePolynomial<C,O,P> const& p) { inline size_t hash_value(carl::MultivariatePolynomial<C,O,P> const& p) {
std::hash<carl::MultivariatePolynomial<C,O,P>> h; std::hash<carl::MultivariatePolynomial<C,O,P>> h;
@ -19,19 +20,19 @@ namespace carl {
template<typename Pol> template<typename Pol>
inline size_t hash_value(carl::FactorizedPolynomial<Pol> const& p) { inline size_t hash_value(carl::FactorizedPolynomial<Pol> const& p) {
std::hash<FactorizedPolynomial<Pol>> h;
std::hash<carl::FactorizedPolynomial<Pol>> h;
return h(p); return h(p);
} }
template<typename Pol, bool AutoSimplify> template<typename Pol, bool AutoSimplify>
inline size_t hash_value(carl::RationalFunction<Pol, AutoSimplify> const& f) { inline size_t hash_value(carl::RationalFunction<Pol, AutoSimplify> const& f) {
std::hash<Pol> h;
return h(f.nominator()) ^ h(f.denominator());
std::hash<carl::RationalFunction<Pol, AutoSimplify>> h;
return h(f);
} }
template<typename Number> template<typename Number>
inline size_t hash_value(carl::Interval<Number> const& i) { inline size_t hash_value(carl::Interval<Number> const& i) {
std::hash<Interval<Number>> h;
std::hash<carl::Interval<Number>> h;
return h(i); return h(i);
} }
@ -52,7 +53,7 @@ namespace storm {
typedef carl::MultivariatePolynomial<RationalFunctionCoefficient> RawPolynomial; typedef carl::MultivariatePolynomial<RationalFunctionCoefficient> RawPolynomial;
typedef carl::FactorizedPolynomial<RawPolynomial> Polynomial; typedef carl::FactorizedPolynomial<RawPolynomial> Polynomial;
typedef carl::Cache<carl::PolynomialFactorizationPair<RawPolynomial>> RawPolynomialCache;
typedef carl::Cache<carl::PolynomialFactorizationPair<RawPolynomial>> RawPolynomialCache;
typedef carl::Relation CompareRelation; typedef carl::Relation CompareRelation;
typedef carl::RationalFunction<Polynomial, true> RationalFunction; typedef carl::RationalFunction<Polynomial, true> RationalFunction;

Loading…
Cancel
Save