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