diff options
author | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2020-02-13 15:00:31 -0500 |
---|---|---|
committer | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2020-02-13 15:00:31 -0500 |
commit | 2242fd6f8b7f16b706d49a2288da3aa20f12314b (patch) | |
tree | 850329d19cebf41b7c4dd6e83be0bf58f1222b19 /octree.hpp | |
parent | d5a7a3f2e5808e7a3327242dc9b368afed9383bf (diff) | |
download | space_wolff-2242fd6f8b7f16b706d49a2288da3aa20f12314b.tar.gz space_wolff-2242fd6f8b7f16b706d49a2288da3aa20f12314b.tar.bz2 space_wolff-2242fd6f8b7f16b706d49a2288da3aa20f12314b.zip |
Added gitignore and fixed Ising to work with new paradigm
Diffstat (limited to 'octree.hpp')
-rw-r--r-- | octree.hpp | 19 |
1 files changed, 15 insertions, 4 deletions
@@ -5,6 +5,8 @@ #include <set> #include <unordered_map> +#include <iostream> + #include "spin.hpp" #include "vector.hpp" @@ -31,16 +33,16 @@ private: std::unordered_map<std::array<signed, D>, std::set<Spin<T, D, S>*>> 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<signed, D> ind(Vector<T, D> x) const { std::array<signed, D> 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<Spin<T, D, S>*> at(const Vector<T, D>& x) const { + auto it = data.find(ind(x)); + if (it == data.end()) { + return {}; + } else { + return it->second; + } + } + std::set<Spin<T, D, S>*> neighbors(const Vector<T, D>& x) const { std::array<signed, D> i0 = ind(x); std::set<Spin<T, D, S>*> ns; |