diff --git a/include/boost/numeric/ublas/tensor/expression.hpp b/include/boost/numeric/ublas/tensor/expression.hpp index 6e70699b9..edf7c03a7 100644 --- a/include/boost/numeric/ublas/tensor/expression.hpp +++ b/include/boost/numeric/ublas/tensor/expression.hpp @@ -181,8 +181,8 @@ struct binary_tensor_expression [[nodiscard]] constexpr auto const& left_expr() const noexcept{ return cast_tensor_expression(el); } [[nodiscard]] constexpr auto const& right_expr() const noexcept{ return cast_tensor_expression(er); } - [[nodiscard]] inline - constexpr decltype(auto) operator()(size_type i) const { return op(left_expr()(i), right_expr()(i)); } + [[nodiscard]] inline constexpr + decltype(auto) operator()(size_type i) const { return std::invoke(op, left_expr()(i), right_expr()(i)); } protected: /** @@ -255,7 +255,7 @@ struct unary_tensor_expression [[nodiscard]] constexpr auto const& expr() const noexcept{ return cast_tensor_expression(e); } [[nodiscard]] inline constexpr - decltype(auto) operator()(size_type i) const { return op(expr()(i)); } + decltype(auto) operator()(size_type i) const { return std::invoke(op, expr()(i)); } protected: /** diff --git a/include/boost/numeric/ublas/tensor/operators_arithmetic.hpp b/include/boost/numeric/ublas/tensor/operators_arithmetic.hpp index fec0f42d3..6bd385870 100644 --- a/include/boost/numeric/ublas/tensor/operators_arithmetic.hpp +++ b/include/boost/numeric/ublas/tensor/operators_arithmetic.hpp @@ -76,9 +76,10 @@ inline constexpr auto operator*( EL&& lhs, ER&& rhs ) noexcept { using tensor_type = boost::numeric::ublas::detail::real_expression_type_t; + using value_type = typename tensor_type::value_type; return boost::numeric::ublas::detail::make_binary_tensor_expression( - std::forward(lhs), std::forward(rhs), std::multiplies<>{} + std::forward(lhs), std::forward(rhs), std::multiplies{} ); } @@ -91,9 +92,10 @@ inline constexpr auto operator+( EL&& lhs, ER&& rhs ) noexcept { using tensor_type = boost::numeric::ublas::detail::real_expression_type_t; + using value_type = typename tensor_type::value_type; return boost::numeric::ublas::detail::make_binary_tensor_expression( - std::forward(lhs), std::forward(rhs), std::plus<>{} + std::forward(lhs), std::forward(rhs), std::plus{} ); } @@ -106,9 +108,10 @@ inline constexpr auto operator-( EL&& lhs, ER&& rhs ) noexcept { using tensor_type = boost::numeric::ublas::detail::real_expression_type_t; + using value_type = typename tensor_type::value_type; return boost::numeric::ublas::detail::make_binary_tensor_expression( - std::forward(lhs), std::forward(rhs), std::minus<>{} + std::forward(lhs), std::forward(rhs), std::minus{} ); } @@ -121,9 +124,10 @@ inline constexpr auto operator/( EL&& lhs, ER&& rhs ) noexcept { using tensor_type = boost::numeric::ublas::detail::real_expression_type_t; + using value_type = typename tensor_type::value_type; return boost::numeric::ublas::detail::make_binary_tensor_expression( - std::forward(lhs), std::forward(rhs), std::divides<>{} + std::forward(lhs), std::forward(rhs), std::divides{} ); } @@ -136,9 +140,10 @@ inline constexpr auto operator*( EL&& lhs, ER&& rhs ) noexcept { using tensor_type = boost::numeric::ublas::detail::real_expression_type_t; + using value_type = typename tensor_type::value_type; return boost::numeric::ublas::detail::make_binary_tensor_expression( - std::forward(lhs), std::forward(rhs), std::multiplies<>{} + std::forward(lhs), std::forward(rhs), std::multiplies{} ); } @@ -151,9 +156,10 @@ inline constexpr auto operator+( EL&& lhs, ER&& rhs ) noexcept { using tensor_type = boost::numeric::ublas::detail::real_expression_type_t; + using value_type = typename tensor_type::value_type; return boost::numeric::ublas::detail::make_binary_tensor_expression( - std::forward(lhs), std::forward(rhs), std::plus<>{} + std::forward(lhs), std::forward(rhs), std::plus{} ); } @@ -166,9 +172,10 @@ inline constexpr auto operator-( EL&& lhs, ER&& rhs ) noexcept { using tensor_type = boost::numeric::ublas::detail::real_expression_type_t; + using value_type = typename tensor_type::value_type; return boost::numeric::ublas::detail::make_binary_tensor_expression( - std::forward(lhs), std::forward(rhs), std::minus<>{} + std::forward(lhs), std::forward(rhs), std::minus{} ); } @@ -180,9 +187,10 @@ template inline constexpr auto operator/( EL&& lhs, ER&& rhs ) noexcept { using tensor_type = boost::numeric::ublas::detail::real_expression_type_t; + using value_type = typename tensor_type::value_type; return boost::numeric::ublas::detail::make_binary_tensor_expression( - std::forward(lhs), std::forward(rhs), std::divides<>{} + std::forward(lhs), std::forward(rhs), std::divides{} ); } @@ -204,7 +212,7 @@ inline constexpr auto operator+( EL&& lhs, ER&& rhs ) noexcept ); return boost::numeric::ublas::detail::make_binary_tensor_expression ( - std::forward(lhs), std::forward(rhs), [](auto const& l, auto const& r){ return l + r; } + std::forward(lhs), std::forward(rhs), std::plus{} ); } @@ -227,7 +235,7 @@ inline constexpr auto operator-( EL&& lhs, ER&& rhs ) noexcept ); return boost::numeric::ublas::detail::make_binary_tensor_expression ( - std::forward(lhs), std::forward(rhs), [](auto const& l, auto const& r){ return l - r; } + std::forward(lhs), std::forward(rhs), std::minus{} ); } @@ -249,7 +257,7 @@ inline constexpr auto operator*( EL&& lhs, ER&& rhs ) noexcept ); return boost::numeric::ublas::detail::make_binary_tensor_expression ( - std::forward(lhs), std::forward(rhs), [](auto const& l, auto const& r){ return l * r; } + std::forward(lhs), std::forward(rhs), std::multiplies{} ); } @@ -271,7 +279,7 @@ inline constexpr auto operator/( EL&& lhs, ER&& rhs ) noexcept ); return boost::numeric::ublas::detail::make_binary_tensor_expression ( - std::forward(lhs), std::forward(rhs), [](auto const& l, auto const& r){ return l / r; } + std::forward(lhs), std::forward(rhs), std::divides{} ); } @@ -284,10 +292,11 @@ inline constexpr auto operator+( ER&& rhs ) noexcept { using tensor_type = boost::numeric::ublas::detail::real_expression_type_t; + using value_type = typename tensor_type::value_type; return boost::numeric::ublas::detail::make_unary_tensor_expression ( std::forward(rhs), - [lhs](auto const& r){ return lhs + r; } + [lhs](value_type const& r){ return lhs + r; } ); } @@ -298,10 +307,11 @@ inline constexpr auto operator-( ER&& rhs ) noexcept { using tensor_type = boost::numeric::ublas::detail::real_expression_type_t; + using value_type = typename tensor_type::value_type; return boost::numeric::ublas::detail::make_unary_tensor_expression ( std::forward(rhs), - [lhs](auto const& r){ return lhs - r; } + [lhs](value_type const& r){ return lhs - r; } ); } @@ -312,10 +322,11 @@ inline constexpr auto operator*( ER&& rhs ) noexcept { using tensor_type = boost::numeric::ublas::detail::real_expression_type_t; + using value_type = typename tensor_type::value_type; return boost::numeric::ublas::detail::make_unary_tensor_expression ( std::forward(rhs), - [lhs](auto const& r){ return lhs * r; } + [lhs](value_type const& r){ return lhs * r; } ); } @@ -326,10 +337,11 @@ inline constexpr auto operator/( ER&& rhs ) noexcept { using tensor_type = boost::numeric::ublas::detail::real_expression_type_t; + using value_type = typename tensor_type::value_type; return boost::numeric::ublas::detail::make_unary_tensor_expression ( std::forward(rhs), - [lhs](auto const& r){ return lhs / r; } + [lhs](value_type const& r){ return lhs / r; } ); } @@ -340,10 +352,11 @@ inline constexpr auto operator+( typename boost::numeric::ublas::detail::real_expression_type_t::value_type rhs ) noexcept { using tensor_type = boost::numeric::ublas::detail::real_expression_type_t; + using value_type = typename tensor_type::value_type; return boost::numeric::ublas::detail::make_unary_tensor_expression ( std::forward(lhs), - [rhs] (auto const& l) { return l + rhs; } + [rhs] (value_type const& l) { return l + rhs; } ); } @@ -354,10 +367,11 @@ inline constexpr auto operator-( typename boost::numeric::ublas::detail::real_expression_type_t::value_type rhs ) noexcept { using tensor_type = boost::numeric::ublas::detail::real_expression_type_t; + using value_type = typename tensor_type::value_type; return boost::numeric::ublas::detail::make_unary_tensor_expression ( std::forward(lhs), - [rhs] (auto const& l) { return l - rhs; } + [rhs] (value_type const& l) { return l - rhs; } ); } @@ -368,10 +382,11 @@ inline constexpr auto operator*( typename boost::numeric::ublas::detail::real_expression_type_t::value_type rhs ) noexcept { using tensor_type = boost::numeric::ublas::detail::real_expression_type_t; + using value_type = typename tensor_type::value_type; return boost::numeric::ublas::detail::make_unary_tensor_expression ( std::forward(lhs), - [rhs] (auto const& l) { return l * rhs; } + [rhs] (value_type const& l) { return l * rhs; } ); } @@ -382,10 +397,11 @@ inline constexpr auto operator/( typename boost::numeric::ublas::detail::real_expression_type_t::value_type rhs ) noexcept { using tensor_type = boost::numeric::ublas::detail::real_expression_type_t; + using value_type = typename tensor_type::value_type; return boost::numeric::ublas::detail::make_unary_tensor_expression ( std::forward(lhs), - [rhs] (auto const& l) { return l / rhs; } + [rhs] (value_type const& l) { return l / rhs; } ); } @@ -394,7 +410,8 @@ inline constexpr auto& operator += ( boost::numeric::ublas::tensor_core& lhs, boost::numeric::ublas::detail::tensor_expression,D> const& expr ){ - boost::numeric::ublas::detail::eval(lhs, expr(), [](auto& l, auto const& r) { l+=r; } ); + using value_type = typename boost::numeric::ublas::tensor_core::value_type; + boost::numeric::ublas::detail::eval(lhs, expr(), [](value_type& l, value_type const& r) { l+=r; } ); return lhs; } @@ -403,7 +420,8 @@ inline constexpr auto& operator -= ( boost::numeric::ublas::tensor_core& lhs, const boost::numeric::ublas::detail::tensor_expression,D> &expr ){ - boost::numeric::ublas::detail::eval(lhs, expr(), [](auto& l, auto const& r) { l-=r; } ); + using value_type = typename boost::numeric::ublas::tensor_core::value_type; + boost::numeric::ublas::detail::eval(lhs, expr(), [](value_type& l, value_type const& r) { l-=r; } ); return lhs; } @@ -412,7 +430,8 @@ inline constexpr auto& operator *= ( boost::numeric::ublas::tensor_core& lhs, const boost::numeric::ublas::detail::tensor_expression,D> &expr ){ - boost::numeric::ublas::detail::eval(lhs, expr(), [](auto& l, auto const& r) { l*=r; } ); + using value_type = typename boost::numeric::ublas::tensor_core::value_type; + boost::numeric::ublas::detail::eval(lhs, expr(), [](value_type& l, value_type const& r) { l*=r; } ); return lhs; } @@ -421,7 +440,8 @@ inline constexpr auto& operator /= ( boost::numeric::ublas::tensor_core& lhs, const boost::numeric::ublas::detail::tensor_expression,D> &expr ){ - boost::numeric::ublas::detail::eval(lhs, expr(), [](auto& l, auto const& r) { l/=r; } ); + using value_type = typename boost::numeric::ublas::tensor_core::value_type; + boost::numeric::ublas::detail::eval(lhs, expr(), [](value_type& l, value_type const& r) { l/=r; } ); return lhs; } @@ -433,7 +453,8 @@ inline constexpr auto& operator += ( boost::numeric::ublas::tensor_core& lhs, typename boost::numeric::ublas::tensor_core::value_type r ){ - boost::numeric::ublas::detail::eval(lhs, [r](auto& l) { l+=r; } ); + using value_type = typename boost::numeric::ublas::tensor_core::value_type; + boost::numeric::ublas::detail::eval(lhs, [r](value_type& l) { l+=r; } ); return lhs; } @@ -442,7 +463,8 @@ inline constexpr auto& operator -= ( boost::numeric::ublas::tensor_core& lhs, typename boost::numeric::ublas::tensor_core::value_type r ){ - boost::numeric::ublas::detail::eval(lhs, [r](auto& l) { l-=r; } ); + using value_type = typename boost::numeric::ublas::tensor_core::value_type; + boost::numeric::ublas::detail::eval(lhs, [r](value_type& l) { l-=r; } ); return lhs; } @@ -451,7 +473,8 @@ inline constexpr auto& operator *= ( boost::numeric::ublas::tensor_core& lhs, typename boost::numeric::ublas::tensor_core::value_type r ){ - boost::numeric::ublas::detail::eval(lhs, [r](auto& l) { l*=r; } ); + using value_type = typename boost::numeric::ublas::tensor_core::value_type; + boost::numeric::ublas::detail::eval(lhs, [r](value_type& l) { l*=r; } ); return lhs; } @@ -460,7 +483,8 @@ inline constexpr auto& operator /= ( boost::numeric::ublas::tensor_core& lhs, typename boost::numeric::ublas::tensor_core::value_type r ){ - boost::numeric::ublas::detail::eval(lhs, [r](auto& l) { l/=r; } ); + using value_type = typename boost::numeric::ublas::tensor_core::value_type; + boost::numeric::ublas::detail::eval(lhs, [r](value_type& l) { l/=r; } ); return lhs; } @@ -476,8 +500,9 @@ template requires boost::numeric::ublas::detail::TensorExpression inline constexpr auto operator -(E&& e) { using tensor_type = boost::numeric::ublas::detail::real_expression_type_t; + using value_type = typename tensor_type::value_type; return boost::numeric::ublas::detail::make_unary_tensor_expression ( - std::forward(e), std::negate<>{} + std::forward(e), std::negate{} ); }