summaryrefslogtreecommitdiff
path: root/uniform.cpp
diff options
context:
space:
mode:
authorJaron Kent-Dobias <jaron@kent-dobias.com>2022-10-10 17:44:58 +0200
committerJaron Kent-Dobias <jaron@kent-dobias.com>2022-10-10 17:44:58 +0200
commitbbc27302fa9ae20de0650154d5d479860cf000de (patch)
tree1089a9c5cac1aa980334aa624b8bd6024a435a86 /uniform.cpp
parent0d20e69294b7550496f83056e3c291b08492c680 (diff)
downloadcode-bbc27302fa9ae20de0650154d5d479860cf000de.tar.gz
code-bbc27302fa9ae20de0650154d5d479860cf000de.tar.bz2
code-bbc27302fa9ae20de0650154d5d479860cf000de.zip
A little more refactoring.
Diffstat (limited to 'uniform.cpp')
-rw-r--r--uniform.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/uniform.cpp b/uniform.cpp
index 519e6c0..c7d6367 100644
--- a/uniform.cpp
+++ b/uniform.cpp
@@ -1,6 +1,7 @@
#include <functional>
#include <iostream>
#include <list>
+#include <ranges>
#include "randutils/randutils.hpp"
#include "pcg-cpp/include/pcg_random.hpp"
@@ -18,16 +19,16 @@ using Face = std::array<std::reference_wrapper<Edge>, 4>;
class AztecDiamond {
public:
std::vector<Edge> edges;
- std::vector<std::vector<Face>> faces;
+ std::vector<std::vector<Face>> lattices;
- AztecDiamond(unsigned n) : edges(pow(2 * n, 2)), faces(n) {
+ AztecDiamond(unsigned n) : edges(pow(2 * n, 2)), lattices(n) {
for (unsigned i = 1; i <= n; i++) {
- faces[n - i].reserve(pow(i, 2));
+ lattices[n - i].reserve(pow(i, 2));
unsigned x0 = n - i;
for (unsigned j = 0; j < pow(i, 2); j++) {
unsigned x = 2 * (j % i);
unsigned y = 2 * (j / i);
- faces[n - i].push_back({
+ lattices[n - i].push_back({
edges[2 * n * (x0 + y) + x0 + x],
edges[2 * n * (x0 + y) + x0 + x + 1],
edges[2 * n * (x0 + y + 1) + x0 + x],
@@ -38,8 +39,8 @@ public:
}
void computeWeights() {
- for (std::vector<Face>& fs : faces) {
- for (Face& f : fs) {
+ for (std::vector<Face>& faces : lattices) {
+ for (Face& f : faces) {
Real w = f[0].get().weights.back();
Real x = f[1].get().weights.back();
Real y = f[2].get().weights.back();
@@ -61,7 +62,7 @@ public:
}
void computeProbabilities() {
- for (auto it = faces.rbegin(); it != faces.rend(); it++) {
+ for (auto it = lattices.rbegin(); it != lattices.rend(); it++) {
for (Face& f : *it) {
Real p = f[0].get().probability;
Real q = f[1].get().probability;