Skip to content

Commit a828ff4

Browse files
committed
don't count identity transform as success
1 parent 690b295 commit a828ff4

File tree

4 files changed

+24
-0
lines changed

4 files changed

+24
-0
lines changed

src/include/lattice.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,9 @@ template <int Dim> class transform {
240240
*/
241241
box<Dim> operator*(const box<Dim> &b) const;
242242

243+
/** @brief Returns true if the transform is the identity. */
244+
bool is_identity() const;
245+
243246
/**
244247
* @brief Returns the inverse transform.
245248
*

src/lattice/transform.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,15 @@ template <int Dim> box<Dim> transform<Dim>::operator*(const box<Dim> &b) const {
7777
return box<Dim>(intervals);
7878
}
7979

80+
template <int Dim> bool transform<Dim>::is_identity() const {
81+
for (int i = 0; i < Dim; ++i) {
82+
if (perm_[i] != i || signs_[i] != 1) {
83+
return false;
84+
}
85+
}
86+
return true;
87+
}
88+
8089
template <int Dim> transform<Dim> transform<Dim>::inverse() const {
8190
std::array<int, Dim> perm;
8291
std::array<int, Dim> signs;

src/walks/walk.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ walk<Dim>::walk(int num_steps, std::optional<unsigned int> seed)
2020

2121
template <int Dim>
2222
std::optional<std::vector<point<Dim>>> walk<Dim>::try_pivot(int step, const transform<Dim> &trans) const {
23+
if (trans.is_identity()) {
24+
return {};
25+
}
26+
2327
std::vector<point<Dim>> new_points(num_steps() - step - 1);
2428
for (int i = step + 1; i < num_steps(); ++i) {
2529
auto q = pivot_point(step, i, trans);

src/walks/walk_tree.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ template <int Dim> walk_node<Dim> &walk_tree<Dim>::find_node(int n) {
8181
/* HIGH-LEVEL FUNCTIONS */
8282

8383
template <int Dim> bool walk_tree<Dim>::try_pivot(int n, const transform<Dim> &r) {
84+
if (r.is_identity()) {
85+
return false;
86+
}
87+
8488
root_->shuffle_up(n);
8589
auto root_symm = root_->symm_;
8690
root_->symm_ = root_->symm_ * r;
@@ -95,6 +99,10 @@ template <int Dim> bool walk_tree<Dim>::try_pivot(int n, const transform<Dim> &r
9599
}
96100

97101
template <int Dim> bool walk_tree<Dim>::try_pivot_fast(int n, const transform<Dim> &t) {
102+
if (t.is_identity()) {
103+
return false;
104+
}
105+
98106
walk_node<Dim> *w = &find_node(n); // TODO: a pointer seems to be needed, but why?
99107
walk_node<Dim> w_copy(*w);
100108
auto success = !w_copy.shuffle_intersect(t, w->is_left_child());

0 commit comments

Comments
 (0)