specialised handling for pow(x,0.5)

This commit is contained in:
conrad
2025-02-07 12:07:38 +10:00
parent 8e02066f52
commit eea1835183
2 changed files with 23 additions and 0 deletions
+14
View File
@@ -321,6 +321,13 @@ accu(const eOp<T1,eop_pow>& expr)
return accu( reinterpret_cast< const modified_expr_type& >(expr) );
}
if((expr.aux == eT(0.5)) && is_non_integral<eT>::value)
{
typedef eOp<T1,eop_sqrt> modified_expr_type;
return accu( reinterpret_cast< const modified_expr_type& >(expr) );
}
const Proxy<expr_type> P(expr);
return (Proxy<expr_type>::use_at) ? accu_proxy_at(P) : accu_proxy_linear(P);
@@ -955,6 +962,13 @@ accu(const eOpCube<T1,eop_pow>& expr)
return accu( reinterpret_cast< const modified_expr_type& >(expr) );
}
if((expr.aux == eT(0.5)) && is_non_integral<eT>::value)
{
typedef eOpCube<T1,eop_sqrt> modified_expr_type;
return accu( reinterpret_cast< const modified_expr_type& >(expr) );
}
const ProxyCube<expr_type> P(expr);
return (ProxyCube<expr_type>::use_at) ? accu_cube_proxy_at(P) : accu_cube_proxy_linear(P);
+9
View File
@@ -163,6 +163,15 @@ op_sum::apply(Mat<typename T1::elem_type>& out, const Op< eOp<T1,eop_pow>, op_su
return;
}
if((in.m.aux == eT(0.5)) && is_non_integral<eT>::value)
{
typedef Op< eOp<T1,eop_sqrt>, op_sum > modified_whole_expr_type;
op_sum::apply(out, reinterpret_cast<const modified_whole_expr_type& >(in) );
return;
}
typedef eOp<T1,eop_pow> inner_expr_type;
typedef typename inner_expr_type::proxy_type::stored_type inner_expr_P_stored_type;