From f8f210993fe199c40df63827c8b1ae0257b02753 Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Wed, 29 Oct 2025 18:24:21 +0100 Subject: Dangling changes from today --- lib/c++/descriptor.hpp | 88 ++++++++++++++++++++++++++++---------------------- lib/c++/iterator.hpp | 36 +++++++++++++++++++++ 2 files changed, 86 insertions(+), 38 deletions(-) (limited to 'lib/c++') diff --git a/lib/c++/descriptor.hpp b/lib/c++/descriptor.hpp index 18ea440..1e3402f 100644 --- a/lib/c++/descriptor.hpp +++ b/lib/c++/descriptor.hpp @@ -165,7 +165,7 @@ public: static constexpr typename saw::native_data_type::type cs2 = 1./3.; }; -/* + template class df_info> { public: @@ -175,38 +175,56 @@ public: static constexpr uint64_t Q = 27u; static constexpr std::array, Q> directions = {{ - { 0, 0, 0}, - {-1, 0, 0}, - { 1, 0, 0}, + { 0, 0, 0}, // 0 + {-1, 0, 0}, // 1 + { 1, 0, 0}, // 2 // Expand into 2D - { 0, -1, 0}, - {-1, -1, 0}, - { 1, -1, 0}, - { 0, 1, 0}, - {-1, 1, 0}, - { 1, 1, 0}, + { 0, -1, 0}, // 3 + {-1, -1, 0}, // 4 + { 1, -1, 0}, // 5 + { 0, 1, 0}, // 6 + {-1, 1, 0}, // 7 + { 1, 1, 0}, // 8 // Expand into 3D - { 0, 0, -1}, - {-1, 0, -1}, - { 1, 0, -1}, - { 0, -1, -1}, - {-1, -1, -1}, - { 1, -1, -1}, - { 0, 1, -1}, - {-1, 1, -1}, - { 1, 1, -1}, - { 0, 0, 1}, - {-1, 0, 1}, - { 1, 0, 1}, - { 0, -1, 1}, - {-1, -1, 1}, - { 1, -1, 1}, - { 0, 1, 1}, - {-1, 1, 1}, - { 1, 1, 1} + { 0, 0, -1}, // 9 + {-1, 0, -1}, // 10 + { 1, 0, -1}, // 11 + { 0, -1, -1},// 12 + {-1, -1, -1},// 13 + { 1, -1, -1},// 14 + { 0, 1, -1}, // 15 + {-1, 1, -1}, // 16 + { 1, 1, -1}, // 17 + { 0, 0, 1}, // 18 + {-1, 0, 1}, // 19 + { 1, 0, 1}, // 20 + { 0, -1, 1}, // 21 + {-1, -1, 1}, // 22 + { 1, -1, 1}, // 23 + { 0, 1, 1}, // 24 + {-1, 1, 1}, // 25 + { 1, 1, 1} // 26 }}; static constexpr std::array::type,Q> weights = { + 8./27., + 1./9., + 1./9., + 1./9., + 1./9., + 1./36., + 1./36., + 1./36., + 1./36., + 8./27., + 1./9., + 1./9., + 1./9., + 1./9., + 1./36., + 1./36., + 1./36., + 1./36., 8./27., 1./9., 1./9., @@ -219,21 +237,15 @@ public: }; static constexpr std::array opposite_index = { - 0, - 2, - 1, - 4, - 3, - 6, - 5, - 8, - 7 + 0,2,1, + 6,8,7,3,5,4, + 18,20,19,24,26,25,21,23,22,9,11,10,15,17,16,12,14,13 }; static constexpr typename saw::native_data_type::type inv_cs2 = 3.0; static constexpr typename saw::native_data_type::type cs2 = 1./3.; }; -*/ + template class cell_schema_builder { diff --git a/lib/c++/iterator.hpp b/lib/c++/iterator.hpp index 78babff..866543a 100644 --- a/lib/c++/iterator.hpp +++ b/lib/c++/iterator.hpp @@ -14,6 +14,42 @@ void iterate_over(Func&& func, const saw::data>& } return; } + +/** + * + */ +template +struct iterator { +private: + template + static void iterate_over_i(Func& func, + const saw::data>& start, + const saw::data>& end, + const saw::data>& dist, + saw::data>& iter + ){ + static_assert(i <= D, "Eh. Too tired to think of a good message"); + if constexpr ( i == D ){ + func(iter); + }else{ + for(iter.at({i}) = start.at({i})+dist.at({i}); (iter.at({i})+dist.at({i}) < end.at({i})); ++iter.at({i})){ + iterate_over_i(func,start,end,dist,iter); + } + } + } +public: + template + static void apply( + Func&& func, + const saw::data>& start, + const saw::data>& end, + const saw::data>& dist = {} + ){ + saw::data> iter; + iterate_over_i<0u,Func>(func, start, end, dist, iter); + } +}; + /* Ambiguous template void iterate_over(Func&& func, const saw::data>& start, const saw::data>& end, const saw::data>& dist = {{{0u,0u,0u}}}){ -- cgit v1.2.3