Skip to content

Commit e025e9c

Browse files
committed
Major cleanup
1 parent 0160209 commit e025e9c

File tree

10 files changed

+160
-519
lines changed

10 files changed

+160
-519
lines changed

eval/visitors/eval_expr.cpp

-129
Original file line numberDiff line numberDiff line change
@@ -152,83 +152,6 @@ auto min_map_visitor2_ = Util::Overload {
152152
}
153153
};
154154

155-
auto min_map_unord_visitor3_ = Util::Overload {
156-
[](LIB::Interval a, LIB::LExp b, LIB::LExp c) {
157-
return MapBaseType(LIB::BasePWMap().minMap(a, b, c));
158-
},
159-
[](LIB::SetPiece a, LIB::Exp b, LIB::Exp c) {
160-
return MapBaseType(LIB::BasePWMap().minMap(a, b, c));
161-
},
162-
[](LIB::UnordSet a, LIB::Exp b, LIB::Exp c) {
163-
return MapBaseType(LIB::BasePWMap().minMap(a, b, c));
164-
},
165-
[](auto a, auto b, auto c) {
166-
Util::ERROR("Wrong arguments for minMap3");
167-
return MapBaseType();
168-
}
169-
};
170-
171-
auto min_map_ord_visitor3_ = Util::Overload {
172-
[](LIB::Interval a, LIB::LExp b, LIB::LExp c) {
173-
return MapBaseType(LIB::CanonPWMap().minMap(a, b, c));
174-
},
175-
[](LIB::SetPiece a, LIB::Exp b, LIB::Exp c) {
176-
return MapBaseType(LIB::CanonPWMap().minMap(a, b, c));
177-
},
178-
[](LIB::OrdSet a, LIB::Exp b, LIB::Exp c) {
179-
return MapBaseType(LIB::CanonPWMap().minMap(a, b, c));
180-
},
181-
[](auto a, auto b, auto c) {
182-
Util::ERROR("Wrong arguments for minMap3");
183-
return MapBaseType();
184-
}
185-
};
186-
187-
auto min_map_visitor4_ = Util::Overload {
188-
[](LIB::BasePWMap a, LIB::BasePWMap b, LIB::BasePWMap c, LIB::BasePWMap d) {
189-
return MapBaseType(a.minMap(b, c, d));
190-
},
191-
[](LIB::CanonPWMap a, LIB::CanonPWMap b, LIB::CanonPWMap c, LIB::CanonPWMap d) {
192-
return MapBaseType(a.minMap(b, c, d));
193-
},
194-
[](auto a, auto b, auto c, auto d) {
195-
Util::ERROR("Wrong arguments for minMap4");
196-
return MapBaseType();
197-
}
198-
};
199-
200-
auto min_map_unord_visitor5_ = Util::Overload {
201-
[](LIB::Interval a, LIB::LExp b, LIB::LExp c, LIB::LExp d, LIB::LExp e) {
202-
return MapBaseType(LIB::BasePWMap().minMap(a, b, c, d, e));
203-
},
204-
[](LIB::SetPiece a, LIB::Exp b, LIB::Exp c, LIB::Exp d, LIB::Exp e) {
205-
return MapBaseType(LIB::BasePWMap().minMap(a, b, c, d, e));
206-
},
207-
[](LIB::UnordSet a, LIB::Exp b, LIB::Exp c, LIB::Exp d, LIB::Exp e) {
208-
return MapBaseType(LIB::BasePWMap().minMap(a, b, c, d, e));
209-
},
210-
[](auto a, auto b, auto c, auto d, auto e) {
211-
Util::ERROR("Wrong arguments for minMap5");
212-
return MapBaseType();
213-
}
214-
};
215-
216-
auto min_map_ord_visitor5_ = Util::Overload {
217-
[](LIB::Interval a, LIB::LExp b, LIB::LExp c, LIB::LExp d, LIB::LExp e) {
218-
return MapBaseType(LIB::CanonPWMap().minMap(a, b, c, d, e));
219-
},
220-
[](LIB::SetPiece a, LIB::Exp b, LIB::Exp c, LIB::Exp d, LIB::Exp e) {
221-
return MapBaseType(LIB::CanonPWMap().minMap(a, b, c, d, e));
222-
},
223-
[](LIB::OrdSet a, LIB::Exp b, LIB::Exp c, LIB::Exp d, LIB::Exp e) {
224-
return MapBaseType(LIB::CanonPWMap().minMap(a, b, c, d, e));
225-
},
226-
[](auto a, auto b, auto c, auto d, auto e) {
227-
Util::ERROR("Wrong arguments for minMap5");
228-
return MapBaseType();
229-
}
230-
};
231-
232155
auto reduce_visitor_ = Util::Overload {
233156
[](LIB::BasePWMap a) { return MapBaseType(a.reduce()); },
234157
[](LIB::CanonPWMap a) { return MapBaseType(a.reduce()); },
@@ -611,58 +534,6 @@ ExprBaseType EvalExpression::operator()(AST::Call v) const
611534
return result;
612535
}
613536

614-
if (eval_args.size() == 3) {
615-
arity_ok = true;
616-
617-
ContainerBaseType container
618-
= std::visit(EvalContainer{}, eval_args[0]);
619-
EvalLinear visit_linear;
620-
LinearBaseType e1 = std::visit(visit_linear, eval_args[1]);
621-
LinearBaseType e2 = std::visit(visit_linear, eval_args[2]);
622-
623-
MapBaseType result;
624-
if (nmbr_dims_ == 1 && opt_conds_)
625-
result = std::visit(min_map_ord_visitor3_, container, e1, e2);
626-
else
627-
result = std::visit(min_map_unord_visitor3_, container, e1, e2);
628-
629-
return result;
630-
}
631-
632-
if (eval_args.size() == 4) {
633-
arity_ok = true;
634-
635-
EvalMap visit_map;
636-
MapBaseType pw1 = std::visit(visit_map, eval_args[0]);
637-
MapBaseType pw2 = std::visit(visit_map, eval_args[1]);
638-
MapBaseType pw3 = std::visit(visit_map, eval_args[2]);
639-
MapBaseType pw4 = std::visit(visit_map, eval_args[3]);
640-
641-
MapBaseType result = std::visit(min_map_visitor4_, pw1, pw2, pw3, pw4);
642-
return result;
643-
}
644-
645-
if (eval_args.size() == 5) {
646-
arity_ok = true;
647-
648-
ContainerBaseType container
649-
= std::visit(EvalContainer{}, eval_args[0]);
650-
EvalLinear visit_linear;
651-
LinearBaseType e1 = std::visit(visit_linear, eval_args[1]);
652-
LinearBaseType e2 = std::visit(visit_linear, eval_args[2]);
653-
LinearBaseType e3 = std::visit(visit_linear, eval_args[3]);
654-
LinearBaseType e4 = std::visit(visit_linear, eval_args[4]);
655-
656-
MapBaseType result;
657-
if (nmbr_dims_ == 1 && opt_conds_)
658-
result = std::visit(min_map_ord_visitor5_, container, e1, e2, e3, e4);
659-
else
660-
result = std::visit(min_map_unord_visitor5_, container, e1, e2, e3, e4);
661-
662-
return result;
663-
}
664-
break;
665-
666537
case Eval::Func::red:
667538
if (eval_args.size() == 1) {
668539
arity_ok = true;

sbg/map.cpp

+13-4
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,11 @@ Interval image(Interval i, LExp le) {
8989
new_end = (m * i.end() + h).toNat();
9090
}
9191

92-
// Decreasing expression
92+
// Decreasing expression
9393
else if (m < 0) {
94-
new_begin = (m * i.begin() + h).toNat();
95-
new_step = (m * i.step()).toNat();
96-
new_end = (m * i.end() + h).toNat();
94+
new_begin = (m * i.end() + h).toNat();
95+
new_step = (-m * i.step()).toNat();
96+
new_end = (m * i.begin() + h).toNat();
9797
}
9898

9999
return Interval(new_begin, new_step, new_end);
@@ -170,6 +170,15 @@ bool SBGMap<Set>::operator!=(const SBGMap &other) const
170170
return !(*this == other);
171171
}
172172

173+
template<typename Set>
174+
SBGMap<Set> SBGMap<Set>::operator+(const SBGMap &other) const
175+
{
176+
Set res_dom = dom_.intersection(other.dom_);
177+
Exp res_exp = exp_ + other.exp_;
178+
179+
return SBGMap(res_dom, res_exp);
180+
}
181+
173182
template<typename Set>
174183
std::ostream &operator<<(std::ostream &out, const SBGMap<Set> &sbgmap)
175184
{

sbg/map.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ struct SBGMap {
5454

5555
bool operator==(const SBGMap &other) const;
5656
bool operator!=(const SBGMap &other) const;
57+
58+
SBGMap operator+(const SBGMap &other) const;
5759

5860
/**
5961
* @brief Traditional map operations.

0 commit comments

Comments
 (0)