Mercurial > hg > segmenter-vamp-plugin
comparison armadillo-3.900.4/include/armadillo_bits/op_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 op_relational | |
10 //! @{ | |
11 | |
12 | |
13 #undef operator_rel | |
14 | |
15 #undef arma_applier_mat_pre | |
16 #undef arma_applier_mat_post | |
17 | |
18 #undef arma_applier_cube_pre | |
19 #undef arma_applier_cube_post | |
20 | |
21 | |
22 #define arma_applier_mat_pre(operator_rel) \ | |
23 {\ | |
24 typedef typename T1::elem_type eT;\ | |
25 typedef typename Proxy<T1>::ea_type ea_type;\ | |
26 \ | |
27 const eT val = X.aux;\ | |
28 \ | |
29 const Proxy<T1> P(X.m);\ | |
30 \ | |
31 const uword n_rows = P.get_n_rows();\ | |
32 const uword n_cols = P.get_n_cols();\ | |
33 \ | |
34 const bool bad_alias = ( Proxy<T1>::has_subview && P.is_alias(out) );\ | |
35 \ | |
36 if(bad_alias == false)\ | |
37 {\ | |
38 out.set_size(n_rows, n_cols);\ | |
39 \ | |
40 uword* out_mem = out.memptr();\ | |
41 \ | |
42 if(Proxy<T1>::prefer_at_accessor == false)\ | |
43 {\ | |
44 ea_type PA = P.get_ea();\ | |
45 const uword n_elem = out.n_elem;\ | |
46 \ | |
47 for(uword i=0; i<n_elem; ++i)\ | |
48 {\ | |
49 out_mem[i] = (val operator_rel PA[i]) ? uword(1) : uword(0);\ | |
50 }\ | |
51 }\ | |
52 else\ | |
53 {\ | |
54 if(n_rows == 1)\ | |
55 {\ | |
56 for(uword count=0; count < n_cols; ++count)\ | |
57 {\ | |
58 out_mem[count] = (val operator_rel P.at(0,count)) ? uword(1) : uword(0);\ | |
59 }\ | |
60 }\ | |
61 else\ | |
62 {\ | |
63 for(uword col=0; col < n_cols; ++col)\ | |
64 for(uword row=0; row < n_rows; ++row)\ | |
65 {\ | |
66 *out_mem = (val operator_rel P.at(row,col)) ? uword(1) : uword(0);\ | |
67 out_mem++;\ | |
68 }\ | |
69 }\ | |
70 }\ | |
71 }\ | |
72 else\ | |
73 {\ | |
74 const Mat<eT> tmp(P.Q);\ | |
75 \ | |
76 out = (val) operator_rel (tmp);\ | |
77 }\ | |
78 } | |
79 | |
80 | |
81 | |
82 #define arma_applier_mat_post(operator_rel) \ | |
83 {\ | |
84 typedef typename T1::elem_type eT;\ | |
85 typedef typename Proxy<T1>::ea_type ea_type;\ | |
86 \ | |
87 const eT val = X.aux;\ | |
88 \ | |
89 const Proxy<T1> P(X.m);\ | |
90 \ | |
91 const uword n_rows = P.get_n_rows();\ | |
92 const uword n_cols = P.get_n_cols();\ | |
93 \ | |
94 const bool bad_alias = ( Proxy<T1>::has_subview && P.is_alias(out) );\ | |
95 \ | |
96 if(bad_alias == false)\ | |
97 {\ | |
98 out.set_size(n_rows, n_cols);\ | |
99 \ | |
100 uword* out_mem = out.memptr();\ | |
101 \ | |
102 if(Proxy<T1>::prefer_at_accessor == false)\ | |
103 {\ | |
104 ea_type PA = P.get_ea();\ | |
105 const uword n_elem = out.n_elem;\ | |
106 \ | |
107 for(uword i=0; i<n_elem; ++i)\ | |
108 {\ | |
109 out_mem[i] = (PA[i] operator_rel val) ? uword(1) : uword(0);\ | |
110 }\ | |
111 }\ | |
112 else\ | |
113 {\ | |
114 if(n_rows == 1)\ | |
115 {\ | |
116 for(uword count=0; count < n_cols; ++count)\ | |
117 {\ | |
118 out_mem[count] = (P.at(0,count) operator_rel val) ? uword(1) : uword(0);\ | |
119 }\ | |
120 }\ | |
121 else\ | |
122 {\ | |
123 for(uword col=0; col < n_cols; ++col)\ | |
124 for(uword row=0; row < n_rows; ++row)\ | |
125 {\ | |
126 *out_mem = (P.at(row,col) operator_rel val) ? uword(1) : uword(0);\ | |
127 out_mem++;\ | |
128 }\ | |
129 }\ | |
130 }\ | |
131 }\ | |
132 else\ | |
133 {\ | |
134 const Mat<eT> tmp(P.Q);\ | |
135 \ | |
136 out = (tmp) operator_rel (val);\ | |
137 }\ | |
138 } | |
139 | |
140 | |
141 | |
142 #define arma_applier_cube_pre(operator_rel) \ | |
143 {\ | |
144 typedef typename T1::elem_type eT;\ | |
145 typedef typename ProxyCube<T1>::ea_type ea_type;\ | |
146 \ | |
147 const eT val = X.aux;\ | |
148 \ | |
149 const ProxyCube<T1> P(X.m);\ | |
150 \ | |
151 const uword n_rows = P.get_n_rows();\ | |
152 const uword n_cols = P.get_n_cols();\ | |
153 const uword n_slices = P.get_n_slices();\ | |
154 \ | |
155 const bool bad_alias = ( ProxyCube<T1>::has_subview && P.is_alias(out) );\ | |
156 \ | |
157 if(bad_alias == false)\ | |
158 {\ | |
159 out.set_size(n_rows, n_cols, n_slices);\ | |
160 \ | |
161 uword* out_mem = out.memptr();\ | |
162 \ | |
163 if(ProxyCube<T1>::prefer_at_accessor == false)\ | |
164 {\ | |
165 ea_type PA = P.get_ea();\ | |
166 const uword n_elem = out.n_elem;\ | |
167 \ | |
168 for(uword i=0; i<n_elem; ++i)\ | |
169 {\ | |
170 out_mem[i] = (val operator_rel PA[i]) ? uword(1) : uword(0);\ | |
171 }\ | |
172 }\ | |
173 else\ | |
174 {\ | |
175 for(uword slice=0; slice < n_slices; ++slice)\ | |
176 for(uword col=0; col < n_cols; ++col )\ | |
177 for(uword row=0; row < n_rows; ++row )\ | |
178 {\ | |
179 *out_mem = (val operator_rel P.at(row,col,slice)) ? uword(1) : uword(0);\ | |
180 out_mem++;\ | |
181 }\ | |
182 }\ | |
183 }\ | |
184 else\ | |
185 {\ | |
186 const unwrap_cube<typename ProxyCube<T1>::stored_type> tmp(P.Q);\ | |
187 \ | |
188 out = (val) operator_rel (tmp.M);\ | |
189 }\ | |
190 } | |
191 | |
192 | |
193 | |
194 #define arma_applier_cube_post(operator_rel) \ | |
195 {\ | |
196 typedef typename T1::elem_type eT;\ | |
197 typedef typename ProxyCube<T1>::ea_type ea_type;\ | |
198 \ | |
199 const eT val = X.aux;\ | |
200 \ | |
201 const ProxyCube<T1> P(X.m);\ | |
202 \ | |
203 const uword n_rows = P.get_n_rows();\ | |
204 const uword n_cols = P.get_n_cols();\ | |
205 const uword n_slices = P.get_n_slices();\ | |
206 \ | |
207 const bool bad_alias = ( ProxyCube<T1>::has_subview && P.is_alias(out) );\ | |
208 \ | |
209 if(bad_alias == false)\ | |
210 {\ | |
211 out.set_size(n_rows, n_cols, n_slices);\ | |
212 \ | |
213 uword* out_mem = out.memptr();\ | |
214 \ | |
215 if(ProxyCube<T1>::prefer_at_accessor == false)\ | |
216 {\ | |
217 ea_type PA = P.get_ea();\ | |
218 const uword n_elem = out.n_elem;\ | |
219 \ | |
220 for(uword i=0; i<n_elem; ++i)\ | |
221 {\ | |
222 out_mem[i] = (PA[i] operator_rel val) ? uword(1) : uword(0);\ | |
223 }\ | |
224 }\ | |
225 else\ | |
226 {\ | |
227 for(uword slice=0; slice < n_slices; ++slice)\ | |
228 for(uword col=0; col < n_cols; ++col )\ | |
229 for(uword row=0; row < n_rows; ++row )\ | |
230 {\ | |
231 *out_mem = (P.at(row,col,slice) operator_rel val) ? uword(1) : uword(0);\ | |
232 out_mem++;\ | |
233 }\ | |
234 }\ | |
235 }\ | |
236 else\ | |
237 {\ | |
238 const unwrap_cube<typename ProxyCube<T1>::stored_type> tmp(P.Q);\ | |
239 \ | |
240 out = (tmp.M) operator_rel (val);\ | |
241 }\ | |
242 } | |
243 | |
244 | |
245 | |
246 template<typename T1> | |
247 inline | |
248 void | |
249 op_rel_lt_pre::apply(Mat<uword>& out, const mtOp<uword, T1, op_rel_lt_pre>& X) | |
250 { | |
251 arma_extra_debug_sigprint(); | |
252 | |
253 arma_applier_mat_pre( < ); | |
254 } | |
255 | |
256 | |
257 | |
258 template<typename T1> | |
259 inline | |
260 void | |
261 op_rel_gt_pre::apply(Mat<uword>& out, const mtOp<uword, T1, op_rel_gt_pre>& X) | |
262 { | |
263 arma_extra_debug_sigprint(); | |
264 | |
265 arma_applier_mat_pre( > ); | |
266 } | |
267 | |
268 | |
269 | |
270 template<typename T1> | |
271 inline | |
272 void | |
273 op_rel_lteq_pre::apply(Mat<uword>& out, const mtOp<uword, T1, op_rel_lteq_pre>& X) | |
274 { | |
275 arma_extra_debug_sigprint(); | |
276 | |
277 arma_applier_mat_pre( <= ); | |
278 } | |
279 | |
280 | |
281 | |
282 template<typename T1> | |
283 inline | |
284 void | |
285 op_rel_gteq_pre::apply(Mat<uword>& out, const mtOp<uword, T1, op_rel_gteq_pre>& X) | |
286 { | |
287 arma_extra_debug_sigprint(); | |
288 | |
289 arma_applier_mat_pre( >= ); | |
290 } | |
291 | |
292 | |
293 | |
294 template<typename T1> | |
295 inline | |
296 void | |
297 op_rel_lt_post::apply(Mat<uword>& out, const mtOp<uword, T1, op_rel_lt_post>& X) | |
298 { | |
299 arma_extra_debug_sigprint(); | |
300 | |
301 arma_applier_mat_post( < ); | |
302 } | |
303 | |
304 | |
305 | |
306 template<typename T1> | |
307 inline | |
308 void | |
309 op_rel_gt_post::apply(Mat<uword>& out, const mtOp<uword, T1, op_rel_gt_post>& X) | |
310 { | |
311 arma_extra_debug_sigprint(); | |
312 | |
313 arma_applier_mat_post( > ); | |
314 } | |
315 | |
316 | |
317 | |
318 template<typename T1> | |
319 inline | |
320 void | |
321 op_rel_lteq_post::apply(Mat<uword>& out, const mtOp<uword, T1, op_rel_lteq_post>& X) | |
322 { | |
323 arma_extra_debug_sigprint(); | |
324 | |
325 arma_applier_mat_post( <= ); | |
326 } | |
327 | |
328 | |
329 | |
330 template<typename T1> | |
331 inline | |
332 void | |
333 op_rel_gteq_post::apply(Mat<uword>& out, const mtOp<uword, T1, op_rel_gteq_post>& X) | |
334 { | |
335 arma_extra_debug_sigprint(); | |
336 | |
337 arma_applier_mat_post( >= ); | |
338 } | |
339 | |
340 | |
341 | |
342 template<typename T1> | |
343 inline | |
344 void | |
345 op_rel_eq::apply(Mat<uword>& out, const mtOp<uword, T1, op_rel_eq>& X) | |
346 { | |
347 arma_extra_debug_sigprint(); | |
348 | |
349 arma_applier_mat_post( == ); | |
350 } | |
351 | |
352 | |
353 | |
354 template<typename T1> | |
355 inline | |
356 void | |
357 op_rel_noteq::apply(Mat<uword>& out, const mtOp<uword, T1, op_rel_noteq>& X) | |
358 { | |
359 arma_extra_debug_sigprint(); | |
360 | |
361 arma_applier_mat_post( != ); | |
362 } | |
363 | |
364 | |
365 | |
366 // | |
367 // | |
368 // | |
369 | |
370 | |
371 | |
372 template<typename T1> | |
373 inline | |
374 void | |
375 op_rel_lt_pre::apply(Cube<uword>& out, const mtOpCube<uword, T1, op_rel_lt_pre>& X) | |
376 { | |
377 arma_extra_debug_sigprint(); | |
378 | |
379 arma_applier_cube_pre( < ); | |
380 } | |
381 | |
382 | |
383 | |
384 template<typename T1> | |
385 inline | |
386 void | |
387 op_rel_gt_pre::apply(Cube<uword>& out, const mtOpCube<uword, T1, op_rel_gt_pre>& X) | |
388 { | |
389 arma_extra_debug_sigprint(); | |
390 | |
391 arma_applier_cube_pre( > ); | |
392 } | |
393 | |
394 | |
395 | |
396 template<typename T1> | |
397 inline | |
398 void | |
399 op_rel_lteq_pre::apply(Cube<uword>& out, const mtOpCube<uword, T1, op_rel_lteq_pre>& X) | |
400 { | |
401 arma_extra_debug_sigprint(); | |
402 | |
403 arma_applier_cube_pre( <= ); | |
404 } | |
405 | |
406 | |
407 | |
408 template<typename T1> | |
409 inline | |
410 void | |
411 op_rel_gteq_pre::apply(Cube<uword>& out, const mtOpCube<uword, T1, op_rel_gteq_pre>& X) | |
412 { | |
413 arma_extra_debug_sigprint(); | |
414 | |
415 arma_applier_cube_pre( >= ); | |
416 } | |
417 | |
418 | |
419 | |
420 template<typename T1> | |
421 inline | |
422 void | |
423 op_rel_lt_post::apply(Cube<uword>& out, const mtOpCube<uword, T1, op_rel_lt_post>& X) | |
424 { | |
425 arma_extra_debug_sigprint(); | |
426 | |
427 arma_applier_cube_post( < ); | |
428 } | |
429 | |
430 | |
431 | |
432 template<typename T1> | |
433 inline | |
434 void | |
435 op_rel_gt_post::apply(Cube<uword>& out, const mtOpCube<uword, T1, op_rel_gt_post>& X) | |
436 { | |
437 arma_extra_debug_sigprint(); | |
438 | |
439 arma_applier_cube_post( > ); | |
440 } | |
441 | |
442 | |
443 | |
444 template<typename T1> | |
445 inline | |
446 void | |
447 op_rel_lteq_post::apply(Cube<uword>& out, const mtOpCube<uword, T1, op_rel_lteq_post>& X) | |
448 { | |
449 arma_extra_debug_sigprint(); | |
450 | |
451 arma_applier_cube_post( <= ); | |
452 } | |
453 | |
454 | |
455 | |
456 template<typename T1> | |
457 inline | |
458 void | |
459 op_rel_gteq_post::apply(Cube<uword>& out, const mtOpCube<uword, T1, op_rel_gteq_post>& X) | |
460 { | |
461 arma_extra_debug_sigprint(); | |
462 | |
463 arma_applier_cube_post( >= ); | |
464 } | |
465 | |
466 | |
467 | |
468 template<typename T1> | |
469 inline | |
470 void | |
471 op_rel_eq::apply(Cube<uword>& out, const mtOpCube<uword, T1, op_rel_eq>& X) | |
472 { | |
473 arma_extra_debug_sigprint(); | |
474 | |
475 arma_applier_cube_post( == ); | |
476 } | |
477 | |
478 | |
479 | |
480 template<typename T1> | |
481 inline | |
482 void | |
483 op_rel_noteq::apply(Cube<uword>& out, const mtOpCube<uword, T1, op_rel_noteq>& X) | |
484 { | |
485 arma_extra_debug_sigprint(); | |
486 | |
487 arma_applier_cube_post( != ); | |
488 } | |
489 | |
490 | |
491 | |
492 #undef arma_applier_mat_pre | |
493 #undef arma_applier_mat_post | |
494 | |
495 #undef arma_applier_cube_pre | |
496 #undef arma_applier_cube_post | |
497 | |
498 | |
499 | |
500 //! @} |