@@ -28,46 +28,7 @@ op_sum::apply(Mat<typename T1::elem_type>& out, const Op<T1,op_sum>& in)
28
28
{
29
29
arma_debug_sigprint ();
30
30
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);
71
32
}
72
33
73
34
@@ -85,12 +46,12 @@ op_sum::apply(Mat<typename T1::elem_type>& out, const Op< eOp<T1,eop_square>, op
85
46
86
47
typedef typename inner_expr_type::proxy_type::stored_type inner_expr_P_stored_type;
87
48
88
- const uword dim = in.aux_uword_a ;
89
-
90
- arma_conform_check ( (dim > 1 ), " sum(): parameter 'dim' must be 0 or 1" );
91
-
92
49
if (is_Mat<inner_expr_P_stored_type>::value)
93
50
{
51
+ const uword dim = in.aux_uword_a ;
52
+
53
+ arma_conform_check ( (dim > 1 ), " sum(): parameter 'dim' must be 0 or 1" );
54
+
94
55
const quasi_unwrap<inner_expr_P_stored_type> U (in.m .P .Q );
95
56
96
57
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
105
66
{
106
67
op_sum::apply_mat_square_noalias (out, U.M , dim);
107
68
}
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
113
69
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 ;
143
71
}
72
+
73
+ op_sum::apply_generic (out, in);
144
74
}
145
75
146
76
@@ -172,17 +102,27 @@ op_sum::apply(Mat<typename T1::elem_type>& out, const Op< eOp<T1,eop_pow>, op_su
172
102
return ;
173
103
}
174
104
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 ();
176
116
177
- typedef typename inner_expr_type::proxy_type::stored_type inner_expr_P_stored_type ;
117
+ typedef typename T1::elem_type eT ;
178
118
179
119
const uword dim = in.aux_uword_a ;
180
120
181
121
arma_conform_check ( (dim > 1 ), " sum(): parameter 'dim' must be 0 or 1" );
182
122
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))
184
124
{
185
- const quasi_unwrap<inner_expr_type > U (in.m ); // force evaluation of eop_pow
125
+ const quasi_unwrap<T1 > U (in.m );
186
126
187
127
if (U.is_alias (out))
188
128
{
@@ -199,7 +139,7 @@ op_sum::apply(Mat<typename T1::elem_type>& out, const Op< eOp<T1,eop_pow>, op_su
199
139
}
200
140
else
201
141
{
202
- const Proxy<inner_expr_type > P (in.m );
142
+ const Proxy<T1 > P (in.m );
203
143
204
144
if (P.is_alias (out))
205
145
{
0 commit comments