comparison armadillo-3.900.4/include/armadillo_bits/glue_relational_meat.hpp @ 49:1ec0e2823891

Switch to using subrepo copies of qm-dsp, nnls-chroma, vamp-plugin-sdk; update Armadillo version; assume build without external BLAS/LAPACK
author Chris Cannam
date Thu, 13 Jun 2013 10:25:24 +0100
parents
children
comparison
equal deleted inserted replaced
48:69251e11a913 49:1ec0e2823891
1 // Copyright (C) 2009-2012 NICTA (www.nicta.com.au)
2 // Copyright (C) 2009-2012 Conrad Sanderson
3 //
4 // This Source Code Form is subject to the terms of the Mozilla Public
5 // License, v. 2.0. If a copy of the MPL was not distributed with this
6 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
7
8
9 //! \addtogroup glue_relational
10 //! @{
11
12
13
14 #undef operator_rel
15 #undef operator_str
16
17 #undef arma_applier_mat
18 #undef arma_applier_cube
19
20
21 #define arma_applier_mat(operator_rel, operator_str) \
22 {\
23 const Proxy<T1> P1(X.A);\
24 const Proxy<T2> P2(X.B);\
25 \
26 arma_debug_assert_same_size(P1, P2, operator_str);\
27 \
28 const bool bad_alias = (Proxy<T1>::has_subview && P1.is_alias(out)) || (Proxy<T2>::has_subview && P2.is_alias(out));\
29 \
30 if(bad_alias == false)\
31 {\
32 \
33 const uword n_rows = P1.get_n_rows();\
34 const uword n_cols = P1.get_n_cols();\
35 \
36 out.set_size(n_rows, n_cols);\
37 \
38 uword* out_mem = out.memptr();\
39 \
40 const bool prefer_at_accessor = (Proxy<T1>::prefer_at_accessor || Proxy<T2>::prefer_at_accessor);\
41 \
42 if(prefer_at_accessor == false)\
43 {\
44 typename Proxy<T1>::ea_type A = P1.get_ea();\
45 typename Proxy<T2>::ea_type B = P2.get_ea();\
46 \
47 const uword n_elem = out.n_elem;\
48 \
49 for(uword i=0; i<n_elem; ++i)\
50 {\
51 out_mem[i] = (A[i] operator_rel B[i]) ? uword(1) : uword(0);\
52 }\
53 }\
54 else\
55 {\
56 if(n_rows == 1)\
57 {\
58 for(uword count=0; count < n_cols; ++count)\
59 {\
60 out_mem[count] = (P1.at(0,count) operator_rel P2.at(0,count)) ? uword(1) : uword(0);\
61 }\
62 }\
63 else\
64 {\
65 for(uword col=0; col<n_cols; ++col)\
66 for(uword row=0; row<n_rows; ++row)\
67 {\
68 *out_mem = (P1.at(row,col) operator_rel P2.at(row,col)) ? uword(1) : uword(0);\
69 out_mem++;\
70 }\
71 }\
72 }\
73 }\
74 else\
75 {\
76 const unwrap_check<typename Proxy<T1>::stored_type> tmp1(P1.Q, P1.is_alias(out));\
77 const unwrap_check<typename Proxy<T2>::stored_type> tmp2(P2.Q, P2.is_alias(out));\
78 \
79 out = (tmp1.M) operator_rel (tmp2.M);\
80 }\
81 }
82
83
84
85
86 #define arma_applier_cube(operator_rel, operator_str) \
87 {\
88 const ProxyCube<T1> P1(X.A);\
89 const ProxyCube<T2> P2(X.B);\
90 \
91 arma_debug_assert_same_size(P1, P2, operator_str);\
92 \
93 const bool bad_alias = (ProxyCube<T1>::has_subview && P1.is_alias(out)) || (ProxyCube<T2>::has_subview && P2.is_alias(out));\
94 \
95 if(bad_alias == false)\
96 {\
97 \
98 const uword n_rows = P1.get_n_rows();\
99 const uword n_cols = P1.get_n_cols();\
100 const uword n_slices = P1.get_n_slices();\
101 \
102 out.set_size(n_rows, n_cols, n_slices);\
103 \
104 uword* out_mem = out.memptr();\
105 \
106 const bool prefer_at_accessor = (ProxyCube<T1>::prefer_at_accessor || ProxyCube<T2>::prefer_at_accessor);\
107 \
108 if(prefer_at_accessor == false)\
109 {\
110 typename ProxyCube<T1>::ea_type A = P1.get_ea();\
111 typename ProxyCube<T2>::ea_type B = P2.get_ea();\
112 \
113 const uword n_elem = out.n_elem;\
114 \
115 for(uword i=0; i<n_elem; ++i)\
116 {\
117 out_mem[i] = (A[i] operator_rel B[i]) ? uword(1) : uword(0);\
118 }\
119 }\
120 else\
121 {\
122 for(uword slice = 0; slice < n_slices; ++slice)\
123 for(uword col = 0; col < n_cols; ++col )\
124 for(uword row = 0; row < n_rows; ++row )\
125 {\
126 *out_mem = (P1.at(row,col,slice) operator_rel P2.at(row,col,slice)) ? uword(1) : uword(0);\
127 out_mem++;\
128 }\
129 }\
130 }\
131 else\
132 {\
133 const unwrap_cube<typename ProxyCube<T1>::stored_type> tmp1(P1.Q);\
134 const unwrap_cube<typename ProxyCube<T2>::stored_type> tmp2(P2.Q);\
135 \
136 out = (tmp1.M) operator_rel (tmp2.M);\
137 }\
138 }
139
140
141
142 template<typename T1, typename T2>
143 inline
144 void
145 glue_rel_lt::apply
146 (
147 Mat <uword>& out,
148 const mtGlue<uword, T1, T2, glue_rel_lt>& X
149 )
150 {
151 arma_extra_debug_sigprint();
152
153 arma_applier_mat(<, "operator<");
154 }
155
156
157
158 template<typename T1, typename T2>
159 inline
160 void
161 glue_rel_gt::apply
162 (
163 Mat <uword>& out,
164 const mtGlue<uword, T1, T2, glue_rel_gt>& X
165 )
166 {
167 arma_extra_debug_sigprint();
168
169 arma_applier_mat(>, "operator>");
170 }
171
172
173
174 template<typename T1, typename T2>
175 inline
176 void
177 glue_rel_lteq::apply
178 (
179 Mat <uword>& out,
180 const mtGlue<uword, T1, T2, glue_rel_lteq>& X
181 )
182 {
183 arma_extra_debug_sigprint();
184
185 arma_applier_mat(<=, "operator<=");
186 }
187
188
189
190 template<typename T1, typename T2>
191 inline
192 void
193 glue_rel_gteq::apply
194 (
195 Mat <uword>& out,
196 const mtGlue<uword, T1, T2, glue_rel_gteq>& X
197 )
198 {
199 arma_extra_debug_sigprint();
200
201 arma_applier_mat(>=, "operator>=");
202 }
203
204
205
206 template<typename T1, typename T2>
207 inline
208 void
209 glue_rel_eq::apply
210 (
211 Mat <uword>& out,
212 const mtGlue<uword, T1, T2, glue_rel_eq>& X
213 )
214 {
215 arma_extra_debug_sigprint();
216
217 arma_applier_mat(==, "operator==");
218 }
219
220
221
222 template<typename T1, typename T2>
223 inline
224 void
225 glue_rel_noteq::apply
226 (
227 Mat <uword>& out,
228 const mtGlue<uword, T1, T2, glue_rel_noteq>& X
229 )
230 {
231 arma_extra_debug_sigprint();
232
233 arma_applier_mat(!=, "operator!=");
234 }
235
236
237
238 //
239 //
240 //
241
242
243
244 template<typename T1, typename T2>
245 inline
246 void
247 glue_rel_lt::apply
248 (
249 Cube <uword>& out,
250 const mtGlueCube<uword, T1, T2, glue_rel_lt>& X
251 )
252 {
253 arma_extra_debug_sigprint();
254
255 arma_applier_cube(<, "operator<");
256 }
257
258
259
260 template<typename T1, typename T2>
261 inline
262 void
263 glue_rel_gt::apply
264 (
265 Cube <uword>& out,
266 const mtGlueCube<uword, T1, T2, glue_rel_gt>& X
267 )
268 {
269 arma_extra_debug_sigprint();
270
271 arma_applier_cube(>, "operator>");
272 }
273
274
275
276 template<typename T1, typename T2>
277 inline
278 void
279 glue_rel_lteq::apply
280 (
281 Cube <uword>& out,
282 const mtGlueCube<uword, T1, T2, glue_rel_lteq>& X
283 )
284 {
285 arma_extra_debug_sigprint();
286
287 arma_applier_cube(<=, "operator<=");
288 }
289
290
291
292 template<typename T1, typename T2>
293 inline
294 void
295 glue_rel_gteq::apply
296 (
297 Cube <uword>& out,
298 const mtGlueCube<uword, T1, T2, glue_rel_gteq>& X
299 )
300 {
301 arma_extra_debug_sigprint();
302
303 arma_applier_cube(>=, "operator>=");
304 }
305
306
307
308 template<typename T1, typename T2>
309 inline
310 void
311 glue_rel_eq::apply
312 (
313 Cube <uword>& out,
314 const mtGlueCube<uword, T1, T2, glue_rel_eq>& X
315 )
316 {
317 arma_extra_debug_sigprint();
318
319 arma_applier_cube(==, "operator==");
320 }
321
322
323
324 template<typename T1, typename T2>
325 inline
326 void
327 glue_rel_noteq::apply
328 (
329 Cube <uword>& out,
330 const mtGlueCube<uword, T1, T2, glue_rel_noteq>& X
331 )
332 {
333 arma_extra_debug_sigprint();
334
335 arma_applier_cube(!=, "operator!=");
336 }
337
338
339
340 #undef arma_applier_mat
341 #undef arma_applier_cube
342
343
344
345 //! @}