diff options
Diffstat (limited to 'lib/include/wolff/finite_states.hpp')
-rw-r--r-- | lib/include/wolff/finite_states.hpp | 41 |
1 files changed, 18 insertions, 23 deletions
diff --git a/lib/include/wolff/finite_states.hpp b/lib/include/wolff/finite_states.hpp index 426edad..4cca69e 100644 --- a/lib/include/wolff/finite_states.hpp +++ b/lib/include/wolff/finite_states.hpp @@ -1,40 +1,35 @@ -#pragma once + +#ifndef WOLFF_FINITE_STATES +#define WOLFF_FINITE_STATES #include <cmath> -#include <functional> #include <array> -#define FINITE_STATES - -// must have N_STATES, states[N_STATES], and state_to_ind defined before -// invoking header +#include "system.hpp" -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; +std::array<std::array<std::array<double, WOLFF_FINITE_STATES_N>, WOLFF_FINITE_STATES_N>, WOLFF_FINITE_STATES_N> finite_states_Zp; +#ifndef WOLFF_NO_FIELD +std::array<std::array<double, WOLFF_FINITE_STATES_N>, WOLFF_FINITE_STATES_N> finite_states_Bp; #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++) { - H_probs[i][j] = 1.0 - exp(-(H(states[i]) - H(states[j])) / T); +template <class R_t, class X_t> +void finite_states_init(const wolff_system<R_t, X_t>& S) { +#ifndef WOLFF_NO_FIELD + for (q_t i = 0; i < WOLFF_FINITE_STATES_N; i++) { + for (q_t j = 0; j < WOLFF_FINITE_STATES_N; j++) { + finite_states_Bp[i][j] = 1.0 - exp(-(S.B(finite_states_possible[i]) - S.B(finite_states_possible[j])) / S.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++) { - 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); + for (q_t i = 0; i < WOLFF_FINITE_STATES_N; i++) { + for (q_t j = 0; j < WOLFF_FINITE_STATES_N; j++) { + for (q_t k = 0; k < WOLFF_FINITE_STATES_N; k++) { + finite_states_Zp[i][j][k] = 1.0 - exp(-(S.Z(finite_states_possible[i], finite_states_possible[k]) - S.Z(finite_states_possible[j], finite_states_possible[k])) / S.T); } } } } - - +#endif |