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 08098d02fdea5a1e7ba933d16cd23c8ba99b067f
parent c3934162ae424f7c3421e1df60ab5fc65f3064c3
Author: samuriddle@gmail.com <samuriddle@gmail.com>
Date:   Mon,  8 Aug 2016 02:28:41 +0300

fix ambiguous conversion

Diffstat:
Minclude/kfr/base/operators.hpp | 12++++++------
Minclude/kfr/base/vec.hpp | 26++++++++++++++++++++++++++
2 files changed, 32 insertions(+), 6 deletions(-)

diff --git a/include/kfr/base/operators.hpp b/include/kfr/base/operators.hpp @@ -61,10 +61,10 @@ constexpr inline T add(T x) { return x; } -template <typename T1, typename T2, typename... Ts, typename Tout = common_type<T1, T2, Ts...>> -constexpr inline Tout add(T1 x, T2 y, Ts... rest) +template <typename T1, typename T2, typename... Ts> +constexpr inline common_type<T1, T2, Ts...> add(T1 x, T2 y, Ts... rest) { - return static_cast<Tout>(x) + static_cast<Tout>(add(std::forward<T2>(y), std::forward<Ts>(rest)...)); + return x + add(std::forward<T2>(y), std::forward<Ts>(rest)...); } template <typename T> constexpr inline T add(initialvalue<T>) @@ -107,10 +107,10 @@ constexpr inline T1 mul(T1 x) { return x; } -template <typename T1, typename T2, typename... Ts, typename Tout = common_type<T1, T2, Ts...>> -constexpr inline Tout mul(T1 x, T2 y, Ts... rest) +template <typename T1, typename T2, typename... Ts> +constexpr inline common_type<T1, T2, Ts...> mul(T1 x, T2 y, Ts... rest) { - return static_cast<Tout>(x) * static_cast<Tout>(mul(std::forward<T2>(y), std::forward<Ts>(rest)...)); + return x * mul(std::forward<T2>(y), std::forward<Ts>(rest)...); } template <typename T> diff --git a/include/kfr/base/vec.hpp b/include/kfr/base/vec.hpp @@ -737,6 +737,32 @@ struct vec : vec_t<T, N> KFR_ASGN_OP(>>=, >>) #undef KFR_ASGN_OP + template <typename U, typename C = common_type<U, T>> + friend constexpr CMT_INLINE vec<C, N> operator+(const vec& x, const vec<U, N>& y) + { + return vec_op<C>::add(static_cast<vec<C, N>>(x).v, static_cast<vec<C, N>>(y).v); + } + template <typename U, typename C = common_type<U, T>> + friend constexpr CMT_INLINE vec<C, N> operator-(const vec& x, const vec<U, N>& y) + { + return vec_op<C>::sub(static_cast<vec<C, N>>(x).v, static_cast<vec<C, N>>(y).v); + } + template <typename U, typename C = common_type<U, T>> + friend constexpr CMT_INLINE vec<C, N> operator*(const vec& x, const vec<U, N>& y) + { + return vec_op<C>::mul(static_cast<vec<C, N>>(x).v, static_cast<vec<C, N>>(y).v); + } + template <typename U, typename C = common_type<U, T>> + friend constexpr CMT_INLINE vec<C, N> operator/(const vec& x, const vec<U, N>& y) + { + return vec_op<C>::div(static_cast<vec<C, N>>(x).v, static_cast<vec<C, N>>(y).v); + } + template <typename U, typename C = common_type<U, T>> + friend constexpr CMT_INLINE vec<C, N> operator%(const vec& x, const vec<U, N>& y) + { + return vec_op<C>::rem(static_cast<vec<C, N>>(x).v, static_cast<vec<C, N>>(y).v); + } + constexpr CMT_INLINE simd_t operator*() const { return v; } constexpr CMT_INLINE simd_t& operator*() { return v; } CMT_INLINE mask<T, N>& asmask() { return ref_cast<mask<T, N>>(*this); }