summaryrefslogtreecommitdiff
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
parent0d20e69294b7550496f83056e3c291b08492c680 (diff)
downloadcode-bbc27302fa9ae20de0650154d5d479860cf000de.tar.gz
code-bbc27302fa9ae20de0650154d5d479860cf000de.tar.bz2
code-bbc27302fa9ae20de0650154d5d479860cf000de.zip
A little more refactoring.
-rw-r--r--Makefile2
-rw-r--r--compile_flags.txt2
-rw-r--r--uniform.cpp15
3 files changed, 10 insertions, 9 deletions
diff --git a/Makefile b/Makefile
index 31d3891..e7b1f6c 100644
--- a/Makefile
+++ b/Makefile
@@ -4,7 +4,7 @@ BLOSSOM_DIRS := $(BLOSSOM_DIR) $(BLOSSOM_DIR)/MinCost $(BLOSSOM_DIR)/GEOM
BLOSSOM_SOURCES := $(filter-out $(BLOSSOM_DIR)/example.cpp, $(foreach dir, $(BLOSSOM_DIRS), $(wildcard $(dir)/*.cpp)))
BLOSSOM_OBJS := $(patsubst %.cpp, %.o, $(BLOSSOM_SOURCES))
-CFLAGS := -flto -fopenmp -O3 -Os -march=native -mtune=native -D_NDEBUG -DPERFECT_MATCHING_DOUBLE
+CFLAGS := -std=c++20 -stdlib=libc++ -flto -fopenmp -O3 -Os -march=native -mtune=native -D_NDEBUG -DPERFECT_MATCHING_DOUBLE
CXX = clang++
LD = ld.lld
LIBS := -lrt
diff --git a/compile_flags.txt b/compile_flags.txt
index 0f75b87..10ac621 100644
--- a/compile_flags.txt
+++ b/compile_flags.txt
@@ -1,2 +1,2 @@
-std=c++20
--O3
+-stdlib=libc++
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;