Mercurial > octave-nkf
comparison liboctave/mx-op-defs.h @ 9578:7dafdb8b062f
refactor comparison ops implementations
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Thu, 27 Aug 2009 11:19:33 +0200 |
parents | 0c72d9284087 |
children | a9b37bae1802 |
comparison
equal
deleted
inserted
replaced
9577:b03062e16c6f | 9578:7dafdb8b062f |
---|---|
115 MS_BIN_OP (R, operator +, M, S, mx_inline_add) \ | 115 MS_BIN_OP (R, operator +, M, S, mx_inline_add) \ |
116 MS_BIN_OP (R, operator -, M, S, mx_inline_sub) \ | 116 MS_BIN_OP (R, operator -, M, S, mx_inline_sub) \ |
117 MS_BIN_OP (R, operator *, M, S, mx_inline_mul) \ | 117 MS_BIN_OP (R, operator *, M, S, mx_inline_mul) \ |
118 MS_BIN_OP (R, operator /, M, S, mx_inline_div) | 118 MS_BIN_OP (R, operator /, M, S, mx_inline_div) |
119 | 119 |
120 #define MS_CMP_OP(F, OP, M, MC, S, SC) \ | 120 #define MS_CMP_OP(F, OP, M, S) \ |
121 boolMatrix \ | 121 boolMatrix \ |
122 F (const M& m, const S& s) \ | 122 F (const M& m, const S& s) \ |
123 { \ | 123 { \ |
124 boolMatrix r; \ | 124 return do_ms_binary_op<boolMatrix, M, S> (m, s, OP); \ |
125 \ | 125 } |
126 octave_idx_type nr = m.rows (); \ | 126 |
127 octave_idx_type nc = m.cols (); \ | 127 #define MS_CMP_OPS(M, S) \ |
128 \ | 128 MS_CMP_OP (mx_el_lt, mx_inline_lt, M, S) \ |
129 r.resize (nr, nc); \ | 129 MS_CMP_OP (mx_el_le, mx_inline_le, M, S) \ |
130 \ | 130 MS_CMP_OP (mx_el_ge, mx_inline_ge, M, S) \ |
131 if (nr > 0 && nc > 0) \ | 131 MS_CMP_OP (mx_el_gt, mx_inline_gt, M, S) \ |
132 { \ | 132 MS_CMP_OP (mx_el_eq, mx_inline_eq, M, S) \ |
133 for (octave_idx_type j = 0; j < nc; j++) \ | 133 MS_CMP_OP (mx_el_ne, mx_inline_ne, M, S) |
134 for (octave_idx_type i = 0; i < nr; i++) \ | |
135 r.elem(i, j) = MC (m.elem(i, j)) OP SC (s); \ | |
136 } \ | |
137 \ | |
138 return r; \ | |
139 } | |
140 | |
141 #define MS_CMP_OPS(M, CM, S, CS) \ | |
142 MS_CMP_OP (mx_el_lt, <, M, CM, S, CS) \ | |
143 MS_CMP_OP (mx_el_le, <=, M, CM, S, CS) \ | |
144 MS_CMP_OP (mx_el_ge, >=, M, CM, S, CS) \ | |
145 MS_CMP_OP (mx_el_gt, >, M, CM, S, CS) \ | |
146 MS_CMP_OP (mx_el_eq, ==, M, , S, ) \ | |
147 MS_CMP_OP (mx_el_ne, !=, M, , S, ) | |
148 | 134 |
149 #define MS_BOOL_OP(F, OP, M, S) \ | 135 #define MS_BOOL_OP(F, OP, M, S) \ |
150 boolMatrix \ | 136 boolMatrix \ |
151 F (const M& m, const S& s) \ | 137 F (const M& m, const S& s) \ |
152 { \ | 138 { \ |
170 SM_BIN_OP (R, operator +, S, M, mx_inline_add) \ | 156 SM_BIN_OP (R, operator +, S, M, mx_inline_add) \ |
171 SM_BIN_OP (R, operator -, S, M, mx_inline_sub) \ | 157 SM_BIN_OP (R, operator -, S, M, mx_inline_sub) \ |
172 SM_BIN_OP (R, operator *, S, M, mx_inline_mul) \ | 158 SM_BIN_OP (R, operator *, S, M, mx_inline_mul) \ |
173 SM_BIN_OP (R, operator /, S, M, mx_inline_div) | 159 SM_BIN_OP (R, operator /, S, M, mx_inline_div) |
174 | 160 |
175 #define SM_CMP_OP(F, OP, S, SC, M, MC) \ | 161 #define SM_CMP_OP(F, OP, S, M) \ |
176 boolMatrix \ | 162 boolMatrix \ |
177 F (const S& s, const M& m) \ | 163 F (const S& s, const M& m) \ |
178 { \ | 164 { \ |
179 boolMatrix r; \ | 165 return do_sm_binary_op<boolMatrix, S, M> (s, m, OP); \ |
180 \ | 166 } |
181 octave_idx_type nr = m.rows (); \ | 167 |
182 octave_idx_type nc = m.cols (); \ | 168 #define SM_CMP_OPS(S, M) \ |
183 \ | 169 SM_CMP_OP (mx_el_lt, mx_inline_lt, S, M) \ |
184 r.resize (nr, nc); \ | 170 SM_CMP_OP (mx_el_le, mx_inline_le, S, M) \ |
185 \ | 171 SM_CMP_OP (mx_el_ge, mx_inline_ge, S, M) \ |
186 if (nr > 0 && nc > 0) \ | 172 SM_CMP_OP (mx_el_gt, mx_inline_gt, S, M) \ |
187 { \ | 173 SM_CMP_OP (mx_el_eq, mx_inline_eq, S, M) \ |
188 for (octave_idx_type j = 0; j < nc; j++) \ | 174 SM_CMP_OP (mx_el_ne, mx_inline_ne, S, M) |
189 for (octave_idx_type i = 0; i < nr; i++) \ | |
190 r.elem(i, j) = SC (s) OP MC (m.elem(i, j)); \ | |
191 } \ | |
192 \ | |
193 return r; \ | |
194 } | |
195 | |
196 #define SM_CMP_OPS(S, CS, M, CM) \ | |
197 SM_CMP_OP (mx_el_lt, <, S, CS, M, CM) \ | |
198 SM_CMP_OP (mx_el_le, <=, S, CS, M, CM) \ | |
199 SM_CMP_OP (mx_el_ge, >=, S, CS, M, CM) \ | |
200 SM_CMP_OP (mx_el_gt, >, S, CS, M, CM) \ | |
201 SM_CMP_OP (mx_el_eq, ==, S, , M, ) \ | |
202 SM_CMP_OP (mx_el_ne, !=, S, , M, ) | |
203 | 175 |
204 #define SM_BOOL_OP(F, OP, S, M) \ | 176 #define SM_BOOL_OP(F, OP, S, M) \ |
205 boolMatrix \ | 177 boolMatrix \ |
206 F (const S& s, const M& m) \ | 178 F (const S& s, const M& m) \ |
207 { \ | 179 { \ |
225 MM_BIN_OP (R, operator +, M1, M2, mx_inline_add) \ | 197 MM_BIN_OP (R, operator +, M1, M2, mx_inline_add) \ |
226 MM_BIN_OP (R, operator -, M1, M2, mx_inline_sub) \ | 198 MM_BIN_OP (R, operator -, M1, M2, mx_inline_sub) \ |
227 MM_BIN_OP (R, product, M1, M2, mx_inline_mul) \ | 199 MM_BIN_OP (R, product, M1, M2, mx_inline_mul) \ |
228 MM_BIN_OP (R, quotient, M1, M2, mx_inline_div) | 200 MM_BIN_OP (R, quotient, M1, M2, mx_inline_div) |
229 | 201 |
230 #define MM_CMP_OP(F, OP, M1, C1, M2, C2) \ | 202 #define MM_CMP_OP(F, OP, M1, M2) \ |
231 boolMatrix \ | 203 boolMatrix \ |
232 F (const M1& m1, const M2& m2) \ | 204 F (const M1& m1, const M2& m2) \ |
233 { \ | 205 { \ |
234 boolMatrix r; \ | 206 return do_mm_binary_op<boolMatrix, M1, M2> (m1, m2, OP, #F); \ |
235 \ | 207 } |
236 octave_idx_type m1_nr = m1.rows (); \ | 208 |
237 octave_idx_type m1_nc = m1.cols (); \ | 209 #define MM_CMP_OPS(M1, M2) \ |
238 \ | 210 MM_CMP_OP (mx_el_lt, mx_inline_lt, M1, M2) \ |
239 octave_idx_type m2_nr = m2.rows (); \ | 211 MM_CMP_OP (mx_el_le, mx_inline_le, M1, M2) \ |
240 octave_idx_type m2_nc = m2.cols (); \ | 212 MM_CMP_OP (mx_el_ge, mx_inline_ge, M1, M2) \ |
241 \ | 213 MM_CMP_OP (mx_el_gt, mx_inline_gt, M1, M2) \ |
242 if (m1_nr == m2_nr && m1_nc == m2_nc) \ | 214 MM_CMP_OP (mx_el_eq, mx_inline_eq, M1, M2) \ |
243 { \ | 215 MM_CMP_OP (mx_el_ne, mx_inline_ne, M1, M2) |
244 r.resize (m1_nr, m1_nc); \ | |
245 \ | |
246 for (octave_idx_type j = 0; j < m1_nc; j++) \ | |
247 for (octave_idx_type i = 0; i < m1_nr; i++) \ | |
248 r.elem(i, j) = C1 (m1.elem(i, j)) OP C2 (m2.elem(i, j)); \ | |
249 } \ | |
250 else \ | |
251 gripe_nonconformant (#F, m1_nr, m1_nc, m2_nr, m2_nc); \ | |
252 \ | |
253 return r; \ | |
254 } | |
255 | |
256 #define MM_CMP_OPS(M1, C1, M2, C2) \ | |
257 MM_CMP_OP (mx_el_lt, <, M1, C1, M2, C2) \ | |
258 MM_CMP_OP (mx_el_le, <=, M1, C1, M2, C2) \ | |
259 MM_CMP_OP (mx_el_ge, >=, M1, C1, M2, C2) \ | |
260 MM_CMP_OP (mx_el_gt, >, M1, C1, M2, C2) \ | |
261 MM_CMP_OP (mx_el_eq, ==, M1, , M2, ) \ | |
262 MM_CMP_OP (mx_el_ne, !=, M1, , M2, ) | |
263 | 216 |
264 #define MM_BOOL_OP(F, OP, M1, M2) \ | 217 #define MM_BOOL_OP(F, OP, M1, M2) \ |
265 boolMatrix \ | 218 boolMatrix \ |
266 F (const M1& m1, const M2& m2) \ | 219 F (const M1& m1, const M2& m2) \ |
267 { \ | 220 { \ |
285 NDS_BIN_OP (R, operator +, ND, S, mx_inline_add) \ | 238 NDS_BIN_OP (R, operator +, ND, S, mx_inline_add) \ |
286 NDS_BIN_OP (R, operator -, ND, S, mx_inline_sub) \ | 239 NDS_BIN_OP (R, operator -, ND, S, mx_inline_sub) \ |
287 NDS_BIN_OP (R, operator *, ND, S, mx_inline_mul) \ | 240 NDS_BIN_OP (R, operator *, ND, S, mx_inline_mul) \ |
288 NDS_BIN_OP (R, operator /, ND, S, mx_inline_div) | 241 NDS_BIN_OP (R, operator /, ND, S, mx_inline_div) |
289 | 242 |
290 #define NDS_CMP_OP(F, OP, ND, NDC, S, SC) \ | 243 #define NDS_CMP_OP(F, OP, ND, S) \ |
291 boolNDArray \ | 244 boolNDArray \ |
292 F (const ND& m, const S& s) \ | 245 F (const ND& m, const S& s) \ |
293 { \ | 246 { \ |
294 boolNDArray r (m.dims ()); \ | 247 return do_ms_binary_op<boolNDArray, ND, S> (m, s, OP); \ |
295 \ | 248 } |
296 octave_idx_type len = m.length (); \ | 249 |
297 \ | 250 #define NDS_CMP_OPS(ND, S) \ |
298 if (s == S ()) \ | 251 NDS_CMP_OP (mx_el_lt, mx_inline_lt, ND, S) \ |
299 { \ | 252 NDS_CMP_OP (mx_el_le, mx_inline_le, ND, S) \ |
300 for (octave_idx_type i = 0; i < len; i++) \ | 253 NDS_CMP_OP (mx_el_ge, mx_inline_ge, ND, S) \ |
301 r.xelem(i) = NDC (m.elem(i)) OP SC (S ()); \ | 254 NDS_CMP_OP (mx_el_gt, mx_inline_gt, ND, S) \ |
302 } \ | 255 NDS_CMP_OP (mx_el_eq, mx_inline_eq, ND, S) \ |
303 else \ | 256 NDS_CMP_OP (mx_el_ne, mx_inline_ne, ND, S) |
304 { \ | |
305 for (octave_idx_type i = 0; i < len; i++) \ | |
306 r.xelem(i) = NDC (m.elem(i)) OP SC (s); \ | |
307 } \ | |
308 \ | |
309 return r; \ | |
310 } | |
311 | |
312 #define NDS_CMP_OPS(ND, NDC, S, SC) \ | |
313 NDS_CMP_OP (mx_el_lt, <, ND, NDC, S, SC) \ | |
314 NDS_CMP_OP (mx_el_le, <=, ND, NDC, S, SC) \ | |
315 NDS_CMP_OP (mx_el_ge, >=, ND, NDC, S, SC) \ | |
316 NDS_CMP_OP (mx_el_gt, >, ND, NDC, S, SC) \ | |
317 NDS_CMP_OP (mx_el_eq, ==, ND, , S, ) \ | |
318 NDS_CMP_OP (mx_el_ne, !=, ND, , S, ) | |
319 | |
320 #define NDS_CMP_OP1(F, OP, ND, NDC, S, SC, SPEC) \ | |
321 boolNDArray \ | |
322 F (const ND& m, const S& s) \ | |
323 { \ | |
324 boolNDArray r (m.dims ()); \ | |
325 \ | |
326 octave_idx_type len = m.length (); \ | |
327 \ | |
328 for (octave_idx_type i = 0; i < len; i++) \ | |
329 r.elem(i) = operator OP <SPEC> (NDC (m.elem(i)), SC (s)); \ | |
330 \ | |
331 return r; \ | |
332 } | |
333 | |
334 #define NDS_CMP_OPS1(ND, NDC, S, SC, SPEC) \ | |
335 NDS_CMP_OP1 (mx_el_lt, <, ND, NDC, S, SC, SPEC) \ | |
336 NDS_CMP_OP1 (mx_el_le, <=, ND, NDC, S, SC, SPEC) \ | |
337 NDS_CMP_OP1 (mx_el_ge, >=, ND, NDC, S, SC, SPEC) \ | |
338 NDS_CMP_OP1 (mx_el_gt, >, ND, NDC, S, SC, SPEC) \ | |
339 NDS_CMP_OP1 (mx_el_eq, ==, ND, , S, , SPEC) \ | |
340 NDS_CMP_OP1 (mx_el_ne, !=, ND, , S, , SPEC) | |
341 | |
342 #define NDS_CMP_OP2(F, OP, ND, NDC, S, SC, SPEC1, SPEC2) \ | |
343 boolNDArray \ | |
344 F (const ND& m, const S& s) \ | |
345 { \ | |
346 boolNDArray r; \ | |
347 \ | |
348 octave_idx_type len = m.length (); \ | |
349 \ | |
350 r.resize (m.dims ()); \ | |
351 \ | |
352 for (octave_idx_type i = 0; i < len; i++) \ | |
353 r.elem(i) = operator OP <SPEC1,SPEC2> (NDC (m.elem(i)), SC (s)); \ | |
354 \ | |
355 return r; \ | |
356 } | |
357 | |
358 #define NDS_CMP_OPS2(ND, NDC, S, SC, SPEC1, SPEC2) \ | |
359 NDS_CMP_OP2 (mx_el_lt, <, ND, NDC, S, SC, SPEC1, SPEC2) \ | |
360 NDS_CMP_OP2 (mx_el_le, <=, ND, NDC, S, SC, SPEC1, SPEC2) \ | |
361 NDS_CMP_OP2 (mx_el_ge, >=, ND, NDC, S, SC, SPEC1, SPEC2) \ | |
362 NDS_CMP_OP2 (mx_el_gt, >, ND, NDC, S, SC, SPEC1, SPEC2) \ | |
363 NDS_CMP_OP2 (mx_el_eq, ==, ND, , S, , SPEC1, SPEC2) \ | |
364 NDS_CMP_OP2 (mx_el_ne, !=, ND, , S, , SPEC1, SPEC2) | |
365 | 257 |
366 #define NDS_BOOL_OP(F, OP, ND, S) \ | 258 #define NDS_BOOL_OP(F, OP, ND, S) \ |
367 boolNDArray \ | 259 boolNDArray \ |
368 F (const ND& m, const S& s) \ | 260 F (const ND& m, const S& s) \ |
369 { \ | 261 { \ |
391 SND_BIN_OP (R, operator +, S, ND, mx_inline_add) \ | 283 SND_BIN_OP (R, operator +, S, ND, mx_inline_add) \ |
392 SND_BIN_OP (R, operator -, S, ND, mx_inline_sub) \ | 284 SND_BIN_OP (R, operator -, S, ND, mx_inline_sub) \ |
393 SND_BIN_OP (R, operator *, S, ND, mx_inline_mul) \ | 285 SND_BIN_OP (R, operator *, S, ND, mx_inline_mul) \ |
394 SND_BIN_OP (R, operator /, S, ND, mx_inline_div) | 286 SND_BIN_OP (R, operator /, S, ND, mx_inline_div) |
395 | 287 |
396 #define SND_CMP_OP(F, OP, S, SC, ND, NDC) \ | 288 #define SND_CMP_OP(F, OP, S, ND) \ |
397 boolNDArray \ | 289 boolNDArray \ |
398 F (const S& s, const ND& m) \ | 290 F (const S& s, const ND& m) \ |
399 { \ | 291 { \ |
400 boolNDArray r (m.dims ()); \ | 292 return do_sm_binary_op<boolNDArray, S, ND> (s, m, OP); \ |
401 \ | 293 } |
402 octave_idx_type len = m.length (); \ | 294 |
403 \ | 295 #define SND_CMP_OPS(S, ND) \ |
404 if (s == S ()) \ | 296 SND_CMP_OP (mx_el_lt, mx_inline_lt, S, ND) \ |
405 { \ | 297 SND_CMP_OP (mx_el_le, mx_inline_le, S, ND) \ |
406 for (octave_idx_type i = 0; i < len; i++) \ | 298 SND_CMP_OP (mx_el_ge, mx_inline_ge, S, ND) \ |
407 r.xelem(i) = SC (S ()) OP NDC (m.elem(i)); \ | 299 SND_CMP_OP (mx_el_gt, mx_inline_gt, S, ND) \ |
408 } \ | 300 SND_CMP_OP (mx_el_eq, mx_inline_eq, S, ND) \ |
409 else \ | 301 SND_CMP_OP (mx_el_ne, mx_inline_ne, S, ND) |
410 { \ | |
411 for (octave_idx_type i = 0; i < len; i++) \ | |
412 r.xelem(i) = SC (s) OP NDC (m.elem(i)); \ | |
413 } \ | |
414 \ | |
415 return r; \ | |
416 } | |
417 | |
418 #define SND_CMP_OPS(S, CS, ND, CND) \ | |
419 SND_CMP_OP (mx_el_lt, <, S, CS, ND, CND) \ | |
420 SND_CMP_OP (mx_el_le, <=, S, CS, ND, CND) \ | |
421 SND_CMP_OP (mx_el_ge, >=, S, CS, ND, CND) \ | |
422 SND_CMP_OP (mx_el_gt, >, S, CS, ND, CND) \ | |
423 SND_CMP_OP (mx_el_eq, ==, S, , ND, ) \ | |
424 SND_CMP_OP (mx_el_ne, !=, S, , ND, ) | |
425 | |
426 #define SND_CMP_OP1(F, OP, S, SC, ND, NDC, SPEC) \ | |
427 boolNDArray \ | |
428 F (const S& s, const ND& m) \ | |
429 { \ | |
430 boolNDArray r (m.dims ()); \ | |
431 \ | |
432 octave_idx_type len = m.length (); \ | |
433 \ | |
434 for (octave_idx_type i = 0; i < len; i++) \ | |
435 r.elem(i) = operator OP <SPEC> (SC (s), NDC (m.elem(i))); \ | |
436 \ | |
437 return r; \ | |
438 } | |
439 | |
440 #define SND_CMP_OPS1(S, CS, ND, CND, SPEC) \ | |
441 SND_CMP_OP1 (mx_el_lt, <, S, CS, ND, CND, SPEC) \ | |
442 SND_CMP_OP1 (mx_el_le, <=, S, CS, ND, CND, SPEC) \ | |
443 SND_CMP_OP1 (mx_el_ge, >=, S, CS, ND, CND, SPEC) \ | |
444 SND_CMP_OP1 (mx_el_gt, >, S, CS, ND, CND, SPEC) \ | |
445 SND_CMP_OP1 (mx_el_eq, ==, S, , ND, , SPEC) \ | |
446 SND_CMP_OP1 (mx_el_ne, !=, S, , ND, , SPEC) | |
447 | |
448 #define SND_CMP_OP2(F, OP, S, SC, ND, NDC, SPEC1, SPEC2) \ | |
449 boolNDArray \ | |
450 F (const S& s, const ND& m) \ | |
451 { \ | |
452 boolNDArray r (m.dims ()); \ | |
453 \ | |
454 octave_idx_type len = m.length (); \ | |
455 \ | |
456 for (octave_idx_type i = 0; i < len; i++) \ | |
457 r.elem(i) = operator OP <SPEC1, SPEC2> (SC (s), NDC (m.elem(i))); \ | |
458 \ | |
459 return r; \ | |
460 } | |
461 | |
462 #define SND_CMP_OPS2(S, CS, ND, CND, SPEC1, SPEC2) \ | |
463 SND_CMP_OP2 (mx_el_lt, <, S, CS, ND, CND, SPEC1, SPEC2) \ | |
464 SND_CMP_OP2 (mx_el_le, <=, S, CS, ND, CND, SPEC1, SPEC2) \ | |
465 SND_CMP_OP2 (mx_el_ge, >=, S, CS, ND, CND, SPEC1, SPEC2) \ | |
466 SND_CMP_OP2 (mx_el_gt, >, S, CS, ND, CND, SPEC1, SPEC2) \ | |
467 SND_CMP_OP2 (mx_el_eq, ==, S, , ND, , SPEC1, SPEC2) \ | |
468 SND_CMP_OP2 (mx_el_ne, !=, S, , ND, , SPEC1, SPEC2) | |
469 | 302 |
470 #define SND_BOOL_OP(F, OP, S, ND) \ | 303 #define SND_BOOL_OP(F, OP, S, ND) \ |
471 boolNDArray \ | 304 boolNDArray \ |
472 F (const S& s, const ND& m) \ | 305 F (const S& s, const ND& m) \ |
473 { \ | 306 { \ |
495 NDND_BIN_OP (R, operator +, ND1, ND2, mx_inline_add) \ | 328 NDND_BIN_OP (R, operator +, ND1, ND2, mx_inline_add) \ |
496 NDND_BIN_OP (R, operator -, ND1, ND2, mx_inline_sub) \ | 329 NDND_BIN_OP (R, operator -, ND1, ND2, mx_inline_sub) \ |
497 NDND_BIN_OP (R, product, ND1, ND2, mx_inline_mul) \ | 330 NDND_BIN_OP (R, product, ND1, ND2, mx_inline_mul) \ |
498 NDND_BIN_OP (R, quotient, ND1, ND2, mx_inline_div) | 331 NDND_BIN_OP (R, quotient, ND1, ND2, mx_inline_div) |
499 | 332 |
500 #define NDND_CMP_OP(F, OP, ND1, C1, ND2, C2) \ | 333 #define NDND_CMP_OP(F, OP, ND1, ND2) \ |
501 boolNDArray \ | 334 boolNDArray \ |
502 F (const ND1& m1, const ND2& m2) \ | 335 F (const ND1& m1, const ND2& m2) \ |
503 { \ | 336 { \ |
504 boolNDArray r; \ | 337 return do_mm_binary_op<boolNDArray, ND1, ND2> (m1, m2, OP, #F); \ |
505 \ | 338 } |
506 dim_vector m1_dims = m1.dims (); \ | 339 |
507 dim_vector m2_dims = m2.dims (); \ | 340 #define NDND_CMP_OPS(ND1, ND2) \ |
508 \ | 341 NDND_CMP_OP (mx_el_lt, mx_inline_lt, ND1, ND2) \ |
509 if (m1_dims == m2_dims) \ | 342 NDND_CMP_OP (mx_el_le, mx_inline_le, ND1, ND2) \ |
510 { \ | 343 NDND_CMP_OP (mx_el_ge, mx_inline_ge, ND1, ND2) \ |
511 r = boolNDArray (m1_dims); \ | 344 NDND_CMP_OP (mx_el_gt, mx_inline_gt, ND1, ND2) \ |
512 \ | 345 NDND_CMP_OP (mx_el_eq, mx_inline_eq, ND1, ND2) \ |
513 for (octave_idx_type i = 0; i < m1.length (); i++) \ | 346 NDND_CMP_OP (mx_el_ne, mx_inline_ne, ND1, ND2) |
514 r.xelem(i) = C1 (m1.elem(i)) OP C2 (m2.elem(i)); \ | |
515 } \ | |
516 else \ | |
517 gripe_nonconformant (#F, m1_dims, m2_dims); \ | |
518 \ | |
519 return r; \ | |
520 } | |
521 | |
522 #define NDND_CMP_OPS(ND1, C1, ND2, C2) \ | |
523 NDND_CMP_OP (mx_el_lt, <, ND1, C1, ND2, C2) \ | |
524 NDND_CMP_OP (mx_el_le, <=, ND1, C1, ND2, C2) \ | |
525 NDND_CMP_OP (mx_el_ge, >=, ND1, C1, ND2, C2) \ | |
526 NDND_CMP_OP (mx_el_gt, >, ND1, C1, ND2, C2) \ | |
527 NDND_CMP_OP (mx_el_eq, ==, ND1, , ND2, ) \ | |
528 NDND_CMP_OP (mx_el_ne, !=, ND1, , ND2, ) | |
529 | 347 |
530 #define NDND_BOOL_OP(F, OP, ND1, ND2) \ | 348 #define NDND_BOOL_OP(F, OP, ND1, ND2) \ |
531 boolNDArray \ | 349 boolNDArray \ |
532 F (const ND1& m1, const ND2& m2) \ | 350 F (const ND1& m1, const ND2& m2) \ |
533 { \ | 351 { \ |