summaryrefslogtreecommitdiff
path: root/src/wolff_potts.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/wolff_potts.cpp')
-rw-r--r--src/wolff_potts.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/wolff_potts.cpp b/src/wolff_potts.cpp
index 3b55472..74e0ea9 100644
--- a/src/wolff_potts.cpp
+++ b/src/wolff_potts.cpp
@@ -90,21 +90,21 @@ int main(int argc, char *argv[]) {
state_t <symmetric_t<POTTSQ>, potts_t<POTTSQ>> s(D, L, T, Z, B);
// define function that generates self-inverse rotations
- std::function <symmetric_t<POTTSQ>(gsl_rng *, const sim_t *)> gen_R = [] (gsl_rng *r, const sim_t *s) -> symmetric_t<POTTSQ> {
+ std::function <symmetric_t<POTTSQ>(gsl_rng *, potts_t<POTTSQ>)> gen_R = [] (gsl_rng *r, potts_t<POTTSQ> v) -> symmetric_t<POTTSQ> {
symmetric_t<POTTSQ> rot;
init(&rot);
- for (int i = POTTSQ - 1; i >= 0; i--) {
- if (rot.perm[i] == i) {
- q_t j = gsl_rng_uniform_int(r, i + 1);
- if (rot.perm[j] == j) {
- q_t tmp = rot.perm[i];
- rot.perm[i] = rot.perm[j];
- rot.perm[j] = tmp;
- }
- }
+ q_t j = gsl_rng_uniform_int(r, POTTSQ - 1);
+ q_t swap_v;
+ if (j < v.x) {
+ swap_v = j;
+ } else {
+ swap_v = j + 1;
}
+ rot.perm[v.x] = swap_v;
+ rot.perm[swap_v] = v.x;
+
return rot;
};