diff --git a/include/armadillo_bits/fn_accu.hpp b/include/armadillo_bits/fn_accu.hpp index 034903f3..57dbb36c 100644 --- a/include/armadillo_bits/fn_accu.hpp +++ b/include/armadillo_bits/fn_accu.hpp @@ -321,6 +321,13 @@ accu(const eOp& expr) return accu( reinterpret_cast< const modified_expr_type& >(expr) ); } + if((expr.aux == eT(0.5)) && is_non_integral::value) + { + typedef eOp modified_expr_type; + + return accu( reinterpret_cast< const modified_expr_type& >(expr) ); + } + const Proxy P(expr); return (Proxy::use_at) ? accu_proxy_at(P) : accu_proxy_linear(P); @@ -955,6 +962,13 @@ accu(const eOpCube& expr) return accu( reinterpret_cast< const modified_expr_type& >(expr) ); } + if((expr.aux == eT(0.5)) && is_non_integral::value) + { + typedef eOpCube modified_expr_type; + + return accu( reinterpret_cast< const modified_expr_type& >(expr) ); + } + const ProxyCube P(expr); return (ProxyCube::use_at) ? accu_cube_proxy_at(P) : accu_cube_proxy_linear(P); diff --git a/include/armadillo_bits/op_sum_meat.hpp b/include/armadillo_bits/op_sum_meat.hpp index 4a903a11..d2f1eb8a 100644 --- a/include/armadillo_bits/op_sum_meat.hpp +++ b/include/armadillo_bits/op_sum_meat.hpp @@ -163,6 +163,15 @@ op_sum::apply(Mat& out, const Op< eOp, op_su return; } + if((in.m.aux == eT(0.5)) && is_non_integral::value) + { + typedef Op< eOp, op_sum > modified_whole_expr_type; + + op_sum::apply(out, reinterpret_cast(in) ); + + return; + } + typedef eOp inner_expr_type; typedef typename inner_expr_type::proxy_type::stored_type inner_expr_P_stored_type;