Skip to content

Commit f0f0c62

Browse files
committed
[iss-45]
1 parent 9cdf271 commit f0f0c62

11 files changed

Lines changed: 535 additions & 2104 deletions

File tree

sbg/af_pwmap.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ PWMap UnordPWMapAF::createPWMap(const Map &m) const
5151
return PWMap(std::make_unique<UnordPWMap>(map_fact_, m));
5252
}
5353

54+
55+
////////////////////////////////////////////////////////////////////////////////
56+
// OrdPWMap AF -----------------------------------------------------------------
57+
////////////////////////////////////////////////////////////////////////////////
58+
5459
OrdPWMapAF::OrdPWMapAF(const MapAF &map_fact) : PWMapAF(map_fact) {}
5560

5661
PWMap OrdPWMapAF::createPWMap() const
@@ -68,6 +73,7 @@ PWMap OrdPWMapAF::createPWMap(const Map &m) const
6873
return PWMap(std::make_unique<OrdPWMap>(map_fact_, m));
6974
}
7075

76+
7177
} // namespace LIB
7278

7379
} // namespace SBG

sbg/af_pwmap.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ struct OrdPWMapAF : public PWMapAF {
6464
PWMap createPWMap(const Map &m) const override;
6565
};
6666

67+
68+
6769
} // namespace LIB
6870

6971
} // namespace SBG

sbg/interval.cpp

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -143,21 +143,16 @@ Interval Interval::least(const Interval &other) const
143143
MaybeInterval Interval::compact(const Interval &other) const
144144
{
145145
if (step_ == other.step_) {
146-
if (end_ + step_ == other.begin_)
146+
if (end_+step_ == other.begin_)
147147
return Interval(begin_, step_, other.end_);
148-
149-
else if (other.end_ + step_ == begin_)
148+
149+
else if (other.end_+step_ == begin_)
150150
return Interval(other.begin_, step_, end_);
151-
152-
else {
153-
Interval inter = intersection(other);
154-
if (!inter.isEmpty()) {
155-
if (inter == other)
156-
return {};
157-
NAT new_b = std::min(begin_, other.begin_);
158-
NAT new_e = std::max(end_, other.end_);
159-
return Interval(new_b, step_, new_e);
160-
}
151+
152+
else if (!intersection(other).isEmpty()) {
153+
NAT new_b = std::min(begin_, other.begin_);
154+
NAT new_e = std::max(end_, other.end_);
155+
return Interval(new_b, step_, new_e);
161156
}
162157
}
163158

sbg/map.cpp

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,6 @@ SetPiece image(SetPiece mdi, Exp mdle)
8484
member_move_imp(Map, Set, dom);
8585
member_move_imp(Map, Exp, exp);
8686

87-
88-
89-
9087
Map::~Map() {}
9188
Map::Map(const SetAF &fact) : fact_(fact), dom_(fact.createSet()){}
9289
Map::Map(const SetAF &fact, MD_NAT x, Exp exp)
@@ -124,51 +121,6 @@ Map &Map::operator=(const Map &other)
124121
return *this;
125122
}
126123

127-
bool Map::operator<(const Map &other) const
128-
{
129-
130-
return minPer() < other.minPer();
131-
}
132-
133-
134-
135-
MD_NAT Map::minPer() const
136-
{
137-
MD_NAT minimo(dom_.arity(), Inf);
138-
139-
if (dom_.isEmpty())
140-
return minimo;
141-
142-
for (const SetPiece &mdi : dom_) {
143-
MD_NAT candidato = mdi.minElem();
144-
145-
for (std::size_t i = 0; i < minimo.arity(); ++i) {
146-
minimo[i] = std::min(minimo[i], candidato[i]);
147-
}
148-
}
149-
150-
return minimo;
151-
}
152-
153-
MD_NAT Map::maxPer() const
154-
{
155-
MD_NAT maximo(dom_.arity(), 0);
156-
157-
if (dom_.isEmpty())
158-
return maximo;
159-
160-
161-
for (const SetPiece &mdi : dom_) {
162-
MD_NAT candidato = mdi.maxElem();
163-
164-
for (std::size_t i = 0; i < maximo.arity(); ++i) {
165-
maximo[i] = std::max(maximo[i], candidato[i]);
166-
}
167-
}
168-
169-
return maximo;
170-
}
171-
172124

173125
Map Map::operator+(const Map &other) const
174126
{
@@ -300,25 +252,6 @@ MaybeMap Map::compact(const Map &other) const
300252
return {};
301253
}
302254

303-
/*
304-
void Map::calcularMinMaxPer() {
305-
MD_NAT maximo(dom_.arity(), 0);
306-
MD_NAT minimo(dom_.arity(), Inf);
307-
308-
for (const SetPiece &mdi : dom_) {
309-
MD_NAT candidatoMax = mdi.maxElem();
310-
MD_NAT candidatoMin = mdi.minElem();
311-
312-
for (std::size_t i = 0; i < maximo.arity(); ++i) {
313-
maximo[i] = std::max(maximo[i], candidatoMax[i]);
314-
minimo[i] = std::min(minimo[i], candidatoMin[i]);
315-
}
316-
}
317-
318-
minPer_ = minimo;
319-
maxPer_ = maximo;
320-
}*/
321-
322255
} // namespace LIB
323256

324257
} // namespace SBG

sbg/map.hpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,6 @@ struct Map {
8585
bool operator==(const Map &other) const;
8686
bool operator!=(const Map &other) const;
8787
Map &operator=(const Map &other);
88-
bool operator<(const Map &other) const;
89-
90-
MD_NAT minPer() const;
91-
MD_NAT maxPer() const;
9288

9389
/**
9490
* @brief Calculates the sum of both maps for elements that belong to both
@@ -153,7 +149,6 @@ struct Map {
153149
*/
154150
MaybeMap compact(const Map &other) const;
155151

156-
//void calcularMinMaxPer();
157152
};
158153
std::ostream &operator<<(std::ostream &out, const Map &s);
159154

sbg/multidim_inter.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -186,17 +186,19 @@ MaybeMDI MultiDimInter::compact(const MultiDimInter &other) const
186186
unsigned int j = 0;
187187
for (; j < arity(); ++j) {
188188
auto ith = operator[](j).compact(other[j]);
189-
if (ith) {
190-
res.emplaceBack(ith.value());
191-
++j;
192-
break;
193-
}
189+
if (operator[](j) == other[j])
190+
res.emplaceBack(operator[](j));
194191

195-
else if (operator[](j) != other[j])
196-
return {};
192+
else {
193+
if (ith) {
194+
res.emplaceBack(ith.value());
195+
++j;
196+
break;
197+
}
197198

198-
else
199-
res.emplaceBack(operator[](j));
199+
else
200+
return {};
201+
}
200202
}
201203

202204
for (; j < arity(); ++j) {

0 commit comments

Comments
 (0)