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