From 3961d9c977933192c39c456d7a5b2e0f4acb174a Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Mon, 10 Oct 2022 18:47:09 +0200 Subject: Output data in style used previously. --- uniform.cpp | 48 +++++++++++++++++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 15 deletions(-) diff --git a/uniform.cpp b/uniform.cpp index 53fd60b..474399b 100644 --- a/uniform.cpp +++ b/uniform.cpp @@ -1,22 +1,20 @@ #include -#include +#include #include -#include "randutils/randutils.hpp" -#include "pcg-cpp/include/pcg_random.hpp" +#include "rbmp.hpp" -using Rng = randutils::random_generator; using Real = long double; -typedef struct Edge { - std::stack weights; - Real probability = 0; -} Edge; - -using Face = std::array, 4>; - class AztecDiamond { public: + typedef struct Edge { + std::stack weights; + Real probability = 0; + } Edge; + + using Face = std::array, 4>; + std::vector edges; std::vector> lattices; @@ -112,13 +110,16 @@ int main(int argc, char* argv[]) { } } + std::string filename = "order_" + std::to_string(n) + "_" + std::to_string(T) + ".dat"; + std::ifstream input(filename); + Rng r; AztecDiamond a(n); std::vector avgProbabilities(a.edges.size()); for (unsigned i = 0; i < m; i++) { - for (Edge& e : a.edges) { + for (AztecDiamond::Edge& e : a.edges) { e.weights.push(exp(- r.variate(1) / T)); e.probability = 0; } @@ -130,11 +131,28 @@ int main(int argc, char* argv[]) { } } + Graph G(n, r); - for (Real& x : avgProbabilities) { - std::cout << x << " "; + std::vector data_x(G.vertices.size()); + std::vector data_y(G.vertices.size()); + + for (unsigned i = 0; i < G.edges.size(); i++) { + const Edge& e = G.edges[i]; + const Vertex& vt = e.halfedges[0].getTail(); + const Vertex& vh = e.halfedges[0].getHead(); + data_x[vt.index] += avgProbabilities[i] * (vt.coordinate[0] - vh.coordinate[0]); + data_y[vt.index] += avgProbabilities[i] * (vt.coordinate[1] - vh.coordinate[1]); + data_x[vh.index] += avgProbabilities[i] * (vt.coordinate[0] - vh.coordinate[0]); + data_y[vh.index] += avgProbabilities[i] * (vt.coordinate[1] - vh.coordinate[1]); } - std::cout << std::endl; + + std::ofstream output(filename); + + for (unsigned i = 0; i < G.vertices.size(); i++) { + output << data_x[i] << " " << data_y[i] << std::endl; + } + + output.close(); return 0; } -- cgit v1.2.3-70-g09d2