diff --git a/src/tenvex/expressions/mul.h b/src/tenvex/expressions/mul.h index 7dc8c24..842382d 100644 --- a/src/tenvex/expressions/mul.h +++ b/src/tenvex/expressions/mul.h @@ -24,6 +24,11 @@ private: tnvx_ref_or_value_t _r; }; + +// this banch of reloads (instead of expression*expression) is required for two thigs: +// 1. to avoid ambiguity with operator* for vector-vector multiplication +// 2. to avoid scalar operator collapses to float instead of lazy-expressions + template [[nodiscard]] TNVX_INLINE Mul operator*(const E& l, float r) noexcept; @@ -36,6 +41,22 @@ template [[nodiscard]] TNVX_INLINE Mul operator*(const L& l, const R& r) noexcept; +template +[[nodiscard]] TNVX_INLINE +Mul operator*(const L& l, const R& r) noexcept; + +template +[[nodiscard]] TNVX_INLINE +Mul operator*(const L& l, const R& r) noexcept; + +template +[[nodiscard]] TNVX_INLINE +Mul operator*(const E& l, float r) noexcept; + +template +[[nodiscard]] TNVX_INLINE +Mul operator*(float l, const E& r) noexcept; + template inline constexpr bool is_vec_expr> = true; template inline constexpr bool is_vec_expr> = true; diff --git a/src/tenvex/expressions/mul_impl.hpp b/src/tenvex/expressions/mul_impl.hpp index 4cb02ee..4c498ce 100644 --- a/src/tenvex/expressions/mul_impl.hpp +++ b/src/tenvex/expressions/mul_impl.hpp @@ -17,7 +17,7 @@ template TNVX_INLINE vf4 Mul::eval() const noexcept { - return _mm_mul_ps(_l.eval(), _r.eval()); + return detail::mul(_l.eval(), _r.eval()); } template @@ -41,4 +41,32 @@ Mul operator*(const L& l, const R& r) noexcept return { l, r }; } +template +TNVX_INLINE +Mul operator*(const L& l, const R& r) noexcept +{ + return { l, r }; +} + +template +TNVX_INLINE +Mul operator*(const L& l, const R& r) noexcept +{ + return { l, r }; +} + +template +TNVX_INLINE +Mul operator*(const E& l, float r) noexcept +{ + return { l, Scalar(r) }; +} + +template +TNVX_INLINE +Mul operator*(float l, const E& r) noexcept +{ + return { Scalar(l), r }; +} + }