diff --git a/include/Disaggregation.h b/include/Disaggregation.h index 21c2ded..1563219 100644 --- a/include/Disaggregation.h +++ b/include/Disaggregation.h @@ -83,12 +83,20 @@ class Disaggregation { size[3] = size4; data.resize(size1 * size2 * size3 * size4, std::numeric_limits::quiet_NaN()); }; - T& operator()(const IndexPart* i1) noexcept { return data[i1->level_index()]; }; - T& operator()(const IndexPart* i1, const IndexPart* i2) noexcept { return data[i1->level_index() + (i2->level_index()) * size[0]]; }; - T& operator()(const IndexPart* i1, const IndexPart* i2, const IndexPart* i3) noexcept { + inline T& at(const IndexPart* i1) { return data.at(i1->level_index()); }; + inline T& at(const IndexPart* i1, const IndexPart* i2) { return data.at(i1->level_index() + (i2->level_index()) * size[0]); }; + inline T& at(const IndexPart* i1, const IndexPart* i2, const IndexPart* i3) { + return data.at(i1->level_index() + (i2->level_index() + (i3->level_index()) * size[1]) * size[0]); + }; + inline T& at(const IndexPart* i1, const IndexPart* i2, const IndexPart* i3, const IndexPart* i4) { + return data.at(i1->level_index() + (i2->level_index() + (i3->level_index() + i4->level_index() * size[2]) * size[1]) * size[0]); + }; + inline T& operator()(const IndexPart* i1) { return data[i1->level_index()]; }; + inline T& operator()(const IndexPart* i1, const IndexPart* i2) { return data[i1->level_index() + (i2->level_index()) * size[0]]; }; + inline T& operator()(const IndexPart* i1, const IndexPart* i2, const IndexPart* i3) { return data[i1->level_index() + (i2->level_index() + (i3->level_index()) * size[1]) * size[0]]; }; - T& operator()(const IndexPart* i1, const IndexPart* i2, const IndexPart* i3, const IndexPart* i4) noexcept { + inline T& operator()(const IndexPart* i1, const IndexPart* i2, const IndexPart* i3, const IndexPart* i4) { return data[i1->level_index() + (i2->level_index() + (i3->level_index() + i4->level_index() * size[2]) * size[1]) * size[0]]; }; }; diff --git a/include/MRIOIndexSet.h b/include/MRIOIndexSet.h index 55bccdf..e4996b4 100644 --- a/include/MRIOIndexSet.h +++ b/include/MRIOIndexSet.h @@ -69,7 +69,7 @@ class Sector : public IndexPart { virtual SuperSector* as_super() = 0; virtual const SuperSector* as_super() const = 0; virtual const SuperSector* super() const = 0; - virtual const bool has_sub() const = 0; + virtual bool has_sub() const = 0; }; template class SubSector : public Sector { @@ -86,7 +86,7 @@ class SubSector : public Sector { SuperSector* as_super() override { return nullptr; }; const SuperSector* as_super() const override { return nullptr; }; const SuperSector* parent() const override { return parent_; }; - const bool has_sub() const override { return false; }; + bool has_sub() const override { return false; }; }; template class SuperRegion; @@ -106,7 +106,7 @@ class SuperSector : public Sector { SuperSector* as_super() override { return this; }; const SuperSector* as_super() const override { return this; }; const SuperSector* parent() const override { return nullptr; }; - const bool has_sub() const override { return sub_.size() > 0; }; + bool has_sub() const override { return sub_.size() > 0; }; }; template @@ -123,7 +123,7 @@ class Region : public IndexPart { virtual SuperRegion* as_super() = 0; virtual const SuperRegion* as_super() const = 0; virtual const SuperRegion* super() const = 0; - virtual const bool has_sub() const = 0; + virtual bool has_sub() const = 0; }; template class SubRegion : public Region { @@ -140,7 +140,7 @@ class SubRegion : public Region { SuperRegion* as_super() override { return nullptr; }; const SuperRegion* as_super() const override { return nullptr; }; const SuperRegion* parent() const override { return parent_; }; - const bool has_sub() const override { return false; }; + bool has_sub() const override { return false; }; }; template class SuperRegion : public Region { @@ -158,7 +158,7 @@ class SuperRegion : public Region { SuperRegion* as_super() override { return this; }; const SuperRegion* as_super() const override { return this; }; const SuperRegion* parent() const override { return nullptr; }; - const bool has_sub() const override { return sub_.size() > 0; }; + bool has_sub() const override { return sub_.size() > 0; }; }; template @@ -235,8 +235,8 @@ class IndexSet { (subregion_it == (*superregion_it)->sub().end()) ? static_cast*>(superregion_it->get()) : static_cast*>(*subregion_it), index}; }; - const bool operator==(const total_iterator& rhs) const { return index == rhs.index; }; - const bool operator!=(const total_iterator& rhs) const { return !(*this == rhs); }; + bool operator==(const total_iterator& rhs) const { return index == rhs.index; }; + bool operator!=(const total_iterator& rhs) const { return !(*this == rhs); }; }; total_iterator tbegin() const { return total_iterator::begin(*this); }; total_iterator tend() const { return total_iterator::end(*this); }; @@ -288,11 +288,11 @@ class IndexSet { return *this; }; const Index operator*() const { return {*sector_it, region_it->get()}; }; - const bool operator==(const super_iterator& rhs) const { + bool operator==(const super_iterator& rhs) const { return (region_it == rhs.region_it && sector_it == rhs.sector_it) || (region_it == parent->superregions().end() && rhs.region_it == rhs.parent->superregions().end()); }; - const bool operator!=(const super_iterator& rhs) const { return !(*this == rhs); }; + bool operator!=(const super_iterator& rhs) const { return !(*this == rhs); }; }; super_iterator sbegin() const { return super_iterator::begin(this); }; super_iterator send() const { return super_iterator::end(this); }; diff --git a/src/Disaggregation.cpp b/src/Disaggregation.cpp index 877cfe6..199c1b2 100644 --- a/src/Disaggregation.cpp +++ b/src/Disaggregation.cpp @@ -56,6 +56,8 @@ void Disaggregation::initialize(const settings::SettingsNode& settings) { } else { throw std::runtime_error("Unknown type"); } + } + for (const auto& d : settings.as_sequence()) { for (const auto& proxy : d["proxies"].as_sequence()) { read_proxy_file(proxy["file"].as(), proxy["level"].as(), proxy["year"].as()); } diff --git a/src/MRIOTable.cpp b/src/MRIOTable.cpp index 0fa1c31..9d85dc7 100644 --- a/src/MRIOTable.cpp +++ b/src/MRIOTable.cpp @@ -542,24 +542,24 @@ void Table::insert_region_offset_y(const SuperRegion* r, template void Table::debug_out() const { #ifdef DEBUGOUT - cout << "\n====\n"; - cout << std::setprecision(3) << std::fixed; + std::cout << "\n====\n"; + std::cout << std::setprecision(3) << std::fixed; for (const auto& y : index_set_.total_indices) { - cout << index_set_.at(y.sector, y.region) << " " << y.sector->name << " " << (!y.sector->parent() ? " " : y.sector->parent()->name) << " " + std::cout << index_set_.at(y.sector, y.region) << " " << y.sector->name << " " << (!y.sector->parent() ? " " : y.sector->parent()->name) << " " << (y.sector->parent() ? *y.sector->parent() : *y.sector) << " " << (*y.sector) << " " << y.sector->level_index() << " " << y.region->name << " " << (!y.region->parent() ? " " : y.region->parent()->name) << " " << (y.region->parent() ? *y.region->parent() : *y.region) << " " << (*y.region) << " " << y.region->level_index() << " | "; for (const auto& x : index_set_.total_indices) { - if (data[x.index * index_set_.size() + y.index] == 0) { - cout << " . "; + if (data[x.index * index_set_.size() + y.index] <= 0) { + std::cout << " . "; } else { - cout << data[x.index * index_set_.size() + y.index]; + std::cout << data[x.index * index_set_.size() + y.index]; } - cout << " "; + std::cout << " "; } - cout << "\n"; + std::cout << "\n"; } - cout << "====\n"; + std::cout << "====\n"; #endif }