diff options
| author | Claudius "keldu" Holeksa <mail@keldu.de> | 2026-05-29 21:56:48 +0200 |
|---|---|---|
| committer | Claudius "keldu" Holeksa <mail@keldu.de> | 2026-05-29 21:56:48 +0200 |
| commit | 2dd7c95a111a930e8e23140ab3fec074e7de4c8c (patch) | |
| tree | 74edc82d6cdad766c31f68d4755a2f49eff4a422 /lib/core/c++/math/round.hpp | |
| parent | 346d979dcdea3e3f37d3ad55680b4f0469d7220c (diff) | |
| download | libs-lbm-2dd7c95a111a930e8e23140ab3fec074e7de4c8c.tar.gz | |
Dangling
Diffstat (limited to 'lib/core/c++/math/round.hpp')
| -rw-r--r-- | lib/core/c++/math/round.hpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/core/c++/math/round.hpp b/lib/core/c++/math/round.hpp new file mode 100644 index 0000000..d3a2586 --- /dev/null +++ b/lib/core/c++/math/round.hpp @@ -0,0 +1,26 @@ +#pragma once + +#include "../common.hpp" + +namespace kel { +namespace lbm { + +template<typename T, uint64_t D> +saw::data<sch::FixedArray<sch::UInt64,D>> round_to_unsigned(const saw::data<sch::Vector<T,D>>& inp){ + saw::data<sch::FixedArray<sch::UInt64,D>> rv; + + auto zero = static_cast<saw::native_data_type<T>::type>(0); + auto half = static_cast<saw::native_data_type<T>::type>(0.5); + + for(uint64_t i{0u}; i < D; ++i){ + auto val = inp.at({{i}}).get()+half; + val = std::max(zero,val); + + rv.at({i}).set(static_cast<uint64_t>(val)); + } + + return rv; +} + +} +} |
