summaryrefslogtreecommitdiff
path: root/lib/cluster.h
diff options
context:
space:
mode:
authorJaron Kent-Dobias <jaron@kent-dobias.com>2018-07-26 16:18:40 -0400
committerJaron Kent-Dobias <jaron@kent-dobias.com>2018-07-26 16:18:40 -0400
commit1160baa61bad605cf8a1d583e8ae356a54a942df (patch)
treee7c865f38836a9a03349bbd803aae8be9b37a200 /lib/cluster.h
parent870555f569bc63fecdc7c0b16e72e4e002f21c13 (diff)
downloadc++-1160baa61bad605cf8a1d583e8ae356a54a942df.tar.gz
c++-1160baa61bad605cf8a1d583e8ae356a54a942df.tar.bz2
c++-1160baa61bad605cf8a1d583e8ae356a54a942df.zip
many changes, including new spin spaces and groups and cleaning up core library code
Diffstat (limited to 'lib/cluster.h')
-rw-r--r--lib/cluster.h16
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/cluster.h b/lib/cluster.h
index c5f2be7..f948586 100644
--- a/lib/cluster.h
+++ b/lib/cluster.h
@@ -31,7 +31,9 @@ void flip_cluster(state_t <R_t, X_t> *state, v_t v0, R_t r, gsl_rng *rand) {
R_old = state->R;
marks[v] = true;
- if (v == state->nv) {
+ bool v_is_ghost = (v == state->nv);
+
+ if (v_is_ghost) {
R_new = r.act(R_old);
} else {
si_old = state->spins[v];
@@ -40,19 +42,18 @@ void flip_cluster(state_t <R_t, X_t> *state, v_t v0, R_t r, gsl_rng *rand) {
for (const v_t &vn : state->g.v_adj[v]) {
X_t sj;
+ bool vn_is_ghost = (vn == state->nv);
- if (vn != state->nv) {
+ if (!vn_is_ghost) {
sj = state->spins[vn];
}
double prob;
- bool is_ext = (v == state->nv || vn == state->nv);
-
- if (is_ext) {
+ if (v_is_ghost || vn_is_ghost) {
X_t rs_old, rs_new;
v_t non_ghost;
- if (vn == state->nv) {
+ if (vn_is_ghost) {
rs_old = R_old.act_inverse(si_old);
rs_new = R_old.act_inverse(si_new);
non_ghost = v;
@@ -61,6 +62,7 @@ void flip_cluster(state_t <R_t, X_t> *state, v_t v0, R_t r, gsl_rng *rand) {
rs_new = R_new.act_inverse(sj);
non_ghost = vn;
}
+
double dE = state->H(rs_old) - state->H(rs_new);
#ifdef FINITE_STATES
prob = H_probs[state_to_ind(rs_old)][state_to_ind(rs_new)];
@@ -97,7 +99,7 @@ void flip_cluster(state_t <R_t, X_t> *state, v_t v0, R_t r, gsl_rng *rand) {
}
}
- if (v == state->nv) {
+ if (v_is_ghost) {
state->R = R_new;
} else {
state->spins[v] = si_new;