kfr

Fast, modern C++ DSP framework, FFT, Sample Rate Conversion, FIR/IIR/Biquad Filters (SSE, AVX, AVX-512, ARM NEON)
Log | Files | Refs | README

commit beb35972bef7c83468209a0f7c854173dc2f230d
parent ad6ead53783f714c528bd7bf7974260251b2585b
Author: d.levin256@gmail.com <d.levin256@gmail.com>
Date:   Wed, 27 Jul 2016 18:45:11 +0300

Move all intrinsics into separate namespace

Diffstat:
Minclude/kfr/base/abs.hpp | 9+++++----
Minclude/kfr/base/asin_acos.hpp | 12++++++------
Minclude/kfr/base/atan.hpp | 20++++++++++----------
Minclude/kfr/base/clamp.hpp | 12++++++------
Minclude/kfr/base/complex.hpp | 69+++++++++++++++++++++++++++++++++++----------------------------------
Minclude/kfr/base/expression.hpp | 8++++----
Minclude/kfr/base/function.hpp | 4++--
Minclude/kfr/base/gamma.hpp | 12++++++------
Minclude/kfr/base/hyperbolic.hpp | 28++++++++++++++--------------
Minclude/kfr/base/log_exp.hpp | 60++++++++++++++++++++++++++++++------------------------------
Minclude/kfr/base/logical.hpp | 9+++++----
Minclude/kfr/base/min_max.hpp | 26+++++++++++++-------------
Minclude/kfr/base/modzerobessel.hpp | 8++++----
Minclude/kfr/base/round.hpp | 40++++++++++++++++++++--------------------
Minclude/kfr/base/saturation.hpp | 14+++++++-------
Minclude/kfr/base/select.hpp | 8++++----
Minclude/kfr/base/sin_cos.hpp | 33+++++++++++++++++----------------
Minclude/kfr/base/sqrt.hpp | 8++++----
Minclude/kfr/base/tan.hpp | 12++++++------
Minclude/kfr/base/types.hpp | 15++++++++++-----
Minclude/kfr/dft/ft.hpp | 6+++---
Minclude/kfr/dsp/fir_design.hpp | 25++++++++++++-------------
Minclude/kfr/dsp/oscillators.hpp | 60++++++++++++++++++++++++++++++------------------------------
Minclude/kfr/dsp/units.hpp | 30+++++++++++++++---------------
Minclude/kfr/expressions/reduce.hpp | 8++++----
25 files changed, 272 insertions(+), 264 deletions(-)

diff --git a/include/kfr/base/abs.hpp b/include/kfr/base/abs.hpp @@ -29,7 +29,7 @@ namespace kfr { -namespace internal +namespace intrinsics { // floating point template <typename T, size_t N, KFR_ENABLE_IF(is_f_class<T>::value)> @@ -72,17 +72,18 @@ KFR_SINTRIN vec<T, N> abs(vec<T, N> x) } #endif KFR_I_CONVERTER(abs) -KFR_I_FN(abs) } +KFR_I_FN(abs) + template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN T1 abs(const T1& x) { - return internal::abs(x); + return intrinsics::abs(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_abs, E1> abs(E1&& x) +KFR_INTRIN expr_func<fn::abs, E1> abs(E1&& x) { return { {}, std::forward<E1>(x) }; } diff --git a/include/kfr/base/asin_acos.hpp b/include/kfr/base/asin_acos.hpp @@ -30,7 +30,7 @@ namespace kfr { -namespace internal +namespace intrinsics { template <typename T, size_t N, typename Tout = flt_type<T>> @@ -48,18 +48,18 @@ KFR_SINTRIN vec<Tout, N> acos(vec<T, N> x) } KFR_I_CONVERTER(asin) KFR_I_CONVERTER(acos) +} KFR_I_FN(asin) KFR_I_FN(acos) -} template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN flt_type<T1> asin(const T1& x) { - return internal::asin(x); + return intrinsics::asin(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_asin, E1> asin(E1&& x) +KFR_INTRIN expr_func<fn::asin, E1> asin(E1&& x) { return { {}, std::forward<E1>(x) }; } @@ -67,11 +67,11 @@ KFR_INTRIN expr_func<internal::fn_asin, E1> asin(E1&& x) template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN flt_type<T1> acos(const T1& x) { - return internal::acos(x); + return intrinsics::acos(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_acos, E1> acos(E1&& x) +KFR_INTRIN expr_func<fn::acos, E1> acos(E1&& x) { return { {}, std::forward<E1>(x) }; } diff --git a/include/kfr/base/atan.hpp b/include/kfr/base/atan.hpp @@ -30,7 +30,7 @@ namespace kfr { -namespace internal +namespace intrinsics { template <size_t N> KFR_SINTRIN vec<f32, N> atan2k(vec<f32, N> y, vec<f32, N> x) @@ -202,20 +202,20 @@ KFR_SINTRIN common_type<T1, T2> atan2deg(const T1& y, const T2& x) KFR_I_CONVERTER(atan) KFR_I_CONVERTER(atan2) +} KFR_I_FN(atan) KFR_I_FN(atandeg) KFR_I_FN(atan2) KFR_I_FN(atan2deg) -} template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN ftype<T1> atan(const T1& x) { - return internal::atan(x); + return intrinsics::atan(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_atan, E1> atan(E1&& x) +KFR_INTRIN expr_func<fn::atan, E1> atan(E1&& x) { return { {}, std::forward<E1>(x) }; } @@ -223,11 +223,11 @@ KFR_INTRIN expr_func<internal::fn_atan, E1> atan(E1&& x) template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN ftype<T1> atandeg(const T1& x) { - return internal::atandeg(x); + return intrinsics::atandeg(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_atandeg, E1> atandeg(E1&& x) +KFR_INTRIN expr_func<fn::atandeg, E1> atandeg(E1&& x) { return { {}, std::forward<E1>(x) }; } @@ -235,11 +235,11 @@ KFR_INTRIN expr_func<internal::fn_atandeg, E1> atandeg(E1&& x) template <typename T1, typename T2, KFR_ENABLE_IF(is_numeric_args<T1, T2>::value)> KFR_INTRIN common_type<T1, T2> atan2(const T1& x, const T2& y) { - return internal::atan2(x, y); + return intrinsics::atan2(x, y); } template <typename E1, typename E2, KFR_ENABLE_IF(is_input_expressions<E1, E2>::value)> -KFR_INTRIN expr_func<internal::fn_atan2, E1, E2> atan2(E1&& x, E2&& y) +KFR_INTRIN expr_func<fn::atan2, E1, E2> atan2(E1&& x, E2&& y) { return { {}, std::forward<E1>(x), std::forward<E2>(y) }; } @@ -247,11 +247,11 @@ KFR_INTRIN expr_func<internal::fn_atan2, E1, E2> atan2(E1&& x, E2&& y) template <typename T1, typename T2, KFR_ENABLE_IF(is_numeric_args<T1, T2>::value)> KFR_INTRIN common_type<T1, T2> atan2deg(const T1& x, const T2& y) { - return internal::atan2deg(x, y); + return intrinsics::atan2deg(x, y); } template <typename E1, typename E2, KFR_ENABLE_IF(is_input_expressions<E1, E2>::value)> -KFR_INTRIN expr_func<internal::fn_atan2deg, E1, E2> atan2deg(E1&& x, E2&& y) +KFR_INTRIN expr_func<fn::atan2deg, E1, E2> atan2deg(E1&& x, E2&& y) { return { {}, std::forward<E1>(x), std::forward<E2>(y) }; } diff --git a/include/kfr/base/clamp.hpp b/include/kfr/base/clamp.hpp @@ -27,7 +27,7 @@ namespace kfr { -namespace internal +namespace intrinsics { template <typename T, size_t N> @@ -42,18 +42,18 @@ KFR_SINTRIN vec<T, N> clamp(vec<T, N> x, vec<T, N> hi) return max(min(x, hi), zerovector<T, N>()); } -KFR_I_FN(clamp) } +KFR_I_FN(clamp) template <typename T1, typename T2, typename T3, KFR_ENABLE_IF(is_numeric_args<T1, T2, T3>::value), typename Tout = common_type<T1, T2, T3>> KFR_INTRIN Tout clamp(const T1& x, const T2& lo, const T3& hi) { - return internal::clamp(static_cast<Tout>(x), static_cast<Tout>(lo), static_cast<Tout>(hi)); + return intrinsics::clamp(static_cast<Tout>(x), static_cast<Tout>(lo), static_cast<Tout>(hi)); } template <typename E1, typename E2, typename E3, KFR_ENABLE_IF(is_input_expressions<E1, E2, E3>::value)> -KFR_INTRIN expr_func<internal::fn_clamp, E1, E2, E3> clamp(E1&& x, E2&& lo, E3&& hi) +KFR_INTRIN expr_func<fn::clamp, E1, E2, E3> clamp(E1&& x, E2&& lo, E3&& hi) { return { {}, std::forward<E1>(x), std::forward<E2>(lo), std::forward<E3>(hi) }; } @@ -62,11 +62,11 @@ template <typename T1, typename T2, KFR_ENABLE_IF(is_numeric_args<T1, T2>::value typename Tout = common_type<T1, T2>> KFR_INTRIN Tout clamp(const T1& x, const T2& hi) { - return internal::clamp(static_cast<Tout>(x), static_cast<Tout>(hi)); + return intrinsics::clamp(static_cast<Tout>(x), static_cast<Tout>(hi)); } template <typename E1, typename E2, KFR_ENABLE_IF(is_input_expressions<E1, E2>::value)> -KFR_INTRIN expr_func<internal::fn_clamp, E1, E2> clamp(E1&& x, E2&& hi) +KFR_INTRIN expr_func<fn::clamp, E1, E2> clamp(E1&& x, E2&& hi) { return { {}, std::forward<E1>(x), std::forward<E2>(hi) }; } diff --git a/include/kfr/base/complex.hpp b/include/kfr/base/complex.hpp @@ -299,7 +299,7 @@ constexpr KFR_INLINE complex<T> make_complex(T1 real, T2 imag = T2(0)) return complex<T>(cast<T>(real), cast<T>(imag)); } -namespace internal +namespace intrinsics { template <typename T, size_t N> @@ -411,13 +411,15 @@ template <typename T1> KFR_SINTRIN realtype<T1> cabs(const T1& a) { using vecout = vec1<T1>; - return to_scalar(internal::cabs(vecout(a))); + return to_scalar(intrinsics::cabs(vecout(a))); } template <typename T1> KFR_SINTRIN realtype<T1> carg(const T1& a) { using vecout = vec1<T1>; - return to_scalar(internal::carg(vecout(a))); + return to_scalar(intrinsics::carg(vecout(a))); +} + } KFR_I_FN(csin) @@ -435,155 +437,154 @@ KFR_I_FN(cexp10) KFR_I_FN(polar) KFR_I_FN(cartesian) KFR_I_FN(csqrt) -} template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN T1 csin(const T1& x) { - return internal::csin(x); + return intrinsics::csin(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_csin, E1> csin(E1&& x) +KFR_INTRIN expr_func<fn::csin, E1> csin(E1&& x) { return { {}, std::forward<E1>(x) }; } template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN T1 csinh(const T1& x) { - return internal::csinh(x); + return intrinsics::csinh(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_csinh, E1> csinh(E1&& x) +KFR_INTRIN expr_func<fn::csinh, E1> csinh(E1&& x) { return { {}, std::forward<E1>(x) }; } template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN T1 ccos(const T1& x) { - return internal::ccos(x); + return intrinsics::ccos(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_ccos, E1> ccos(E1&& x) +KFR_INTRIN expr_func<fn::ccos, E1> ccos(E1&& x) { return { {}, std::forward<E1>(x) }; } template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN T1 ccosh(const T1& x) { - return internal::ccosh(x); + return intrinsics::ccosh(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_ccosh, E1> ccosh(E1&& x) +KFR_INTRIN expr_func<fn::ccosh, E1> ccosh(E1&& x) { return { {}, std::forward<E1>(x) }; } template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN realtype<T1> cabs(const T1& x) { - return internal::cabs(x); + return intrinsics::cabs(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_cabs, E1> cabs(E1&& x) +KFR_INTRIN expr_func<fn::cabs, E1> cabs(E1&& x) { return { {}, std::forward<E1>(x) }; } template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN realtype<T1> carg(const T1& x) { - return internal::carg(x); + return intrinsics::carg(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_carg, E1> carg(E1&& x) +KFR_INTRIN expr_func<fn::carg, E1> carg(E1&& x) { return { {}, std::forward<E1>(x) }; } template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN T1 clog(const T1& x) { - return internal::clog(x); + return intrinsics::clog(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_clog, E1> clog(E1&& x) +KFR_INTRIN expr_func<fn::clog, E1> clog(E1&& x) { return { {}, std::forward<E1>(x) }; } template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN T1 clog2(const T1& x) { - return internal::clog2(x); + return intrinsics::clog2(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_clog2, E1> clog2(E1&& x) +KFR_INTRIN expr_func<fn::clog2, E1> clog2(E1&& x) { return { {}, std::forward<E1>(x) }; } template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN T1 clog10(const T1& x) { - return internal::clog10(x); + return intrinsics::clog10(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_clog10, E1> clog10(E1&& x) +KFR_INTRIN expr_func<fn::clog10, E1> clog10(E1&& x) { return { {}, std::forward<E1>(x) }; } template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN T1 cexp(const T1& x) { - return internal::cexp(x); + return intrinsics::cexp(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_cexp, E1> cexp(E1&& x) +KFR_INTRIN expr_func<fn::cexp, E1> cexp(E1&& x) { return { {}, std::forward<E1>(x) }; } template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN T1 cexp2(const T1& x) { - return internal::cexp2(x); + return intrinsics::cexp2(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_cexp2, E1> cexp2(E1&& x) +KFR_INTRIN expr_func<fn::cexp2, E1> cexp2(E1&& x) { return { {}, std::forward<E1>(x) }; } template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN T1 cexp10(const T1& x) { - return internal::cexp10(x); + return intrinsics::cexp10(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_cexp10, E1> cexp10(E1&& x) +KFR_INTRIN expr_func<fn::cexp10, E1> cexp10(E1&& x) { return { {}, std::forward<E1>(x) }; } template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN T1 polar(const T1& x) { - return internal::polar(x); + return intrinsics::polar(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_polar, E1> polar(E1&& x) +KFR_INTRIN expr_func<fn::polar, E1> polar(E1&& x) { return { {}, std::forward<E1>(x) }; } template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN T1 cartesian(const T1& x) { - return internal::cartesian(x); + return intrinsics::cartesian(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_cartesian, E1> cartesian(E1&& x) +KFR_INTRIN expr_func<fn::cartesian, E1> cartesian(E1&& x) { return { {}, std::forward<E1>(x) }; } template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN T1 csqrt(const T1& x) { - return internal::csqrt(x); + return intrinsics::csqrt(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_csqrt, E1> csqrt(E1&& x) +KFR_INTRIN expr_func<fn::csqrt, E1> csqrt(E1&& x) { return { {}, std::forward<E1>(x) }; } diff --git a/include/kfr/base/expression.hpp b/include/kfr/base/expression.hpp @@ -227,11 +227,11 @@ KFR_INLINE internal::expression_scalar<T, N> scalar(vec<T, N> val) } template <typename Fn, typename... Args> -KFR_INLINE internal::expression_function<decay<Fn>, internal::arg<Args>...> bind_expression(Fn&& fn, - Args&&... args) +KFR_INLINE internal::expression_function<decay<Fn>, internal::arg<Args>...> bind_expression( + Fn&& fn, Args&&... args) { - return internal::expression_function<decay<Fn>, internal::arg<Args>...>(std::forward<Fn>(fn), - std::forward<Args>(args)...); + return internal::expression_function<decay<Fn>, internal::arg<Args>...>( + std::forward<Fn>(fn), std::forward<Args>(args)...); } template <typename Tout, cpu_t c = cpu_t::native, size_t width = 0, typename OutFn, typename Fn> diff --git a/include/kfr/base/function.hpp b/include/kfr/base/function.hpp @@ -38,13 +38,13 @@ namespace kfr KFR_SINTRIN Tout fn(const T1& a, const Args&... b) \ { \ using vecout = vec1<Tout>; \ - return to_scalar(internal::fn(vecout(a), vecout(b)...)); \ + return to_scalar(::kfr::intrinsics::fn(vecout(a), vecout(b)...)); \ } template <typename T> using flt_type = conditional<std::is_floating_point<deep_subtype<T>>::value, T, deep_rebind<T, fbase>>; -namespace internal +namespace intrinsics { #ifdef CID_ARCH_X86 using f32sse = vec<f32, 4>; diff --git a/include/kfr/base/gamma.hpp b/include/kfr/base/gamma.hpp @@ -32,7 +32,7 @@ namespace kfr { -namespace internal +namespace intrinsics { template <typename T> constexpr T gamma_precalc[] = { @@ -60,18 +60,18 @@ KFR_SINTRIN vec<T, N> factorial_approx(vec<T, N> x) } KFR_I_CONVERTER(gamma) KFR_I_CONVERTER(factorial_approx) +} KFR_I_FN(gamma) KFR_I_FN(factorial_approx) -} template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN T1 gamma(const T1& x) { - return internal::gamma(x); + return intrinsics::gamma(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_gamma, E1> gamma(E1&& x) +KFR_INTRIN expr_func<fn::gamma, E1> gamma(E1&& x) { return { {}, std::forward<E1>(x) }; } @@ -79,11 +79,11 @@ KFR_INTRIN expr_func<internal::fn_gamma, E1> gamma(E1&& x) template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN T1 factorial_approx(const T1& x) { - return internal::factorial_approx(x); + return intrinsics::factorial_approx(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_factorial_approx, E1> factorial_approx(E1&& x) +KFR_INTRIN expr_func<fn::factorial_approx, E1> factorial_approx(E1&& x) { return { {}, std::forward<E1>(x) }; } diff --git a/include/kfr/base/hyperbolic.hpp b/include/kfr/base/hyperbolic.hpp @@ -32,7 +32,7 @@ namespace kfr { -namespace internal +namespace intrinsics { template <typename T, size_t N> @@ -83,22 +83,22 @@ KFR_I_CONVERTER(tanh) KFR_I_CONVERTER(coth) KFR_I_CONVERTER(sinhcosh) KFR_I_CONVERTER(coshsinh) +} KFR_I_FN(sinh) KFR_I_FN(cosh) KFR_I_FN(tanh) KFR_I_FN(coth) KFR_I_FN(sinhcosh) KFR_I_FN(coshsinh) -} template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN T1 sinh(const T1& x) { - return internal::sinh(x); + return intrinsics::sinh(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_sinh, E1> sinh(E1&& x) +KFR_INTRIN expr_func<fn::sinh, E1> sinh(E1&& x) { return { {}, std::forward<E1>(x) }; } @@ -106,11 +106,11 @@ KFR_INTRIN expr_func<internal::fn_sinh, E1> sinh(E1&& x) template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN T1 cosh(const T1& x) { - return internal::cosh(x); + return intrinsics::cosh(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_cosh, E1> cosh(E1&& x) +KFR_INTRIN expr_func<fn::cosh, E1> cosh(E1&& x) { return { {}, std::forward<E1>(x) }; } @@ -118,11 +118,11 @@ KFR_INTRIN expr_func<internal::fn_cosh, E1> cosh(E1&& x) template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN T1 tanh(const T1& x) { - return internal::tanh(x); + return intrinsics::tanh(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_tanh, E1> tanh(E1&& x) +KFR_INTRIN expr_func<fn::tanh, E1> tanh(E1&& x) { return { {}, std::forward<E1>(x) }; } @@ -130,11 +130,11 @@ KFR_INTRIN expr_func<internal::fn_tanh, E1> tanh(E1&& x) template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN T1 coth(const T1& x) { - return internal::coth(x); + return intrinsics::coth(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_coth, E1> coth(E1&& x) +KFR_INTRIN expr_func<fn::coth, E1> coth(E1&& x) { return { {}, std::forward<E1>(x) }; } @@ -142,11 +142,11 @@ KFR_INTRIN expr_func<internal::fn_coth, E1> coth(E1&& x) template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN T1 sinhcosh(const T1& x) { - return internal::sinhcosh(x); + return intrinsics::sinhcosh(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_sinhcosh, E1> sinhcosh(E1&& x) +KFR_INTRIN expr_func<fn::sinhcosh, E1> sinhcosh(E1&& x) { return { {}, std::forward<E1>(x) }; } @@ -154,11 +154,11 @@ KFR_INTRIN expr_func<internal::fn_sinhcosh, E1> sinhcosh(E1&& x) template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN T1 coshsinh(const T1& x) { - return internal::coshsinh(x); + return intrinsics::coshsinh(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_coshsinh, E1> coshsinh(E1&& x) +KFR_INTRIN expr_func<fn::coshsinh, E1> coshsinh(E1&& x) { return { {}, std::forward<E1>(x) }; } diff --git a/include/kfr/base/log_exp.hpp b/include/kfr/base/log_exp.hpp @@ -35,7 +35,7 @@ namespace kfr { -namespace internal +namespace intrinsics { template <size_t N> @@ -325,6 +325,7 @@ KFR_I_CONVERTER(pow) KFR_I_CONVERTER(root) KFR_I_CONVERTER(cbrt) +} KFR_I_FN(exp) KFR_I_FN(exp2) KFR_I_FN(exp10) @@ -339,16 +340,15 @@ KFR_I_FN(log_fmadd) KFR_I_FN(pow) KFR_I_FN(root) KFR_I_FN(cbrt) -} template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN T1 exp(const T1& x) { - return internal::exp(x); + return intrinsics::exp(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_exp, E1> exp(E1&& x) +KFR_INTRIN expr_func<fn::exp, E1> exp(E1&& x) { return { {}, std::forward<E1>(x) }; } @@ -356,11 +356,11 @@ KFR_INTRIN expr_func<internal::fn_exp, E1> exp(E1&& x) template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN T1 exp2(const T1& x) { - return internal::exp2(x); + return intrinsics::exp2(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_exp2, E1> exp2(E1&& x) +KFR_INTRIN expr_func<fn::exp2, E1> exp2(E1&& x) { return { {}, std::forward<E1>(x) }; } @@ -368,11 +368,11 @@ KFR_INTRIN expr_func<internal::fn_exp2, E1> exp2(E1&& x) template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN T1 exp10(const T1& x) { - return internal::exp10(x); + return intrinsics::exp10(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_exp10, E1> exp10(E1&& x) +KFR_INTRIN expr_func<fn::exp10, E1> exp10(E1&& x) { return { {}, std::forward<E1>(x) }; } @@ -380,11 +380,11 @@ KFR_INTRIN expr_func<internal::fn_exp10, E1> exp10(E1&& x) template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN T1 log(const T1& x) { - return internal::log(x); + return intrinsics::log(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_log, E1> log(E1&& x) +KFR_INTRIN expr_func<fn::log, E1> log(E1&& x) { return { {}, std::forward<E1>(x) }; } @@ -392,11 +392,11 @@ KFR_INTRIN expr_func<internal::fn_log, E1> log(E1&& x) template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN T1 log2(const T1& x) { - return internal::log2(x); + return intrinsics::log2(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_log2, E1> log2(E1&& x) +KFR_INTRIN expr_func<fn::log2, E1> log2(E1&& x) { return { {}, std::forward<E1>(x) }; } @@ -404,11 +404,11 @@ KFR_INTRIN expr_func<internal::fn_log2, E1> log2(E1&& x) template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN T1 log10(const T1& x) { - return internal::log10(x); + return intrinsics::log10(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_log10, E1> log10(E1&& x) +KFR_INTRIN expr_func<fn::log10, E1> log10(E1&& x) { return { {}, std::forward<E1>(x) }; } @@ -416,11 +416,11 @@ KFR_INTRIN expr_func<internal::fn_log10, E1> log10(E1&& x) template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN T1 logb(const T1& x) { - return internal::logb(x); + return intrinsics::logb(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_logb, E1> logb(E1&& x) +KFR_INTRIN expr_func<fn::logb, E1> logb(E1&& x) { return { {}, std::forward<E1>(x) }; } @@ -428,11 +428,11 @@ KFR_INTRIN expr_func<internal::fn_logb, E1> logb(E1&& x) template <typename T1, typename T2, KFR_ENABLE_IF(is_numeric_args<T1, T2>::value)> KFR_INTRIN common_type<T1, T2> logn(const T1& x, const T2& y) { - return internal::logn(x, y); + return intrinsics::logn(x, y); } template <typename E1, typename E2, KFR_ENABLE_IF(is_input_expressions<E1, E2>::value)> -KFR_INTRIN expr_func<internal::fn_logn, E1, E2> logn(E1&& x, E2&& y) +KFR_INTRIN expr_func<fn::logn, E1, E2> logn(E1&& x, E2&& y) { return { {}, std::forward<E1>(x), std::forward<E2>(y) }; } @@ -440,11 +440,11 @@ KFR_INTRIN expr_func<internal::fn_logn, E1, E2> logn(E1&& x, E2&& y) template <typename T1, typename T2, KFR_ENABLE_IF(is_numeric_args<T1, T2>::value)> KFR_INTRIN common_type<T1, T2> logm(const T1& x, const T2& y) { - return internal::logm(x, y); + return intrinsics::logm(x, y); } template <typename E1, typename E2, KFR_ENABLE_IF(is_input_expressions<E1, E2>::value)> -KFR_INTRIN expr_func<internal::fn_logm, E1, E2> logm(E1&& x, E2&& y) +KFR_INTRIN expr_func<fn::logm, E1, E2> logm(E1&& x, E2&& y) { return { {}, std::forward<E1>(x), std::forward<E2>(y) }; } @@ -452,11 +452,11 @@ KFR_INTRIN expr_func<internal::fn_logm, E1, E2> logm(E1&& x, E2&& y) template <typename T1, typename T2, typename T3, KFR_ENABLE_IF(is_numeric_args<T1, T2, T3>::value)> KFR_INTRIN common_type<T1, T2, T3> exp_fmadd(const T1& x, const T2& y, const T3& z) { - return internal::exp_fmadd(x, y, z); + return intrinsics::exp_fmadd(x, y, z); } template <typename E1, typename E2, typename E3, KFR_ENABLE_IF(is_input_expressions<E1, E2, E3>::value)> -KFR_INTRIN expr_func<internal::fn_exp_fmadd, E1, E2, E3> exp_fmadd(E1&& x, E2&& y, E3&& z) +KFR_INTRIN expr_func<fn::exp_fmadd, E1, E2, E3> exp_fmadd(E1&& x, E2&& y, E3&& z) { return { {}, std::forward<E1>(x), std::forward<E2>(y), std::forward<E3>(z) }; } @@ -464,11 +464,11 @@ KFR_INTRIN expr_func<internal::fn_exp_fmadd, E1, E2, E3> exp_fmadd(E1&& x, E2&& template <typename T1, typename T2, typename T3, KFR_ENABLE_IF(is_numeric_args<T1, T2, T3>::value)> KFR_INTRIN common_type<T1, T2, T3> log_fmadd(const T1& x, const T2& y, const T3& z) { - return internal::log_fmadd(x, y, z); + return intrinsics::log_fmadd(x, y, z); } template <typename E1, typename E2, typename E3, KFR_ENABLE_IF(is_input_expressions<E1, E2, E3>::value)> -KFR_INTRIN expr_func<internal::fn_log_fmadd, E1, E2, E3> log_fmadd(E1&& x, E2&& y, E3&& z) +KFR_INTRIN expr_func<fn::log_fmadd, E1, E2, E3> log_fmadd(E1&& x, E2&& y, E3&& z) { return { {}, std::forward<E1>(x), std::forward<E2>(y), std::forward<E3>(z) }; } @@ -476,11 +476,11 @@ KFR_INTRIN expr_func<internal::fn_log_fmadd, E1, E2, E3> log_fmadd(E1&& x, E2&& template <typename T1, typename T2, KFR_ENABLE_IF(is_numeric_args<T1, T2>::value)> KFR_INTRIN common_type<T1, T2> pow(const T1& x, const T2& y) { - return internal::pow(x, y); + return intrinsics::pow(x, y); } template <typename E1, typename E2, KFR_ENABLE_IF(is_input_expressions<E1, E2>::value)> -KFR_INTRIN expr_func<internal::fn_pow, E1, E2> pow(E1&& x, E2&& y) +KFR_INTRIN expr_func<fn::pow, E1, E2> pow(E1&& x, E2&& y) { return { {}, std::forward<E1>(x), std::forward<E2>(y) }; } @@ -488,11 +488,11 @@ KFR_INTRIN expr_func<internal::fn_pow, E1, E2> pow(E1&& x, E2&& y) template <typename T1, typename T2, KFR_ENABLE_IF(is_numeric_args<T1, T2>::value)> KFR_INTRIN common_type<T1, T2> root(const T1& x, const T2& y) { - return internal::root(x, y); + return intrinsics::root(x, y); } template <typename E1, typename E2, KFR_ENABLE_IF(is_input_expressions<E1, E2>::value)> -KFR_INTRIN expr_func<internal::fn_root, E1, E2> root(E1&& x, E2&& y) +KFR_INTRIN expr_func<fn::root, E1, E2> root(E1&& x, E2&& y) { return { {}, std::forward<E1>(x), std::forward<E2>(y) }; } @@ -500,11 +500,11 @@ KFR_INTRIN expr_func<internal::fn_root, E1, E2> root(E1&& x, E2&& y) template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN T1 cbrt(const T1& x) { - return internal::cbrt(x); + return intrinsics::cbrt(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_cbrt, E1> cbrt(E1&& x) +KFR_INTRIN expr_func<fn::cbrt, E1> cbrt(E1&& x) { return { {}, std::forward<E1>(x) }; } diff --git a/include/kfr/base/logical.hpp b/include/kfr/base/logical.hpp @@ -28,7 +28,7 @@ namespace kfr { -namespace internal +namespace intrinsics { template <size_t bits> @@ -79,7 +79,6 @@ KFR_SINTRIN bool bittestany(f64avx x) { return !_mm256_testz_pd(*x, *x); } KFR_SINTRIN bool bittestnall(f32avx x) { return _mm256_testc_ps(*x, *allonesvector(x)); } KFR_SINTRIN bool bittestnall(f64avx x) { return _mm256_testc_pd(*x, *allonesvector(x)); } -#endif KFR_SINTRIN bool bittestany(u8avx x) { return !_mm256_testz_si256(*x, *x); } KFR_SINTRIN bool bittestany(u16avx x) { return !_mm256_testz_si256(*x, *x); } @@ -99,6 +98,8 @@ KFR_SINTRIN bool bittestall(i16avx x) { return _mm256_testc_si256(*x, *allonesve KFR_SINTRIN bool bittestall(i32avx x) { return _mm256_testc_si256(*x, *allonesvector(x)); } KFR_SINTRIN bool bittestall(i64avx x) { return _mm256_testc_si256(*x, *allonesvector(x)); } +#endif + #if !defined CID_ARCH_SSE41 KFR_SINTRIN bool bittestany(f32sse x) { return _mm_movemask_ps(*x); } @@ -187,13 +188,13 @@ KFR_SINTRIN bool bittestall(vec<T, N> x, vec<T, N> y) template <typename T, size_t N> KFR_SINTRIN bool all(const mask<T, N>& x) { - return internal::bittestall(x.asvec()); + return intrinsics::bittestall(x.asvec()); } /// Returns x[0] || x[1] || ... || x[N-1] template <typename T, size_t N> KFR_SINTRIN bool any(const mask<T, N>& x) { - return internal::bittestany(x.asvec()); + return intrinsics::bittestany(x.asvec()); } } diff --git a/include/kfr/base/min_max.hpp b/include/kfr/base/min_max.hpp @@ -30,7 +30,7 @@ namespace kfr { -namespace internal +namespace intrinsics { #if defined CID_ARCH_SSE2 @@ -151,24 +151,24 @@ KFR_SINTRIN vec<T, N> absmax(vec<T, N> x, vec<T, N> y) } KFR_I_CONVERTER(min) -KFR_I_FN(min) KFR_I_CONVERTER(max) -KFR_I_FN(max) KFR_I_CONVERTER(absmin) -KFR_I_FN(absmin) KFR_I_CONVERTER(absmax) -KFR_I_FN(absmax) } +KFR_I_FN(min) +KFR_I_FN(max) +KFR_I_FN(absmin) +KFR_I_FN(absmax) template <typename T1, typename T2, KFR_ENABLE_IF(is_numeric_args<T1, T2>::value), typename Tout = common_type<T1, T2>> KFR_INTRIN Tout min(const T1& x, const T2& y) { - return internal::min(x, y); + return intrinsics::min(x, y); } template <typename E1, typename E2, KFR_ENABLE_IF(is_input_expressions<E1, E2>::value)> -KFR_INTRIN expr_func<internal::fn_min, E1, E2> min(E1&& x, E2&& y) +KFR_INTRIN expr_func<fn::min, E1, E2> min(E1&& x, E2&& y) { return { {}, std::forward<E1>(x), std::forward<E2>(y) }; } @@ -177,11 +177,11 @@ template <typename T1, typename T2, KFR_ENABLE_IF(is_numeric_args<T1, T2>::value typename Tout = common_type<T1, T2>> KFR_INTRIN Tout max(const T1& x, const T2& y) { - return internal::max(x, y); + return intrinsics::max(x, y); } template <typename E1, typename E2, KFR_ENABLE_IF(is_input_expressions<E1, E2>::value)> -KFR_INTRIN expr_func<internal::fn_max, E1, E2> max(E1&& x, E2&& y) +KFR_INTRIN expr_func<fn::max, E1, E2> max(E1&& x, E2&& y) { return { {}, std::forward<E1>(x), std::forward<E2>(y) }; } @@ -190,11 +190,11 @@ template <typename T1, typename T2, KFR_ENABLE_IF(is_numeric_args<T1, T2>::value typename Tout = common_type<T1, T2>> KFR_INTRIN Tout absmin(const T1& x, const T2& y) { - return internal::absmin(x, y); + return intrinsics::absmin(x, y); } template <typename E1, typename E2, KFR_ENABLE_IF(is_input_expressions<E1, E2>::value)> -KFR_INTRIN expr_func<internal::fn_absmin, E1, E2> absmin(E1&& x, E2&& y) +KFR_INTRIN expr_func<fn::absmin, E1, E2> absmin(E1&& x, E2&& y) { return { {}, std::forward<E1>(x), std::forward<E2>(y) }; } @@ -203,11 +203,11 @@ template <typename T1, typename T2, KFR_ENABLE_IF(is_numeric_args<T1, T2>::value typename Tout = common_type<T1, T2>> KFR_INTRIN Tout absmax(const T1& x, const T2& y) { - return internal::absmax(x, y); + return intrinsics::absmax(x, y); } template <typename E1, typename E2, KFR_ENABLE_IF(is_input_expressions<E1, E2>::value)> -KFR_INTRIN expr_func<internal::fn_absmax, E1, E2> absmax(E1&& x, E2&& y) +KFR_INTRIN expr_func<fn::absmax, E1, E2> absmax(E1&& x, E2&& y) { return { {}, std::forward<E1>(x), std::forward<E2>(y) }; } diff --git a/include/kfr/base/modzerobessel.hpp b/include/kfr/base/modzerobessel.hpp @@ -32,7 +32,7 @@ namespace kfr { -namespace internal +namespace intrinsics { template <typename T> @@ -94,17 +94,17 @@ KFR_INLINE vec<T, N> modzerobessel(vec<T, N> x) } KFR_I_CONVERTER(modzerobessel) -KFR_I_FN(modzerobessel) } +KFR_I_FN(modzerobessel) template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN T1 modzerobessel(const T1& x) { - return internal::modzerobessel(x); + return intrinsics::modzerobessel(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_modzerobessel, E1> modzerobessel(E1&& x) +KFR_INTRIN expr_func<fn::modzerobessel, E1> modzerobessel(E1&& x) { return { {}, std::forward<E1>(x) }; } diff --git a/include/kfr/base/round.hpp b/include/kfr/base/round.hpp @@ -28,7 +28,7 @@ namespace kfr { -namespace internal +namespace intrinsics { #define KFR_mm_trunc_ps(V) _mm_round_ps((V), _MM_FROUND_TRUNC) @@ -200,6 +200,7 @@ KFR_I_CONVERTER(ifloor) KFR_I_CONVERTER(iceil) KFR_I_CONVERTER(iround) KFR_I_CONVERTER(itrunc) +} KFR_I_FN(floor) KFR_I_FN(ceil) KFR_I_FN(round) @@ -209,16 +210,15 @@ KFR_I_FN(ifloor) KFR_I_FN(iceil) KFR_I_FN(iround) KFR_I_FN(itrunc) -} template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN T1 floor(const T1& x) { - return internal::floor(x); + return intrinsics::floor(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_floor, E1> floor(E1&& x) +KFR_INTRIN expr_func<fn::floor, E1> floor(E1&& x) { return { {}, std::forward<E1>(x) }; } @@ -226,11 +226,11 @@ KFR_INTRIN expr_func<internal::fn_floor, E1> floor(E1&& x) template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN T1 ceil(const T1& x) { - return internal::ceil(x); + return intrinsics::ceil(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_ceil, E1> ceil(E1&& x) +KFR_INTRIN expr_func<fn::ceil, E1> ceil(E1&& x) { return { {}, std::forward<E1>(x) }; } @@ -238,11 +238,11 @@ KFR_INTRIN expr_func<internal::fn_ceil, E1> ceil(E1&& x) template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN T1 round(const T1& x) { - return internal::round(x); + return intrinsics::round(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_round, E1> round(E1&& x) +KFR_INTRIN expr_func<fn::round, E1> round(E1&& x) { return { {}, std::forward<E1>(x) }; } @@ -250,11 +250,11 @@ KFR_INTRIN expr_func<internal::fn_round, E1> round(E1&& x) template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN T1 trunc(const T1& x) { - return internal::trunc(x); + return intrinsics::trunc(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_trunc, E1> trunc(E1&& x) +KFR_INTRIN expr_func<fn::trunc, E1> trunc(E1&& x) { return { {}, std::forward<E1>(x) }; } @@ -262,11 +262,11 @@ KFR_INTRIN expr_func<internal::fn_trunc, E1> trunc(E1&& x) template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN T1 fract(const T1& x) { - return internal::fract(x); + return intrinsics::fract(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_fract, E1> fract(E1&& x) +KFR_INTRIN expr_func<fn::fract, E1> fract(E1&& x) { return { {}, std::forward<E1>(x) }; } @@ -274,11 +274,11 @@ KFR_INTRIN expr_func<internal::fn_fract, E1> fract(E1&& x) template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN itype<T1> ifloor(const T1& x) { - return internal::ifloor(x); + return intrinsics::ifloor(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_ifloor, E1> ifloor(E1&& x) +KFR_INTRIN expr_func<fn::ifloor, E1> ifloor(E1&& x) { return { {}, std::forward<E1>(x) }; } @@ -286,11 +286,11 @@ KFR_INTRIN expr_func<internal::fn_ifloor, E1> ifloor(E1&& x) template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN itype<T1> iceil(const T1& x) { - return internal::iceil(x); + return intrinsics::iceil(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_iceil, E1> iceil(E1&& x) +KFR_INTRIN expr_func<fn::iceil, E1> iceil(E1&& x) { return { {}, std::forward<E1>(x) }; } @@ -298,11 +298,11 @@ KFR_INTRIN expr_func<internal::fn_iceil, E1> iceil(E1&& x) template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN itype<T1> iround(const T1& x) { - return internal::iround(x); + return intrinsics::iround(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_iround, E1> iround(E1&& x) +KFR_INTRIN expr_func<fn::iround, E1> iround(E1&& x) { return { {}, std::forward<E1>(x) }; } @@ -310,11 +310,11 @@ KFR_INTRIN expr_func<internal::fn_iround, E1> iround(E1&& x) template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN itype<T1> itrunc(const T1& x) { - return internal::itrunc(x); + return intrinsics::itrunc(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_itrunc, E1> itrunc(E1&& x) +KFR_INTRIN expr_func<fn::itrunc, E1> itrunc(E1&& x) { return { {}, std::forward<E1>(x) }; } diff --git a/include/kfr/base/saturation.hpp b/include/kfr/base/saturation.hpp @@ -28,7 +28,7 @@ namespace kfr { -namespace internal +namespace intrinsics { template <typename T, size_t N> KFR_SINTRIN vec<T, N> saturated_signed_add(vec<T, N> a, vec<T, N> b) @@ -127,20 +127,20 @@ KFR_SINTRIN vec<T, N> satsub(vec<T, N> a, vec<T, N> b) } #endif KFR_I_CONVERTER(satadd) -KFR_I_FN(satadd) KFR_I_CONVERTER(satsub) -KFR_I_FN(satsub) } +KFR_I_FN(satadd) +KFR_I_FN(satsub) template <typename T1, typename T2, KFR_ENABLE_IF(is_numeric_args<T1, T2>::value), typename Tout = common_type<T1, T2>> KFR_INTRIN Tout satadd(const T1& x, const T2& y) { - return internal::satadd(x, y); + return intrinsics::satadd(x, y); } template <typename E1, typename E2, KFR_ENABLE_IF(is_input_expressions<E1, E2>::value)> -KFR_INTRIN expr_func<internal::fn_satadd, E1, E2> satadd(E1&& x, E2&& y) +KFR_INTRIN expr_func<fn::satadd, E1, E2> satadd(E1&& x, E2&& y) { return { {}, std::forward<E1>(x), std::forward<E2>(y) }; } @@ -149,11 +149,11 @@ template <typename T1, typename T2, KFR_ENABLE_IF(is_numeric_args<T1, T2>::value typename Tout = common_type<T1, T2>> KFR_INTRIN Tout satsub(const T1& x, const T2& y) { - return internal::satsub(x, y); + return intrinsics::satsub(x, y); } template <typename E1, typename E2, KFR_ENABLE_IF(is_input_expressions<E1, E2>::value)> -KFR_INTRIN expr_func<internal::fn_satsub, E1, E2> satsub(E1&& x, E2&& y) +KFR_INTRIN expr_func<fn::satsub, E1, E2> satsub(E1&& x, E2&& y) { return { {}, std::forward<E1>(x), std::forward<E2>(y) }; } diff --git a/include/kfr/base/select.hpp b/include/kfr/base/select.hpp @@ -26,7 +26,7 @@ namespace kfr { -namespace internal +namespace intrinsics { #if defined CID_ARCH_SSE41 @@ -79,20 +79,20 @@ KFR_SINTRIN vec<T, N> select(mask<T, N> m, vec<T, N> x, vec<T, N> y) } #endif -KFR_I_FN(select) } +KFR_I_FN(select) template <typename T1, size_t N, typename T2, typename T3, KFR_ENABLE_IF(is_numeric_args<T1, T2, T3>::value), typename Tout = subtype<common_type<T2, T3>>> KFR_INTRIN vec<Tout, N> select(const mask<T1, N>& m, const T2& x, const T3& y) { static_assert(sizeof(T1) == sizeof(Tout), "select: incompatible types"); - return internal::select(bitcast<Tout>(m).asmask(), static_cast<vec<Tout, N>>(x), + return intrinsics::select(bitcast<Tout>(m).asmask(), static_cast<vec<Tout, N>>(x), static_cast<vec<Tout, N>>(y)); } template <typename E1, typename E2, typename E3, KFR_ENABLE_IF(is_input_expressions<E1, E2, E3>::value)> -KFR_INTRIN expr_func<internal::fn_select, E1, E2, E3> select(E1&& m, E2&& x, E3&& y) +KFR_INTRIN expr_func<fn::select, E1, E2, E3> select(E1&& m, E2&& x, E3&& y) { return { {}, std::forward<E1>(m), std::forward<E2>(x), std::forward<E3>(y) }; } diff --git a/include/kfr/base/sin_cos.hpp b/include/kfr/base/sin_cos.hpp @@ -38,7 +38,7 @@ namespace kfr { -namespace internal +namespace intrinsics { template <typename T> @@ -323,6 +323,8 @@ KFR_I_CONVERTER(sincos) KFR_I_CONVERTER(cossin) KFR_I_CONVERTER(sinc) +} + KFR_I_FN(sin) KFR_I_FN(cos) KFR_I_FN(fastsin) @@ -330,16 +332,15 @@ KFR_I_FN(fastcos) KFR_I_FN(sincos) KFR_I_FN(cossin) KFR_I_FN(sinc) -} template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN ftype<T1> sin(const T1& x) { - return internal::sin(x); + return intrinsics::sin(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_sin, E1> sin(E1&& x) +KFR_INTRIN expr_func<fn::sin, E1> sin(E1&& x) { return { {}, std::forward<E1>(x) }; } @@ -347,11 +348,11 @@ KFR_INTRIN expr_func<internal::fn_sin, E1> sin(E1&& x) template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN ftype<T1> cos(const T1& x) { - return internal::cos(x); + return intrinsics::cos(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_cos, E1> cos(E1&& x) +KFR_INTRIN expr_func<fn::cos, E1> cos(E1&& x) { return { {}, std::forward<E1>(x) }; } @@ -359,11 +360,11 @@ KFR_INTRIN expr_func<internal::fn_cos, E1> cos(E1&& x) template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN ftype<T1> fastsin(const T1& x) { - return internal::fastsin(x); + return intrinsics::fastsin(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_fastsin, E1> fastsin(E1&& x) +KFR_INTRIN expr_func<fn::fastsin, E1> fastsin(E1&& x) { return { {}, std::forward<E1>(x) }; } @@ -371,11 +372,11 @@ KFR_INTRIN expr_func<internal::fn_fastsin, E1> fastsin(E1&& x) template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN ftype<T1> fastcos(const T1& x) { - return internal::fastcos(x); + return intrinsics::fastcos(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_fastcos, E1> fastcos(E1&& x) +KFR_INTRIN expr_func<fn::fastcos, E1> fastcos(E1&& x) { return { {}, std::forward<E1>(x) }; } @@ -383,11 +384,11 @@ KFR_INTRIN expr_func<internal::fn_fastcos, E1> fastcos(E1&& x) template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN ftype<T1> sincos(const T1& x) { - return internal::sincos(x); + return intrinsics::sincos(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_sincos, E1> sincos(E1&& x) +KFR_INTRIN expr_func<fn::sincos, E1> sincos(E1&& x) { return { {}, std::forward<E1>(x) }; } @@ -395,11 +396,11 @@ KFR_INTRIN expr_func<internal::fn_sincos, E1> sincos(E1&& x) template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN ftype<T1> cossin(const T1& x) { - return internal::cossin(x); + return intrinsics::cossin(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_cossin, E1> cossin(E1&& x) +KFR_INTRIN expr_func<fn::cossin, E1> cossin(E1&& x) { return { {}, std::forward<E1>(x) }; } @@ -407,11 +408,11 @@ KFR_INTRIN expr_func<internal::fn_cossin, E1> cossin(E1&& x) template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN ftype<T1> sinc(const T1& x) { - return internal::sinc(x); + return intrinsics::sinc(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_sinc, E1> sinc(E1&& x) +KFR_INTRIN expr_func<fn::sinc, E1> sinc(E1&& x) { return { {}, std::forward<E1>(x) }; } diff --git a/include/kfr/base/sqrt.hpp b/include/kfr/base/sqrt.hpp @@ -27,7 +27,7 @@ namespace kfr { -namespace internal +namespace intrinsics { #if defined CID_ARCH_SSE2 @@ -54,17 +54,17 @@ KFR_SINTRIN vec<Tout, N> sqrt(vec<T, N> x) } #endif KFR_I_CONVERTER(sqrt) -KFR_I_FN(sqrt) } +KFR_I_FN(sqrt) template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN flt_type<T1> sqrt(const T1& x) { - return internal::sqrt(x); + return intrinsics::sqrt(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_sqrt, E1> sqrt(E1&& x) +KFR_INTRIN expr_func<fn::sqrt, E1> sqrt(E1&& x) { return { {}, std::forward<E1>(x) }; } diff --git a/include/kfr/base/tan.hpp b/include/kfr/base/tan.hpp @@ -31,7 +31,7 @@ namespace kfr { -namespace internal +namespace intrinsics { template <typename T, size_t N, typename IT = itype<T>> @@ -126,18 +126,18 @@ KFR_SINTRIN T tandeg(const T& x) } KFR_I_CONVERTER(tan) +} KFR_I_FN(tan) KFR_I_FN(tandeg) -} template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN T1 tan(const T1& x) { - return internal::tan(x); + return intrinsics::tan(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_tan, E1> tan(E1&& x) +KFR_INTRIN expr_func<fn::tan, E1> tan(E1&& x) { return { {}, std::forward<E1>(x) }; } @@ -145,11 +145,11 @@ KFR_INTRIN expr_func<internal::fn_tan, E1> tan(E1&& x) template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN T1 tandeg(const T1& x) { - return internal::tandeg(x); + return intrinsics::tandeg(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_tandeg, E1> tandeg(E1&& x) +KFR_INTRIN expr_func<fn::tandeg, E1> tandeg(E1&& x) { return { {}, std::forward<E1>(x) }; } diff --git a/include/kfr/base/types.hpp b/include/kfr/base/types.hpp @@ -47,15 +47,19 @@ } \ }; -#define KFR_I_FN(fn) \ - struct fn_##fn \ +#define KFR_I_FN(FN) \ + namespace fn \ + { \ + struct FN \ { \ template <typename... Args> \ - CID_INLINE_MEMBER decltype(internal::fn(std::declval<Args>()...)) operator()(Args&&... args) const \ + CID_INLINE_MEMBER decltype(::kfr::intrinsics::FN(std::declval<Args>()...)) operator()( \ + Args&&... args) const \ { \ - return internal::fn(std::forward<Args>(args)...); \ + return ::kfr::intrinsics::FN(std::forward<Args>(args)...); \ } \ - }; + }; \ + } #define KFR_FNR(fn, in, out) \ struct fn_##fn \ @@ -390,6 +394,7 @@ using is_i_class = std::integral_constant<bool, typeclass<T> == datatype::i>; template <typename T> struct typebits { + static_assert(is_number<deep_subtype<T>>::value, ""); constexpr static size_t bits = sizeof(typename compound_type_traits<T>::subtype) * 8; constexpr static size_t width = compound_type_traits<T>::is_scalar ? 0 : compound_type_traits<T>::width; using subtype = typename compound_type_traits<T>::subtype; diff --git a/include/kfr/dft/ft.hpp b/include/kfr/dft/ft.hpp @@ -67,7 +67,7 @@ KFR_INLINE vec<T, std::max(N1, N2)> cmul(vec<T, N1> x, vec<T, N2> y) { return internal::cmul_impl(x, y); } -KFR_I_FN(cmul) +KFR_FN(cmul) template <typename T, size_t N, KFR_ENABLE_IF(N >= 2)> KFR_INLINE vec<T, N> cmul_conj(vec<T, N> x, vec<T, N> y) @@ -103,8 +103,8 @@ KFR_INLINE vec<T, N> cmul_conj(vec<T, 2> x, vec<T, N> y) vec<T, N> xx = resize<N>(x); return cmul_conj(xx, y); } -KFR_I_FN(cmul_conj) -KFR_I_FN(cmul_2conj) +KFR_FN(cmul_conj) +KFR_FN(cmul_2conj) template <size_t N, bool A = false, typename T> KFR_INLINE cvec<T, N> cread(const complex<T>* src) diff --git a/include/kfr/dsp/fir_design.hpp b/include/kfr/dsp/fir_design.hpp @@ -27,14 +27,14 @@ namespace kfr { -namespace internal +namespace intrinsics { template <typename T> KFR_SINTRIN void fir_lowpass(univector_ref<T> taps, T cutoff, const expression_pointer<T>& window, bool normalize = true) { const T scale = 2.0 * cutoff; - taps = bind_expression(fn_sinc(), + taps = bind_expression(fn::sinc(), symmlinspace<T, true>((taps.size() - 1) * cutoff * c_pi<T>, taps.size(), true)) * scale * window; @@ -52,7 +52,7 @@ KFR_SINTRIN void fir_highpass(univector_ref<T> taps, T cutoff, const expression_ bool normalize = true) { const T scale = 2.0 * -cutoff; - taps = bind_expression(fn_sinc(), + taps = bind_expression(fn::sinc(), symmlinspace<T, true>((taps.size() - 1) * cutoff * c_pi<T>, taps.size(), true)) * scale * window; @@ -76,8 +76,8 @@ KFR_SINTRIN void fir_bandpass(univector_ref<T> taps, T frequency1, T frequency2, const T start1 = sc * frequency1; const T start2 = sc * frequency2; - taps = (bind_expression(fn_sinc(), symmlinspace<T, true>(start2, taps.size(), true)) * scale2 - - bind_expression(fn_sinc(), symmlinspace<T, true>(start1, taps.size(), true)) * scale1) * + taps = (bind_expression(fn::sinc(), symmlinspace<T, true>(start2, taps.size(), true)) * scale2 - + bind_expression(fn::sinc(), symmlinspace<T, true>(start1, taps.size(), true)) * scale1) * window; if (is_odd(taps.size())) @@ -100,8 +100,8 @@ KFR_SINTRIN void fir_bandstop(univector_ref<T> taps, T frequency1, T frequency2, const T start1 = sc * frequency1; const T start2 = sc * frequency2; - taps = (bind_expression(fn_sinc(), symmlinspace<T, true>(start1, taps.size(), true)) * scale1 - - bind_expression(fn_sinc(), symmlinspace<T, true>(start2, taps.size(), true)) * scale2) * + taps = (bind_expression(fn::sinc(), symmlinspace<T, true>(start1, taps.size(), true)) * scale1 - + bind_expression(fn::sinc(), symmlinspace<T, true>(start2, taps.size(), true)) * scale2) * window; if (is_odd(taps.size())) @@ -113,35 +113,34 @@ KFR_SINTRIN void fir_bandstop(univector_ref<T> taps, T frequency1, T frequency2, taps = taps * invsum; } } - +} KFR_I_FN(fir_lowpass) KFR_I_FN(fir_highpass) KFR_I_FN(fir_bandpass) KFR_I_FN(fir_bandstop) -} template <typename T, size_t Tag> KFR_INLINE void fir_lowpass(univector<T, Tag>& taps, identity<T> cutoff, const expression_pointer<T>& window, bool normalize = true) { - return internal::fir_lowpass(taps.slice(), cutoff, window, normalize); + return intrinsics::fir_lowpass(taps.slice(), cutoff, window, normalize); } template <typename T, size_t Tag> KFR_INLINE void fir_highpass(univector<T, Tag>& taps, identity<T> cutoff, const expression_pointer<T>& window, bool normalize = true) { - return internal::fir_highpass(taps.slice(), cutoff, window, normalize); + return intrinsics::fir_highpass(taps.slice(), cutoff, window, normalize); } template <typename T, size_t Tag> KFR_INLINE void fir_bandpass(univector<T, Tag>& taps, identity<T> frequency1, identity<T> frequency2, const expression_pointer<T>& window, bool normalize = true) { - return internal::fir_bandpass(taps.slice(), frequency1, frequency2, window, normalize); + return intrinsics::fir_bandpass(taps.slice(), frequency1, frequency2, window, normalize); } template <typename T, size_t Tag> KFR_INLINE void fir_bandstop(univector<T, Tag>& taps, identity<T> frequency1, identity<T> frequency2, const expression_pointer<T>& window, bool normalize = true) { - return internal::fir_bandstop(taps.slice(), frequency1, frequency2, window, normalize); + return intrinsics::fir_bandstop(taps.slice(), frequency1, frequency2, window, normalize); } } diff --git a/include/kfr/dsp/oscillators.hpp b/include/kfr/dsp/oscillators.hpp @@ -42,7 +42,7 @@ auto swept(T magn, size_t size) size); } -namespace internal +namespace intrinsics { template <typename T> KFR_SINTRIN T rawsine(T x) @@ -119,6 +119,7 @@ KFR_SINTRIN T triangle(T x) return trianglenorm(c_recip_pi<T, 1, 2> * x); } +} KFR_I_FN(rawsine) KFR_I_FN(sine) KFR_I_FN(sinenorm) @@ -133,145 +134,144 @@ KFR_I_FN(sawtooth) KFR_I_FN(sawtoothnorm) KFR_I_FN(isawtooth) KFR_I_FN(isawtoothnorm) -} template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN T1 rawsine(const T1& x) { - return internal::rawsine(x); + return intrinsics::rawsine(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_rawsine, E1> rawsine(E1&& x) +KFR_INTRIN expr_func<fn::rawsine, E1> rawsine(E1&& x) { return { {}, std::forward<E1>(x) }; } template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN T1 sine(const T1& x) { - return internal::sine(x); + return intrinsics::sine(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_sine, E1> sine(E1&& x) +KFR_INTRIN expr_func<fn::sine, E1> sine(E1&& x) { return { {}, std::forward<E1>(x) }; } template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN T1 sinenorm(const T1& x) { - return internal::sinenorm(x); + return intrinsics::sinenorm(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_sinenorm, E1> sinenorm(E1&& x) +KFR_INTRIN expr_func<fn::sinenorm, E1> sinenorm(E1&& x) { return { {}, std::forward<E1>(x) }; } template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN T1 rawsquare(const T1& x) { - return internal::rawsquare(x); + return intrinsics::rawsquare(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_rawsquare, E1> rawsquare(E1&& x) +KFR_INTRIN expr_func<fn::rawsquare, E1> rawsquare(E1&& x) { return { {}, std::forward<E1>(x) }; } template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN T1 square(const T1& x) { - return internal::square(x); + return intrinsics::square(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_square, E1> square(E1&& x) +KFR_INTRIN expr_func<fn::square, E1> square(E1&& x) { return { {}, std::forward<E1>(x) }; } template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN T1 squarenorm(const T1& x) { - return internal::squarenorm(x); + return intrinsics::squarenorm(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_squarenorm, E1> squarenorm(E1&& x) +KFR_INTRIN expr_func<fn::squarenorm, E1> squarenorm(E1&& x) { return { {}, std::forward<E1>(x) }; } template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN T1 rawtriangle(const T1& x) { - return internal::rawtriangle(x); + return intrinsics::rawtriangle(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_rawtriangle, E1> rawtriangle(E1&& x) +KFR_INTRIN expr_func<fn::rawtriangle, E1> rawtriangle(E1&& x) { return { {}, std::forward<E1>(x) }; } template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN T1 triangle(const T1& x) { - return internal::triangle(x); + return intrinsics::triangle(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_triangle, E1> triangle(E1&& x) +KFR_INTRIN expr_func<fn::triangle, E1> triangle(E1&& x) { return { {}, std::forward<E1>(x) }; } template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN T1 trianglenorm(const T1& x) { - return internal::trianglenorm(x); + return intrinsics::trianglenorm(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_trianglenorm, E1> trianglenorm(E1&& x) +KFR_INTRIN expr_func<fn::trianglenorm, E1> trianglenorm(E1&& x) { return { {}, std::forward<E1>(x) }; } template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN T1 rawsawtooth(const T1& x) { - return internal::rawsawtooth(x); + return intrinsics::rawsawtooth(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_rawsawtooth, E1> rawsawtooth(E1&& x) +KFR_INTRIN expr_func<fn::rawsawtooth, E1> rawsawtooth(E1&& x) { return { {}, std::forward<E1>(x) }; } template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN T1 sawtooth(const T1& x) { - return internal::sawtooth(x); + return intrinsics::sawtooth(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_sawtooth, E1> sawtooth(E1&& x) +KFR_INTRIN expr_func<fn::sawtooth, E1> sawtooth(E1&& x) { return { {}, std::forward<E1>(x) }; } template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN T1 sawtoothnorm(const T1& x) { - return internal::sawtoothnorm(x); + return intrinsics::sawtoothnorm(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_sawtoothnorm, E1> sawtoothnorm(E1&& x) +KFR_INTRIN expr_func<fn::sawtoothnorm, E1> sawtoothnorm(E1&& x) { return { {}, std::forward<E1>(x) }; } template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN T1 isawtooth(const T1& x) { - return internal::isawtooth(x); + return intrinsics::isawtooth(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_isawtooth, E1> isawtooth(E1&& x) +KFR_INTRIN expr_func<fn::isawtooth, E1> isawtooth(E1&& x) { return { {}, std::forward<E1>(x) }; } template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN T1 isawtoothnorm(const T1& x) { - return internal::isawtoothnorm(x); + return intrinsics::isawtoothnorm(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_isawtoothnorm, E1> isawtoothnorm(E1&& x) +KFR_INTRIN expr_func<fn::isawtoothnorm, E1> isawtoothnorm(E1&& x) { return { {}, std::forward<E1>(x) }; } diff --git a/include/kfr/dsp/units.hpp b/include/kfr/dsp/units.hpp @@ -36,7 +36,7 @@ namespace kfr using sample_rate_t = double; -namespace internal +namespace intrinsics { template <typename T, typename TF = ftype<T>> KFR_SINTRIN TF amp_to_dB(T amp) @@ -53,7 +53,7 @@ KFR_SINTRIN TF dB_to_amp(T dB) } template <typename T, typename TF = ftype<T>> -KFR_SINTRIN TF amp_to_dB2(T amp, T offset) +KFR_SINTRIN TF amp_to_dB(T amp, T offset) { return log_fmadd(amp, subtype<TF>(8.6858896380650365530225783783322), offset); // return T( 20.0 ) * log10( level ); @@ -114,22 +114,22 @@ KFR_SINTRIN Tc hertz_to_note(T1 hertz, T2 tunenote, T3 tunehertz) return log_fmadd(hertz, subtype<Tc>(17.312340490667560888319096172023), offset); } +} KFR_I_FN(note_to_hertz) KFR_I_FN(hertz_to_note) KFR_I_FN(amp_to_dB) KFR_I_FN(dB_to_amp) KFR_I_FN(power_to_dB) KFR_I_FN(dB_to_power) -} template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN T1 note_to_hertz(const T1& x) { - return internal::note_to_hertz(x); + return intrinsics::note_to_hertz(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_note_to_hertz, E1> note_to_hertz(E1&& x) +KFR_INTRIN expr_func<fn::note_to_hertz, E1> note_to_hertz(E1&& x) { return { {}, std::forward<E1>(x) }; } @@ -137,11 +137,11 @@ KFR_INTRIN expr_func<internal::fn_note_to_hertz, E1> note_to_hertz(E1&& x) template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN T1 hertz_to_note(const T1& x) { - return internal::hertz_to_note(x); + return intrinsics::hertz_to_note(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_hertz_to_note, E1> hertz_to_note(E1&& x) +KFR_INTRIN expr_func<fn::hertz_to_note, E1> hertz_to_note(E1&& x) { return { {}, std::forward<E1>(x) }; } @@ -149,11 +149,11 @@ KFR_INTRIN expr_func<internal::fn_hertz_to_note, E1> hertz_to_note(E1&& x) template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN T1 amp_to_dB(const T1& x) { - return internal::amp_to_dB(x); + return intrinsics::amp_to_dB(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_amp_to_dB, E1> amp_to_dB(E1&& x) +KFR_INTRIN expr_func<fn::amp_to_dB, E1> amp_to_dB(E1&& x) { return { {}, std::forward<E1>(x) }; } @@ -161,11 +161,11 @@ KFR_INTRIN expr_func<internal::fn_amp_to_dB, E1> amp_to_dB(E1&& x) template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN T1 dB_to_amp(const T1& x) { - return internal::dB_to_amp(x); + return intrinsics::dB_to_amp(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_dB_to_amp, E1> dB_to_amp(E1&& x) +KFR_INTRIN expr_func<fn::dB_to_amp, E1> dB_to_amp(E1&& x) { return { {}, std::forward<E1>(x) }; } @@ -173,11 +173,11 @@ KFR_INTRIN expr_func<internal::fn_dB_to_amp, E1> dB_to_amp(E1&& x) template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN T1 power_to_dB(const T1& x) { - return internal::power_to_dB(x); + return intrinsics::power_to_dB(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_power_to_dB, E1> power_to_dB(E1&& x) +KFR_INTRIN expr_func<fn::power_to_dB, E1> power_to_dB(E1&& x) { return { {}, std::forward<E1>(x) }; } @@ -185,11 +185,11 @@ KFR_INTRIN expr_func<internal::fn_power_to_dB, E1> power_to_dB(E1&& x) template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)> KFR_INTRIN T1 dB_to_power(const T1& x) { - return internal::dB_to_power(x); + return intrinsics::dB_to_power(x); } template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)> -KFR_INTRIN expr_func<internal::fn_dB_to_power, E1> dB_to_power(E1&& x) +KFR_INTRIN expr_func<fn::dB_to_power, E1> dB_to_power(E1&& x) { return { {}, std::forward<E1>(x) }; } diff --git a/include/kfr/expressions/reduce.hpp b/include/kfr/expressions/reduce.hpp @@ -142,7 +142,7 @@ KFR_SINTRIN T minof(E1&& x) { static_assert(!is_generic<E1>::value, "e1 must be a typed expression (use typed<T>())"); static_assert(!is_infinite<E1>::value, "e1 must be a sized expression (use typed<T>())"); - return internal::reduce(std::forward<E1>(x), internal::fn_min()); + return internal::reduce(std::forward<E1>(x), fn::min()); } template <typename E1, typename T = value_type_of<E1>, KFR_ENABLE_IF(is_input_expression<E1>::value)> @@ -150,7 +150,7 @@ KFR_SINTRIN T maxof(E1&& x) { static_assert(!is_generic<E1>::value, "e1 must be a typed expression (use typed<T>())"); static_assert(!is_infinite<E1>::value, "e1 must be a sized expression (use typed<T>())"); - return internal::reduce(std::forward<E1>(x), internal::fn_max()); + return internal::reduce(std::forward<E1>(x), fn::max()); } template <typename E1, typename T = value_type_of<E1>, KFR_ENABLE_IF(is_input_expression<E1>::value)> @@ -158,7 +158,7 @@ KFR_SINTRIN T absminof(E1&& x) { static_assert(!is_generic<E1>::value, "e1 must be a typed expression (use typed<T>())"); static_assert(!is_infinite<E1>::value, "e1 must be a sized expression (use typed<T>())"); - return internal::reduce(std::forward<E1>(x), internal::fn_absmin()); + return internal::reduce(std::forward<E1>(x), fn::absmin()); } template <typename E1, typename T = value_type_of<E1>, KFR_ENABLE_IF(is_input_expression<E1>::value)> @@ -166,7 +166,7 @@ KFR_SINTRIN T absmaxof(E1&& x) { static_assert(!is_generic<E1>::value, "e1 must be a typed expression (use typed<T>())"); static_assert(!is_infinite<E1>::value, "e1 must be a sized expression (use typed<T>())"); - return internal::reduce(std::forward<E1>(x), internal::fn_absmax()); + return internal::reduce(std::forward<E1>(x), fn::absmax()); } template <typename E1, typename E2, typename T = value_type_of<E1>,