From e85b713cf31697a3309e12f30ba5759fee1cd3cc Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Fri, 20 Mar 2026 16:08:25 +0100 Subject: Trying out n linear interpolation --- lib/core/tests/math.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 lib/core/tests/math.cpp (limited to 'lib/core/tests') diff --git a/lib/core/tests/math.cpp b/lib/core/tests/math.cpp new file mode 100644 index 0000000..738d637 --- /dev/null +++ b/lib/core/tests/math.cpp @@ -0,0 +1,20 @@ +#include + +#include "../c++/math/n_linear.hpp" + +namespace { +namespace sch { +using namespace saw::schema; +} + +SAW_TEST("Math 2-Linear"){ + using namespace kel; + + saw::data,32u,32u>> field; + + saw::data> pos; + + SAW_EXPECT(true, "Default true check"); +} + +} -- cgit v1.2.3 From 16c1198f8fb401c3a98d927053fb2d29c2ce5f91 Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Fri, 20 Mar 2026 18:17:55 +0100 Subject: Too much time spent on downcasts, but well. Here I am. --- lib/core/tests/math.cpp | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'lib/core/tests') diff --git a/lib/core/tests/math.cpp b/lib/core/tests/math.cpp index 738d637..7c9dc14 100644 --- a/lib/core/tests/math.cpp +++ b/lib/core/tests/math.cpp @@ -1,5 +1,6 @@ #include +#include #include "../c++/math/n_linear.hpp" namespace { @@ -7,13 +8,34 @@ namespace sch { using namespace saw::schema; } -SAW_TEST("Math 2-Linear"){ +SAW_TEST("Math 1-Linear"){ using namespace kel; + + saw::data,2u>> field; + { + field.at({{0u}}).at({{0u}}).set(-1.0); + field.at({{1u}}).at({{0u}}).set(2.0); + } + saw::data> pos; + pos.at({{0u}}).set(0.3); +} - saw::data,32u,32u>> field; +SAW_TEST("Math/Floor Index from Pos"){ + using namespace kel; saw::data> pos; + { + pos.at({{0u}}) = 43.999; + pos.at({{1u}}) = -50.0; + } + + auto ind = lbm::floor_index_from_position(pos); + for(uint64_t i = 0u; i < 2u; ++i){ + std::cout< Date: Fri, 20 Mar 2026 18:23:39 +0100 Subject: Fraction and downcast looks ok. Need upper bound now --- lib/core/tests/math.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'lib/core/tests') diff --git a/lib/core/tests/math.cpp b/lib/core/tests/math.cpp index 7c9dc14..970004b 100644 --- a/lib/core/tests/math.cpp +++ b/lib/core/tests/math.cpp @@ -30,11 +30,17 @@ SAW_TEST("Math/Floor Index from Pos"){ pos.at({{1u}}) = -50.0; } - auto ind = lbm::floor_index_from_position(pos); + auto ind_frac = lbm::position_to_index_and_fraction(pos); + auto& ind = ind_frac.template get<0u>(); for(uint64_t i = 0u; i < 2u; ++i){ std::cout<(); + for(uint64_t i = 0u; i < 2u; ++i){ + std::cout< Date: Fri, 20 Mar 2026 18:33:31 +0100 Subject: Wanted to finish n linearity today, but I guess I should be happy with this --- lib/core/tests/math.cpp | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'lib/core/tests') diff --git a/lib/core/tests/math.cpp b/lib/core/tests/math.cpp index 970004b..d456ce8 100644 --- a/lib/core/tests/math.cpp +++ b/lib/core/tests/math.cpp @@ -20,7 +20,7 @@ SAW_TEST("Math 1-Linear"){ pos.at({{0u}}).set(0.3); } -SAW_TEST("Math/Floor Index from Pos"){ +SAW_TEST("Math/Floor Index and Fraction from Position"){ using namespace kel; saw::data> pos; @@ -45,4 +45,35 @@ SAW_TEST("Math/Floor Index from Pos"){ SAW_EXPECT(true, "Default true check"); } +SAW_TEST("Math/Floor Index and Fraction from Position and Bounded"){ + using namespace kel; + + saw::data> pos; + + { + pos.at({{0u}}) = 43.999; + pos.at({{1u}}) = -50.0; + } + + saw::data> bound; + { + bound.at({{0u}}) = 32u; + bound.at({{1u}}) = 16u; + } + + auto ind_frac = lbm::position_to_index_and_fraction_bounded(pos,bound); + auto& ind = ind_frac.template get<0u>(); + for(uint64_t i = 0u; i < 2u; ++i){ + std::cout<(); + for(uint64_t i = 0u; i < 2u; ++i){ + std::cout<