Skip to content

Commit 7a910a4

Browse files
committed
Adapted SBG structures [may need debugging]
1 parent abd363d commit 7a910a4

14 files changed

Lines changed: 267 additions & 215 deletions

ast/statement.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ ConfigDims::ConfigDims(LIB::NAT nmbr_dims) : nmbr_dims_() {
4242
set_nmbr_dims(nmbr_dims);
4343

4444
else
45-
Util::ERROR("ConfigDims: dimension should be greater than 0\n");
45+
Debug::ERROR("ConfigDims: dimension should be greater than 0\n");
4646
}
4747

4848
member_imp(ConfigDims, LIB::NAT, nmbr_dims);

parser/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ void parseProgramFromFile(std::string fname)
2727
{
2828
std::ifstream in(fname.c_str());
2929
if (in.fail())
30-
SBG::Util::ERROR("Unable to open file ", fname, "\n");
30+
SBG::Debug::ERROR("Unable to open file ", fname, "\n");
3131
in.unsetf(std::ios::skipws);
3232

3333
std::string str(
@@ -160,7 +160,7 @@ int main(int argc, char** argv)
160160
if (!filename.empty())
161161
parseProgramFromFile(filename);
162162
else
163-
SBG::Util::ERROR("A filename should be provided\n");
163+
SBG::Debug::ERROR("A filename should be provided\n");
164164

165165
return 0;
166166
}

sbg/Makefile.include

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ SBG_ROOT := sbg
44

55
# Sources
66
SBG_SRC := \
7+
$(SBG_ROOT)/sbg.cpp \
78
$(SBG_ROOT)/af_pwmap.cpp \
89
$(SBG_ROOT)/pw_map.cpp \
910
$(SBG_ROOT)/af_map.cpp \
@@ -17,7 +18,6 @@ SBG_ROOT := sbg
1718
$(SBG_ROOT)/interval.cpp \
1819
$(SBG_ROOT)/natural.cpp \
1920
$(UTIL_ROOT)/logger.cpp #\
20-
#$(SBG_ROOT)/sbg.cpp \
2121
#$(SBG_ROOT)/sbg_algorithms.cpp
2222

2323
include util/Makefile.include

sbg/multidim_inter.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,16 @@ member_imp(MultiDimInter, InterVector, intervals);
2828
MultiDimInter::MultiDimInter() : intervals_() {}
2929
MultiDimInter::MultiDimInter(const MD_NAT &x) : intervals_() {
3030
for (NAT xi : x)
31-
intervals_.emplace_back(Interval(xi, 1, xi));
31+
intervals_.push_back(Interval(xi, 1, xi));
3232
}
3333
MultiDimInter::MultiDimInter(const Interval &i) : intervals_()
3434
{
35-
intervals_.emplace_back(i);
35+
intervals_.push_back(i);
3636
}
3737
MultiDimInter::MultiDimInter(const unsigned int &nmbr_copies
3838
, const Interval &i) : intervals_() {
3939
for (unsigned int j = 0; j < nmbr_copies; ++j)
40-
intervals_.emplace_back(i);
40+
intervals_.push_back(i);
4141
}
4242
MultiDimInter::MultiDimInter(const InterVector &iv)
4343
: intervals_(std::move(iv)) {}
@@ -58,7 +58,7 @@ void MultiDimInter::emplaceBack(Interval i)
5858
if (i.isEmpty())
5959
intervals_ = InterVector();
6060
else
61-
intervals_.emplace_back(i);
61+
intervals_.push_back(i);
6262
return;
6363
}
6464

sbg/multidim_inter.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ struct MultiDimInter {
6666
MultiDimInter(const unsigned int &nmbr_copies, const Interval &i);
6767

6868
/**
69-
* @brief Pseudo copy constructor.
69+
* @brief Collection move constructor.
7070
*/
7171
MultiDimInter(const InterVector &iv);
7272

sbg/multidim_lexp.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,18 @@ namespace SBG {
2424
namespace LIB {
2525

2626
MDLExp::MDLExp() : exps_() {}
27-
MDLExp::MDLExp(MD_NAT x)
27+
MDLExp::MDLExp(const MD_NAT &x)
2828
{
2929
for (NAT xi : x)
30-
exps_.emplace_back(LExp(0, RATIONAL(xi)));
30+
exps_.push_back(LExp(0, RATIONAL(xi)));
3131
}
32-
MDLExp::MDLExp(LExp le) : exps_() { exps_.emplace_back(le); }
33-
MDLExp::MDLExp(unsigned int nmbr_copies, LExp le) : exps_()
32+
MDLExp::MDLExp(const LExp &le) : exps_() { exps_.push_back(le); }
33+
MDLExp::MDLExp(unsigned int nmbr_copies, const LExp &le) : exps_()
3434
{
3535
for (unsigned int j = 0; j < nmbr_copies; ++j)
36-
exps_.emplace_back(le);
36+
exps_.push_back(le);
3737
}
38-
MDLExp::MDLExp(LExpVector v) : exps_(std::move(v)) {}
38+
MDLExp::MDLExp(const LExpVector &v) : exps_(std::move(v)) {}
3939

4040
member_imp(MDLExp, LExpVector, exps);
4141

@@ -44,7 +44,7 @@ MDLExp::iterator MDLExp::end() { return exps_.end(); }
4444
MDLExp::const_iterator MDLExp::begin() const { return exps_.begin(); }
4545
MDLExp::const_iterator MDLExp::end() const { return exps_.end(); }
4646

47-
void MDLExp::emplaceBack(LExp le) { exps_.emplace_back(le); }
47+
void MDLExp::emplaceBack(LExp le) { exps_.push_back(le); }
4848

4949
LExp &MDLExp::operator[](std::size_t n) { return exps_[n]; }
5050
const LExp &MDLExp::operator[](std::size_t n) const { return exps_[n]; }

sbg/multidim_lexp.hpp

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,31 @@ typedef LExpVector::const_iterator LExpVectorConstIt;
4040
struct MDLExp {
4141
member_class(LExpVector, exps);
4242

43+
/**
44+
* @brief Empty multi-dimensional expression constructor.
45+
*/
4346
MDLExp();
44-
MDLExp(MD_NAT x);
45-
MDLExp(LExp le);
46-
MDLExp(unsigned int nmbr_copies, LExp le);
47-
MDLExp(LExpVector v);
47+
48+
/**
49+
* @brief Constructs a constant mdle in all dimensions that maps to x.
50+
*/
51+
MDLExp(const MD_NAT &x);
52+
53+
/**
54+
* @brief Constructs a one-dimensional mdle composed only by le.
55+
*/
56+
MDLExp(const LExp &le);
57+
58+
/**
59+
* @brief Constructs a mdle of dimension nmbr_copies with le as linear
60+
* expression in each dimensions.
61+
*/
62+
MDLExp(unsigned int nmbr_copies, const LExp &le);
63+
64+
/**
65+
* @brief Collection move constructor.
66+
*/
67+
MDLExp(const LExpVector &v);
4868

4969
typedef LExpVectorIt iterator;
5070
typedef LExpVectorConstIt const_iterator;

sbg/pw_map.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ UnordPWMap::UnordPWMap(const MapAF &fact, const UnordMapCollection &pieces)
5353
UnordPWMap::UnordPWMap(const UnordPWMap &pw)
5454
: PWMapDelegate(pw.fact_), pieces_(pw.pieces_) {}
5555

56+
PWMapDelegPtr UnordPWMap::clone() const
57+
{
58+
return std::make_unique<UnordPWMap>(*this);
59+
}
60+
5661
member_imp(UnordPWMap::Iterator, UnordMapCollection::const_iterator, it);
5762

5863
UnordPWMap::Iterator::Iterator(UnordMapCollection::const_iterator it)
@@ -695,6 +700,8 @@ PWMapDelegPtr UnordPWMap::compact() const
695700
////////////////////////////////////////////////////////////////////////////////
696701

697702
PWMap::PWMap(PWMapDelegPtr deleg) : delegate_(std::move(deleg)) {}
703+
PWMap::PWMap(const PWMap &other)
704+
: delegate_(other.delegate_ ? other.delegate_->clone() : nullptr) {}
698705

699706
PWMap::Iterator::Iterator(std::shared_ptr<PWMapDelegate::Iterator> it)
700707
: it_(std::move(it)) {}
@@ -728,6 +735,14 @@ bool PWMap::operator==(const PWMap &other) const
728735

729736
bool PWMap::operator!=(const PWMap &other) const { return !(*this == other); }
730737

738+
PWMap &PWMap::operator=(const PWMap &other)
739+
{
740+
if (this != &other)
741+
delegate_ = other.delegate_->clone();
742+
743+
return *this;
744+
}
745+
731746
PWMap &PWMap::operator=(PWMap &&other)
732747
{
733748
if (this != &other)

sbg/pw_map.hpp

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -56,20 +56,10 @@ struct PWMapDelegate {
5656
*/
5757
PWMapDelegate(const MapAF &fact);
5858

59-
///**
60-
// * @brief Constructs a pw with s as its domain, and the 1*x+0 as its law.
61-
// */
62-
//PWMapDelegate(const MapAF &fact, const Set &s);
63-
64-
///**
65-
// * @brief Constructs a pw with an unique map m.
66-
// */
67-
//PWMapDelegate(const MapAF &fact, const Map &m);
68-
6959
/**
7060
* @brief Auxiliary function for defining the copy constructor of PWMap.
7161
*/
72-
//virtual SetDelegPtr clone() const = 0;
62+
virtual PWMapDelegPtr clone() const = 0;
7363

7464
struct Iterator {
7565
public:
@@ -289,7 +279,7 @@ struct UnordPWMap : public PWMapDelegate {
289279
UnordPWMap(const MapAF &fact, const UnordMapCollection &pieces);
290280
UnordPWMap(const UnordPWMap &pw);
291281

292-
//SetDelegPtr clone() const override;
282+
PWMapDelegPtr clone() const override;
293283

294284
struct Iterator : public PWMapDelegate::Iterator {
295285
member_class(UnordMapCollection::const_iterator, it);
@@ -368,8 +358,7 @@ struct PWMap {
368358

369359
public:
370360
PWMap(PWMapDelegPtr deleg);
371-
372-
//SetDelegPtr clone() const;
361+
PWMap(const PWMap &other);
373362

374363
struct Iterator {
375364
private:
@@ -389,6 +378,7 @@ struct PWMap {
389378

390379
bool operator==(const PWMap &other) const;
391380
bool operator!=(const PWMap &other) const;
381+
PWMap &operator=(const PWMap &other);
392382
PWMap &operator=(PWMap &&other);
393383
std::ostream &print(std::ostream &out) const;
394384

0 commit comments

Comments
 (0)