constexpr inline T sin(T x) { x = x - trunc(x / c_pi<T, 2>) * c_pi<T, 2>; constexpr T c2 = -0.16665853559970855712890625; constexpr T c4 = +8.31427983939647674560546875e-3; constexpr T c6 = -1.85423981747590005397796630859375e-4; x -= c_pi<T>; T y = abs(x); y = select(y > c_pi<T, 1, 2>, c_pi<T> - y, y); y = mulsign(y, -x); const T y2 = y * y; T formula = c6; const T y3 = y2 * y; formula = fmadd(formula, y2, c4); formula = fmadd(formula, y2, c2); formula = formula * y3 + y; return formula; }
constexpr CMT_INLINE common_type<T1, T2, T3, Ts...> horner_odd(const T1& x, const T2& c1, const T3& c3, const Ts&... values) { const T1 x2 = x * x; return fmadd(horner(x2, c3, values...), x2, c1) * x; }
constexpr CMT_INLINE common_type<T1, T2, T3, Ts...> horner_even(const T1& x, const T2& c0, const T3& c2, const Ts&... values) { const T1 x2 = x * x; return fmadd(horner(x2, c2, values...), x2, c0); }
constexpr CMT_INLINE common_type<T1, T2, T3, Ts...> horner(const T1& x, const T2& c0, const T3& c1, const Ts&... values) { return fmadd(horner(x, c1, values...), x, c0); }
KFR_INTRIN constexpr common_type<T1, T2, T3> mixs(const T1& c, const T2& x, const T3& y) { return mix(fmadd(c, 0.5, 0.5), x, y); }
KFR_INTRIN constexpr common_type<T1, T2, T3> mix(const T1& c, const T2& x, const T3& y) { return fmadd(c, y - x, x); }