From 722bc71ed8d4e1ae5616c5c8284fbffe21c4ffa4 Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Tue, 17 Jul 2018 23:27:10 -0400 Subject: working generator of rotations near the current state --- lib/cluster.h | 6 +++--- lib/orthogonal.h | 22 +++++++++++++++++----- 2 files changed, 20 insertions(+), 8 deletions(-) (limited to 'lib') diff --git a/lib/cluster.h b/lib/cluster.h index ccd8725..5f770ad 100644 --- a/lib/cluster.h +++ b/lib/cluster.h @@ -58,7 +58,7 @@ v_t flip_cluster(state_t *state, v_t v0, R_t r, gsl_rng *rand) { ll_t *stack = NULL; // create a new stack stack_push(&stack, v0); // push the initial vertex to the stack - bool *marks = (bool *)calloc(state->nv, sizeof(bool)); + bool *marks = (bool *)calloc(state->nv + 1, sizeof(bool)); while (stack != NULL) { v_t v = stack_pop(&stack); @@ -67,10 +67,10 @@ v_t flip_cluster(state_t *state, v_t v0, R_t r, gsl_rng *rand) { X_t si_old, si_new; R_t R_old, R_new; + R_old = state->R; marks[v] = true; if (v == state->nv) { - R_old = state->R; R_new = act (r, R_old); } else { si_old = state->spins[v]; @@ -94,7 +94,7 @@ v_t flip_cluster(state_t *state, v_t v0, R_t r, gsl_rng *rand) { if (is_ext) { X_t rs_old, rs_new; - if (vn == state->g->nv - 1) { + if (vn == state->nv) { rs_old = act_inverse (R_old, si_old); rs_new = act_inverse (R_old, si_new); } else { diff --git a/lib/orthogonal.h b/lib/orthogonal.h index 6166223..d8ad33d 100644 --- a/lib/orthogonal.h +++ b/lib/orthogonal.h @@ -167,9 +167,9 @@ orthogonal_t generate_rotation_uniform (gsl_rng *r, const state_t orthogonal_t generate_rotation_perturbation (gsl_rng *r, const state_t , vector_t > *s, double epsilon) { - orthogonal_t ptr; + orthogonal_t m; vector_t tmp_v; - ptr.is_reflection = true; + m.is_reflection = true; tmp_v.x = (double *)malloc(q * sizeof(double)); @@ -196,10 +196,22 @@ orthogonal_t generate_rotation_perturbation (gsl_rng *r, const state tmp_v.x[i] /= mag_v; } - vector_t v = act(s->R, tmp_v); + vector_t v = act_inverse(s->R, tmp_v); free(tmp_v.x); - ptr.x = v.x; + m.x = v.x; - return ptr; + v2 = 0; + + for (q_t i = 0; i < q; i++) { + v2 += m.x[i] * m.x[i]; + } + + mag_v = sqrt(v2); + + for (q_t i = 0; i < q; i++) { + m.x[i] /= mag_v; + } + + return m; } -- cgit v1.2.3-70-g09d2