annotate armadillo-2.4.4/include/armadillo_bits/eglue_core_meat.hpp @ 5:79b343f3e4b8

In thi version the problem of letters assigned to each segment has been solved.
author maxzanoni76 <max.zanoni@eecs.qmul.ac.uk>
date Wed, 11 Apr 2012 13:48:13 +0100
parents 8b6102e2a9b0
children
rev   line source
max@0 1 // Copyright (C) 2010-2011 NICTA (www.nicta.com.au)
max@0 2 // Copyright (C) 2010-2011 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 eglue_core
max@0 15 //! @{
max@0 16
max@0 17
max@0 18
max@0 19 class eglue_plus : public eglue_core<eglue_plus>
max@0 20 {
max@0 21 public:
max@0 22
max@0 23 inline static const char* text() { return "addition"; }
max@0 24 };
max@0 25
max@0 26
max@0 27
max@0 28 class eglue_minus : public eglue_core<eglue_minus>
max@0 29 {
max@0 30 public:
max@0 31
max@0 32 inline static const char* text() { return "subtraction"; }
max@0 33 };
max@0 34
max@0 35
max@0 36
max@0 37 class eglue_div : public eglue_core<eglue_div>
max@0 38 {
max@0 39 public:
max@0 40
max@0 41 inline static const char* text() { return "element-wise division"; }
max@0 42 };
max@0 43
max@0 44
max@0 45
max@0 46 class eglue_schur : public eglue_core<eglue_schur>
max@0 47 {
max@0 48 public:
max@0 49
max@0 50 inline static const char* text() { return "element-wise multiplication"; }
max@0 51 };
max@0 52
max@0 53
max@0 54
max@0 55 #undef arma_applier_1
max@0 56 #undef arma_applier_2
max@0 57 #undef arma_applier_3
max@0 58 #undef operatorA
max@0 59 #undef operatorB
max@0 60
max@0 61 #define arma_applier_1(operatorA, operatorB) \
max@0 62 {\
max@0 63 uword i,j;\
max@0 64 \
max@0 65 for(i=0, j=1; j<n_elem; i+=2, j+=2)\
max@0 66 {\
max@0 67 eT tmp_i = P1[i];\
max@0 68 eT tmp_j = P1[j];\
max@0 69 \
max@0 70 tmp_i operatorB##= P2[i];\
max@0 71 tmp_j operatorB##= P2[j];\
max@0 72 \
max@0 73 out_mem[i] operatorA tmp_i;\
max@0 74 out_mem[j] operatorA tmp_j;\
max@0 75 }\
max@0 76 \
max@0 77 if(i < n_elem)\
max@0 78 {\
max@0 79 out_mem[i] operatorA P1[i] operatorB P2[i];\
max@0 80 }\
max@0 81 }
max@0 82
max@0 83
max@0 84
max@0 85 #define arma_applier_2(operatorA, operatorB) \
max@0 86 {\
max@0 87 uword count = 0;\
max@0 88 \
max@0 89 for(uword col=0; col<n_cols; ++col)\
max@0 90 {\
max@0 91 uword i,j;\
max@0 92 \
max@0 93 for(i=0, j=1; j<n_rows; i+=2, j+=2, count+=2)\
max@0 94 {\
max@0 95 eT tmp_i = P1.at(i,col);\
max@0 96 eT tmp_j = P1.at(j,col);\
max@0 97 \
max@0 98 tmp_i operatorB##= P2.at(i,col);\
max@0 99 tmp_j operatorB##= P2.at(j,col);\
max@0 100 \
max@0 101 out_mem[count ] operatorA tmp_i;\
max@0 102 out_mem[count+1] operatorA tmp_j;\
max@0 103 }\
max@0 104 \
max@0 105 if(i < n_rows)\
max@0 106 {\
max@0 107 out_mem[count] operatorA P1.at(i,col) operatorB P2.at(i,col);\
max@0 108 ++count;\
max@0 109 }\
max@0 110 }\
max@0 111 }
max@0 112
max@0 113
max@0 114
max@0 115 #define arma_applier_3(operatorA, operatorB) \
max@0 116 {\
max@0 117 uword count = 0;\
max@0 118 \
max@0 119 for(uword slice=0; slice<n_slices; ++slice)\
max@0 120 {\
max@0 121 for(uword col=0; col<n_cols; ++col)\
max@0 122 {\
max@0 123 uword i,j;\
max@0 124 \
max@0 125 for(i=0, j=1; j<n_rows; i+=2, j+=2, count+=2)\
max@0 126 {\
max@0 127 eT tmp_i = P1.at(i,col,slice);\
max@0 128 eT tmp_j = P1.at(j,col,slice);\
max@0 129 \
max@0 130 tmp_i operatorB##= P2.at(i,col,slice);\
max@0 131 tmp_j operatorB##= P2.at(j,col,slice);\
max@0 132 \
max@0 133 out_mem[count ] operatorA tmp_i;\
max@0 134 out_mem[count+1] operatorA tmp_j;\
max@0 135 }\
max@0 136 \
max@0 137 if(i < n_rows)\
max@0 138 {\
max@0 139 out_mem[count] operatorA P1.at(i,col,slice) operatorB P2.at(i,col,slice);\
max@0 140 ++count;\
max@0 141 }\
max@0 142 }\
max@0 143 }\
max@0 144 }
max@0 145
max@0 146
max@0 147
max@0 148 //
max@0 149 // matrices
max@0 150
max@0 151
max@0 152
max@0 153 template<typename eglue_type>
max@0 154 template<typename T1, typename T2>
max@0 155 arma_hot
max@0 156 inline
max@0 157 void
max@0 158 eglue_core<eglue_type>::apply(Mat<typename T1::elem_type>& out, const eGlue<T1, T2, eglue_type>& x)
max@0 159 {
max@0 160 arma_extra_debug_sigprint();
max@0 161
max@0 162 typedef typename T1::elem_type eT;
max@0 163
max@0 164 const bool prefer_at_accessor = (Proxy<T1>::prefer_at_accessor || Proxy<T2>::prefer_at_accessor);
max@0 165
max@0 166 // NOTE: we're assuming that the matrix has already been set to the correct size and there is no aliasing;
max@0 167 // size setting and alias checking is done by either the Mat contructor or operator=()
max@0 168
max@0 169 eT* out_mem = out.memptr();
max@0 170
max@0 171 if(prefer_at_accessor == false)
max@0 172 {
max@0 173 const uword n_elem = out.n_elem;
max@0 174
max@0 175 typename Proxy<T1>::ea_type P1 = x.P1.get_ea();
max@0 176 typename Proxy<T2>::ea_type P2 = x.P2.get_ea();
max@0 177
max@0 178 if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_applier_1(=, +); }
max@0 179 else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_applier_1(=, -); }
max@0 180 else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_applier_1(=, /); }
max@0 181 else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_applier_1(=, *); }
max@0 182 }
max@0 183 else
max@0 184 {
max@0 185 const uword n_rows = out.n_rows;
max@0 186 const uword n_cols = out.n_cols;
max@0 187
max@0 188 const Proxy<T1>& P1 = x.P1;
max@0 189 const Proxy<T2>& P2 = x.P2;
max@0 190
max@0 191 if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_applier_2(=, +); }
max@0 192 else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_applier_2(=, -); }
max@0 193 else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_applier_2(=, /); }
max@0 194 else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_applier_2(=, *); }
max@0 195 }
max@0 196 }
max@0 197
max@0 198
max@0 199
max@0 200 template<typename eglue_type>
max@0 201 template<typename T1, typename T2>
max@0 202 arma_hot
max@0 203 inline
max@0 204 void
max@0 205 eglue_core<eglue_type>::apply_inplace_plus(Mat<typename T1::elem_type>& out, const eGlue<T1, T2, eglue_type>& x)
max@0 206 {
max@0 207 arma_extra_debug_sigprint();
max@0 208
max@0 209 arma_debug_assert_same_size(out, x.P1, "addition");
max@0 210
max@0 211 typedef typename T1::elem_type eT;
max@0 212
max@0 213 eT* out_mem = out.memptr();
max@0 214
max@0 215 const bool prefer_at_accessor = (Proxy<T1>::prefer_at_accessor || Proxy<T2>::prefer_at_accessor);
max@0 216
max@0 217 if(prefer_at_accessor == false)
max@0 218 {
max@0 219 const uword n_elem = out.n_elem;
max@0 220
max@0 221 typename Proxy<T1>::ea_type P1 = x.P1.get_ea();
max@0 222 typename Proxy<T2>::ea_type P2 = x.P2.get_ea();
max@0 223
max@0 224 if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_applier_1(+=, +); }
max@0 225 else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_applier_1(+=, -); }
max@0 226 else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_applier_1(+=, /); }
max@0 227 else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_applier_1(+=, *); }
max@0 228 }
max@0 229 else
max@0 230 {
max@0 231 const uword n_rows = out.n_rows;
max@0 232 const uword n_cols = out.n_cols;
max@0 233
max@0 234 const Proxy<T1>& P1 = x.P1;
max@0 235 const Proxy<T2>& P2 = x.P2;
max@0 236
max@0 237 if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_applier_2(+=, +); }
max@0 238 else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_applier_2(+=, -); }
max@0 239 else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_applier_2(+=, /); }
max@0 240 else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_applier_2(+=, *); }
max@0 241 }
max@0 242 }
max@0 243
max@0 244
max@0 245
max@0 246 template<typename eglue_type>
max@0 247 template<typename T1, typename T2>
max@0 248 arma_hot
max@0 249 inline
max@0 250 void
max@0 251 eglue_core<eglue_type>::apply_inplace_minus(Mat<typename T1::elem_type>& out, const eGlue<T1, T2, eglue_type>& x)
max@0 252 {
max@0 253 arma_extra_debug_sigprint();
max@0 254
max@0 255 arma_debug_assert_same_size(out, x.P1, "subtraction");
max@0 256
max@0 257 typedef typename T1::elem_type eT;
max@0 258
max@0 259 eT* out_mem = out.memptr();
max@0 260
max@0 261 const bool prefer_at_accessor = (Proxy<T1>::prefer_at_accessor || Proxy<T2>::prefer_at_accessor);
max@0 262
max@0 263 if(prefer_at_accessor == false)
max@0 264 {
max@0 265 const uword n_elem = out.n_elem;
max@0 266
max@0 267 typename Proxy<T1>::ea_type P1 = x.P1.get_ea();
max@0 268 typename Proxy<T2>::ea_type P2 = x.P2.get_ea();
max@0 269
max@0 270 if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_applier_1(-=, +); }
max@0 271 else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_applier_1(-=, -); }
max@0 272 else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_applier_1(-=, /); }
max@0 273 else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_applier_1(-=, *); }
max@0 274 }
max@0 275 else
max@0 276 {
max@0 277 const uword n_rows = out.n_rows;
max@0 278 const uword n_cols = out.n_cols;
max@0 279
max@0 280 const Proxy<T1>& P1 = x.P1;
max@0 281 const Proxy<T2>& P2 = x.P2;
max@0 282
max@0 283 if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_applier_2(-=, +); }
max@0 284 else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_applier_2(-=, -); }
max@0 285 else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_applier_2(-=, /); }
max@0 286 else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_applier_2(-=, *); }
max@0 287 }
max@0 288 }
max@0 289
max@0 290
max@0 291
max@0 292 template<typename eglue_type>
max@0 293 template<typename T1, typename T2>
max@0 294 arma_hot
max@0 295 inline
max@0 296 void
max@0 297 eglue_core<eglue_type>::apply_inplace_schur(Mat<typename T1::elem_type>& out, const eGlue<T1, T2, eglue_type>& x)
max@0 298 {
max@0 299 arma_extra_debug_sigprint();
max@0 300
max@0 301 arma_debug_assert_same_size(out, x.P1, "element-wise multiplication");
max@0 302
max@0 303 typedef typename T1::elem_type eT;
max@0 304
max@0 305 eT* out_mem = out.memptr();
max@0 306
max@0 307 const bool prefer_at_accessor = (Proxy<T1>::prefer_at_accessor || Proxy<T2>::prefer_at_accessor);
max@0 308
max@0 309 if(prefer_at_accessor == false)
max@0 310 {
max@0 311 const uword n_elem = out.n_elem;
max@0 312
max@0 313 typename Proxy<T1>::ea_type P1 = x.P1.get_ea();
max@0 314 typename Proxy<T2>::ea_type P2 = x.P2.get_ea();
max@0 315
max@0 316 if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_applier_1(*=, +); }
max@0 317 else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_applier_1(*=, -); }
max@0 318 else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_applier_1(*=, /); }
max@0 319 else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_applier_1(*=, *); }
max@0 320 }
max@0 321 else
max@0 322 {
max@0 323 const uword n_rows = out.n_rows;
max@0 324 const uword n_cols = out.n_cols;
max@0 325
max@0 326 const Proxy<T1>& P1 = x.P1;
max@0 327 const Proxy<T2>& P2 = x.P2;
max@0 328
max@0 329 if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_applier_2(*=, +); }
max@0 330 else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_applier_2(*=, -); }
max@0 331 else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_applier_2(*=, /); }
max@0 332 else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_applier_2(*=, *); }
max@0 333 }
max@0 334 }
max@0 335
max@0 336
max@0 337
max@0 338 template<typename eglue_type>
max@0 339 template<typename T1, typename T2>
max@0 340 arma_hot
max@0 341 inline
max@0 342 void
max@0 343 eglue_core<eglue_type>::apply_inplace_div(Mat<typename T1::elem_type>& out, const eGlue<T1, T2, eglue_type>& x)
max@0 344 {
max@0 345 arma_extra_debug_sigprint();
max@0 346
max@0 347 arma_debug_assert_same_size(out, x.P1, "element-wise division");
max@0 348
max@0 349 typedef typename T1::elem_type eT;
max@0 350
max@0 351 eT* out_mem = out.memptr();
max@0 352
max@0 353 const bool prefer_at_accessor = (Proxy<T1>::prefer_at_accessor || Proxy<T2>::prefer_at_accessor);
max@0 354
max@0 355 if(prefer_at_accessor == false)
max@0 356 {
max@0 357 const uword n_elem = out.n_elem;
max@0 358
max@0 359 typename Proxy<T1>::ea_type P1 = x.P1.get_ea();
max@0 360 typename Proxy<T2>::ea_type P2 = x.P2.get_ea();
max@0 361
max@0 362 if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_applier_1(/=, +); }
max@0 363 else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_applier_1(/=, -); }
max@0 364 else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_applier_1(/=, /); }
max@0 365 else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_applier_1(/=, *); }
max@0 366 }
max@0 367 else
max@0 368 {
max@0 369 const uword n_rows = out.n_rows;
max@0 370 const uword n_cols = out.n_cols;
max@0 371
max@0 372 const Proxy<T1>& P1 = x.P1;
max@0 373 const Proxy<T2>& P2 = x.P2;
max@0 374
max@0 375 if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_applier_2(*=, +); }
max@0 376 else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_applier_2(*=, -); }
max@0 377 else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_applier_2(*=, /); }
max@0 378 else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_applier_2(*=, *); }
max@0 379 }
max@0 380 }
max@0 381
max@0 382
max@0 383
max@0 384 //
max@0 385 // cubes
max@0 386
max@0 387
max@0 388
max@0 389 template<typename eglue_type>
max@0 390 template<typename T1, typename T2>
max@0 391 arma_hot
max@0 392 inline
max@0 393 void
max@0 394 eglue_core<eglue_type>::apply(Cube<typename T1::elem_type>& out, const eGlueCube<T1, T2, eglue_type>& x)
max@0 395 {
max@0 396 arma_extra_debug_sigprint();
max@0 397
max@0 398 typedef typename T1::elem_type eT;
max@0 399
max@0 400 const bool prefer_at_accessor = (ProxyCube<T1>::prefer_at_accessor || ProxyCube<T2>::prefer_at_accessor);
max@0 401
max@0 402 // NOTE: we're assuming that the cube has already been set to the correct size and there is no aliasing;
max@0 403 // size setting and alias checking is done by either the Cube contructor or operator=()
max@0 404
max@0 405
max@0 406 eT* out_mem = out.memptr();
max@0 407
max@0 408 if(prefer_at_accessor == false)
max@0 409 {
max@0 410 const uword n_elem = out.n_elem;
max@0 411
max@0 412 typename ProxyCube<T1>::ea_type P1 = x.P1.get_ea();
max@0 413 typename ProxyCube<T2>::ea_type P2 = x.P2.get_ea();
max@0 414
max@0 415 if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_applier_1(=, +); }
max@0 416 else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_applier_1(=, -); }
max@0 417 else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_applier_1(=, /); }
max@0 418 else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_applier_1(=, *); }
max@0 419 }
max@0 420 else
max@0 421 {
max@0 422 const uword n_rows = x.get_n_rows();
max@0 423 const uword n_cols = x.get_n_cols();
max@0 424 const uword n_slices = x.get_n_slices();
max@0 425
max@0 426 const ProxyCube<T1>& P1 = x.P1;
max@0 427 const ProxyCube<T2>& P2 = x.P2;
max@0 428
max@0 429 if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_applier_3(=, +); }
max@0 430 else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_applier_3(=, -); }
max@0 431 else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_applier_3(=, /); }
max@0 432 else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_applier_3(=, *); }
max@0 433 }
max@0 434 }
max@0 435
max@0 436
max@0 437
max@0 438 template<typename eglue_type>
max@0 439 template<typename T1, typename T2>
max@0 440 arma_hot
max@0 441 inline
max@0 442 void
max@0 443 eglue_core<eglue_type>::apply_inplace_plus(Cube<typename T1::elem_type>& out, const eGlueCube<T1, T2, eglue_type>& x)
max@0 444 {
max@0 445 arma_extra_debug_sigprint();
max@0 446
max@0 447 const uword n_rows = x.get_n_rows();
max@0 448 const uword n_cols = x.get_n_cols();
max@0 449 const uword n_slices = x.get_n_slices();
max@0 450
max@0 451 arma_debug_assert_same_size(out.n_rows, out.n_cols, out.n_slices, n_rows, n_cols, n_slices, "addition");
max@0 452
max@0 453 typedef typename T1::elem_type eT;
max@0 454
max@0 455 eT* out_mem = out.memptr();
max@0 456
max@0 457 const bool prefer_at_accessor = (ProxyCube<T1>::prefer_at_accessor || ProxyCube<T2>::prefer_at_accessor);
max@0 458
max@0 459 if(prefer_at_accessor == false)
max@0 460 {
max@0 461 const uword n_elem = out.n_elem;
max@0 462
max@0 463 typename ProxyCube<T1>::ea_type P1 = x.P1.get_ea();
max@0 464 typename ProxyCube<T2>::ea_type P2 = x.P2.get_ea();
max@0 465
max@0 466 if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_applier_1(+=, +); }
max@0 467 else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_applier_1(+=, -); }
max@0 468 else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_applier_1(+=, /); }
max@0 469 else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_applier_1(+=, *); }
max@0 470 }
max@0 471 else
max@0 472 {
max@0 473 const ProxyCube<T1>& P1 = x.P1;
max@0 474 const ProxyCube<T2>& P2 = x.P2;
max@0 475
max@0 476 if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_applier_3(+=, +); }
max@0 477 else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_applier_3(+=, -); }
max@0 478 else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_applier_3(+=, /); }
max@0 479 else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_applier_3(+=, *); }
max@0 480 }
max@0 481 }
max@0 482
max@0 483
max@0 484
max@0 485 template<typename eglue_type>
max@0 486 template<typename T1, typename T2>
max@0 487 arma_hot
max@0 488 inline
max@0 489 void
max@0 490 eglue_core<eglue_type>::apply_inplace_minus(Cube<typename T1::elem_type>& out, const eGlueCube<T1, T2, eglue_type>& x)
max@0 491 {
max@0 492 arma_extra_debug_sigprint();
max@0 493
max@0 494 const uword n_rows = x.get_n_rows();
max@0 495 const uword n_cols = x.get_n_cols();
max@0 496 const uword n_slices = x.get_n_slices();
max@0 497
max@0 498 arma_debug_assert_same_size(out.n_rows, out.n_cols, out.n_slices, n_rows, n_cols, n_slices, "subtraction");
max@0 499
max@0 500 typedef typename T1::elem_type eT;
max@0 501
max@0 502 eT* out_mem = out.memptr();
max@0 503
max@0 504 const bool prefer_at_accessor = (ProxyCube<T1>::prefer_at_accessor || ProxyCube<T2>::prefer_at_accessor);
max@0 505
max@0 506 if(prefer_at_accessor == false)
max@0 507 {
max@0 508 const uword n_elem = out.n_elem;
max@0 509
max@0 510 typename ProxyCube<T1>::ea_type P1 = x.P1.get_ea();
max@0 511 typename ProxyCube<T2>::ea_type P2 = x.P2.get_ea();
max@0 512
max@0 513 if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_applier_1(-=, +); }
max@0 514 else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_applier_1(-=, -); }
max@0 515 else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_applier_1(-=, /); }
max@0 516 else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_applier_1(-=, *); }
max@0 517 }
max@0 518 else
max@0 519 {
max@0 520 const ProxyCube<T1>& P1 = x.P1;
max@0 521 const ProxyCube<T2>& P2 = x.P2;
max@0 522
max@0 523 if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_applier_3(-=, +); }
max@0 524 else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_applier_3(-=, -); }
max@0 525 else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_applier_3(-=, /); }
max@0 526 else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_applier_3(-=, *); }
max@0 527 }
max@0 528 }
max@0 529
max@0 530
max@0 531
max@0 532 template<typename eglue_type>
max@0 533 template<typename T1, typename T2>
max@0 534 arma_hot
max@0 535 inline
max@0 536 void
max@0 537 eglue_core<eglue_type>::apply_inplace_schur(Cube<typename T1::elem_type>& out, const eGlueCube<T1, T2, eglue_type>& x)
max@0 538 {
max@0 539 arma_extra_debug_sigprint();
max@0 540
max@0 541 const uword n_rows = x.get_n_rows();
max@0 542 const uword n_cols = x.get_n_cols();
max@0 543 const uword n_slices = x.get_n_slices();
max@0 544
max@0 545 arma_debug_assert_same_size(out.n_rows, out.n_cols, out.n_slices, n_rows, n_cols, n_slices, "element-wise multiplication");
max@0 546
max@0 547 typedef typename T1::elem_type eT;
max@0 548
max@0 549 eT* out_mem = out.memptr();
max@0 550
max@0 551 const bool prefer_at_accessor = (ProxyCube<T1>::prefer_at_accessor || ProxyCube<T2>::prefer_at_accessor);
max@0 552
max@0 553 if(prefer_at_accessor == false)
max@0 554 {
max@0 555 const uword n_elem = out.n_elem;
max@0 556
max@0 557 typename ProxyCube<T1>::ea_type P1 = x.P1.get_ea();
max@0 558 typename ProxyCube<T2>::ea_type P2 = x.P2.get_ea();
max@0 559
max@0 560 if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_applier_1(*=, +); }
max@0 561 else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_applier_1(*=, -); }
max@0 562 else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_applier_1(*=, /); }
max@0 563 else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_applier_1(*=, *); }
max@0 564 }
max@0 565 else
max@0 566 {
max@0 567 const ProxyCube<T1>& P1 = x.P1;
max@0 568 const ProxyCube<T2>& P2 = x.P2;
max@0 569
max@0 570 if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_applier_3(*=, +); }
max@0 571 else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_applier_3(*=, -); }
max@0 572 else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_applier_3(*=, /); }
max@0 573 else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_applier_3(*=, *); }
max@0 574 }
max@0 575 }
max@0 576
max@0 577
max@0 578
max@0 579 template<typename eglue_type>
max@0 580 template<typename T1, typename T2>
max@0 581 arma_hot
max@0 582 inline
max@0 583 void
max@0 584 eglue_core<eglue_type>::apply_inplace_div(Cube<typename T1::elem_type>& out, const eGlueCube<T1, T2, eglue_type>& x)
max@0 585 {
max@0 586 arma_extra_debug_sigprint();
max@0 587
max@0 588 const uword n_rows = x.get_n_rows();
max@0 589 const uword n_cols = x.get_n_cols();
max@0 590 const uword n_slices = x.get_n_slices();
max@0 591
max@0 592 arma_debug_assert_same_size(out.n_rows, out.n_cols, out.n_slices, n_rows, n_cols, n_slices, "element-wise division");
max@0 593
max@0 594 typedef typename T1::elem_type eT;
max@0 595
max@0 596 eT* out_mem = out.memptr();
max@0 597
max@0 598 const bool prefer_at_accessor = (ProxyCube<T1>::prefer_at_accessor || ProxyCube<T2>::prefer_at_accessor);
max@0 599
max@0 600 if(prefer_at_accessor == false)
max@0 601 {
max@0 602 const uword n_elem = out.n_elem;
max@0 603
max@0 604 typename ProxyCube<T1>::ea_type P1 = x.P1.get_ea();
max@0 605 typename ProxyCube<T2>::ea_type P2 = x.P2.get_ea();
max@0 606
max@0 607 if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_applier_1(/=, +); }
max@0 608 else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_applier_1(/=, -); }
max@0 609 else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_applier_1(/=, /); }
max@0 610 else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_applier_1(/=, *); }
max@0 611 }
max@0 612 else
max@0 613 {
max@0 614 const ProxyCube<T1>& P1 = x.P1;
max@0 615 const ProxyCube<T2>& P2 = x.P2;
max@0 616
max@0 617 if(is_same_type<eglue_type, eglue_plus >::value == true) { arma_applier_3(/=, +); }
max@0 618 else if(is_same_type<eglue_type, eglue_minus>::value == true) { arma_applier_3(/=, -); }
max@0 619 else if(is_same_type<eglue_type, eglue_div >::value == true) { arma_applier_3(/=, /); }
max@0 620 else if(is_same_type<eglue_type, eglue_schur>::value == true) { arma_applier_3(/=, *); }
max@0 621 }
max@0 622 }
max@0 623
max@0 624
max@0 625
max@0 626 #undef arma_applier_1
max@0 627 #undef arma_applier_2
max@0 628 #undef arma_applier_3
max@0 629
max@0 630
max@0 631
max@0 632 //! @}