Commit 35b02bc5 authored by gbalduzz's avatar gbalduzz
Browse files

cleanup

parent b47687e9
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -76,7 +76,7 @@ public:
    return entries_ == rhs.entries_;
  }

protected:
private:
  linalg::util::HostVector<details::SectorEntry> entries_;
  std::vector<std::uint64_t> tags_;
};
+20 −20
Original line number Diff line number Diff line
@@ -61,8 +61,8 @@ public:
  // Out: sector_from, from.
  template <class Alloc>
  void moveAndShrink(std::array<std::vector<int, Alloc>, 2>& sector_from,
                     std::array<std::vector<int, Alloc>, 2>& sector_to, std::vector<int>& from,
                     std::vector<int>& to);
                     std::array<std::vector<int, Alloc>, 2>& sector_remove, std::vector<int>& from,
                     std::vector<int>& remove);

  inline void swapVertices(short i, short j);

@@ -283,17 +283,17 @@ int SolverConfiguration::nPartners(int vertex_index) const {

template <class Alloc>
inline void SolverConfiguration::moveAndShrink(std::array<std::vector<int, Alloc>, 2>& sector_from,
                                               std::array<std::vector<int, Alloc>, 2>& sector_to,
                                               std::vector<int>& from, std::vector<int>& to) {
                                               std::array<std::vector<int, Alloc>, 2>& sector_remove,
                                               std::vector<int>& from, std::vector<int>& remove) {
  for (int s = 0; s < 2; ++s) {
    // Sort and prepare source array.
    auto& sector = BaseClass::sectors_[s].entries_;
    std::sort(sector_to[s].begin(), sector_to[s].end());
    std::sort(sector_remove[s].begin(), sector_remove[s].end());
    auto& tags = BaseClass::sectors_[s].tags_;
    sector_from[s].clear();
    int source_idx = sector.size() - sector_to[s].size();
    for (int i = 0; source_idx < sector.size(); ++i, ++source_idx) {
      while (std::binary_search(sector_to[s].begin(), sector_to[s].end(), source_idx))
    int source_idx = sector.size() - sector_remove[s].size();
    for (; source_idx < sector.size(); ++source_idx) {
      while (std::binary_search(sector_remove[s].begin(), sector_remove[s].end(), source_idx))
        ++source_idx;
      if (source_idx < sector.size())
        sector_from[s].push_back(source_idx);
@@ -301,19 +301,19 @@ inline void SolverConfiguration::moveAndShrink(std::array<std::vector<int, Alloc

    // Move configuration elements.
    for (int i = 0; i < sector_from[s].size(); ++i) {
      sector[sector_to[s][i]] = sector[sector_from[s][i]];
      tags[sector_to[s][i]] = tags[sector_from[s][i]];
      sector[sector_remove[s][i]] = sector[sector_from[s][i]];
      tags[sector_remove[s][i]] = tags[sector_from[s][i]];
    }
    // Shrink sector configuration.
    sector.erase(sector.end() - sector_to[s].size(), sector.end());
    tags.erase(tags.end() - sector_to[s].size(), tags.end());
    sector.erase(sector.end() - sector_remove[s].size(), sector.end());
    tags.erase(tags.end() - sector_remove[s].size(), tags.end());
  }

  std::sort(to.begin(), to.end());
  std::sort(remove.begin(), remove.end());
  from.clear();
  int source_idx = size() - to.size();
  for (int i = 0; source_idx < size(); ++i, ++source_idx) {
    while (std::binary_search(to.begin(), to.end(), source_idx))
  int source_idx = size() - remove.size();
  for (; source_idx < size(); ++source_idx) {
    while (std::binary_search(remove.begin(), remove.end(), source_idx))
      ++source_idx;
    if (source_idx < size())
      from.push_back(source_idx);
@@ -321,8 +321,8 @@ inline void SolverConfiguration::moveAndShrink(std::array<std::vector<int, Alloc

  // Move and shrink configuration.
  for (int i = 0; i < from.size(); ++i)
    vertices_[to[i]] = vertices_[from[i]];
  vertices_.erase(vertices_.end() - to.size(), vertices_.end());
    vertices_[remove[i]] = vertices_[from[i]];
  vertices_.erase(vertices_.end() - remove.size(), vertices_.end());

  assert(checkConsistency());
}
+1 −1
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@ namespace details {
// dca::phys::solver::ctint::details::

template<class T>
T getRandomElement(const std::vector<std::vector<T>*>& v_ptrs, const double rand){
T getRandomElement(const std::vector<const std::vector<T>*>& v_ptrs, const double rand){
    assert(rand >= 0 && rand <= 1);

    unsigned size = 0;
+1 −1
Original line number Diff line number Diff line
@@ -80,7 +80,7 @@ TEST(SolverConfigurationTest, MatrixConfigurationUpdate) {
  EXPECT_FALSE(config.checkConsistency());
}

TEST(SolverConfigurationTest, ShrinkAndMove) {
TEST(SolverConfigurationTest, MoveAndShrink) {
  dca::phys::solver::ctint::InteractionVertices interactions;
  interactions.insertElement({{0, 0, 0, 0}, {0, 0, 1, 1}, 1});  // up-down
  interactions.insertElement({{1, 1, 1, 1}, {0, 0, 1, 1}, 1});