From 2242fd6f8b7f16b706d49a2288da3aa20f12314b Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Thu, 13 Feb 2020 15:00:31 -0500 Subject: Added gitignore and fixed Ising to work with new paradigm --- octree.hpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'octree.hpp') diff --git a/octree.hpp b/octree.hpp index 1be6e0a..bb13242 100644 --- a/octree.hpp +++ b/octree.hpp @@ -5,6 +5,8 @@ #include #include +#include + #include "spin.hpp" #include "vector.hpp" @@ -31,16 +33,16 @@ private: std::unordered_map, std::set*>> data; public: - Octree(T L, unsigned N) { - L = L; - N = N; + Octree(T L_tmp, unsigned N_tmp) { + L = L_tmp; + N = N_tmp; } std::array ind(Vector x) const { std::array ind; for (unsigned i = 0; i < D; i++) { - ind[i] = (signed)std::floor(N * x(i) / L); + ind[i] = std::floor(N * x(i) / L); } return ind; @@ -55,6 +57,15 @@ public: } }; + std::set*> at(const Vector& x) const { + auto it = data.find(ind(x)); + if (it == data.end()) { + return {}; + } else { + return it->second; + } + } + std::set*> neighbors(const Vector& x) const { std::array i0 = ind(x); std::set*> ns; -- cgit v1.2.3-54-g00ecf