op_relational_meat.hpp
Go to the documentation of this file.
1 // Copyright (C) 2009-2010 NICTA (www.nicta.com.au)
2 // Copyright (C) 2009-2010 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 
16 
17 
18 
19 template<typename T1>
20 inline
21 void
23  {
25 
26  typedef typename T1::elem_type eT;
27  typedef typename Proxy<T1>::ea_type ea_type;
28 
29  const Proxy<T1> Y(X.m);
30 
31  out.set_size(Y.get_n_rows(), Y.get_n_cols());
32 
33  const eT val = X.aux;
34  ea_type A = Y.get_ea();
35  uword* out_mem = out.memptr();
36  const uword n_elem = out.n_elem;
37 
38  uword i,j;
39 
40  for(i=0, j=1; j<n_elem; i+=2, j+=2)
41  {
42  out_mem[i] = (val < A[i]) ? uword(1) : uword(0);
43  out_mem[j] = (val < A[j]) ? uword(1) : uword(0);
44  }
45 
46  if(i < n_elem)
47  {
48  out_mem[i] = (val < A[i]) ? uword(1) : uword(0);
49  }
50  }
51 
52 
53 
54 template<typename T1>
55 inline
56 void
58  {
60 
61  typedef typename T1::elem_type eT;
62  typedef typename Proxy<T1>::ea_type ea_type;
63 
64  const Proxy<T1> Y(X.m);
65 
66  out.set_size(Y.get_n_rows(), Y.get_n_cols());
67 
68  const eT val = X.aux;
69  ea_type A = Y.get_ea();
70  uword* out_mem = out.memptr();
71  const uword n_elem = out.n_elem;
72 
73  uword i,j;
74 
75  for(i=0, j=1; j<n_elem; i+=2, j+=2)
76  {
77  out_mem[i] = (A[i] < val) ? uword(1) : uword(0);
78  out_mem[j] = (A[j] < val) ? uword(1) : uword(0);
79  }
80 
81  if(i < n_elem)
82  {
83  out_mem[i] = (A[i] < val) ? uword(1) : uword(0);
84  }
85  }
86 
87 
88 
89 template<typename T1>
90 inline
91 void
93  {
95 
96  typedef typename T1::elem_type eT;
97  typedef typename Proxy<T1>::ea_type ea_type;
98 
99  const Proxy<T1> Y(X.m);
100 
101  out.set_size(Y.get_n_rows(), Y.get_n_cols());
102 
103  const eT val = X.aux;
104  ea_type A = Y.get_ea();
105  uword* out_mem = out.memptr();
106  const uword n_elem = out.n_elem;
107 
108  uword i,j;
109 
110  for(i=0, j=1; j<n_elem; i+=2, j+=2)
111  {
112  out_mem[i] = (val > A[i]) ? uword(1) : uword(0);
113  out_mem[j] = (val > A[j]) ? uword(1) : uword(0);
114  }
115 
116  if(i < n_elem)
117  {
118  out_mem[i] = (val > A[i]) ? uword(1) : uword(0);
119  }
120  }
121 
122 
123 
124 template<typename T1>
125 inline
126 void
128  {
130 
131  typedef typename T1::elem_type eT;
132  typedef typename Proxy<T1>::ea_type ea_type;
133 
134  const Proxy<T1> Y(X.m);
135 
136  out.set_size(Y.get_n_rows(), Y.get_n_cols());
137 
138  const eT val = X.aux;
139  ea_type A = Y.get_ea();
140  uword* out_mem = out.memptr();
141  const uword n_elem = out.n_elem;
142 
143  uword i,j;
144 
145  for(i=0, j=1; j<n_elem; i+=2, j+=2)
146  {
147  out_mem[i] = (A[i] > val) ? uword(1) : uword(0);
148  out_mem[j] = (A[j] > val) ? uword(1) : uword(0);
149  }
150 
151  if(i < n_elem)
152  {
153  out_mem[i] = (A[i] > val) ? uword(1) : uword(0);
154  }
155  }
156 
157 
158 
159 template<typename T1>
160 inline
161 void
163  {
165 
166  typedef typename T1::elem_type eT;
167  typedef typename Proxy<T1>::ea_type ea_type;
168 
169  const Proxy<T1> Y(X.m);
170 
171  out.set_size(Y.get_n_rows(), Y.get_n_cols());
172 
173  const eT val = X.aux;
174  ea_type A = Y.get_ea();
175  uword* out_mem = out.memptr();
176  const uword n_elem = out.n_elem;
177 
178  uword i,j;
179 
180  for(i=0, j=1; j<n_elem; i+=2, j+=2)
181  {
182  out_mem[i] = (val <= A[i]) ? uword(1) : uword(0);
183  out_mem[j] = (val <= A[j]) ? uword(1) : uword(0);
184  }
185 
186  if(i < n_elem)
187  {
188  out_mem[i] = (val <= A[i]) ? uword(1) : uword(0);
189  }
190  }
191 
192 
193 
194 template<typename T1>
195 inline
196 void
198  {
200 
201  typedef typename T1::elem_type eT;
202  typedef typename Proxy<T1>::ea_type ea_type;
203 
204  const Proxy<T1> Y(X.m);
205 
206  out.set_size(Y.get_n_rows(), Y.get_n_cols());
207 
208  const eT val = X.aux;
209  ea_type A = Y.get_ea();
210  uword* out_mem = out.memptr();
211  const uword n_elem = out.n_elem;
212 
213  uword i,j;
214 
215  for(i=0, j=1; j<n_elem; i+=2, j+=2)
216  {
217  out_mem[i] = (A[i] <= val) ? uword(1) : uword(0);
218  out_mem[j] = (A[j] <= val) ? uword(1) : uword(0);
219  }
220 
221  if(i < n_elem)
222  {
223  out_mem[i] = (A[i] <= val) ? uword(1) : uword(0);
224  }
225  }
226 
227 
228 
229 template<typename T1>
230 inline
231 void
233  {
235 
236  typedef typename T1::elem_type eT;
237  typedef typename Proxy<T1>::ea_type ea_type;
238 
239  const Proxy<T1> Y(X.m);
240 
241  out.set_size(Y.get_n_rows(), Y.get_n_cols());
242 
243  const eT val = X.aux;
244  ea_type A = Y.get_ea();
245  uword* out_mem = out.memptr();
246  const uword n_elem = out.n_elem;
247 
248  uword i,j;
249 
250  for(i=0, j=1; j<n_elem; i+=2, j+=2)
251  {
252  out_mem[i] = (val >= A[i]) ? uword(1) : uword(0);
253  out_mem[j] = (val >= A[j]) ? uword(1) : uword(0);
254  }
255 
256  if(i < n_elem)
257  {
258  out_mem[i] = (val >= A[i]) ? uword(1) : uword(0);
259  }
260  }
261 
262 
263 
264 template<typename T1>
265 inline
266 void
268  {
270 
271  typedef typename T1::elem_type eT;
272  typedef typename Proxy<T1>::ea_type ea_type;
273 
274  const Proxy<T1> Y(X.m);
275 
276  out.set_size(Y.get_n_rows(), Y.get_n_cols());
277 
278  const eT val = X.aux;
279  ea_type A = Y.get_ea();
280  uword* out_mem = out.memptr();
281  const uword n_elem = out.n_elem;
282 
283  uword i,j;
284 
285  for(i=0, j=1; j<n_elem; i+=2, j+=2)
286  {
287  out_mem[i] = (A[i] >= val) ? uword(1) : uword(0);
288  out_mem[j] = (A[j] >= val) ? uword(1) : uword(0);
289  }
290 
291  if(i < n_elem)
292  {
293  out_mem[i] = (A[i] >= val) ? uword(1) : uword(0);
294  }
295  }
296 
297 
298 
299 template<typename T1>
300 inline
301 void
303  {
305 
306  typedef typename T1::elem_type eT;
307  typedef typename Proxy<T1>::ea_type ea_type;
308 
309  const Proxy<T1> Y(X.m);
310 
311  out.set_size(Y.get_n_rows(), Y.get_n_cols());
312 
313  const eT val = X.aux;
314  ea_type A = Y.get_ea();
315  uword* out_mem = out.memptr();
316  const uword n_elem = out.n_elem;
317 
318  uword i,j;
319 
320  for(i=0, j=1; j<n_elem; i+=2, j+=2)
321  {
322  out_mem[i] = (A[i] == val) ? uword(1) : uword(0);
323  out_mem[j] = (A[j] == val) ? uword(1) : uword(0);
324  }
325 
326  if(i < n_elem)
327  {
328  out_mem[i] = (A[i] == val) ? uword(1) : uword(0);
329  }
330  }
331 
332 
333 
334 template<typename T1>
335 inline
336 void
338  {
340 
341  typedef typename T1::elem_type eT;
342  typedef typename Proxy<T1>::ea_type ea_type;
343 
344  const Proxy<T1> Y(X.m);
345 
346  out.set_size(Y.get_n_rows(), Y.get_n_cols());
347 
348  const eT val = X.aux;
349  ea_type A = Y.get_ea();
350  uword* out_mem = out.memptr();
351  const uword n_elem = out.n_elem;
352 
353  uword i,j;
354 
355  for(i=0, j=1; j<n_elem; i+=2, j+=2)
356  {
357  out_mem[i] = (A[i] != val) ? uword(1) : uword(0);
358  out_mem[j] = (A[j] != val) ? uword(1) : uword(0);
359  }
360 
361  if(i < n_elem)
362  {
363  out_mem[i] = (A[i] != val) ? uword(1) : uword(0);
364  }
365  }
366 
367 
368 
369 //
370 //
371 //
372 
373 
374 
375 template<typename T1>
376 inline
377 void
379  {
381 
382  typedef typename T1::elem_type eT;
383  typedef typename ProxyCube<T1>::ea_type ea_type;
384 
385  const ProxyCube<T1> Y(X.m);
386 
387  out.set_size(Y.get_n_rows(), Y.get_n_cols(), Y.get_n_slices());
388 
389  const eT val = X.aux;
390  ea_type A = Y.get_ea();
391  uword* out_mem = out.memptr();
392  const uword n_elem = out.n_elem;
393 
394  uword i,j;
395 
396  for(i=0, j=1; j<n_elem; i+=2, j+=2)
397  {
398  out_mem[i] = (val < A[i]) ? uword(1) : uword(0);
399  out_mem[j] = (val < A[j]) ? uword(1) : uword(0);
400  }
401 
402  if(i < n_elem)
403  {
404  out_mem[i] = (val < A[i]) ? uword(1) : uword(0);
405  }
406  }
407 
408 
409 
410 template<typename T1>
411 inline
412 void
414  {
416 
417  typedef typename T1::elem_type eT;
418  typedef typename ProxyCube<T1>::ea_type ea_type;
419 
420  const ProxyCube<T1> Y(X.m);
421 
422  out.set_size(Y.get_n_rows(), Y.get_n_cols(), Y.get_n_slices());
423 
424  const eT val = X.aux;
425  ea_type A = Y.get_ea();
426  uword* out_mem = out.memptr();
427  const uword n_elem = out.n_elem;
428 
429  uword i,j;
430 
431  for(i=0, j=1; j<n_elem; i+=2, j+=2)
432  {
433  out_mem[i] = (A[i] < val) ? uword(1) : uword(0);
434  out_mem[j] = (A[j] < val) ? uword(1) : uword(0);
435  }
436 
437  if(i < n_elem)
438  {
439  out_mem[i] = (A[i] < val) ? uword(1) : uword(0);
440  }
441  }
442 
443 
444 
445 template<typename T1>
446 inline
447 void
449  {
451 
452  typedef typename T1::elem_type eT;
453  typedef typename ProxyCube<T1>::ea_type ea_type;
454 
455  const ProxyCube<T1> Y(X.m);
456 
457  out.set_size(Y.get_n_rows(), Y.get_n_cols(), Y.get_n_slices());
458 
459  const eT val = X.aux;
460  ea_type A = Y.get_ea();
461  uword* out_mem = out.memptr();
462  const uword n_elem = out.n_elem;
463 
464  uword i,j;
465 
466  for(i=0, j=1; j<n_elem; i+=2, j+=2)
467  {
468  out_mem[i] = (val > A[i]) ? uword(1) : uword(0);
469  out_mem[j] = (val > A[j]) ? uword(1) : uword(0);
470  }
471 
472  if(i < n_elem)
473  {
474  out_mem[i] = (val > A[i]) ? uword(1) : uword(0);
475  }
476  }
477 
478 
479 
480 template<typename T1>
481 inline
482 void
484  {
486 
487  typedef typename T1::elem_type eT;
488  typedef typename ProxyCube<T1>::ea_type ea_type;
489 
490  const ProxyCube<T1> Y(X.m);
491 
492  out.set_size(Y.get_n_rows(), Y.get_n_cols(), Y.get_n_slices());
493 
494  const eT val = X.aux;
495  ea_type A = Y.get_ea();
496  uword* out_mem = out.memptr();
497  const uword n_elem = out.n_elem;
498 
499  uword i,j;
500 
501  for(i=0, j=1; j<n_elem; i+=2, j+=2)
502  {
503  out_mem[i] = (A[i] > val) ? uword(1) : uword(0);
504  out_mem[j] = (A[j] > val) ? uword(1) : uword(0);
505  }
506 
507  if(i < n_elem)
508  {
509  out_mem[i] = (A[i] > val) ? uword(1) : uword(0);
510  }
511  }
512 
513 
514 
515 template<typename T1>
516 inline
517 void
519  {
521 
522  typedef typename T1::elem_type eT;
523  typedef typename ProxyCube<T1>::ea_type ea_type;
524 
525  const ProxyCube<T1> Y(X.m);
526 
527  out.set_size(Y.get_n_rows(), Y.get_n_cols(), Y.get_n_slices());
528 
529  const eT val = X.aux;
530  ea_type A = Y.get_ea();
531  uword* out_mem = out.memptr();
532  const uword n_elem = out.n_elem;
533 
534  uword i,j;
535 
536  for(i=0, j=1; j<n_elem; i+=2, j+=2)
537  {
538  out_mem[i] = (val <= A[i]) ? uword(1) : uword(0);
539  out_mem[j] = (val <= A[j]) ? uword(1) : uword(0);
540  }
541 
542  if(i < n_elem)
543  {
544  out_mem[i] = (val <= A[i]) ? uword(1) : uword(0);
545  }
546  }
547 
548 
549 
550 template<typename T1>
551 inline
552 void
554  {
556 
557  typedef typename T1::elem_type eT;
558  typedef typename ProxyCube<T1>::ea_type ea_type;
559 
560  const ProxyCube<T1> Y(X.m);
561 
562  out.set_size(Y.get_n_rows(), Y.get_n_cols(), Y.get_n_slices());
563 
564  const eT val = X.aux;
565  ea_type A = Y.get_ea();
566  uword* out_mem = out.memptr();
567  const uword n_elem = out.n_elem;
568 
569  uword i,j;
570 
571  for(i=0, j=1; j<n_elem; i+=2, j+=2)
572  {
573  out_mem[i] = (A[i] <= val) ? uword(1) : uword(0);
574  out_mem[j] = (A[j] <= val) ? uword(1) : uword(0);
575  }
576 
577  if(i < n_elem)
578  {
579  out_mem[i] = (A[i] <= val) ? uword(1) : uword(0);
580  }
581  }
582 
583 
584 
585 template<typename T1>
586 inline
587 void
589  {
591 
592  typedef typename T1::elem_type eT;
593  typedef typename ProxyCube<T1>::ea_type ea_type;
594 
595  const ProxyCube<T1> Y(X.m);
596 
597  out.set_size(Y.get_n_rows(), Y.get_n_cols(), Y.get_n_slices());
598 
599  const eT val = X.aux;
600  ea_type A = Y.get_ea();
601  uword* out_mem = out.memptr();
602  const uword n_elem = out.n_elem;
603 
604  uword i,j;
605 
606  for(i=0, j=1; j<n_elem; i+=2, j+=2)
607  {
608  out_mem[i] = (val >= A[i]) ? uword(1) : uword(0);
609  out_mem[j] = (val >= A[j]) ? uword(1) : uword(0);
610  }
611 
612  if(i < n_elem)
613  {
614  out_mem[i] = (val >= A[i]) ? uword(1) : uword(0);
615  }
616  }
617 
618 
619 
620 template<typename T1>
621 inline
622 void
624  {
626 
627  typedef typename T1::elem_type eT;
628  typedef typename ProxyCube<T1>::ea_type ea_type;
629 
630  const ProxyCube<T1> Y(X.m);
631 
632  out.set_size(Y.get_n_rows(), Y.get_n_cols(), Y.get_n_slices());
633 
634  const eT val = X.aux;
635  ea_type A = Y.get_ea();
636  uword* out_mem = out.memptr();
637  const uword n_elem = out.n_elem;
638 
639  uword i,j;
640 
641  for(i=0, j=1; j<n_elem; i+=2, j+=2)
642  {
643  out_mem[i] = (A[i] >= val) ? uword(1) : uword(0);
644  out_mem[j] = (A[j] >= val) ? uword(1) : uword(0);
645  }
646 
647  if(i < n_elem)
648  {
649  out_mem[i] = (A[i] >= val) ? uword(1) : uword(0);
650  }
651  }
652 
653 
654 
655 template<typename T1>
656 inline
657 void
659  {
661 
662  typedef typename T1::elem_type eT;
663  typedef typename ProxyCube<T1>::ea_type ea_type;
664 
665  const ProxyCube<T1> Y(X.m);
666 
667  out.set_size(Y.get_n_rows(), Y.get_n_cols(), Y.get_n_slices());
668 
669  const eT val = X.aux;
670  ea_type A = Y.get_ea();
671  uword* out_mem = out.memptr();
672  const uword n_elem = out.n_elem;
673 
674  uword i,j;
675 
676  for(i=0, j=1; j<n_elem; i+=2, j+=2)
677  {
678  out_mem[i] = (A[i] == val) ? uword(1) : uword(0);
679  out_mem[j] = (A[j] == val) ? uword(1) : uword(0);
680  }
681 
682  if(i < n_elem)
683  {
684  out_mem[i] = (A[i] == val) ? uword(1) : uword(0);
685  }
686  }
687 
688 
689 
690 template<typename T1>
691 inline
692 void
694  {
696 
697  typedef typename T1::elem_type eT;
698  typedef typename ProxyCube<T1>::ea_type ea_type;
699 
700  const ProxyCube<T1> Y(X.m);
701 
702  out.set_size(Y.get_n_rows(), Y.get_n_cols(), Y.get_n_slices());
703 
704  const eT val = X.aux;
705  ea_type A = Y.get_ea();
706  uword* out_mem = out.memptr();
707  const uword n_elem = out.n_elem;
708 
709  uword i,j;
710 
711  for(i=0, j=1; j<n_elem; i+=2, j+=2)
712  {
713  out_mem[i] = (A[i] != val) ? uword(1) : uword(0);
714  out_mem[j] = (A[j] != val) ? uword(1) : uword(0);
715  }
716 
717  if(i < n_elem)
718  {
719  out_mem[i] = (A[i] != val) ? uword(1) : uword(0);
720  }
721  }
722 
723 
724 
arma_inline arma_warn_unused eT * memptr()
returns a pointer to array of eTs used by the matrix
Definition: Mat_meat.hpp:4024
arma_aligned in_eT aux
storage of auxiliary data, using the element type as used by T1
static void apply(Mat< uword > &out, const mtOp< uword, T1, op_rel_gt_pre > &X)
void set_size(const uword in_elem)
change the matrix to have user specified dimensions (data is not preserved)
Definition: Mat_meat.hpp:4211
arma_aligned const T1 & m
storage of reference to the operand (eg. a matrix)
Definition: mtOp_bones.hpp:39
arma_aligned in_eT aux
storage of auxiliary data, using the element type as used by T1
Definition: mtOp_bones.hpp:40
void set_size(const uword in_rows, const uword in_cols, const uword in_slices)
change the cube to have user specified dimensions (data is not preserved)
Definition: Cube_meat.hpp:2414
const uword n_elem
number of elements in the matrix (read-only)
Definition: Mat_bones.hpp:31
static void apply(Mat< uword > &out, const mtOp< uword, T1, op_rel_gt_post > &X)
static void apply(Mat< uword > &out, const mtOp< uword, T1, op_rel_lt_pre > &X)
u32 uword
Definition: typedef.hpp:85
arma_inline arma_warn_unused eT * memptr()
returns a pointer to array of eTs used by the cube
Definition: Cube_meat.hpp:2260
Dense cube class.
Definition: Cube_bones.hpp:30
static void apply(Mat< uword > &out, const mtOp< uword, T1, op_rel_gteq_pre > &X)
#define arma_extra_debug_sigprint
Definition: debug.hpp:1116
static void apply(Mat< uword > &out, const mtOp< uword, T1, op_rel_gteq_post > &X)
const uword n_elem
number of elements in the cube (read-only)
Definition: Cube_bones.hpp:41
Dense matrix class.
static void apply(Mat< uword > &out, const mtOp< uword, T1, op_rel_lteq_pre > &X)
static void apply(Mat< uword > &out, const mtOp< uword, T1, op_rel_noteq > &X)
static void apply(Mat< uword > &out, const mtOp< uword, T1, op_rel_lt_post > &X)
static void apply(Mat< uword > &out, const mtOp< uword, T1, op_rel_eq > &X)
arma_aligned const T1 & m
storage of reference to the operand (eg. a matrix)
static void apply(Mat< uword > &out, const mtOp< uword, T1, op_rel_lteq_post > &X)


armadillo_matrix
Author(s):
autogenerated on Fri Apr 16 2021 02:31:58