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