@@ -28,46 +28,7 @@ op_sum::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_sum>& in)
2828 {
2929 arma_debug_sigprint ();
3030
31- typedef typename T1::elem_type eT;
32-
33- const uword dim = in.aux_uword_a ;
34-
35- arma_conform_check ( (dim > 1 ), " sum(): parameter 'dim' must be 0 or 1" );
36-
37- if ((is_Mat<T1>::value) || (is_Mat<typename Proxy<T1>::stored_type>::value) || (arma_config::openmp && Proxy<T1>::use_mp))
38- {
39- const quasi_unwrap<T1> U (in.m );
40-
41- if (U.is_alias (out))
42- {
43- Mat<eT> tmp;
44-
45- op_sum::apply_mat_noalias (tmp, U.M , dim);
46-
47- out.steal_mem (tmp);
48- }
49- else
50- {
51- op_sum::apply_mat_noalias (out, U.M , dim);
52- }
53- }
54- else
55- {
56- const Proxy<T1> P (in.m );
57-
58- if (P.is_alias (out))
59- {
60- Mat<eT> tmp;
61-
62- op_sum::apply_proxy_noalias (tmp, P, dim);
63-
64- out.steal_mem (tmp);
65- }
66- else
67- {
68- op_sum::apply_proxy_noalias (out, P, dim);
69- }
70- }
31+ op_sum::apply_generic (out, in);
7132 }
7233
7334
@@ -85,12 +46,12 @@ op_sum::apply(Mat<typename T1::elem_type>& out, const Op< eOp<T1,eop_square>, op
8546
8647 typedef typename inner_expr_type::proxy_type::stored_type inner_expr_P_stored_type;
8748
88- const uword dim = in.aux_uword_a ;
89-
90- arma_conform_check ( (dim > 1 ), " sum(): parameter 'dim' must be 0 or 1" );
91-
9249 if (is_Mat<inner_expr_P_stored_type>::value)
9350 {
51+ const uword dim = in.aux_uword_a ;
52+
53+ arma_conform_check ( (dim > 1 ), " sum(): parameter 'dim' must be 0 or 1" );
54+
9455 const quasi_unwrap<inner_expr_P_stored_type> U (in.m .P .Q );
9556
9657 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
10566 {
10667 op_sum::apply_mat_square_noalias (out, U.M , dim);
10768 }
108- }
109- else
110- if (arma_config::openmp && Proxy<inner_expr_type>::use_mp)
111- {
112- const quasi_unwrap<inner_expr_type> U (in.m ); // force evaluation of compound inner expression
11369
114- if (U.is_alias (out))
115- {
116- Mat<eT> tmp;
117-
118- op_sum::apply_mat_noalias (tmp, U.M , dim);
119-
120- out.steal_mem (tmp);
121- }
122- else
123- {
124- op_sum::apply_mat_noalias (out, U.M , dim);
125- }
126- }
127- else
128- {
129- const Proxy<inner_expr_type> P (in.m );
130-
131- if (P.is_alias (out))
132- {
133- Mat<eT> tmp;
134-
135- op_sum::apply_proxy_noalias (tmp, P, dim);
136-
137- out.steal_mem (tmp);
138- }
139- else
140- {
141- op_sum::apply_proxy_noalias (out, P, dim);
142- }
70+ return ;
14371 }
72+
73+ op_sum::apply_generic (out, in);
14474 }
14575
14676
@@ -172,17 +102,27 @@ op_sum::apply(Mat<typename T1::elem_type>& out, const Op< eOp<T1,eop_pow>, op_su
172102 return ;
173103 }
174104
175- typedef eOp<T1,eop_pow> inner_expr_type;
105+ op_sum::apply_generic (out, in);
106+ }
107+
108+
109+
110+ template <typename T1>
111+ inline
112+ void
113+ op_sum::apply_generic (Mat<typename T1::elem_type>& out, const Op<T1,op_sum>& in)
114+ {
115+ arma_debug_sigprint ();
176116
177- typedef typename inner_expr_type::proxy_type::stored_type inner_expr_P_stored_type ;
117+ typedef typename T1::elem_type eT ;
178118
179119 const uword dim = in.aux_uword_a ;
180120
181121 arma_conform_check ( (dim > 1 ), " sum(): parameter 'dim' must be 0 or 1" );
182122
183- if ( (is_Mat<inner_expr_P_stored_type >::value) || (arma_config::openmp && Proxy<inner_expr_type >::use_mp) )
123+ if ((is_Mat<T1>::value) || (is_Mat<typename Proxy<T1 >::stored_type>:: value) || (arma_config::openmp && Proxy<T1 >::use_mp))
184124 {
185- const quasi_unwrap<inner_expr_type > U (in.m ); // force evaluation of eop_pow
125+ const quasi_unwrap<T1 > U (in.m );
186126
187127 if (U.is_alias (out))
188128 {
@@ -199,7 +139,7 @@ op_sum::apply(Mat<typename T1::elem_type>& out, const Op< eOp<T1,eop_pow>, op_su
199139 }
200140 else
201141 {
202- const Proxy<inner_expr_type > P (in.m );
142+ const Proxy<T1 > P (in.m );
203143
204144 if (P.is_alias (out))
205145 {
0 commit comments