diff options
author | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2018-07-24 13:12:35 -0400 |
---|---|---|
committer | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2018-07-24 13:12:35 -0400 |
commit | c48fd16fe1554c88c79a1f0d50e81c803da8f61f (patch) | |
tree | 2b8a07de4e0fc795854fc4c1ac0ff095783218fa /lib/finite_states.h | |
parent | 8d96c4d30214a2c27561740b7b3f7e1e3b0bbfe4 (diff) | |
download | c++-c48fd16fe1554c88c79a1f0d50e81c803da8f61f.tar.gz c++-c48fd16fe1554c88c79a1f0d50e81c803da8f61f.tar.bz2 c++-c48fd16fe1554c88c79a1f0d50e81c803da8f61f.zip |
implemented updating the first fourier moment in wolff_finite, but also make wolff_finite obselete by adding a hacky preprocessor method for making wolff.h as efficient
Diffstat (limited to 'lib/finite_states.h')
-rw-r--r-- | lib/finite_states.h | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/finite_states.h b/lib/finite_states.h new file mode 100644 index 0000000..1e8800c --- /dev/null +++ b/lib/finite_states.h @@ -0,0 +1,33 @@ + +#pragma once + +#include <cmath> +#include <functional> + +#define FINITE_STATES + +// must have N_STATES, states[N_STATES], and state_to_ind defined before +// invoking header + +double J_probs[N_STATES * N_STATES * N_STATES]; +double H_probs[N_STATES * N_STATES]; + +template <class X_t> +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 * N_STATES * N_STATES + j * N_STATES +k] = 1.0 - exp(-(J(states[i], states[k]) - J(states[j], states[k])) / T); + } + } + } + for (q_t i = 0; i < N_STATES; i++) { + for (q_t j = 0; j < N_STATES; j++) { + H_probs[i * N_STATES + j] = 1.0 - exp(-(H(states[i]) - H(states[j])) / T); + } + } +} + + + + |