Skip to content

Commit

Permalink
Major cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Kalashnikovni committed Jul 31, 2024
1 parent 22e3caf commit 0160209
Show file tree
Hide file tree
Showing 19 changed files with 11 additions and 90 deletions.
2 changes: 1 addition & 1 deletion Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 0 additions & 10 deletions sbg/interval.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 0 additions & 2 deletions sbg/interval.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 3 additions & 15 deletions sbg/lexp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
2 changes: 0 additions & 2 deletions sbg/lexp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 0 additions & 12 deletions sbg/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,25 +282,13 @@ std::optional<SBGMap<Set>> SBGMap<Set>::compact(const SBGMap<Set> &other) const
return {};
}

template<typename Set>
std::size_t hash_value(const SBGMap<Set> &sbgmap)
{
std::size_t seed = 0;
boost::hash_combine(seed, sbgmap.dom());
boost::hash_combine(seed, sbgmap.exp());

return seed;
}

// Templates -------------------------------------------------------------------

template struct SBGMap<UnordSet>;
template std::ostream &operator<<(std::ostream &out, const BaseMap &sbgmap);
template std::size_t hash_value<UnordSet>(const BaseMap &sbgmap);

template struct SBGMap<OrdSet>;
template std::ostream &operator<<(std::ostream &out, const CanonMap &sbgmap);
template std::size_t hash_value<OrdSet>(const CanonMap &sbgmap);

} // namespace LIB

Expand Down
3 changes: 0 additions & 3 deletions sbg/map.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,6 @@ struct SBGMap {
template<typename Set>
std::ostream &operator<<(std::ostream &out, const SBGMap<Set> &sbgmap);

template<typename Set>
std::size_t hash_value(const SBGMap<Set> &sbgmap);

template<typename Set>
using SBGMap = SBGMap<Set>;

Expand Down
5 changes: 0 additions & 5 deletions sbg/multidim_inter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 0 additions & 2 deletions sbg/multidim_inter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 0 additions & 5 deletions sbg/multidim_lexp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 0 additions & 2 deletions sbg/multidim_lexp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 2 additions & 7 deletions sbg/ord_pw_mdinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -41,7 +41,7 @@ std::ostream &operator<<(std::ostream &out, const MDInterOrdSet &ii)
++j;
}
}
out << "}}";
out << "}";

return out;
}
Expand Down Expand Up @@ -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
2 changes: 0 additions & 2 deletions sbg/ord_pw_mdinter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 0 additions & 8 deletions sbg/pw_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -947,23 +947,15 @@ Set PWMap<Set>::sharedImage()
return res;
}

template<typename Set>
std::size_t hash_value(const PWMap<Set> &pw)
{
return boost::hash_range(pw.begin(), pw.end());
}

// Templates -------------------------------------------------------------------

template std::ostream &operator<<(std::ostream &out, const MapSet<UnordSet> &ms);
template struct PWMap<UnordSet>;
template std::ostream &operator<<(std::ostream &out, const BasePWMap &pw);
template std::size_t hash_value(const PWMap<UnordSet> &pw);

template std::ostream &operator<<(std::ostream &out, const MapSet<OrdSet> &ms);
template struct PWMap<OrdSet>;
template std::ostream &operator<<(std::ostream &out, const CanonPWMap &pw);
template std::size_t hash_value(const PWMap<OrdSet> &pw);

} // namespace LIB

Expand Down
4 changes: 0 additions & 4 deletions sbg/pw_map.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,6 @@ struct PWMap {
template<typename Set>
std::ostream &operator<<(std::ostream &out, const PWMap<Set> &pw);


template<typename Set>
std::size_t hash_value(const PWMap<Set> &pw);

typedef PWMap<UnordSet> BasePWMap;
typedef PWMap<OrdSet> CanonPWMap;

Expand Down
5 changes: 0 additions & 5 deletions sbg/unord_pw_mdinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 0 additions & 2 deletions sbg/unord_pw_mdinter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions test/performance/boost/ordinary_graph_builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 3 additions & 1 deletion util/defs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 0160209

Please sign in to comment.