annotate armadillo-3.900.4/include/armadillo_bits/eop_core_meat.hpp @ 84:55a047986812 tip

Update library URI so as not to be document-local
author Chris Cannam
date Wed, 22 Apr 2020 14:21:57 +0100
parents 1ec0e2823891
children
rev   line source
Chris@49 1 // Copyright (C) 2010-2013 NICTA (www.nicta.com.au)
Chris@49 2 // Copyright (C) 2010-2013 Conrad Sanderson
Chris@49 3 //
Chris@49 4 // This Source Code Form is subject to the terms of the Mozilla Public
Chris@49 5 // License, v. 2.0. If a copy of the MPL was not distributed with this
Chris@49 6 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
Chris@49 7
Chris@49 8
Chris@49 9 //! \addtogroup eop_core
Chris@49 10 //! @{
Chris@49 11
Chris@49 12
Chris@49 13 #undef arma_applier_1u
Chris@49 14 #undef arma_applier_1a
Chris@49 15 #undef arma_applier_2
Chris@49 16 #undef arma_applier_3
Chris@49 17 #undef operatorA
Chris@49 18
Chris@49 19 #define arma_applier_1u(operatorA) \
Chris@49 20 {\
Chris@49 21 uword i,j;\
Chris@49 22 \
Chris@49 23 for(i=0, j=1; j<n_elem; i+=2, j+=2)\
Chris@49 24 {\
Chris@49 25 eT tmp_i = P[i];\
Chris@49 26 eT tmp_j = P[j];\
Chris@49 27 \
Chris@49 28 tmp_i = eop_core<eop_type>::process(tmp_i, k);\
Chris@49 29 tmp_j = eop_core<eop_type>::process(tmp_j, k);\
Chris@49 30 \
Chris@49 31 out_mem[i] operatorA tmp_i;\
Chris@49 32 out_mem[j] operatorA tmp_j;\
Chris@49 33 }\
Chris@49 34 \
Chris@49 35 if(i < n_elem)\
Chris@49 36 {\
Chris@49 37 out_mem[i] operatorA eop_core<eop_type>::process(P[i], k);\
Chris@49 38 }\
Chris@49 39 }
Chris@49 40
Chris@49 41
Chris@49 42 #define arma_applier_1a(operatorA) \
Chris@49 43 {\
Chris@49 44 uword i,j;\
Chris@49 45 \
Chris@49 46 for(i=0, j=1; j<n_elem; i+=2, j+=2)\
Chris@49 47 {\
Chris@49 48 eT tmp_i = P.at_alt(i);\
Chris@49 49 eT tmp_j = P.at_alt(j);\
Chris@49 50 \
Chris@49 51 tmp_i = eop_core<eop_type>::process(tmp_i, k);\
Chris@49 52 tmp_j = eop_core<eop_type>::process(tmp_j, k);\
Chris@49 53 \
Chris@49 54 out_mem[i] operatorA tmp_i;\
Chris@49 55 out_mem[j] operatorA tmp_j;\
Chris@49 56 }\
Chris@49 57 \
Chris@49 58 if(i < n_elem)\
Chris@49 59 {\
Chris@49 60 out_mem[i] operatorA eop_core<eop_type>::process(P.at_alt(i), k);\
Chris@49 61 }\
Chris@49 62 }
Chris@49 63
Chris@49 64
Chris@49 65 #define arma_applier_2(operatorA) \
Chris@49 66 {\
Chris@49 67 if(n_rows != 1)\
Chris@49 68 {\
Chris@49 69 for(uword col=0; col<n_cols; ++col)\
Chris@49 70 {\
Chris@49 71 uword i,j;\
Chris@49 72 \
Chris@49 73 for(i=0, j=1; j<n_rows; i+=2, j+=2)\
Chris@49 74 {\
Chris@49 75 eT tmp_i = P.at(i,col);\
Chris@49 76 eT tmp_j = P.at(j,col);\
Chris@49 77 \
Chris@49 78 tmp_i = eop_core<eop_type>::process(tmp_i, k);\
Chris@49 79 tmp_j = eop_core<eop_type>::process(tmp_j, k);\
Chris@49 80 \
Chris@49 81 *out_mem operatorA tmp_i; out_mem++;\
Chris@49 82 *out_mem operatorA tmp_j; out_mem++;\
Chris@49 83 }\
Chris@49 84 \
Chris@49 85 if(i < n_rows)\
Chris@49 86 {\
Chris@49 87 *out_mem operatorA eop_core<eop_type>::process(P.at(i,col), k); out_mem++;\
Chris@49 88 }\
Chris@49 89 }\
Chris@49 90 }\
Chris@49 91 else\
Chris@49 92 {\
Chris@49 93 for(uword count=0; count < n_cols; ++count)\
Chris@49 94 {\
Chris@49 95 out_mem[count] operatorA eop_core<eop_type>::process(P.at(0,count), k);\
Chris@49 96 }\
Chris@49 97 }\
Chris@49 98 }
Chris@49 99
Chris@49 100
Chris@49 101
Chris@49 102 #define arma_applier_3(operatorA) \
Chris@49 103 {\
Chris@49 104 for(uword slice=0; slice<n_slices; ++slice)\
Chris@49 105 {\
Chris@49 106 for(uword col=0; col<n_cols; ++col)\
Chris@49 107 {\
Chris@49 108 uword i,j;\
Chris@49 109 \
Chris@49 110 for(i=0, j=1; j<n_rows; i+=2, j+=2)\
Chris@49 111 {\
Chris@49 112 eT tmp_i = P.at(i,col,slice);\
Chris@49 113 eT tmp_j = P.at(j,col,slice);\
Chris@49 114 \
Chris@49 115 tmp_i = eop_core<eop_type>::process(tmp_i, k);\
Chris@49 116 tmp_j = eop_core<eop_type>::process(tmp_j, k);\
Chris@49 117 \
Chris@49 118 *out_mem operatorA tmp_i; out_mem++; \
Chris@49 119 *out_mem operatorA tmp_j; out_mem++; \
Chris@49 120 }\
Chris@49 121 \
Chris@49 122 if(i < n_rows)\
Chris@49 123 {\
Chris@49 124 *out_mem operatorA eop_core<eop_type>::process(P.at(i,col,slice), k); out_mem++; \
Chris@49 125 }\
Chris@49 126 }\
Chris@49 127 }\
Chris@49 128 }
Chris@49 129
Chris@49 130
Chris@49 131
Chris@49 132 //
Chris@49 133 // matrices
Chris@49 134
Chris@49 135
Chris@49 136
Chris@49 137 template<typename eop_type>
Chris@49 138 template<typename T1>
Chris@49 139 arma_hot
Chris@49 140 inline
Chris@49 141 void
Chris@49 142 eop_core<eop_type>::apply(Mat<typename T1::elem_type>& out, const eOp<T1, eop_type>& x)
Chris@49 143 {
Chris@49 144 arma_extra_debug_sigprint();
Chris@49 145
Chris@49 146 typedef typename T1::elem_type eT;
Chris@49 147
Chris@49 148 // NOTE: we're assuming that the matrix has already been set to the correct size and there is no aliasing;
Chris@49 149 // size setting and alias checking is done by either the Mat contructor or operator=()
Chris@49 150
Chris@49 151 const eT k = x.aux;
Chris@49 152 eT* out_mem = out.memptr();
Chris@49 153
Chris@49 154 if(Proxy<T1>::prefer_at_accessor == false)
Chris@49 155 {
Chris@49 156 const uword n_elem = (Proxy<T1>::is_fixed) ? x.get_n_elem() : out.n_elem;
Chris@49 157
Chris@49 158 //if(memory::is_aligned(out_mem))
Chris@49 159 if( memory::is_aligned(out_mem) && ((Proxy<T1>::is_fixed) ? (x.get_n_elem() >= 32) : true) )
Chris@49 160 {
Chris@49 161 memory::mark_as_aligned(out_mem);
Chris@49 162
Chris@49 163 if(x.P.is_aligned())
Chris@49 164 {
Chris@49 165 typename Proxy<T1>::aligned_ea_type P = x.P.get_aligned_ea();
Chris@49 166
Chris@49 167 arma_applier_1a(=);
Chris@49 168 }
Chris@49 169 else
Chris@49 170 {
Chris@49 171 typename Proxy<T1>::ea_type P = x.P.get_ea();
Chris@49 172
Chris@49 173 arma_applier_1u(=);
Chris@49 174 }
Chris@49 175 }
Chris@49 176 else
Chris@49 177 {
Chris@49 178 typename Proxy<T1>::ea_type P = x.P.get_ea();
Chris@49 179
Chris@49 180 arma_applier_1u(=);
Chris@49 181 }
Chris@49 182 }
Chris@49 183 else
Chris@49 184 {
Chris@49 185 const uword n_rows = x.get_n_rows();
Chris@49 186 const uword n_cols = x.get_n_cols();
Chris@49 187
Chris@49 188 const Proxy<T1>& P = x.P;
Chris@49 189
Chris@49 190 arma_applier_2(=);
Chris@49 191 }
Chris@49 192 }
Chris@49 193
Chris@49 194
Chris@49 195
Chris@49 196 template<typename eop_type>
Chris@49 197 template<typename T1>
Chris@49 198 arma_hot
Chris@49 199 inline
Chris@49 200 void
Chris@49 201 eop_core<eop_type>::apply_inplace_plus(Mat<typename T1::elem_type>& out, const eOp<T1, eop_type>& x)
Chris@49 202 {
Chris@49 203 arma_extra_debug_sigprint();
Chris@49 204
Chris@49 205 typedef typename T1::elem_type eT;
Chris@49 206
Chris@49 207 const uword n_rows = x.get_n_rows();
Chris@49 208 const uword n_cols = x.get_n_cols();
Chris@49 209
Chris@49 210 arma_debug_assert_same_size(out.n_rows, out.n_cols, n_rows, n_cols, "addition");
Chris@49 211
Chris@49 212 const eT k = x.aux;
Chris@49 213 eT* out_mem = out.memptr();
Chris@49 214
Chris@49 215 if(Proxy<T1>::prefer_at_accessor == false)
Chris@49 216 {
Chris@49 217 const uword n_elem = (Proxy<T1>::is_fixed) ? x.get_n_elem() : out.n_elem;
Chris@49 218
Chris@49 219 if(memory::is_aligned(out_mem))
Chris@49 220 {
Chris@49 221 memory::mark_as_aligned(out_mem);
Chris@49 222
Chris@49 223 if(x.P.is_aligned())
Chris@49 224 {
Chris@49 225 typename Proxy<T1>::aligned_ea_type P = x.P.get_aligned_ea();
Chris@49 226
Chris@49 227 arma_applier_1a(+=);
Chris@49 228 }
Chris@49 229 else
Chris@49 230 {
Chris@49 231 typename Proxy<T1>::ea_type P = x.P.get_ea();
Chris@49 232
Chris@49 233 arma_applier_1u(+=);
Chris@49 234 }
Chris@49 235 }
Chris@49 236 else
Chris@49 237 {
Chris@49 238 typename Proxy<T1>::ea_type P = x.P.get_ea();
Chris@49 239
Chris@49 240 arma_applier_1u(+=);
Chris@49 241 }
Chris@49 242 }
Chris@49 243 else
Chris@49 244 {
Chris@49 245 const Proxy<T1>& P = x.P;
Chris@49 246
Chris@49 247 arma_applier_2(+=);
Chris@49 248 }
Chris@49 249 }
Chris@49 250
Chris@49 251
Chris@49 252
Chris@49 253 template<typename eop_type>
Chris@49 254 template<typename T1>
Chris@49 255 arma_hot
Chris@49 256 inline
Chris@49 257 void
Chris@49 258 eop_core<eop_type>::apply_inplace_minus(Mat<typename T1::elem_type>& out, const eOp<T1, eop_type>& x)
Chris@49 259 {
Chris@49 260 arma_extra_debug_sigprint();
Chris@49 261
Chris@49 262 typedef typename T1::elem_type eT;
Chris@49 263
Chris@49 264 const uword n_rows = x.get_n_rows();
Chris@49 265 const uword n_cols = x.get_n_cols();
Chris@49 266
Chris@49 267 arma_debug_assert_same_size(out.n_rows, out.n_cols, n_rows, n_cols, "subtraction");
Chris@49 268
Chris@49 269 const eT k = x.aux;
Chris@49 270 eT* out_mem = out.memptr();
Chris@49 271
Chris@49 272 if(Proxy<T1>::prefer_at_accessor == false)
Chris@49 273 {
Chris@49 274 const uword n_elem = (Proxy<T1>::is_fixed) ? x.get_n_elem() : out.n_elem;
Chris@49 275
Chris@49 276 if(memory::is_aligned(out_mem))
Chris@49 277 {
Chris@49 278 memory::mark_as_aligned(out_mem);
Chris@49 279
Chris@49 280 if(x.P.is_aligned())
Chris@49 281 {
Chris@49 282 typename Proxy<T1>::aligned_ea_type P = x.P.get_aligned_ea();
Chris@49 283
Chris@49 284 arma_applier_1a(-=);
Chris@49 285 }
Chris@49 286 else
Chris@49 287 {
Chris@49 288 typename Proxy<T1>::ea_type P = x.P.get_ea();
Chris@49 289
Chris@49 290 arma_applier_1u(-=);
Chris@49 291 }
Chris@49 292 }
Chris@49 293 else
Chris@49 294 {
Chris@49 295 typename Proxy<T1>::ea_type P = x.P.get_ea();
Chris@49 296
Chris@49 297 arma_applier_1u(-=);
Chris@49 298 }
Chris@49 299 }
Chris@49 300 else
Chris@49 301 {
Chris@49 302 const Proxy<T1>& P = x.P;
Chris@49 303
Chris@49 304 arma_applier_2(-=);
Chris@49 305 }
Chris@49 306 }
Chris@49 307
Chris@49 308
Chris@49 309
Chris@49 310 template<typename eop_type>
Chris@49 311 template<typename T1>
Chris@49 312 arma_hot
Chris@49 313 inline
Chris@49 314 void
Chris@49 315 eop_core<eop_type>::apply_inplace_schur(Mat<typename T1::elem_type>& out, const eOp<T1, eop_type>& x)
Chris@49 316 {
Chris@49 317 arma_extra_debug_sigprint();
Chris@49 318
Chris@49 319 typedef typename T1::elem_type eT;
Chris@49 320
Chris@49 321 const uword n_rows = x.get_n_rows();
Chris@49 322 const uword n_cols = x.get_n_cols();
Chris@49 323
Chris@49 324 arma_debug_assert_same_size(out.n_rows, out.n_cols, n_rows, n_cols, "element-wise multiplication");
Chris@49 325
Chris@49 326 const eT k = x.aux;
Chris@49 327 eT* out_mem = out.memptr();
Chris@49 328
Chris@49 329 if(Proxy<T1>::prefer_at_accessor == false)
Chris@49 330 {
Chris@49 331 const uword n_elem = (Proxy<T1>::is_fixed) ? x.get_n_elem() : out.n_elem;
Chris@49 332
Chris@49 333 if(memory::is_aligned(out_mem))
Chris@49 334 {
Chris@49 335 memory::mark_as_aligned(out_mem);
Chris@49 336
Chris@49 337 if(x.P.is_aligned())
Chris@49 338 {
Chris@49 339 typename Proxy<T1>::aligned_ea_type P = x.P.get_aligned_ea();
Chris@49 340
Chris@49 341 arma_applier_1a(*=);
Chris@49 342 }
Chris@49 343 else
Chris@49 344 {
Chris@49 345 typename Proxy<T1>::ea_type P = x.P.get_ea();
Chris@49 346
Chris@49 347 arma_applier_1u(*=);
Chris@49 348 }
Chris@49 349 }
Chris@49 350 else
Chris@49 351 {
Chris@49 352 typename Proxy<T1>::ea_type P = x.P.get_ea();
Chris@49 353
Chris@49 354 arma_applier_1u(*=);
Chris@49 355 }
Chris@49 356 }
Chris@49 357 else
Chris@49 358 {
Chris@49 359 const Proxy<T1>& P = x.P;
Chris@49 360
Chris@49 361 arma_applier_2(*=);
Chris@49 362 }
Chris@49 363 }
Chris@49 364
Chris@49 365
Chris@49 366
Chris@49 367 template<typename eop_type>
Chris@49 368 template<typename T1>
Chris@49 369 arma_hot
Chris@49 370 inline
Chris@49 371 void
Chris@49 372 eop_core<eop_type>::apply_inplace_div(Mat<typename T1::elem_type>& out, const eOp<T1, eop_type>& x)
Chris@49 373 {
Chris@49 374 arma_extra_debug_sigprint();
Chris@49 375
Chris@49 376 typedef typename T1::elem_type eT;
Chris@49 377
Chris@49 378 const uword n_rows = x.get_n_rows();
Chris@49 379 const uword n_cols = x.get_n_cols();
Chris@49 380
Chris@49 381 arma_debug_assert_same_size(out.n_rows, out.n_cols, n_rows, n_cols, "element-wise division");
Chris@49 382
Chris@49 383 const eT k = x.aux;
Chris@49 384 eT* out_mem = out.memptr();
Chris@49 385
Chris@49 386 if(Proxy<T1>::prefer_at_accessor == false)
Chris@49 387 {
Chris@49 388 const uword n_elem = (Proxy<T1>::is_fixed) ? x.get_n_elem() : out.n_elem;
Chris@49 389
Chris@49 390 if(memory::is_aligned(out_mem))
Chris@49 391 {
Chris@49 392 memory::mark_as_aligned(out_mem);
Chris@49 393
Chris@49 394 if(x.P.is_aligned())
Chris@49 395 {
Chris@49 396 typename Proxy<T1>::aligned_ea_type P = x.P.get_aligned_ea();
Chris@49 397
Chris@49 398 arma_applier_1a(/=);
Chris@49 399 }
Chris@49 400 else
Chris@49 401 {
Chris@49 402 typename Proxy<T1>::ea_type P = x.P.get_ea();
Chris@49 403
Chris@49 404 arma_applier_1u(/=);
Chris@49 405 }
Chris@49 406 }
Chris@49 407 else
Chris@49 408 {
Chris@49 409 typename Proxy<T1>::ea_type P = x.P.get_ea();
Chris@49 410
Chris@49 411 arma_applier_1u(/=);
Chris@49 412 }
Chris@49 413 }
Chris@49 414 else
Chris@49 415 {
Chris@49 416 const Proxy<T1>& P = x.P;
Chris@49 417
Chris@49 418 arma_applier_2(/=);
Chris@49 419 }
Chris@49 420 }
Chris@49 421
Chris@49 422
Chris@49 423
Chris@49 424 //
Chris@49 425 // cubes
Chris@49 426
Chris@49 427
Chris@49 428
Chris@49 429 template<typename eop_type>
Chris@49 430 template<typename T1>
Chris@49 431 arma_hot
Chris@49 432 inline
Chris@49 433 void
Chris@49 434 eop_core<eop_type>::apply(Cube<typename T1::elem_type>& out, const eOpCube<T1, eop_type>& x)
Chris@49 435 {
Chris@49 436 arma_extra_debug_sigprint();
Chris@49 437
Chris@49 438 typedef typename T1::elem_type eT;
Chris@49 439
Chris@49 440 // NOTE: we're assuming that the matrix has already been set to the correct size and there is no aliasing;
Chris@49 441 // size setting and alias checking is done by either the Mat contructor or operator=()
Chris@49 442
Chris@49 443 const eT k = x.aux;
Chris@49 444 eT* out_mem = out.memptr();
Chris@49 445
Chris@49 446 if(ProxyCube<T1>::prefer_at_accessor == false)
Chris@49 447 {
Chris@49 448 const uword n_elem = out.n_elem;
Chris@49 449
Chris@49 450 if(memory::is_aligned(out_mem))
Chris@49 451 {
Chris@49 452 memory::mark_as_aligned(out_mem);
Chris@49 453
Chris@49 454 if(x.P.is_aligned())
Chris@49 455 {
Chris@49 456 typename ProxyCube<T1>::aligned_ea_type P = x.P.get_aligned_ea();
Chris@49 457
Chris@49 458 arma_applier_1a(=);
Chris@49 459 }
Chris@49 460 else
Chris@49 461 {
Chris@49 462 typename ProxyCube<T1>::ea_type P = x.P.get_ea();
Chris@49 463
Chris@49 464 arma_applier_1u(=);
Chris@49 465 }
Chris@49 466 }
Chris@49 467 else
Chris@49 468 {
Chris@49 469 typename ProxyCube<T1>::ea_type P = x.P.get_ea();
Chris@49 470
Chris@49 471 arma_applier_1u(=);
Chris@49 472 }
Chris@49 473 }
Chris@49 474 else
Chris@49 475 {
Chris@49 476 const uword n_rows = x.get_n_rows();
Chris@49 477 const uword n_cols = x.get_n_cols();
Chris@49 478 const uword n_slices = x.get_n_slices();
Chris@49 479
Chris@49 480 const ProxyCube<T1>& P = x.P;
Chris@49 481
Chris@49 482 arma_applier_3(=);
Chris@49 483 }
Chris@49 484 }
Chris@49 485
Chris@49 486
Chris@49 487
Chris@49 488 template<typename eop_type>
Chris@49 489 template<typename T1>
Chris@49 490 arma_hot
Chris@49 491 inline
Chris@49 492 void
Chris@49 493 eop_core<eop_type>::apply_inplace_plus(Cube<typename T1::elem_type>& out, const eOpCube<T1, eop_type>& x)
Chris@49 494 {
Chris@49 495 arma_extra_debug_sigprint();
Chris@49 496
Chris@49 497 typedef typename T1::elem_type eT;
Chris@49 498
Chris@49 499 const uword n_rows = x.get_n_rows();
Chris@49 500 const uword n_cols = x.get_n_cols();
Chris@49 501 const uword n_slices = x.get_n_slices();
Chris@49 502
Chris@49 503 arma_debug_assert_same_size(out.n_rows, out.n_cols, out.n_slices, n_rows, n_cols, n_slices, "addition");
Chris@49 504
Chris@49 505 const eT k = x.aux;
Chris@49 506 eT* out_mem = out.memptr();
Chris@49 507
Chris@49 508 if(ProxyCube<T1>::prefer_at_accessor == false)
Chris@49 509 {
Chris@49 510 const uword n_elem = out.n_elem;
Chris@49 511
Chris@49 512 if(memory::is_aligned(out_mem))
Chris@49 513 {
Chris@49 514 memory::mark_as_aligned(out_mem);
Chris@49 515
Chris@49 516 if(x.P.is_aligned())
Chris@49 517 {
Chris@49 518 typename ProxyCube<T1>::aligned_ea_type P = x.P.get_aligned_ea();
Chris@49 519
Chris@49 520 arma_applier_1a(+=);
Chris@49 521 }
Chris@49 522 else
Chris@49 523 {
Chris@49 524 typename ProxyCube<T1>::ea_type P = x.P.get_ea();
Chris@49 525
Chris@49 526 arma_applier_1u(+=);
Chris@49 527 }
Chris@49 528 }
Chris@49 529 else
Chris@49 530 {
Chris@49 531 typename ProxyCube<T1>::ea_type P = x.P.get_ea();
Chris@49 532
Chris@49 533 arma_applier_1u(+=);
Chris@49 534 }
Chris@49 535 }
Chris@49 536 else
Chris@49 537 {
Chris@49 538 const ProxyCube<T1>& P = x.P;
Chris@49 539
Chris@49 540 arma_applier_3(+=);
Chris@49 541 }
Chris@49 542 }
Chris@49 543
Chris@49 544
Chris@49 545
Chris@49 546 template<typename eop_type>
Chris@49 547 template<typename T1>
Chris@49 548 arma_hot
Chris@49 549 inline
Chris@49 550 void
Chris@49 551 eop_core<eop_type>::apply_inplace_minus(Cube<typename T1::elem_type>& out, const eOpCube<T1, eop_type>& x)
Chris@49 552 {
Chris@49 553 arma_extra_debug_sigprint();
Chris@49 554
Chris@49 555 typedef typename T1::elem_type eT;
Chris@49 556
Chris@49 557 const uword n_rows = x.get_n_rows();
Chris@49 558 const uword n_cols = x.get_n_cols();
Chris@49 559 const uword n_slices = x.get_n_slices();
Chris@49 560
Chris@49 561 arma_debug_assert_same_size(out.n_rows, out.n_cols, out.n_slices, n_rows, n_cols, n_slices, "subtraction");
Chris@49 562
Chris@49 563 const eT k = x.aux;
Chris@49 564 eT* out_mem = out.memptr();
Chris@49 565
Chris@49 566 if(ProxyCube<T1>::prefer_at_accessor == false)
Chris@49 567 {
Chris@49 568 const uword n_elem = out.n_elem;
Chris@49 569
Chris@49 570 if(memory::is_aligned(out_mem))
Chris@49 571 {
Chris@49 572 memory::mark_as_aligned(out_mem);
Chris@49 573
Chris@49 574 if(x.P.is_aligned())
Chris@49 575 {
Chris@49 576 typename ProxyCube<T1>::aligned_ea_type P = x.P.get_aligned_ea();
Chris@49 577
Chris@49 578 arma_applier_1a(-=);
Chris@49 579 }
Chris@49 580 else
Chris@49 581 {
Chris@49 582 typename ProxyCube<T1>::ea_type P = x.P.get_ea();
Chris@49 583
Chris@49 584 arma_applier_1u(-=);
Chris@49 585 }
Chris@49 586 }
Chris@49 587 else
Chris@49 588 {
Chris@49 589 typename ProxyCube<T1>::ea_type P = x.P.get_ea();
Chris@49 590
Chris@49 591 arma_applier_1u(-=);
Chris@49 592 }
Chris@49 593 }
Chris@49 594 else
Chris@49 595 {
Chris@49 596 const ProxyCube<T1>& P = x.P;
Chris@49 597
Chris@49 598 arma_applier_3(-=);
Chris@49 599 }
Chris@49 600 }
Chris@49 601
Chris@49 602
Chris@49 603
Chris@49 604 template<typename eop_type>
Chris@49 605 template<typename T1>
Chris@49 606 arma_hot
Chris@49 607 inline
Chris@49 608 void
Chris@49 609 eop_core<eop_type>::apply_inplace_schur(Cube<typename T1::elem_type>& out, const eOpCube<T1, eop_type>& x)
Chris@49 610 {
Chris@49 611 arma_extra_debug_sigprint();
Chris@49 612
Chris@49 613 typedef typename T1::elem_type eT;
Chris@49 614
Chris@49 615 const uword n_rows = x.get_n_rows();
Chris@49 616 const uword n_cols = x.get_n_cols();
Chris@49 617 const uword n_slices = x.get_n_slices();
Chris@49 618
Chris@49 619 arma_debug_assert_same_size(out.n_rows, out.n_cols, out.n_slices, n_rows, n_cols, n_slices, "element-wise multiplication");
Chris@49 620
Chris@49 621 const eT k = x.aux;
Chris@49 622 eT* out_mem = out.memptr();
Chris@49 623
Chris@49 624 if(ProxyCube<T1>::prefer_at_accessor == false)
Chris@49 625 {
Chris@49 626 const uword n_elem = out.n_elem;
Chris@49 627
Chris@49 628 if(memory::is_aligned(out_mem))
Chris@49 629 {
Chris@49 630 memory::mark_as_aligned(out_mem);
Chris@49 631
Chris@49 632 if(x.P.is_aligned())
Chris@49 633 {
Chris@49 634 typename ProxyCube<T1>::aligned_ea_type P = x.P.get_aligned_ea();
Chris@49 635
Chris@49 636 arma_applier_1a(*=);
Chris@49 637 }
Chris@49 638 else
Chris@49 639 {
Chris@49 640 typename ProxyCube<T1>::ea_type P = x.P.get_ea();
Chris@49 641
Chris@49 642 arma_applier_1u(*=);
Chris@49 643 }
Chris@49 644 }
Chris@49 645 else
Chris@49 646 {
Chris@49 647 typename ProxyCube<T1>::ea_type P = x.P.get_ea();
Chris@49 648
Chris@49 649 arma_applier_1u(*=);
Chris@49 650 }
Chris@49 651 }
Chris@49 652 else
Chris@49 653 {
Chris@49 654 const ProxyCube<T1>& P = x.P;
Chris@49 655
Chris@49 656 arma_applier_3(*=);
Chris@49 657 }
Chris@49 658 }
Chris@49 659
Chris@49 660
Chris@49 661
Chris@49 662 template<typename eop_type>
Chris@49 663 template<typename T1>
Chris@49 664 arma_hot
Chris@49 665 inline
Chris@49 666 void
Chris@49 667 eop_core<eop_type>::apply_inplace_div(Cube<typename T1::elem_type>& out, const eOpCube<T1, eop_type>& x)
Chris@49 668 {
Chris@49 669 arma_extra_debug_sigprint();
Chris@49 670
Chris@49 671 typedef typename T1::elem_type eT;
Chris@49 672
Chris@49 673 const uword n_rows = x.get_n_rows();
Chris@49 674 const uword n_cols = x.get_n_cols();
Chris@49 675 const uword n_slices = x.get_n_slices();
Chris@49 676
Chris@49 677 arma_debug_assert_same_size(out.n_rows, out.n_cols, out.n_slices, n_rows, n_cols, n_slices, "element-wise division");
Chris@49 678
Chris@49 679 const eT k = x.aux;
Chris@49 680 eT* out_mem = out.memptr();
Chris@49 681
Chris@49 682 if(ProxyCube<T1>::prefer_at_accessor == false)
Chris@49 683 {
Chris@49 684 const uword n_elem = out.n_elem;
Chris@49 685
Chris@49 686 if(memory::is_aligned(out_mem))
Chris@49 687 {
Chris@49 688 memory::mark_as_aligned(out_mem);
Chris@49 689
Chris@49 690 if(x.P.is_aligned())
Chris@49 691 {
Chris@49 692 typename ProxyCube<T1>::aligned_ea_type P = x.P.get_aligned_ea();
Chris@49 693
Chris@49 694 arma_applier_1a(/=);
Chris@49 695 }
Chris@49 696 else
Chris@49 697 {
Chris@49 698 typename ProxyCube<T1>::ea_type P = x.P.get_ea();
Chris@49 699
Chris@49 700 arma_applier_1u(/=);
Chris@49 701 }
Chris@49 702 }
Chris@49 703 else
Chris@49 704 {
Chris@49 705 typename ProxyCube<T1>::ea_type P = x.P.get_ea();
Chris@49 706
Chris@49 707 arma_applier_1u(/=);
Chris@49 708 }
Chris@49 709 }
Chris@49 710 else
Chris@49 711 {
Chris@49 712 const ProxyCube<T1>& P = x.P;
Chris@49 713
Chris@49 714 arma_applier_3(/=);
Chris@49 715 }
Chris@49 716 }
Chris@49 717
Chris@49 718
Chris@49 719
Chris@49 720 //
Chris@49 721 // common
Chris@49 722
Chris@49 723
Chris@49 724
Chris@49 725 template<typename eop_type>
Chris@49 726 template<typename eT>
Chris@49 727 arma_hot
Chris@49 728 arma_pure
Chris@49 729 arma_inline
Chris@49 730 eT
Chris@49 731 eop_core<eop_type>::process(const eT, const eT)
Chris@49 732 {
Chris@49 733 arma_stop("eop_core::process(): unhandled eop_type");
Chris@49 734 return eT(0);
Chris@49 735 }
Chris@49 736
Chris@49 737
Chris@49 738
Chris@49 739 template<> template<typename eT> arma_hot arma_const arma_inline eT
Chris@49 740 eop_core<eop_scalar_plus >::process(const eT val, const eT k) { return val + k; }
Chris@49 741
Chris@49 742 template<> template<typename eT> arma_hot arma_const arma_inline eT
Chris@49 743 eop_core<eop_scalar_minus_pre >::process(const eT val, const eT k) { return k - val; }
Chris@49 744
Chris@49 745 template<> template<typename eT> arma_hot arma_const arma_inline eT
Chris@49 746 eop_core<eop_scalar_minus_post>::process(const eT val, const eT k) { return val - k; }
Chris@49 747
Chris@49 748 template<> template<typename eT> arma_hot arma_const arma_inline eT
Chris@49 749 eop_core<eop_scalar_times >::process(const eT val, const eT k) { return val * k; }
Chris@49 750
Chris@49 751 template<> template<typename eT> arma_hot arma_const arma_inline eT
Chris@49 752 eop_core<eop_scalar_div_pre >::process(const eT val, const eT k) { return k / val; }
Chris@49 753
Chris@49 754 template<> template<typename eT> arma_hot arma_const arma_inline eT
Chris@49 755 eop_core<eop_scalar_div_post >::process(const eT val, const eT k) { return val / k; }
Chris@49 756
Chris@49 757 template<> template<typename eT> arma_hot arma_const arma_inline eT
Chris@49 758 eop_core<eop_square >::process(const eT val, const eT ) { return val*val; }
Chris@49 759
Chris@49 760 template<> template<typename eT> arma_hot arma_const arma_inline eT
Chris@49 761 eop_core<eop_neg >::process(const eT val, const eT ) { return eop_aux::neg(val); }
Chris@49 762
Chris@49 763 template<> template<typename eT> arma_hot arma_pure arma_inline eT
Chris@49 764 eop_core<eop_sqrt >::process(const eT val, const eT ) { return eop_aux::sqrt(val); }
Chris@49 765
Chris@49 766 template<> template<typename eT> arma_hot arma_pure arma_inline eT
Chris@49 767 eop_core<eop_log >::process(const eT val, const eT ) { return eop_aux::log(val); }
Chris@49 768
Chris@49 769 template<> template<typename eT> arma_hot arma_pure arma_inline eT
Chris@49 770 eop_core<eop_log2 >::process(const eT val, const eT ) { return eop_aux::log2(val); }
Chris@49 771
Chris@49 772 template<> template<typename eT> arma_hot arma_pure arma_inline eT
Chris@49 773 eop_core<eop_log10 >::process(const eT val, const eT ) { return eop_aux::log10(val); }
Chris@49 774
Chris@49 775 template<> template<typename eT> arma_hot arma_pure arma_inline eT
Chris@49 776 eop_core<eop_trunc_log >::process(const eT val, const eT ) { return arma::trunc_log(val); }
Chris@49 777
Chris@49 778 template<> template<typename eT> arma_hot arma_pure arma_inline eT
Chris@49 779 eop_core<eop_exp >::process(const eT val, const eT ) { return eop_aux::exp(val); }
Chris@49 780
Chris@49 781 template<> template<typename eT> arma_hot arma_pure arma_inline eT
Chris@49 782 eop_core<eop_exp2 >::process(const eT val, const eT ) { return eop_aux::exp2(val); }
Chris@49 783
Chris@49 784 template<> template<typename eT> arma_hot arma_pure arma_inline eT
Chris@49 785 eop_core<eop_exp10 >::process(const eT val, const eT ) { return eop_aux::exp10(val); }
Chris@49 786
Chris@49 787 template<> template<typename eT> arma_hot arma_pure arma_inline eT
Chris@49 788 eop_core<eop_trunc_exp >::process(const eT val, const eT ) { return arma::trunc_exp(val); }
Chris@49 789
Chris@49 790 template<> template<typename eT> arma_hot arma_pure arma_inline eT
Chris@49 791 eop_core<eop_cos >::process(const eT val, const eT ) { return eop_aux::cos(val); }
Chris@49 792
Chris@49 793 template<> template<typename eT> arma_hot arma_pure arma_inline eT
Chris@49 794 eop_core<eop_sin >::process(const eT val, const eT ) { return eop_aux::sin(val); }
Chris@49 795
Chris@49 796 template<> template<typename eT> arma_hot arma_pure arma_inline eT
Chris@49 797 eop_core<eop_tan >::process(const eT val, const eT ) { return eop_aux::tan(val); }
Chris@49 798
Chris@49 799 template<> template<typename eT> arma_hot arma_pure arma_inline eT
Chris@49 800 eop_core<eop_acos >::process(const eT val, const eT ) { return eop_aux::acos(val); }
Chris@49 801
Chris@49 802 template<> template<typename eT> arma_hot arma_pure arma_inline eT
Chris@49 803 eop_core<eop_asin >::process(const eT val, const eT ) { return eop_aux::asin(val); }
Chris@49 804
Chris@49 805 template<> template<typename eT> arma_hot arma_pure arma_inline eT
Chris@49 806 eop_core<eop_atan >::process(const eT val, const eT ) { return eop_aux::atan(val); }
Chris@49 807
Chris@49 808 template<> template<typename eT> arma_hot arma_pure arma_inline eT
Chris@49 809 eop_core<eop_cosh >::process(const eT val, const eT ) { return eop_aux::cosh(val); }
Chris@49 810
Chris@49 811 template<> template<typename eT> arma_hot arma_pure arma_inline eT
Chris@49 812 eop_core<eop_sinh >::process(const eT val, const eT ) { return eop_aux::sinh(val); }
Chris@49 813
Chris@49 814 template<> template<typename eT> arma_hot arma_pure arma_inline eT
Chris@49 815 eop_core<eop_tanh >::process(const eT val, const eT ) { return eop_aux::tanh(val); }
Chris@49 816
Chris@49 817 template<> template<typename eT> arma_hot arma_pure arma_inline eT
Chris@49 818 eop_core<eop_acosh >::process(const eT val, const eT ) { return eop_aux::acosh(val); }
Chris@49 819
Chris@49 820 template<> template<typename eT> arma_hot arma_pure arma_inline eT
Chris@49 821 eop_core<eop_asinh >::process(const eT val, const eT ) { return eop_aux::asinh(val); }
Chris@49 822
Chris@49 823 template<> template<typename eT> arma_hot arma_pure arma_inline eT
Chris@49 824 eop_core<eop_atanh >::process(const eT val, const eT ) { return eop_aux::atanh(val); }
Chris@49 825
Chris@49 826 template<> template<typename eT> arma_hot arma_pure arma_inline eT
Chris@49 827 eop_core<eop_eps >::process(const eT val, const eT ) { return eop_aux::direct_eps(val); }
Chris@49 828
Chris@49 829 template<> template<typename eT> arma_hot arma_pure arma_inline eT
Chris@49 830 eop_core<eop_abs >::process(const eT val, const eT ) { return eop_aux::arma_abs(val); }
Chris@49 831
Chris@49 832 template<> template<typename eT> arma_hot arma_pure arma_inline eT
Chris@49 833 eop_core<eop_conj >::process(const eT val, const eT ) { return eop_aux::conj(val); }
Chris@49 834
Chris@49 835 template<> template<typename eT> arma_hot arma_pure arma_inline eT
Chris@49 836 eop_core<eop_pow >::process(const eT val, const eT k) { return eop_aux::pow(val, k); }
Chris@49 837
Chris@49 838 template<> template<typename eT> arma_hot arma_pure arma_inline eT
Chris@49 839 eop_core<eop_floor >::process(const eT val, const eT ) { return eop_aux::floor(val); }
Chris@49 840
Chris@49 841 template<> template<typename eT> arma_hot arma_pure arma_inline eT
Chris@49 842 eop_core<eop_ceil >::process(const eT val, const eT ) { return eop_aux::ceil(val); }
Chris@49 843
Chris@49 844 template<> template<typename eT> arma_hot arma_pure arma_inline eT
Chris@49 845 eop_core<eop_round >::process(const eT val, const eT ) { return eop_aux::round(val); }
Chris@49 846
Chris@49 847
Chris@49 848 #undef arma_applier_1u
Chris@49 849 #undef arma_applier_1a
Chris@49 850 #undef arma_applier_2
Chris@49 851 #undef arma_applier_3
Chris@49 852
Chris@49 853
Chris@49 854
Chris@49 855 //! @}