summaryrefslogtreecommitdiff
path: root/lib/finite_states.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/finite_states.h')
-rw-r--r--lib/finite_states.h9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/finite_states.h b/lib/finite_states.h
index 1e8800c..08eff30 100644
--- a/lib/finite_states.h
+++ b/lib/finite_states.h
@@ -3,27 +3,28 @@
#include <cmath>
#include <functional>
+#include <array>
#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];
+std::array<std::array<std::array<double, N_STATES>, N_STATES>, N_STATES> J_probs;
+std::array<std::array<double, N_STATES>, N_STATES> H_probs;
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);
+ 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 < 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);
+ H_probs[i][j] = 1.0 - exp(-(H(states[i]) - H(states[j])) / T);
}
}
}