glue_relational_meat.hpp
Go to the documentation of this file.
1 // Copyright (C) 2009-2011 NICTA (www.nicta.com.au)
2 // Copyright (C) 2009-2011 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 #undef operator_rel
20 #undef operator_str
21 
22 #undef arma_applier_mat
23 #undef arma_applier_cube
24 
25 
26 #define arma_applier_mat(operator_rel, operator_str) \
27  {\
28  const Proxy<T1> P1(X.A);\
29  const Proxy<T2> P2(X.B);\
30  \
31  arma_debug_assert_same_size(P1, P2, operator_str);\
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  uword count = 0;\
57  \
58  for(uword col=0; col<n_cols; ++col)\
59  {\
60  for(uword row=0; row<n_rows; ++row, ++count)\
61  {\
62  out_mem[count] = (P1.at(row,col) operator_rel P2.at(row,col)) ? uword(1) : uword(0);\
63  }\
64  }\
65  }\
66  }
67 
68 
69 
70 
71 #define arma_applier_cube(operator_rel, operator_str) \
72  {\
73  const ProxyCube<T1> P1(X.A);\
74  const ProxyCube<T2> P2(X.B);\
75  \
76  arma_debug_assert_same_size(P1, P2, operator_str);\
77  \
78  const uword n_rows = P1.get_n_rows();\
79  const uword n_cols = P1.get_n_cols();\
80  const uword n_slices = P1.get_n_slices();\
81  \
82  out.set_size(n_rows, n_cols, n_slices);\
83  \
84  uword* out_mem = out.memptr();\
85  \
86  const bool prefer_at_accessor = (ProxyCube<T1>::prefer_at_accessor || ProxyCube<T2>::prefer_at_accessor);\
87  \
88  if(prefer_at_accessor == false)\
89  {\
90  typename ProxyCube<T1>::ea_type A = P1.get_ea();\
91  typename ProxyCube<T2>::ea_type B = P2.get_ea();\
92  \
93  const uword n_elem = out.n_elem;\
94  \
95  for(uword i=0; i<n_elem; ++i)\
96  {\
97  out_mem[i] = (A[i] operator_rel B[i]) ? uword(1) : uword(0);\
98  }\
99  }\
100  else\
101  {\
102  uword count = 0;\
103  \
104  for(uword slice = 0; slice < n_slices; ++slice)\
105  for(uword col = 0; col < n_cols; ++col)\
106  for(uword row = 0; row < n_rows; ++row, ++count)\
107  {\
108  out_mem[count] = (P1.at(row,col,slice) operator_rel P2.at(row,col,slice)) ? uword(1) : uword(0);\
109  }\
110  }\
111  }
112 
113 
114 
115 template<typename T1, typename T2>
116 inline
117 void
119  (
120  Mat <uword>& out,
122  )
123  {
125 
126  arma_applier_mat(<, "operator<");
127  }
128 
129 
130 
131 template<typename T1, typename T2>
132 inline
133 void
135  (
136  Mat <uword>& out,
138  )
139  {
141 
142  arma_applier_mat(>, "operator>");
143  }
144 
145 
146 
147 template<typename T1, typename T2>
148 inline
149 void
151  (
152  Mat <uword>& out,
154  )
155  {
157 
158  arma_applier_mat(<=, "operator<=");
159  }
160 
161 
162 
163 template<typename T1, typename T2>
164 inline
165 void
167  (
168  Mat <uword>& out,
170  )
171  {
173 
174  arma_applier_mat(>=, "operator>=");
175  }
176 
177 
178 
179 template<typename T1, typename T2>
180 inline
181 void
183  (
184  Mat <uword>& out,
186  )
187  {
189 
190  arma_applier_mat(==, "operator==");
191  }
192 
193 
194 
195 template<typename T1, typename T2>
196 inline
197 void
199  (
200  Mat <uword>& out,
202  )
203  {
205 
206  arma_applier_mat(!=, "operator!=");
207  }
208 
209 
210 
211 //
212 //
213 //
214 
215 
216 
217 template<typename T1, typename T2>
218 inline
219 void
221  (
222  Cube <uword>& out,
224  )
225  {
227 
228  arma_applier_cube(<, "operator<");
229  }
230 
231 
232 
233 template<typename T1, typename T2>
234 inline
235 void
237  (
238  Cube <uword>& out,
240  )
241  {
243 
244  arma_applier_cube(>, "operator>");
245  }
246 
247 
248 
249 template<typename T1, typename T2>
250 inline
251 void
253  (
254  Cube <uword>& out,
256  )
257  {
259 
260  arma_applier_cube(<=, "operator<=");
261  }
262 
263 
264 
265 template<typename T1, typename T2>
266 inline
267 void
269  (
270  Cube <uword>& out,
272  )
273  {
275 
276  arma_applier_cube(>=, "operator>=");
277  }
278 
279 
280 
281 template<typename T1, typename T2>
282 inline
283 void
285  (
286  Cube <uword>& out,
288  )
289  {
291 
292  arma_applier_cube(==, "operator==");
293  }
294 
295 
296 
297 template<typename T1, typename T2>
298 inline
299 void
301  (
302  Cube <uword>& out,
304  )
305  {
307 
308  arma_applier_cube(!=, "operator!=");
309  }
310 
311 
312 
313 #undef arma_applier_mat
314 #undef arma_applier_cube
315 
316 
317 
#define arma_applier_cube(operator_rel, operator_str)
static void apply(Mat< uword > &out, const mtGlue< uword, T1, T2, glue_rel_gt > &X)
static void apply(Mat< uword > &out, const mtGlue< uword, T1, T2, glue_rel_gteq > &X)
Dense cube class.
Definition: Cube_bones.hpp:30
static void apply(Mat< uword > &out, const mtGlue< uword, T1, T2, glue_rel_lt > &X)
#define arma_extra_debug_sigprint
Definition: debug.hpp:1116
Dense matrix class.
static void apply(Mat< uword > &out, const mtGlue< uword, T1, T2, glue_rel_eq > &X)
static void apply(Mat< uword > &out, const mtGlue< uword, T1, T2, glue_rel_noteq > &X)
static void apply(Mat< uword > &out, const mtGlue< uword, T1, T2, glue_rel_lteq > &X)
#define arma_applier_mat(operator_rel, operator_str)


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