summaryrefslogtreecommitdiff
path: root/lib/core/c++/math
diff options
context:
space:
mode:
authorClaudius "keldu" Holeksa <mail@keldu.de>2026-03-03 15:51:21 +0100
committerClaudius "keldu" Holeksa <mail@keldu.de>2026-03-03 15:51:21 +0100
commitf6d15fa2bd684e8120d8aa88bd01c41bc714f241 (patch)
treec9208f2e566e91294b349ec5808f0f826cfb08ec /lib/core/c++/math
parent67b0a3ee7ba5c5df47bde0700385e43864d210e4 (diff)
parent8be0ee7f948c52c1e71e2437bf6e15800daca47d (diff)
downloadlibs-lbm-f6d15fa2bd684e8120d8aa88bd01c41bc714f241.tar.gz
Merge branch 'dev'
Diffstat (limited to 'lib/core/c++/math')
-rw-r--r--lib/core/c++/math/n_linear.hpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/core/c++/math/n_linear.hpp b/lib/core/c++/math/n_linear.hpp
new file mode 100644
index 0000000..62906cd
--- /dev/null
+++ b/lib/core/c++/math/n_linear.hpp
@@ -0,0 +1,29 @@
+#pragma once
+
+#include "../common.hpp"
+
+namespace kel {
+namespace lbm {
+
+template<typename FieldSchema, typename T, uint64_t D>
+void n_linear_interpolate(const saw::data<FieldSchema>& field, const saw::data<sch::FixedArray<T,D>>& pos){
+
+ auto pos_bound = pos;
+ auto meta = field.dims();
+ saw::data<sch::UInt64> ind;
+ for(saw::data<sch::UInt64> i{0u}; i < saw::data<sch::UInt64>{D}; ++i){
+ pos_bound.at(i).set(
+ std::max(
+ std::min(
+ meta.at(i).template cast_to<T>().get(),
+ pos.at(i).get() + 1.5
+ ),
+ 1,
+ )
+ -1
+ );
+ ind.at(i) = pos_bound.at(i).template cast_to<sch::UInt64>();
+ }
+}
+}
+}