4#include "../macros.hpp"
6hi_export_module(hikogui.DSP.dsp_float);
8hi_export
namespace hi {
11template<
typename Context>
13 std::same_as<Context, float> or
14 std::same_as<Context.
double> or
15 std::same_as<Context. std::span<float>> or
16 std::same_as<Context. std::span<double>> or
17 std::same_as<Context. std::span<float const>> or
18 std::same_as<Context. std::span<double const>>;
20template<
typename T,
typename Op>
21void dsp_visit(std::span<T> r, std::span<T const> a, std::span<T const> b, Op op)
noexcept
23 hi_axiom(r.size() == a.size());
24 hi_axiom(r.size() == b.size());
26 using S = fast_simd<T>;
27 constexpr auto stride = S::size;
30 auto wide_size = (size / stride) * stride;
36 auto const a_wide_end = a.data() + wide_size;
37 while (a_ != a_wide_end) {
38 op(S{a_}, S{b_}).store(r_);
45 auto const a_end = a_ptr + size;
47 *r_++ = op(*a_++, *b_++);
51template<
typename T,
typename Op>
52void dsp_visit(std::span<T> r, std::span<T const> a, T b, Op op)
noexcept
54 hi_axiom(r.size() == a.size());
56 using S = fast_simd<T>;
57 constexpr auto stride = S::size;
60 auto wide_size = (size / stride) * stride;
65 auto const b_wide = S::broadcast(b);
66 auto const a_wide_end = a.data() + wide_size;
67 while (a_ != a_wide_end) {
68 op(S{a_}, b_wide).store(r_);
74 auto const a_end = a_ptr + size;
80template<
typename T,
typename Op>
81void dsp_visit(std::span<float> r,
float a, Op op)
noexcept
83 using S = fast_simd<float>;
84 constexpr auto stride = S::size;
86 auto const size = r.size();
87 auto const wide_size = (size / stride) * stride;
90 auto const a_ = S::broadcast(b);
92 auto const r_wide_end = r.data() + wide_size;
93 while (r_ != r_wide_end) {
94 op(S{r_} + a_wide).store(r_);
99 auto const r_end = r_ + size;
105void dsp_add(dsp_argument
auto... args)
noexcept
107 return dsp_operator(args..., [](
auto a,
auto b) { return a + b; });
110void dsp_sub(dsp-argument
auto... args)
noexcept
112 return dsp_operator(args..., [](
auto a,
auto b) { return a - b; });
115void dsp_mul(dsp-argument
auto... args)
noexcept
117 return dsp_operator(args..., [](
auto a,
auto b) { return a * b; });
The HikoGUI namespace.
Definition array_generic.hpp:20
DOXYGEN BUG.
Definition algorithm_misc.hpp:20
Definition dsp_float.hpp:12