From 01602099a8f59888ab70db9dd5fa3a5c283ab7ba Mon Sep 17 00:00:00 2001 From: kalashnikovni Date: Wed, 31 Jul 2024 14:58:40 -0300 Subject: [PATCH] Major cleanup --- Makefile.in | 2 +- sbg/interval.cpp | 10 ---------- sbg/interval.hpp | 2 -- sbg/lexp.cpp | 18 +++--------------- sbg/lexp.hpp | 2 -- sbg/map.cpp | 12 ------------ sbg/map.hpp | 3 --- sbg/multidim_inter.cpp | 5 ----- sbg/multidim_inter.hpp | 2 -- sbg/multidim_lexp.cpp | 5 ----- sbg/multidim_lexp.hpp | 2 -- sbg/ord_pw_mdinter.cpp | 9 ++------- sbg/ord_pw_mdinter.hpp | 2 -- sbg/pw_map.cpp | 8 -------- sbg/pw_map.hpp | 4 ---- sbg/unord_pw_mdinter.cpp | 5 ----- sbg/unord_pw_mdinter.hpp | 2 -- .../boost/ordinary_graph_builder.cpp | 4 ++-- util/defs.cpp | 4 +++- 19 files changed, 11 insertions(+), 90 deletions(-) diff --git a/Makefile.in b/Makefile.in index ff2e7c6..00d7850 100755 --- a/Makefile.in +++ b/Makefile.in @@ -91,7 +91,7 @@ doc: test: lib-gtest $(SBG_TEST) -TEST_DIRS := test/parser test/performance test/eval +TEST_DIRS := test/parser test/performance test/performance/boost test/eval clean: $(RM) -rf $(BIN_DIR) $(OBJ_DIR) $(LIB_SBGRAPH) $(ROOT)/lib $(ROOT)/include $(3RD_PARTY_DIR)/gtest/usr diff --git a/sbg/interval.cpp b/sbg/interval.cpp index ea3bf47..676136c 100755 --- a/sbg/interval.cpp +++ b/sbg/interval.cpp @@ -159,16 +159,6 @@ Interval::MaybeInterval Interval::compact(const Interval &other) const return {}; } -std::size_t hash_value(const Interval &i) -{ - std::size_t seed = 0; - boost::hash_combine(seed, i.begin()); - boost::hash_combine(seed, i.step()); - boost::hash_combine(seed, i.end()); - - return seed; -} - } // namespace LIB } // namespace SBG diff --git a/sbg/interval.hpp b/sbg/interval.hpp index 31ebf50..35da6ec 100755 --- a/sbg/interval.hpp +++ b/sbg/interval.hpp @@ -76,8 +76,6 @@ struct Interval { }; std::ostream &operator<<(std::ostream &out, const Interval &i); -std::size_t hash_value(const Interval &i); - } // namespace LIB } // namespace SBG diff --git a/sbg/lexp.cpp b/sbg/lexp.cpp index dac5fe5..2802f43 100755 --- a/sbg/lexp.cpp +++ b/sbg/lexp.cpp @@ -94,10 +94,9 @@ LExp LExp::inverse() const RAT new_slope(0, 1), new_offset(0, 1); // Non constant map - RAT slo = slope_; - if (slo != 0) { - new_slope = RAT(slo.denominator(), slo.numerator()); - new_offset = (-offset_)/slo; + if (slope_ != 0) { + new_slope = RAT(slope_.denominator(), slope_.numerator()); + new_offset = (-offset_)/slope_; } // Constant map @@ -113,17 +112,6 @@ bool LExp::isId() const { return slope_ == 1 && offset_ == 0; } bool LExp::isConstant() const { return slope_ == 0; } -std::size_t hash_value(const LExp &le) -{ - std::size_t seed = 0; - boost::hash_combine(seed, le.slope().numerator()); - boost::hash_combine(seed, le.slope().denominator()); - boost::hash_combine(seed, le.offset().numerator()); - boost::hash_combine(seed, le.offset().denominator()); - - return seed; -} - } // namespace LIB } // namespace SBG diff --git a/sbg/lexp.hpp b/sbg/lexp.hpp index d6a229d..66752fd 100755 --- a/sbg/lexp.hpp +++ b/sbg/lexp.hpp @@ -70,8 +70,6 @@ struct LExp { }; std::ostream &operator<<(std::ostream &out, const LExp &le); -std::size_t hash_value(const LExp &le); - } // namespace LIB } // namespace SBG diff --git a/sbg/map.cpp b/sbg/map.cpp index bca7ab9..a604379 100755 --- a/sbg/map.cpp +++ b/sbg/map.cpp @@ -282,25 +282,13 @@ std::optional> SBGMap::compact(const SBGMap &other) const return {}; } -template -std::size_t hash_value(const SBGMap &sbgmap) -{ - std::size_t seed = 0; - boost::hash_combine(seed, sbgmap.dom()); - boost::hash_combine(seed, sbgmap.exp()); - - return seed; -} - // Templates ------------------------------------------------------------------- template struct SBGMap; template std::ostream &operator<<(std::ostream &out, const BaseMap &sbgmap); -template std::size_t hash_value(const BaseMap &sbgmap); template struct SBGMap; template std::ostream &operator<<(std::ostream &out, const CanonMap &sbgmap); -template std::size_t hash_value(const CanonMap &sbgmap); } // namespace LIB diff --git a/sbg/map.hpp b/sbg/map.hpp index b4b3db4..1b3a584 100755 --- a/sbg/map.hpp +++ b/sbg/map.hpp @@ -76,9 +76,6 @@ struct SBGMap { template std::ostream &operator<<(std::ostream &out, const SBGMap &sbgmap); -template -std::size_t hash_value(const SBGMap &sbgmap); - template using SBGMap = SBGMap; diff --git a/sbg/multidim_inter.cpp b/sbg/multidim_inter.cpp index c6a3096..d5c7696 100755 --- a/sbg/multidim_inter.cpp +++ b/sbg/multidim_inter.cpp @@ -248,11 +248,6 @@ MultiDimInter::MaybeMDI MultiDimInter::compact(const MultiDimInter &other) const return res; } -std::size_t hash_value(const MultiDimInter &mdi) -{ - return boost::hash_range(mdi.begin(), mdi.end()); -} - } // namespace LIB } // namespace SBG diff --git a/sbg/multidim_inter.hpp b/sbg/multidim_inter.hpp index 3d79a27..45cc3d2 100755 --- a/sbg/multidim_inter.hpp +++ b/sbg/multidim_inter.hpp @@ -82,8 +82,6 @@ struct MultiDimInter { }; std::ostream &operator<<(std::ostream &out, const MultiDimInter &mi); -std::size_t hash_value(const MultiDimInter &mdi); - typedef MultiDimInter SetPiece; } // namespace LIB diff --git a/sbg/multidim_lexp.cpp b/sbg/multidim_lexp.cpp index 9eb4b66..b45d536 100755 --- a/sbg/multidim_lexp.cpp +++ b/sbg/multidim_lexp.cpp @@ -139,11 +139,6 @@ bool MDLExp::isConstant() const return true; } -std::size_t hash_value(const MDLExp &mdle) -{ - return boost::hash_range(mdle.begin(), mdle.end()); -} - } // namespace LIB } // namespace SBG diff --git a/sbg/multidim_lexp.hpp b/sbg/multidim_lexp.hpp index 7a606f9..96caae9 100755 --- a/sbg/multidim_lexp.hpp +++ b/sbg/multidim_lexp.hpp @@ -79,8 +79,6 @@ struct MDLExp { }; std::ostream &operator<<(std::ostream &out, const MDLExp &mdle); -std::size_t hash_value(const MDLExp &mdle); - typedef MDLExp Exp; } // namespace LIB diff --git a/sbg/ord_pw_mdinter.cpp b/sbg/ord_pw_mdinter.cpp index b356dfd..36e49ca 100755 --- a/sbg/ord_pw_mdinter.cpp +++ b/sbg/ord_pw_mdinter.cpp @@ -29,7 +29,7 @@ std::ostream &operator<<(std::ostream &out, const MDInterOrdSet &ii) { std::size_t sz = ii.size(); - out << "{{"; + out << "{"; if (sz > 0) { unsigned int j = 0; for (const SetPiece &mdi : ii) { @@ -41,7 +41,7 @@ std::ostream &operator<<(std::ostream &out, const MDInterOrdSet &ii) ++j; } } - out << "}}"; + out << "}"; return out; } @@ -436,11 +436,6 @@ MDInterOrdSet OrdPWMDInter::traverse( return res; } -std::size_t hash_value(const OrdPWMDInter &pwi) -{ - return boost::hash_range(pwi.begin(), pwi.end()); -} - } // namespace LIB } // namespace SBG diff --git a/sbg/ord_pw_mdinter.hpp b/sbg/ord_pw_mdinter.hpp index 608dc47..d79bf36 100755 --- a/sbg/ord_pw_mdinter.hpp +++ b/sbg/ord_pw_mdinter.hpp @@ -130,8 +130,6 @@ struct OrdPWMDInter { }; std::ostream &operator<<(std::ostream &out, const OrdPWMDInter &i); -std::size_t hash_value(const OrdPWMDInter &pwi); - typedef OrdPWMDInter OrdSet; } // namespace LIB diff --git a/sbg/pw_map.cpp b/sbg/pw_map.cpp index c261f1f..693ba9b 100644 --- a/sbg/pw_map.cpp +++ b/sbg/pw_map.cpp @@ -947,23 +947,15 @@ Set PWMap::sharedImage() return res; } -template -std::size_t hash_value(const PWMap &pw) -{ - return boost::hash_range(pw.begin(), pw.end()); -} - // Templates ------------------------------------------------------------------- template std::ostream &operator<<(std::ostream &out, const MapSet &ms); template struct PWMap; template std::ostream &operator<<(std::ostream &out, const BasePWMap &pw); -template std::size_t hash_value(const PWMap &pw); template std::ostream &operator<<(std::ostream &out, const MapSet &ms); template struct PWMap; template std::ostream &operator<<(std::ostream &out, const CanonPWMap &pw); -template std::size_t hash_value(const PWMap &pw); } // namespace LIB diff --git a/sbg/pw_map.hpp b/sbg/pw_map.hpp index 164ff19..69698e0 100755 --- a/sbg/pw_map.hpp +++ b/sbg/pw_map.hpp @@ -183,10 +183,6 @@ struct PWMap { template std::ostream &operator<<(std::ostream &out, const PWMap &pw); - -template -std::size_t hash_value(const PWMap &pw); - typedef PWMap BasePWMap; typedef PWMap CanonPWMap; diff --git a/sbg/unord_pw_mdinter.cpp b/sbg/unord_pw_mdinter.cpp index 75d89ef..381bbd6 100755 --- a/sbg/unord_pw_mdinter.cpp +++ b/sbg/unord_pw_mdinter.cpp @@ -413,11 +413,6 @@ UnordPWMDInter UnordPWMDInter::compact() const return res; } -std::size_t hash_value(const UnordPWMDInter &pwi) -{ - return boost::hash_range(pwi.begin(), pwi.end()); -} - } // namespace LIB } // namespace SBG diff --git a/sbg/unord_pw_mdinter.hpp b/sbg/unord_pw_mdinter.hpp index 1937f29..51a03ee 100755 --- a/sbg/unord_pw_mdinter.hpp +++ b/sbg/unord_pw_mdinter.hpp @@ -137,8 +137,6 @@ struct UnordPWMDInter { }; std::ostream &operator<<(std::ostream &out, const UnordPWMDInter &pwi); -std::size_t hash_value(const UnordPWMDInter &pwi); - typedef UnordPWMDInter UnordSet; } // namespace LIB diff --git a/test/performance/boost/ordinary_graph_builder.cpp b/test/performance/boost/ordinary_graph_builder.cpp index a5ad1c7..1563592 100644 --- a/test/performance/boost/ordinary_graph_builder.cpp +++ b/test/performance/boost/ordinary_graph_builder.cpp @@ -25,13 +25,13 @@ SBG::Util::MD_NAT nextElem(SBG::Util::MD_NAT curr, SBG::LIB::SetPiece mdi) { assert(!mdi.isEmpty()); SBG::Util::MD_NAT min = mdi.minElem(), max = mdi.maxElem(), res; - for (unsigned int j = 0; j < mdi.size(); ++j) { + for (unsigned int j = 0; j < mdi.arity(); ++j) { if (curr[j] == max[j]) res.emplaceBack(min[j]); else { res.emplaceBack(curr[j] + 1); - for (unsigned int k = 1; k < mdi.size() - j; ++k) + for (unsigned int k = 1; k < mdi.arity() - j; ++k) res.emplaceBack(curr[j]); break; } diff --git a/util/defs.cpp b/util/defs.cpp index a1c090b..3288a13 100755 --- a/util/defs.cpp +++ b/util/defs.cpp @@ -229,7 +229,9 @@ NAT RATIONAL::toNat() const if (denominator() == 1 && 0 <= value_) return numerator(); - ERROR("toNat: RATIONAL is not NAT"); + std::stringstream ss; + ss << *this; + ERROR("toNat: RATIONAL %s is not NAT", ss.str().c_str()); return 0; }