summaryrefslogtreecommitdiff
path: root/rbmp.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'rbmp.hpp')
-rw-r--r--rbmp.hpp22
1 files changed, 15 insertions, 7 deletions
diff --git a/rbmp.hpp b/rbmp.hpp
index 15b7e97..aefa046 100644
--- a/rbmp.hpp
+++ b/rbmp.hpp
@@ -1,8 +1,4 @@
-#include <cmath>
-#include <functional>
-#include <random>
#include <vector>
-#include <limits>
#include <stack>
#include "randutils/randutils.hpp"
@@ -49,7 +45,7 @@ public:
std::vector<Vertex> vertices;
std::vector<Edge> edges;
- AztecDiamond(int n, Rng& r) : n(n), vertices(2 * n * (n + 1)), edges(pow(2 * n, 2)) {
+ AztecDiamond(int n) : n(n), vertices(2 * n * (n + 1)), edges(pow(2 * n, 2)) {
unsigned M = vertices.size() / 2;
for (int i = 0; i < M; i++) {
vertices[i].index = i;
@@ -60,11 +56,20 @@ public:
for (unsigned i = 0; i < edges.size(); i++) {
edges[i].tail = &vertices[(1 + (i % (2 * n))) / 2 + (n + 1) * ((i / 4) / n)];
edges[i].head = &vertices[M + (i % (2 * n)) / 2 + n * (((i + 2 * n) / 4) / n)];
- edges[i].weight = r.variate<double, std::exponential_distribution>(1);
}
}
- void computeWeights() {
+ void setWeights(Rng& r) {
+ for (Edge& e : edges) {
+ e.weight = r.variate<Real, std::exponential_distribution>(1);
+ }
+ }
+
+ void computeWeights(Real T) {
+ for (Edge& e : edges) {
+ e.weights.push(exp(-e.weight / T));
+ }
+
for (unsigned i = n; i > 0; i--) {
#pragma omp parallel for
for (unsigned j = 0; j < pow(i, 2); j++) {
@@ -91,6 +96,9 @@ public:
}
Real computeProbabilities() { // destroys *all* weights
+ for (Edge& e : edges) {
+ e.probability = 0;
+ }
Real partitionFunction = 1;
for (unsigned i = 1; i <= n; i++) {