diff options
| author | Claudius "keldu" Holeksa <mail@keldu.de> | 2026-07-06 01:37:34 +0200 |
|---|---|---|
| committer | Claudius "keldu" Holeksa <mail@keldu.de> | 2026-07-06 01:37:34 +0200 |
| commit | af4b3f8f9bf7b19c169d9fbd0a2b49668af8ad10 (patch) | |
| tree | 3e98fff4bad333affa55e082de0da759bad57229 /lib/core/c++/flatten.hpp | |
| parent | 52326efc80dfeae6e830527df2e7803ecf61b00a (diff) | |
| parent | 015e941a91552ce6ea4cde4507ec9451c3708e77 (diff) | |
| download | libs-lbm-af4b3f8f9bf7b19c169d9fbd0a2b49668af8ad10.tar.gz | |
Merge branch 'dev'
Diffstat (limited to 'lib/core/c++/flatten.hpp')
| -rw-r--r-- | lib/core/c++/flatten.hpp | 42 |
1 files changed, 0 insertions, 42 deletions
diff --git a/lib/core/c++/flatten.hpp b/lib/core/c++/flatten.hpp deleted file mode 100644 index 1609589..0000000 --- a/lib/core/c++/flatten.hpp +++ /dev/null @@ -1,42 +0,0 @@ -#pragma once - -#include <forstio/error.hpp> -#include <forstio/codec/data.hpp> - -namespace kel { -namespace lbm { -namespace sch { -using namespace saw::schema; -} - -template<typename T, uint64_t D> -struct flatten_index { -public: - template<uint64_t i> - static constexpr saw::data<sch::UInt64> stride(const saw::data<sch::FixedArray<sch::UInt64,D>>& meta) { - if constexpr (i > 0u){ - return stride<i-1u>(meta) * meta.at({i-1u}); - } - - return 1u; - } -private: - /// 2,3,4 => 2,6,24 - /// i + j * 2 + k * 3*2 - /// 1 + 2 * 2 + 3 * 3*2 = 1+4+18 = 23 - template<uint64_t i> - static void apply_i(saw::data<sch::UInt64>& flat_ind, const saw::data<sch::FixedArray<T,D>>& index, const saw::data<sch::FixedArray<T,D>>& meta){ - if constexpr ( D > i ) { - flat_ind = flat_ind + index.at({i}) * stride<i>(meta); - apply_i<i+1u>(flat_ind,index,meta); - } - } -public: - static saw::data<T> apply(const saw::data<sch::FixedArray<T,D>>& index, const saw::data<sch::FixedArray<T,D>>& meta){ - saw::data<T> flat_ind{0u}; - apply_i<0u>(flat_ind, index, meta); - return flat_ind; - } -}; -} -} |
