Compare commits

...
4 Commits
Author SHA1 Message Date
conrad 98c13f4bc7 patch bump 2025-08-08 13:56:43 +10:00
conrad 92cd541f57 move conformance check to avoid doing two checks 2025-08-05 23:51:07 +10:00
conrad f002bffd96 simplified fallback in handling of op_sum specialisations 2025-08-05 23:43:29 +10:00
conrad cba9c87169 fix 2025-08-05 12:39:40 +10:00
4 changed files with 31 additions and 88 deletions
+1 -1
View File
@@ -23,7 +23,7 @@
#define ARMA_VERSION_MAJOR 14
#define ARMA_VERSION_MINOR 6
#define ARMA_VERSION_PATCH 1
#define ARMA_VERSION_PATCH 2
#define ARMA_VERSION_NAME "Caffe Mocha"
+2 -2
View File
@@ -56,7 +56,7 @@ op_omit::apply(Mat<typename T1::elem_type>& out, const T1& X, functor is_omitted
typedef typename T1::elem_type eT;
if(is_Mat<T1>::value || is_subview_col<T1>::value || is_Mat<typename Proxy<T1>::stored_type>::value || Proxy<T1>::use_mp)
if(is_Mat<T1>::value || is_subview_col<T1>::value || is_Mat<typename Proxy<T1>::stored_type>::value || (arma_config::openmp && Proxy<T1>::use_mp))
{
const quasi_unwrap<T1> U(X);
@@ -160,7 +160,7 @@ op_omit_cube::apply(Mat<typename T1::elem_type>& out, const T1& X, functor is_om
typedef typename T1::elem_type eT;
if(is_Cube<T1>::value || is_Cube<typename ProxyCube<T1>::stored_type>::value || ProxyCube<T1>::use_mp)
if(is_Cube<T1>::value || is_Cube<typename ProxyCube<T1>::stored_type>::value || (arma_config::openmp && ProxyCube<T1>::use_mp))
{
const unwrap_cube<T1> U(X);
+5 -2
View File
@@ -32,10 +32,13 @@ class op_sum
template<typename T1>
inline static void apply(Mat<typename T1::elem_type>& out, const Op< eOp<T1,eop_square>, op_sum >& in);
template<typename T1>
inline static void apply(Mat<typename T1::elem_type>& out, const Op< eOp<T1,eop_pow >, op_sum >& in);
template<typename T1>
inline static void apply_generic(Mat<typename T1::elem_type>& out, const Op<T1,op_sum>& in);
template<typename eT>
inline static void apply_mat_noalias(Mat<eT>& out, const Mat<eT>& X, const uword dim);
+23 -83
View File
@@ -28,46 +28,7 @@ op_sum::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_sum>& in)
{
arma_debug_sigprint();
typedef typename T1::elem_type eT;
const uword dim = in.aux_uword_a;
arma_conform_check( (dim > 1), "sum(): parameter 'dim' must be 0 or 1" );
if((is_Mat<T1>::value) || (is_Mat<typename Proxy<T1>::stored_type>::value) || (arma_config::openmp && Proxy<T1>::use_mp))
{
const quasi_unwrap<T1> U(in.m);
if(U.is_alias(out))
{
Mat<eT> tmp;
op_sum::apply_mat_noalias(tmp, U.M, dim);
out.steal_mem(tmp);
}
else
{
op_sum::apply_mat_noalias(out, U.M, dim);
}
}
else
{
const Proxy<T1> P(in.m);
if(P.is_alias(out))
{
Mat<eT> tmp;
op_sum::apply_proxy_noalias(tmp, P, dim);
out.steal_mem(tmp);
}
else
{
op_sum::apply_proxy_noalias(out, P, dim);
}
}
op_sum::apply_generic(out, in);
}
@@ -85,12 +46,12 @@ op_sum::apply(Mat<typename T1::elem_type>& out, const Op< eOp<T1,eop_square>, op
typedef typename inner_expr_type::proxy_type::stored_type inner_expr_P_stored_type;
const uword dim = in.aux_uword_a;
arma_conform_check( (dim > 1), "sum(): parameter 'dim' must be 0 or 1" );
if(is_Mat<inner_expr_P_stored_type>::value)
{
const uword dim = in.aux_uword_a;
arma_conform_check( (dim > 1), "sum(): parameter 'dim' must be 0 or 1" );
const quasi_unwrap<inner_expr_P_stored_type> U(in.m.P.Q);
if(U.is_alias(out))
@@ -105,42 +66,11 @@ op_sum::apply(Mat<typename T1::elem_type>& out, const Op< eOp<T1,eop_square>, op
{
op_sum::apply_mat_square_noalias(out, U.M, dim);
}
}
else
if(arma_config::openmp && Proxy<inner_expr_type>::use_mp)
{
const quasi_unwrap<inner_expr_type> U(in.m); // force evaluation of compound inner expression
if(U.is_alias(out))
{
Mat<eT> tmp;
op_sum::apply_mat_noalias(tmp, U.M, dim);
out.steal_mem(tmp);
}
else
{
op_sum::apply_mat_noalias(out, U.M, dim);
}
}
else
{
const Proxy<inner_expr_type> P(in.m);
if(P.is_alias(out))
{
Mat<eT> tmp;
op_sum::apply_proxy_noalias(tmp, P, dim);
out.steal_mem(tmp);
}
else
{
op_sum::apply_proxy_noalias(out, P, dim);
}
return;
}
op_sum::apply_generic(out, in);
}
@@ -172,17 +102,27 @@ op_sum::apply(Mat<typename T1::elem_type>& out, const Op< eOp<T1,eop_pow>, op_su
return;
}
typedef eOp<T1,eop_pow> inner_expr_type;
op_sum::apply_generic(out, in);
}
template<typename T1>
inline
void
op_sum::apply_generic(Mat<typename T1::elem_type>& out, const Op<T1,op_sum>& in)
{
arma_debug_sigprint();
typedef typename inner_expr_type::proxy_type::stored_type inner_expr_P_stored_type;
typedef typename T1::elem_type eT;
const uword dim = in.aux_uword_a;
arma_conform_check( (dim > 1), "sum(): parameter 'dim' must be 0 or 1" );
if( (is_Mat<inner_expr_P_stored_type>::value) || (arma_config::openmp && Proxy<inner_expr_type>::use_mp) )
if((is_Mat<T1>::value) || (is_Mat<typename Proxy<T1>::stored_type>::value) || (arma_config::openmp && Proxy<T1>::use_mp))
{
const quasi_unwrap<inner_expr_type> U(in.m); // force evaluation of eop_pow
const quasi_unwrap<T1> U(in.m);
if(U.is_alias(out))
{
@@ -199,7 +139,7 @@ op_sum::apply(Mat<typename T1::elem_type>& out, const Op< eOp<T1,eop_pow>, op_su
}
else
{
const Proxy<inner_expr_type> P(in.m);
const Proxy<T1> P(in.m);
if(P.is_alias(out))
{