summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaron Kent-Dobias <jaron@kent-dobias.com>2018-02-02 19:07:35 -0500
committerJaron Kent-Dobias <jaron@kent-dobias.com>2018-02-02 19:07:35 -0500
commit2342ffc71240db398f0d5274ea8e3b1f14e6fef3 (patch)
treeb793c06463be43976883909ef177e5bdf0e548cd
parentda28d64d45984364b6cd08ed5fb9324998cf496b (diff)
downloadc++-2342ffc71240db398f0d5274ea8e3b1f14e6fef3.tar.gz
c++-2342ffc71240db398f0d5274ea8e3b1f14e6fef3.tar.bz2
c++-2342ffc71240db398f0d5274ea8e3b1f14e6fef3.zip
regretfully replacing the beautifully implemented binary search tree I was using to check if a vertex was marked with a calloc of num_vertices bools
-rw-r--r--lib/wolff_tools.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/wolff_tools.c b/lib/wolff_tools.c
index 416a498..ddce40f 100644
--- a/lib/wolff_tools.c
+++ b/lib/wolff_tools.c
@@ -12,17 +12,20 @@ v_t flip_cluster(ising_state_t *s, v_t v0, q_t step, gsl_rng *r) {
ll_t *stack = NULL; // create a new stack
stack_push(&stack, v0); // push the initial vertex to the stack
- node_t *T = NULL;
+ //node_t *T = NULL;
+ bool *marks = (bool *)calloc(s->g->nv, sizeof(bool));
while (stack != NULL) {
v_t v = stack_pop(&stack);
- if (!tree_contains(T, v)) { // if the vertex hasn't already been flipped
+// if (!tree_contains(T, v)) { // if the vertex hasn't already been flipped
+ if (!marks[v]) {
q_t s_old = s->spins[v];
q_t s_new = (s->spins[v] + step) % s->q;
s->spins[v] = s_new; // flip the vertex
- tree_insert(&T, v);
+ //tree_insert(&T, v);
+ marks[v] = true;
v_t nn = s->g->v_i[v + 1] - s->g->v_i[v];
@@ -63,7 +66,8 @@ v_t flip_cluster(ising_state_t *s, v_t v0, q_t step, gsl_rng *r) {
}
}
- tree_freeNode(T);
+ //tree_freeNode(T);
+ free(marks);
return nv;
}