diff options
author | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2018-10-10 00:26:35 -0400 |
---|---|---|
committer | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2018-10-10 00:26:35 -0400 |
commit | 3b53450b9236dc50abe652913cad17dedfca50df (patch) | |
tree | 73b09b41937479f2d9cf9fa524079b5fb098b1bf /lib | |
parent | 4239e2bfc6701f0b5170132d01af381129618b34 (diff) | |
download | c++-3b53450b9236dc50abe652913cad17dedfca50df.tar.gz c++-3b53450b9236dc50abe652913cad17dedfca50df.tar.bz2 c++-3b53450b9236dc50abe652913cad17dedfca50df.zip |
extended NOFIELD support when FINITE_STATES is also invoked
Diffstat (limited to 'lib')
-rw-r--r-- | lib/finite_states.h | 14 | ||||
-rw-r--r-- | lib/wolff.h | 4 |
2 files changed, 14 insertions, 4 deletions
diff --git a/lib/finite_states.h b/lib/finite_states.h index 08eff30..426edad 100644 --- a/lib/finite_states.h +++ b/lib/finite_states.h @@ -11,20 +11,26 @@ // invoking header std::array<std::array<std::array<double, N_STATES>, N_STATES>, N_STATES> J_probs; +#ifndef NOFIELD std::array<std::array<double, N_STATES>, N_STATES> H_probs; +#endif template <class X_t> +#ifndef NOFIELD void initialize_probs(std::function <double(X_t, X_t)> J, std::function <double(X_t)> H, double T) { for (q_t i = 0; i < N_STATES; i++) { for (q_t j = 0; j < N_STATES; j++) { - for (q_t k = 0; k < N_STATES; k++) { - J_probs[i][j][k] = 1.0 - exp(-(J(states[i], states[k]) - J(states[j], states[k])) / T); - } + H_probs[i][j] = 1.0 - exp(-(H(states[i]) - H(states[j])) / T); } } +#else +void initialize_probs(std::function <double(X_t, X_t)> J, double T) { +#endif for (q_t i = 0; i < N_STATES; i++) { for (q_t j = 0; j < N_STATES; j++) { - H_probs[i][j] = 1.0 - exp(-(H(states[i]) - H(states[j])) / T); + for (q_t k = 0; k < N_STATES; k++) { + J_probs[i][j][k] = 1.0 - exp(-(J(states[i], states[k]) - J(states[j], states[k])) / T); + } } } } diff --git a/lib/wolff.h b/lib/wolff.h index 498f7f3..141a5b2 100644 --- a/lib/wolff.h +++ b/lib/wolff.h @@ -6,8 +6,12 @@ template <class R_t, class X_t> void wolff(count_t N, state_t <R_t, X_t>& s, std::function <R_t(gsl_rng *, X_t s0)> gen_R, std::function <void(const state_t <R_t, X_t>&)> measurements, gsl_rng *r, bool silent) { #ifdef FINITE_STATES +#ifdef NOFIELD + initialize_probs(s.J, s.T); +#else initialize_probs(s.J, s.H, s.T); #endif +#endif if (!silent) printf("\n"); for (count_t steps = 0; steps < N; steps++) { |