annotate armadillo-2.4.4/include/armadillo_bits/subview_cube_meat.hpp @ 18:8d046a9d36aa slimline

Back out rev 13:ac07c60aa798. Like an idiot, I committed a whole pile of unrelated changes in the guise of a single typo fix. Will re-commit in stages
author Chris Cannam
date Thu, 10 May 2012 10:45:44 +0100
parents 8b6102e2a9b0
children
rev   line source
max@0 1 // Copyright (C) 2008-2011 NICTA (www.nicta.com.au)
max@0 2 // Copyright (C) 2008-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 subview_cube
max@0 15 //! @{
max@0 16
max@0 17
max@0 18 template<typename eT>
max@0 19 inline
max@0 20 subview_cube<eT>::~subview_cube()
max@0 21 {
max@0 22 arma_extra_debug_sigprint();
max@0 23 }
max@0 24
max@0 25
max@0 26
max@0 27 template<typename eT>
max@0 28 arma_inline
max@0 29 subview_cube<eT>::subview_cube
max@0 30 (
max@0 31 const Cube<eT>& in_m,
max@0 32 const uword in_row1,
max@0 33 const uword in_col1,
max@0 34 const uword in_slice1,
max@0 35 const uword in_n_rows,
max@0 36 const uword in_n_cols,
max@0 37 const uword in_n_slices
max@0 38 )
max@0 39 : m (in_m)
max@0 40 , m_ptr (0)
max@0 41 , aux_row1 (in_row1)
max@0 42 , aux_col1 (in_col1)
max@0 43 , aux_slice1 (in_slice1)
max@0 44 , n_rows (in_n_rows)
max@0 45 , n_cols (in_n_cols)
max@0 46 , n_elem_slice(in_n_rows * in_n_cols)
max@0 47 , n_slices (in_n_slices)
max@0 48 , n_elem (n_elem_slice * in_n_slices)
max@0 49 {
max@0 50 arma_extra_debug_sigprint();
max@0 51 }
max@0 52
max@0 53
max@0 54
max@0 55 template<typename eT>
max@0 56 arma_inline
max@0 57 subview_cube<eT>::subview_cube
max@0 58 (
max@0 59 Cube<eT>& in_m,
max@0 60 const uword in_row1,
max@0 61 const uword in_col1,
max@0 62 const uword in_slice1,
max@0 63 const uword in_n_rows,
max@0 64 const uword in_n_cols,
max@0 65 const uword in_n_slices
max@0 66 )
max@0 67 : m (in_m)
max@0 68 , m_ptr (&in_m)
max@0 69 , aux_row1 (in_row1)
max@0 70 , aux_col1 (in_col1)
max@0 71 , aux_slice1 (in_slice1)
max@0 72 , n_rows (in_n_rows)
max@0 73 , n_cols (in_n_cols)
max@0 74 , n_elem_slice(in_n_rows * in_n_cols)
max@0 75 , n_slices (in_n_slices)
max@0 76 , n_elem (n_elem_slice * in_n_slices)
max@0 77 {
max@0 78 arma_extra_debug_sigprint();
max@0 79 }
max@0 80
max@0 81
max@0 82
max@0 83 template<typename eT>
max@0 84 inline
max@0 85 void
max@0 86 subview_cube<eT>::operator+= (const eT val)
max@0 87 {
max@0 88 arma_extra_debug_sigprint();
max@0 89
max@0 90 const uword local_n_rows = n_rows;
max@0 91 const uword local_n_cols = n_cols;
max@0 92 const uword local_n_slices = n_slices;
max@0 93
max@0 94 for(uword slice = 0; slice < local_n_slices; ++slice)
max@0 95 {
max@0 96 for(uword col = 0; col < local_n_cols; ++col)
max@0 97 {
max@0 98 arrayops::inplace_plus( slice_colptr(slice,col), val, local_n_rows );
max@0 99 }
max@0 100 }
max@0 101 }
max@0 102
max@0 103
max@0 104
max@0 105 template<typename eT>
max@0 106 inline
max@0 107 void
max@0 108 subview_cube<eT>::operator-= (const eT val)
max@0 109 {
max@0 110 arma_extra_debug_sigprint();
max@0 111
max@0 112 const uword local_n_rows = n_rows;
max@0 113 const uword local_n_cols = n_cols;
max@0 114 const uword local_n_slices = n_slices;
max@0 115
max@0 116 for(uword slice = 0; slice < local_n_slices; ++slice)
max@0 117 {
max@0 118 for(uword col = 0; col < local_n_cols; ++col)
max@0 119 {
max@0 120 arrayops::inplace_minus( slice_colptr(slice,col), val, local_n_rows );
max@0 121 }
max@0 122 }
max@0 123 }
max@0 124
max@0 125
max@0 126
max@0 127 template<typename eT>
max@0 128 inline
max@0 129 void
max@0 130 subview_cube<eT>::operator*= (const eT val)
max@0 131 {
max@0 132 arma_extra_debug_sigprint();
max@0 133
max@0 134 const uword local_n_rows = n_rows;
max@0 135 const uword local_n_cols = n_cols;
max@0 136 const uword local_n_slices = n_slices;
max@0 137
max@0 138 for(uword slice = 0; slice < local_n_slices; ++slice)
max@0 139 {
max@0 140 for(uword col = 0; col < local_n_cols; ++col)
max@0 141 {
max@0 142 arrayops::inplace_mul( slice_colptr(slice,col), val, local_n_rows );
max@0 143 }
max@0 144 }
max@0 145 }
max@0 146
max@0 147
max@0 148
max@0 149 template<typename eT>
max@0 150 inline
max@0 151 void
max@0 152 subview_cube<eT>::operator/= (const eT val)
max@0 153 {
max@0 154 arma_extra_debug_sigprint();
max@0 155
max@0 156 const uword local_n_rows = n_rows;
max@0 157 const uword local_n_cols = n_cols;
max@0 158 const uword local_n_slices = n_slices;
max@0 159
max@0 160 for(uword slice = 0; slice < local_n_slices; ++slice)
max@0 161 {
max@0 162 for(uword col = 0; col < local_n_cols; ++col)
max@0 163 {
max@0 164 arrayops::inplace_div( slice_colptr(slice,col), val, local_n_rows );
max@0 165 }
max@0 166 }
max@0 167 }
max@0 168
max@0 169
max@0 170
max@0 171 template<typename eT>
max@0 172 template<typename T1>
max@0 173 inline
max@0 174 void
max@0 175 subview_cube<eT>::operator= (const BaseCube<eT,T1>& in)
max@0 176 {
max@0 177 arma_extra_debug_sigprint();
max@0 178
max@0 179 const unwrap_cube<T1> tmp(in.get_ref());
max@0 180
max@0 181 const Cube<eT>& x = tmp.M;
max@0 182 subview_cube<eT>& t = *this;
max@0 183
max@0 184 arma_debug_assert_same_size(t, x, "copy into subcube");
max@0 185
max@0 186 const uword t_n_rows = t.n_rows;
max@0 187 const uword t_n_cols = t.n_cols;
max@0 188 const uword t_n_slices = t.n_slices;
max@0 189
max@0 190 for(uword slice = 0; slice < t_n_slices; ++slice)
max@0 191 {
max@0 192 for(uword col = 0; col < t_n_cols; ++col)
max@0 193 {
max@0 194 arrayops::copy( t.slice_colptr(slice,col), x.slice_colptr(slice,col), t_n_rows );
max@0 195 }
max@0 196 }
max@0 197 }
max@0 198
max@0 199
max@0 200
max@0 201 template<typename eT>
max@0 202 template<typename T1>
max@0 203 inline
max@0 204 void
max@0 205 subview_cube<eT>::operator+= (const BaseCube<eT,T1>& in)
max@0 206 {
max@0 207 arma_extra_debug_sigprint();
max@0 208
max@0 209 const unwrap_cube<T1> tmp(in.get_ref());
max@0 210
max@0 211 const Cube<eT>& x = tmp.M;
max@0 212 subview_cube<eT>& t = *this;
max@0 213
max@0 214 arma_debug_assert_same_size(t, x, "addition");
max@0 215
max@0 216 const uword t_n_rows = t.n_rows;
max@0 217 const uword t_n_cols = t.n_cols;
max@0 218 const uword t_n_slices = t.n_slices;
max@0 219
max@0 220 for(uword slice = 0; slice < t_n_slices; ++slice)
max@0 221 {
max@0 222 for(uword col = 0; col < t_n_cols; ++col)
max@0 223 {
max@0 224 arrayops::inplace_plus( t.slice_colptr(slice,col), x.slice_colptr(slice,col), t_n_rows );
max@0 225 }
max@0 226 }
max@0 227 }
max@0 228
max@0 229
max@0 230
max@0 231 template<typename eT>
max@0 232 template<typename T1>
max@0 233 inline
max@0 234 void
max@0 235 subview_cube<eT>::operator-= (const BaseCube<eT,T1>& in)
max@0 236 {
max@0 237 arma_extra_debug_sigprint();
max@0 238
max@0 239 const unwrap_cube<T1> tmp(in.get_ref());
max@0 240
max@0 241 const Cube<eT>& x = tmp.M;
max@0 242 subview_cube<eT>& t = *this;
max@0 243
max@0 244 arma_debug_assert_same_size(t, x, "subtraction");
max@0 245
max@0 246 const uword t_n_rows = t.n_rows;
max@0 247 const uword t_n_cols = t.n_cols;
max@0 248 const uword t_n_slices = t.n_slices;
max@0 249
max@0 250 for(uword slice = 0; slice < t_n_slices; ++slice)
max@0 251 {
max@0 252 for(uword col = 0; col < t_n_cols; ++col)
max@0 253 {
max@0 254 arrayops::inplace_minus( t.slice_colptr(slice,col), x.slice_colptr(slice,col), t_n_rows );
max@0 255 }
max@0 256 }
max@0 257 }
max@0 258
max@0 259
max@0 260
max@0 261 template<typename eT>
max@0 262 template<typename T1>
max@0 263 inline
max@0 264 void
max@0 265 subview_cube<eT>::operator%= (const BaseCube<eT,T1>& in)
max@0 266 {
max@0 267 arma_extra_debug_sigprint();
max@0 268
max@0 269 const unwrap_cube<T1> tmp(in.get_ref());
max@0 270
max@0 271 const Cube<eT>& x = tmp.M;
max@0 272 subview_cube<eT>& t = *this;
max@0 273
max@0 274 arma_debug_assert_same_size(t, x, "element-wise multiplication");
max@0 275
max@0 276 const uword t_n_rows = t.n_rows;
max@0 277 const uword t_n_cols = t.n_cols;
max@0 278 const uword t_n_slices = t.n_slices;
max@0 279
max@0 280 for(uword slice = 0; slice < t_n_slices; ++slice)
max@0 281 {
max@0 282 for(uword col = 0; col < t_n_cols; ++col)
max@0 283 {
max@0 284 arrayops::inplace_mul( t.slice_colptr(slice,col), x.slice_colptr(slice,col), t_n_rows );
max@0 285 }
max@0 286 }
max@0 287 }
max@0 288
max@0 289
max@0 290
max@0 291 template<typename eT>
max@0 292 template<typename T1>
max@0 293 inline
max@0 294 void
max@0 295 subview_cube<eT>::operator/= (const BaseCube<eT,T1>& in)
max@0 296 {
max@0 297 arma_extra_debug_sigprint();
max@0 298
max@0 299 const unwrap_cube<T1> tmp(in.get_ref());
max@0 300
max@0 301 const Cube<eT>& x = tmp.M;
max@0 302 subview_cube<eT>& t = *this;
max@0 303
max@0 304 arma_debug_assert_same_size(t, x, "element-wise division");
max@0 305
max@0 306 const uword t_n_rows = t.n_rows;
max@0 307 const uword t_n_cols = t.n_cols;
max@0 308 const uword t_n_slices = t.n_slices;
max@0 309
max@0 310 for(uword slice = 0; slice < t_n_slices; ++slice)
max@0 311 {
max@0 312 for(uword col = 0; col < t_n_cols; ++col)
max@0 313 {
max@0 314 arrayops::inplace_div( t.slice_colptr(slice,col), x.slice_colptr(slice,col), t_n_rows );
max@0 315 }
max@0 316 }
max@0 317 }
max@0 318
max@0 319
max@0 320
max@0 321 //! x.subcube(...) = y.subcube(...)
max@0 322 template<typename eT>
max@0 323 inline
max@0 324 void
max@0 325 subview_cube<eT>::operator= (const subview_cube<eT>& x_in)
max@0 326 {
max@0 327 arma_extra_debug_sigprint();
max@0 328
max@0 329 const bool overlap = check_overlap(x_in);
max@0 330
max@0 331 Cube<eT>* tmp_cube = overlap ? new Cube<eT>(x_in.m) : 0;
max@0 332 const subview_cube<eT>* tmp_subview_cube = overlap ? new subview_cube<eT>(*tmp_cube, x_in.aux_row1, x_in.aux_col1, x_in.aux_slice1, x_in.n_rows, x_in.n_cols, x_in.n_slices) : 0;
max@0 333 const subview_cube<eT>& x = overlap ? (*tmp_subview_cube) : x_in;
max@0 334
max@0 335 subview_cube<eT>& t = *this;
max@0 336
max@0 337 arma_debug_assert_same_size(t, x, "copy into subcube");
max@0 338
max@0 339 const uword t_n_rows = t.n_rows;
max@0 340 const uword t_n_cols = t.n_cols;
max@0 341 const uword t_n_slices = t.n_slices;
max@0 342
max@0 343 for(uword slice = 0; slice < t_n_slices; ++slice)
max@0 344 {
max@0 345 for(uword col = 0; col < t_n_cols; ++col)
max@0 346 {
max@0 347 arrayops::copy( t.slice_colptr(slice,col), x.slice_colptr(slice,col), t_n_rows );
max@0 348 }
max@0 349 }
max@0 350
max@0 351 if(overlap)
max@0 352 {
max@0 353 delete tmp_subview_cube;
max@0 354 delete tmp_cube;
max@0 355 }
max@0 356
max@0 357 }
max@0 358
max@0 359
max@0 360
max@0 361 template<typename eT>
max@0 362 inline
max@0 363 void
max@0 364 subview_cube<eT>::operator+= (const subview_cube<eT>& x_in)
max@0 365 {
max@0 366 arma_extra_debug_sigprint();
max@0 367
max@0 368 const bool overlap = check_overlap(x_in);
max@0 369
max@0 370 Cube<eT>* tmp_cube = overlap ? new Cube<eT>(x_in.m) : 0;
max@0 371 const subview_cube<eT>* tmp_subview_cube = overlap ? new subview_cube<eT>(*tmp_cube, x_in.aux_row1, x_in.aux_col1, x_in.aux_slice1, x_in.n_rows, x_in.n_cols, x_in.n_slices) : 0;
max@0 372 const subview_cube<eT>& x = overlap ? (*tmp_subview_cube) : x_in;
max@0 373
max@0 374 subview_cube<eT>& t = *this;
max@0 375
max@0 376 arma_debug_assert_same_size(t, x, "addition");
max@0 377
max@0 378 const uword t_n_rows = t.n_rows;
max@0 379 const uword t_n_cols = t.n_cols;
max@0 380 const uword t_n_slices = t.n_slices;
max@0 381
max@0 382 for(uword slice = 0; slice < t_n_slices; ++slice)
max@0 383 {
max@0 384 for(uword col = 0; col < t_n_cols; ++col)
max@0 385 {
max@0 386 arrayops::inplace_plus( t.slice_colptr(slice,col), x.slice_colptr(slice,col), t_n_rows );
max@0 387 }
max@0 388 }
max@0 389
max@0 390 if(overlap)
max@0 391 {
max@0 392 delete tmp_subview_cube;
max@0 393 delete tmp_cube;
max@0 394 }
max@0 395
max@0 396 }
max@0 397
max@0 398
max@0 399
max@0 400 template<typename eT>
max@0 401 inline
max@0 402 void
max@0 403 subview_cube<eT>::operator-= (const subview_cube<eT>& x_in)
max@0 404 {
max@0 405 arma_extra_debug_sigprint();
max@0 406
max@0 407 const bool overlap = check_overlap(x_in);
max@0 408
max@0 409 Cube<eT>* tmp_cube = overlap ? new Cube<eT>(x_in.m) : 0;
max@0 410 const subview_cube<eT>* tmp_subview_cube = overlap ? new subview_cube<eT>(*tmp_cube, x_in.aux_row1, x_in.aux_col1, x_in.aux_slice1, x_in.n_rows, x_in.n_cols, x_in.n_slices) : 0;
max@0 411 const subview_cube<eT>& x = overlap ? (*tmp_subview_cube) : x_in;
max@0 412
max@0 413 subview_cube<eT>& t = *this;
max@0 414
max@0 415 arma_debug_assert_same_size(t, x, "subtraction");
max@0 416
max@0 417 const uword t_n_rows = t.n_rows;
max@0 418 const uword t_n_cols = t.n_cols;
max@0 419 const uword t_n_slices = t.n_slices;
max@0 420
max@0 421 for(uword slice = 0; slice < t_n_slices; ++slice)
max@0 422 {
max@0 423 for(uword col = 0; col < t_n_cols; ++col)
max@0 424 {
max@0 425 arrayops::inplace_minus( t.slice_colptr(slice,col), x.slice_colptr(slice,col), t_n_rows );
max@0 426 }
max@0 427 }
max@0 428
max@0 429 if(overlap)
max@0 430 {
max@0 431 delete tmp_subview_cube;
max@0 432 delete tmp_cube;
max@0 433 }
max@0 434
max@0 435 }
max@0 436
max@0 437
max@0 438
max@0 439 template<typename eT>
max@0 440 inline
max@0 441 void
max@0 442 subview_cube<eT>::operator%= (const subview_cube<eT>& x_in)
max@0 443 {
max@0 444 arma_extra_debug_sigprint();
max@0 445
max@0 446 const bool overlap = check_overlap(x_in);
max@0 447
max@0 448 Cube<eT>* tmp_cube = overlap ? new Cube<eT>(x_in.m) : 0;
max@0 449 const subview_cube<eT>* tmp_subview_cube = overlap ? new subview_cube<eT>(*tmp_cube, x_in.aux_row1, x_in.aux_col1, x_in.aux_slice1, x_in.n_rows, x_in.n_cols, x_in.n_slices) : 0;
max@0 450 const subview_cube<eT>& x = overlap ? (*tmp_subview_cube) : x_in;
max@0 451
max@0 452 subview_cube<eT>& t = *this;
max@0 453
max@0 454 arma_debug_assert_same_size(t, x, "element-wise multiplication");
max@0 455
max@0 456 const uword t_n_rows = t.n_rows;
max@0 457 const uword t_n_cols = t.n_cols;
max@0 458 const uword t_n_slices = t.n_slices;
max@0 459
max@0 460 for(uword slice = 0; slice < t_n_slices; ++slice)
max@0 461 {
max@0 462 for(uword col = 0; col < t_n_cols; ++col)
max@0 463 {
max@0 464 arrayops::inplace_mul( t.slice_colptr(slice,col), x.slice_colptr(slice,col), t_n_rows );
max@0 465 }
max@0 466 }
max@0 467
max@0 468 if(overlap)
max@0 469 {
max@0 470 delete tmp_subview_cube;
max@0 471 delete tmp_cube;
max@0 472 }
max@0 473
max@0 474 }
max@0 475
max@0 476
max@0 477
max@0 478 template<typename eT>
max@0 479 inline
max@0 480 void
max@0 481 subview_cube<eT>::operator/= (const subview_cube<eT>& x_in)
max@0 482 {
max@0 483 arma_extra_debug_sigprint();
max@0 484
max@0 485 const bool overlap = check_overlap(x_in);
max@0 486
max@0 487 Cube<eT>* tmp_cube = overlap ? new Cube<eT>(x_in.m) : 0;
max@0 488 const subview_cube<eT>* tmp_subview_cube = overlap ? new subview_cube<eT>(*tmp_cube, x_in.aux_row1, x_in.aux_col1, x_in.aux_slice1, x_in.n_rows, x_in.n_cols, x_in.n_slices) : 0;
max@0 489 const subview_cube<eT>& x = overlap ? (*tmp_subview_cube) : x_in;
max@0 490
max@0 491 subview_cube<eT>& t = *this;
max@0 492
max@0 493 arma_debug_assert_same_size(t, x, "element-wise division");
max@0 494
max@0 495 const uword t_n_rows = t.n_rows;
max@0 496 const uword t_n_cols = t.n_cols;
max@0 497 const uword t_n_slices = t.n_slices;
max@0 498
max@0 499 for(uword slice = 0; slice < t_n_slices; ++slice)
max@0 500 {
max@0 501 for(uword col = 0; col < t_n_cols; ++col)
max@0 502 {
max@0 503 arrayops::inplace_div( t.slice_colptr(slice,col), x.slice_colptr(slice,col), t_n_rows );
max@0 504 }
max@0 505 }
max@0 506
max@0 507 if(overlap)
max@0 508 {
max@0 509 delete tmp_subview_cube;
max@0 510 delete tmp_cube;
max@0 511 }
max@0 512
max@0 513 }
max@0 514
max@0 515
max@0 516
max@0 517 template<typename eT>
max@0 518 template<typename T1>
max@0 519 inline
max@0 520 void
max@0 521 subview_cube<eT>::operator= (const Base<eT,T1>& in)
max@0 522 {
max@0 523 arma_extra_debug_sigprint();
max@0 524
max@0 525 const unwrap<T1> tmp(in.get_ref());
max@0 526
max@0 527 const Mat<eT>& x = tmp.M;
max@0 528 subview_cube<eT>& t = *this;
max@0 529
max@0 530 const uword t_n_rows = t.n_rows;
max@0 531 const uword t_n_cols = t.n_cols;
max@0 532 const uword t_n_slices = t.n_slices;
max@0 533
max@0 534 const uword x_n_rows = x.n_rows;
max@0 535 const uword x_n_cols = x.n_cols;
max@0 536
max@0 537 if( (t_n_rows == x_n_rows) && (t_n_cols == x_n_cols) && (t_n_slices == 1) )
max@0 538 {
max@0 539 // interpret the matrix as a cube with one slice
max@0 540
max@0 541 for(uword col = 0; col < t_n_cols; ++col)
max@0 542 {
max@0 543 arrayops::copy( t.slice_colptr(0, col), x.colptr(col), t_n_rows );
max@0 544 }
max@0 545 }
max@0 546 else
max@0 547 if( (t_n_rows == x_n_rows) && (t_n_cols == 1) && (t_n_slices == x_n_cols) )
max@0 548 {
max@0 549 for(uword i=0; i < t_n_slices; ++i)
max@0 550 {
max@0 551 arrayops::copy( t.slice_colptr(i, 0), x.colptr(i), t_n_rows );
max@0 552 }
max@0 553 }
max@0 554 else
max@0 555 if( (t_n_rows == 1) && (t_n_cols == x_n_rows) && (t_n_slices == x_n_cols) )
max@0 556 {
max@0 557 Cube<eT>& Q = *(t.m_ptr);
max@0 558
max@0 559 const uword t_aux_row1 = t.aux_row1;
max@0 560 const uword t_aux_col1 = t.aux_col1;
max@0 561 const uword t_aux_slice1 = t.aux_slice1;
max@0 562
max@0 563 for(uword slice=0; slice < t_n_slices; ++slice)
max@0 564 {
max@0 565 const uword mod_slice = t_aux_slice1 + slice;
max@0 566
max@0 567 const eT* x_colptr = x.colptr(slice);
max@0 568
max@0 569 uword i,j;
max@0 570 for(i=0, j=1; j < t_n_cols; i+=2, j+=2)
max@0 571 {
max@0 572 const eT tmp_i = x_colptr[i];
max@0 573 const eT tmp_j = x_colptr[j];
max@0 574
max@0 575 Q.at(t_aux_row1, t_aux_col1 + i, mod_slice) = tmp_i;
max@0 576 Q.at(t_aux_row1, t_aux_col1 + j, mod_slice) = tmp_j;
max@0 577 }
max@0 578
max@0 579 if(i < t_n_cols)
max@0 580 {
max@0 581 Q.at(t_aux_row1, t_aux_col1 + i, mod_slice) = x_colptr[i];
max@0 582 }
max@0 583 }
max@0 584 }
max@0 585 else
max@0 586 {
max@0 587 if(arma_config::debug == true)
max@0 588 {
max@0 589 arma_stop( arma_incompat_size_string(t, x, "copy into subcube") );
max@0 590 }
max@0 591 }
max@0 592 }
max@0 593
max@0 594
max@0 595
max@0 596 template<typename eT>
max@0 597 template<typename T1>
max@0 598 inline
max@0 599 void
max@0 600 subview_cube<eT>::operator+= (const Base<eT,T1>& in)
max@0 601 {
max@0 602 arma_extra_debug_sigprint();
max@0 603
max@0 604 const unwrap<T1> tmp(in.get_ref());
max@0 605
max@0 606 const Mat<eT>& x = tmp.M;
max@0 607 subview_cube<eT>& t = *this;
max@0 608
max@0 609 const uword t_n_rows = t.n_rows;
max@0 610 const uword t_n_cols = t.n_cols;
max@0 611 const uword t_n_slices = t.n_slices;
max@0 612
max@0 613 const uword x_n_rows = x.n_rows;
max@0 614 const uword x_n_cols = x.n_cols;
max@0 615
max@0 616 if( (t_n_rows == x_n_rows) && (t_n_cols == x_n_cols) && (t_n_slices == 1) )
max@0 617 {
max@0 618 for(uword col = 0; col < t_n_cols; ++col)
max@0 619 {
max@0 620 arrayops::inplace_plus( t.slice_colptr(0, col), x.colptr(col), t_n_rows );
max@0 621 }
max@0 622 }
max@0 623 else
max@0 624 if( (t_n_rows == x_n_rows) && (t_n_cols == 1) && (t_n_slices == x_n_cols) )
max@0 625 {
max@0 626 for(uword i=0; i < t_n_slices; ++i)
max@0 627 {
max@0 628 arrayops::inplace_plus( t.slice_colptr(i, 0), x.colptr(i), t_n_rows );
max@0 629 }
max@0 630 }
max@0 631 else
max@0 632 if( (t_n_rows == 1) && (t_n_cols == x_n_rows) && (t_n_slices == x_n_cols) )
max@0 633 {
max@0 634 Cube<eT>& Q = *(t.m_ptr);
max@0 635
max@0 636 const uword t_aux_row1 = t.aux_row1;
max@0 637 const uword t_aux_col1 = t.aux_col1;
max@0 638 const uword t_aux_slice1 = t.aux_slice1;
max@0 639
max@0 640 for(uword slice=0; slice < t_n_slices; ++slice)
max@0 641 {
max@0 642 const uword mod_slice = t_aux_slice1 + slice;
max@0 643
max@0 644 const eT* x_colptr = x.colptr(slice);
max@0 645
max@0 646 uword i,j;
max@0 647 for(i=0, j=1; j < t_n_cols; i+=2, j+=2)
max@0 648 {
max@0 649 const eT tmp_i = x_colptr[i];
max@0 650 const eT tmp_j = x_colptr[j];
max@0 651
max@0 652 Q.at(t_aux_row1, t_aux_col1 + i, mod_slice) += tmp_i;
max@0 653 Q.at(t_aux_row1, t_aux_col1 + j, mod_slice) += tmp_j;
max@0 654 }
max@0 655
max@0 656 if(i < t_n_cols)
max@0 657 {
max@0 658 Q.at(t_aux_row1, t_aux_col1 + i, mod_slice) += x_colptr[i];
max@0 659 }
max@0 660 }
max@0 661 }
max@0 662 else
max@0 663 {
max@0 664 if(arma_config::debug == true)
max@0 665 {
max@0 666 arma_stop( arma_incompat_size_string(t, x, "addition") );
max@0 667 }
max@0 668 }
max@0 669 }
max@0 670
max@0 671
max@0 672
max@0 673 template<typename eT>
max@0 674 template<typename T1>
max@0 675 inline
max@0 676 void
max@0 677 subview_cube<eT>::operator-= (const Base<eT,T1>& in)
max@0 678 {
max@0 679 arma_extra_debug_sigprint();
max@0 680
max@0 681 const unwrap<T1> tmp(in.get_ref());
max@0 682
max@0 683 const Mat<eT>& x = tmp.M;
max@0 684 subview_cube<eT>& t = *this;
max@0 685
max@0 686 const uword t_n_rows = t.n_rows;
max@0 687 const uword t_n_cols = t.n_cols;
max@0 688 const uword t_n_slices = t.n_slices;
max@0 689
max@0 690 const uword x_n_rows = x.n_rows;
max@0 691 const uword x_n_cols = x.n_cols;
max@0 692
max@0 693 if( (t_n_rows == x_n_rows) && (t_n_cols == x_n_cols) && (t_n_slices == 1) )
max@0 694 {
max@0 695 for(uword col = 0; col < t_n_cols; ++col)
max@0 696 {
max@0 697 arrayops::inplace_minus( t.slice_colptr(0, col), x.colptr(col), t_n_rows );
max@0 698 }
max@0 699 }
max@0 700 else
max@0 701 if( (t_n_rows == x_n_rows) && (t_n_cols == 1) && (t_n_slices == x_n_cols) )
max@0 702 {
max@0 703 for(uword i=0; i < t_n_slices; ++i)
max@0 704 {
max@0 705 arrayops::inplace_minus( t.slice_colptr(i, 0), x.colptr(i), t_n_rows );
max@0 706 }
max@0 707 }
max@0 708 else
max@0 709 if( (t_n_rows == 1) && (t_n_cols == x_n_rows) && (t_n_slices == x_n_cols) )
max@0 710 {
max@0 711 Cube<eT>& Q = *(t.m_ptr);
max@0 712
max@0 713 const uword t_aux_row1 = t.aux_row1;
max@0 714 const uword t_aux_col1 = t.aux_col1;
max@0 715 const uword t_aux_slice1 = t.aux_slice1;
max@0 716
max@0 717 for(uword slice=0; slice < t_n_slices; ++slice)
max@0 718 {
max@0 719 const uword mod_slice = t_aux_slice1 + slice;
max@0 720
max@0 721 const eT* x_colptr = x.colptr(slice);
max@0 722
max@0 723 uword i,j;
max@0 724 for(i=0, j=1; j < t_n_cols; i+=2, j+=2)
max@0 725 {
max@0 726 const eT tmp_i = x_colptr[i];
max@0 727 const eT tmp_j = x_colptr[j];
max@0 728
max@0 729 Q.at(t_aux_row1, t_aux_col1 + i, mod_slice) -= tmp_i;
max@0 730 Q.at(t_aux_row1, t_aux_col1 + j, mod_slice) -= tmp_j;
max@0 731 }
max@0 732
max@0 733 if(i < t_n_cols)
max@0 734 {
max@0 735 Q.at(t_aux_row1, t_aux_col1 + i, mod_slice) -= x_colptr[i];
max@0 736 }
max@0 737 }
max@0 738 }
max@0 739 else
max@0 740 {
max@0 741 if(arma_config::debug == true)
max@0 742 {
max@0 743 arma_stop( arma_incompat_size_string(t, x, "subtraction") );
max@0 744 }
max@0 745 }
max@0 746 }
max@0 747
max@0 748
max@0 749
max@0 750 template<typename eT>
max@0 751 template<typename T1>
max@0 752 inline
max@0 753 void
max@0 754 subview_cube<eT>::operator%= (const Base<eT,T1>& in)
max@0 755 {
max@0 756 arma_extra_debug_sigprint();
max@0 757
max@0 758 const unwrap<T1> tmp(in.get_ref());
max@0 759
max@0 760 const Mat<eT>& x = tmp.M;
max@0 761 subview_cube<eT>& t = *this;
max@0 762
max@0 763 const uword t_n_rows = t.n_rows;
max@0 764 const uword t_n_cols = t.n_cols;
max@0 765 const uword t_n_slices = t.n_slices;
max@0 766
max@0 767 const uword x_n_rows = x.n_rows;
max@0 768 const uword x_n_cols = x.n_cols;
max@0 769
max@0 770 if( (t_n_rows == x_n_rows) && (t_n_cols == x_n_cols) && (t_n_slices == 1) )
max@0 771 {
max@0 772 for(uword col = 0; col < t_n_cols; ++col)
max@0 773 {
max@0 774 arrayops::inplace_mul( t.slice_colptr(0, col), x.colptr(col), t_n_rows );
max@0 775 }
max@0 776 }
max@0 777 else
max@0 778 if( (t_n_rows == x_n_rows) && (t_n_cols == 1) && (t_n_slices == x_n_cols) )
max@0 779 {
max@0 780 for(uword i=0; i < t_n_slices; ++i)
max@0 781 {
max@0 782 arrayops::inplace_mul( t.slice_colptr(i, 0), x.colptr(i), t_n_rows );
max@0 783 }
max@0 784 }
max@0 785 else
max@0 786 if( (t_n_rows == 1) && (t_n_cols == x_n_rows) && (t_n_slices == x_n_cols) )
max@0 787 {
max@0 788 Cube<eT>& Q = *(t.m_ptr);
max@0 789
max@0 790 const uword t_aux_row1 = t.aux_row1;
max@0 791 const uword t_aux_col1 = t.aux_col1;
max@0 792 const uword t_aux_slice1 = t.aux_slice1;
max@0 793
max@0 794 for(uword slice=0; slice < t_n_slices; ++slice)
max@0 795 {
max@0 796 const uword mod_slice = t_aux_slice1 + slice;
max@0 797
max@0 798 const eT* x_colptr = x.colptr(slice);
max@0 799
max@0 800 uword i,j;
max@0 801 for(i=0, j=1; j < t_n_cols; i+=2, j+=2)
max@0 802 {
max@0 803 const eT tmp_i = x_colptr[i];
max@0 804 const eT tmp_j = x_colptr[j];
max@0 805
max@0 806 Q.at(t_aux_row1, t_aux_col1 + i, mod_slice) *= tmp_i;
max@0 807 Q.at(t_aux_row1, t_aux_col1 + j, mod_slice) *= tmp_j;
max@0 808 }
max@0 809
max@0 810 if(i < t_n_cols)
max@0 811 {
max@0 812 Q.at(t_aux_row1, t_aux_col1 + i, mod_slice) *= x_colptr[i];
max@0 813 }
max@0 814 }
max@0 815 }
max@0 816 else
max@0 817 {
max@0 818 if(arma_config::debug == true)
max@0 819 {
max@0 820 arma_stop( arma_incompat_size_string(t, x, "element-wise multiplication") );
max@0 821 }
max@0 822 }
max@0 823 }
max@0 824
max@0 825
max@0 826
max@0 827 template<typename eT>
max@0 828 template<typename T1>
max@0 829 inline
max@0 830 void
max@0 831 subview_cube<eT>::operator/= (const Base<eT,T1>& in)
max@0 832 {
max@0 833 arma_extra_debug_sigprint();
max@0 834
max@0 835 const unwrap<T1> tmp(in.get_ref());
max@0 836
max@0 837 const Mat<eT>& x = tmp.M;
max@0 838 subview_cube<eT>& t = *this;
max@0 839
max@0 840 const uword t_n_rows = t.n_rows;
max@0 841 const uword t_n_cols = t.n_cols;
max@0 842 const uword t_n_slices = t.n_slices;
max@0 843
max@0 844 const uword x_n_rows = x.n_rows;
max@0 845 const uword x_n_cols = x.n_cols;
max@0 846
max@0 847 if( (t_n_rows == x_n_rows) && (t_n_cols == x_n_cols) && (t_n_slices == 1) )
max@0 848 {
max@0 849 for(uword col = 0; col < t_n_cols; ++col)
max@0 850 {
max@0 851 arrayops::inplace_div( t.slice_colptr(0, col), x.colptr(col), t_n_rows );
max@0 852 }
max@0 853 }
max@0 854 else
max@0 855 if( (t_n_rows == x_n_rows) && (t_n_cols == 1) && (t_n_slices == x_n_cols) )
max@0 856 {
max@0 857 for(uword i=0; i < t_n_slices; ++i)
max@0 858 {
max@0 859 arrayops::inplace_div( t.slice_colptr(i, 0), x.colptr(i), t_n_rows );
max@0 860 }
max@0 861 }
max@0 862 else
max@0 863 if( (t_n_rows == 1) && (t_n_cols == x_n_rows) && (t_n_slices == x_n_cols) )
max@0 864 {
max@0 865 Cube<eT>& Q = *(t.m_ptr);
max@0 866
max@0 867 const uword t_aux_row1 = t.aux_row1;
max@0 868 const uword t_aux_col1 = t.aux_col1;
max@0 869 const uword t_aux_slice1 = t.aux_slice1;
max@0 870
max@0 871 for(uword slice=0; slice < t_n_slices; ++slice)
max@0 872 {
max@0 873 const uword mod_slice = t_aux_slice1 + slice;
max@0 874
max@0 875 const eT* x_colptr = x.colptr(slice);
max@0 876
max@0 877 uword i,j;
max@0 878 for(i=0, j=1; j < t_n_cols; i+=2, j+=2)
max@0 879 {
max@0 880 const eT tmp_i = x_colptr[i];
max@0 881 const eT tmp_j = x_colptr[j];
max@0 882
max@0 883 Q.at(t_aux_row1, t_aux_col1 + i, mod_slice) /= tmp_i;
max@0 884 Q.at(t_aux_row1, t_aux_col1 + j, mod_slice) /= tmp_j;
max@0 885 }
max@0 886
max@0 887 if(i < t_n_cols)
max@0 888 {
max@0 889 Q.at(t_aux_row1, t_aux_col1 + i, mod_slice) /= x_colptr[i];
max@0 890 }
max@0 891 }
max@0 892 }
max@0 893 else
max@0 894 {
max@0 895 if(arma_config::debug == true)
max@0 896 {
max@0 897 arma_stop( arma_incompat_size_string(t, x, "element-wise division") );
max@0 898 }
max@0 899 }
max@0 900 }
max@0 901
max@0 902
max@0 903
max@0 904 template<typename eT>
max@0 905 inline
max@0 906 void
max@0 907 subview_cube<eT>::fill(const eT val)
max@0 908 {
max@0 909 arma_extra_debug_sigprint();
max@0 910
max@0 911 const uword local_n_rows = n_rows;
max@0 912 const uword local_n_cols = n_cols;
max@0 913 const uword local_n_slices = n_slices;
max@0 914
max@0 915 for(uword slice = 0; slice < local_n_slices; ++slice)
max@0 916 {
max@0 917 for(uword col = 0; col < local_n_cols; ++col)
max@0 918 {
max@0 919 arrayops::inplace_set( slice_colptr(slice,col), val, local_n_rows );
max@0 920 }
max@0 921 }
max@0 922
max@0 923 }
max@0 924
max@0 925
max@0 926
max@0 927 template<typename eT>
max@0 928 inline
max@0 929 void
max@0 930 subview_cube<eT>::zeros()
max@0 931 {
max@0 932 arma_extra_debug_sigprint();
max@0 933
max@0 934 fill(eT(0));
max@0 935 }
max@0 936
max@0 937
max@0 938
max@0 939 template<typename eT>
max@0 940 inline
max@0 941 void
max@0 942 subview_cube<eT>::ones()
max@0 943 {
max@0 944 arma_extra_debug_sigprint();
max@0 945
max@0 946 fill(eT(1));
max@0 947 }
max@0 948
max@0 949
max@0 950
max@0 951 template<typename eT>
max@0 952 inline
max@0 953 eT&
max@0 954 subview_cube<eT>::operator[](const uword i)
max@0 955 {
max@0 956 const uword in_slice = i / n_elem_slice;
max@0 957 const uword offset = in_slice * n_elem_slice;
max@0 958 const uword j = i - offset;
max@0 959
max@0 960 const uword in_col = j / n_rows;
max@0 961 const uword in_row = j % n_rows;
max@0 962
max@0 963 const uword index = (in_slice + aux_slice1)*m.n_elem_slice + (in_col + aux_col1)*m.n_rows + aux_row1 + in_row;
max@0 964 return access::rw( (*m_ptr).mem[index] );
max@0 965 }
max@0 966
max@0 967
max@0 968
max@0 969 template<typename eT>
max@0 970 inline
max@0 971 eT
max@0 972 subview_cube<eT>::operator[](const uword i) const
max@0 973 {
max@0 974 const uword in_slice = i / n_elem_slice;
max@0 975 const uword offset = in_slice * n_elem_slice;
max@0 976 const uword j = i - offset;
max@0 977
max@0 978 const uword in_col = j / n_rows;
max@0 979 const uword in_row = j % n_rows;
max@0 980
max@0 981 const uword index = (in_slice + aux_slice1)*m.n_elem_slice + (in_col + aux_col1)*m.n_rows + aux_row1 + in_row;
max@0 982 return m.mem[index];
max@0 983 }
max@0 984
max@0 985
max@0 986
max@0 987 template<typename eT>
max@0 988 inline
max@0 989 eT&
max@0 990 subview_cube<eT>::operator()(const uword i)
max@0 991 {
max@0 992 arma_debug_check( (i >= n_elem), "subview_cube::operator(): index out of bounds");
max@0 993
max@0 994 const uword in_slice = i / n_elem_slice;
max@0 995 const uword offset = in_slice * n_elem_slice;
max@0 996 const uword j = i - offset;
max@0 997
max@0 998 const uword in_col = j / n_rows;
max@0 999 const uword in_row = j % n_rows;
max@0 1000
max@0 1001 const uword index = (in_slice + aux_slice1)*m.n_elem_slice + (in_col + aux_col1)*m.n_rows + aux_row1 + in_row;
max@0 1002 return access::rw( (*m_ptr).mem[index] );
max@0 1003 }
max@0 1004
max@0 1005
max@0 1006
max@0 1007 template<typename eT>
max@0 1008 inline
max@0 1009 eT
max@0 1010 subview_cube<eT>::operator()(const uword i) const
max@0 1011 {
max@0 1012 arma_debug_check( (i >= n_elem), "subview_cube::operator(): index out of bounds");
max@0 1013
max@0 1014 const uword in_slice = i / n_elem_slice;
max@0 1015 const uword offset = in_slice * n_elem_slice;
max@0 1016 const uword j = i - offset;
max@0 1017
max@0 1018 const uword in_col = j / n_rows;
max@0 1019 const uword in_row = j % n_rows;
max@0 1020
max@0 1021 const uword index = (in_slice + aux_slice1)*m.n_elem_slice + (in_col + aux_col1)*m.n_rows + aux_row1 + in_row;
max@0 1022 return m.mem[index];
max@0 1023 }
max@0 1024
max@0 1025
max@0 1026
max@0 1027 template<typename eT>
max@0 1028 arma_inline
max@0 1029 eT&
max@0 1030 subview_cube<eT>::operator()(const uword in_row, const uword in_col, const uword in_slice)
max@0 1031 {
max@0 1032 arma_debug_check( ( (in_row >= n_rows) || (in_col >= n_cols) || (in_slice >= n_slices) ), "subview_cube::operator(): location out of bounds");
max@0 1033
max@0 1034 const uword index = (in_slice + aux_slice1)*m.n_elem_slice + (in_col + aux_col1)*m.n_rows + aux_row1 + in_row;
max@0 1035 return access::rw( (*m_ptr).mem[index] );
max@0 1036 }
max@0 1037
max@0 1038
max@0 1039
max@0 1040 template<typename eT>
max@0 1041 arma_inline
max@0 1042 eT
max@0 1043 subview_cube<eT>::operator()(const uword in_row, const uword in_col, const uword in_slice) const
max@0 1044 {
max@0 1045 arma_debug_check( ( (in_row >= n_rows) || (in_col >= n_cols) || (in_slice >= n_slices) ), "subview_cube::operator(): location out of bounds");
max@0 1046
max@0 1047 const uword index = (in_slice + aux_slice1)*m.n_elem_slice + (in_col + aux_col1)*m.n_rows + aux_row1 + in_row;
max@0 1048 return m.mem[index];
max@0 1049 }
max@0 1050
max@0 1051
max@0 1052
max@0 1053 template<typename eT>
max@0 1054 arma_inline
max@0 1055 eT&
max@0 1056 subview_cube<eT>::at(const uword in_row, const uword in_col, const uword in_slice)
max@0 1057 {
max@0 1058 const uword index = (in_slice + aux_slice1)*m.n_elem_slice + (in_col + aux_col1)*m.n_rows + aux_row1 + in_row;
max@0 1059 return access::rw( (*m_ptr).mem[index] );
max@0 1060 }
max@0 1061
max@0 1062
max@0 1063
max@0 1064 template<typename eT>
max@0 1065 arma_inline
max@0 1066 eT
max@0 1067 subview_cube<eT>::at(const uword in_row, const uword in_col, const uword in_slice) const
max@0 1068 {
max@0 1069 const uword index = (in_slice + aux_slice1)*m.n_elem_slice + (in_col + aux_col1)*m.n_rows + aux_row1 + in_row;
max@0 1070 return m.mem[index];
max@0 1071 }
max@0 1072
max@0 1073
max@0 1074
max@0 1075 template<typename eT>
max@0 1076 arma_inline
max@0 1077 eT*
max@0 1078 subview_cube<eT>::slice_colptr(const uword in_slice, const uword in_col)
max@0 1079 {
max@0 1080 return & access::rw((*m_ptr).mem[ (in_slice + aux_slice1)*m.n_elem_slice + (in_col + aux_col1)*m.n_rows + aux_row1 ]);
max@0 1081 }
max@0 1082
max@0 1083
max@0 1084
max@0 1085 template<typename eT>
max@0 1086 arma_inline
max@0 1087 const eT*
max@0 1088 subview_cube<eT>::slice_colptr(const uword in_slice, const uword in_col) const
max@0 1089 {
max@0 1090 return & m.mem[ (in_slice + aux_slice1)*m.n_elem_slice + (in_col + aux_col1)*m.n_rows + aux_row1 ];
max@0 1091 }
max@0 1092
max@0 1093
max@0 1094
max@0 1095 template<typename eT>
max@0 1096 inline
max@0 1097 bool
max@0 1098 subview_cube<eT>::check_overlap(const subview_cube<eT>& x) const
max@0 1099 {
max@0 1100 const subview_cube<eT>& t = *this;
max@0 1101
max@0 1102 if(&t.m != &x.m)
max@0 1103 {
max@0 1104 return false;
max@0 1105 }
max@0 1106 else
max@0 1107 {
max@0 1108 if( (t.n_elem == 0) || (x.n_elem == 0) )
max@0 1109 {
max@0 1110 return false;
max@0 1111 }
max@0 1112 else
max@0 1113 {
max@0 1114 const uword t_row_start = t.aux_row1;
max@0 1115 const uword t_row_end_p1 = t_row_start + t.n_rows;
max@0 1116
max@0 1117 const uword t_col_start = t.aux_col1;
max@0 1118 const uword t_col_end_p1 = t_col_start + t.n_cols;
max@0 1119
max@0 1120 const uword t_slice_start = t.aux_slice1;
max@0 1121 const uword t_slice_end_p1 = t_slice_start + t.n_slices;
max@0 1122
max@0 1123
max@0 1124 const uword x_row_start = x.aux_row1;
max@0 1125 const uword x_row_end_p1 = x_row_start + x.n_rows;
max@0 1126
max@0 1127 const uword x_col_start = x.aux_col1;
max@0 1128 const uword x_col_end_p1 = x_col_start + x.n_cols;
max@0 1129
max@0 1130 const uword x_slice_start = x.aux_slice1;
max@0 1131 const uword x_slice_end_p1 = x_slice_start + x.n_slices;
max@0 1132
max@0 1133
max@0 1134 const bool outside_rows = ( (x_row_start >= t_row_end_p1 ) || (t_row_start >= x_row_end_p1 ) );
max@0 1135 const bool outside_cols = ( (x_col_start >= t_col_end_p1 ) || (t_col_start >= x_col_end_p1 ) );
max@0 1136 const bool outside_slices = ( (x_slice_start >= t_slice_end_p1) || (t_slice_start >= x_slice_end_p1) );
max@0 1137
max@0 1138 return ( (outside_rows == false) && (outside_cols == false) && (outside_slices == false) );
max@0 1139 }
max@0 1140 }
max@0 1141 }
max@0 1142
max@0 1143
max@0 1144
max@0 1145 template<typename eT>
max@0 1146 inline
max@0 1147 bool
max@0 1148 subview_cube<eT>::check_overlap(const Mat<eT>& x) const
max@0 1149 {
max@0 1150 const subview_cube<eT>& t = *this;
max@0 1151
max@0 1152 const uword t_aux_slice1 = t.aux_slice1;
max@0 1153 const uword t_aux_slice2_plus_1 = t_aux_slice1 + t.n_slices;
max@0 1154
max@0 1155 for(uword slice = t_aux_slice1; slice < t_aux_slice2_plus_1; ++slice)
max@0 1156 {
max@0 1157 const Mat<eT>& y = *(t.m.mat_ptrs[slice]);
max@0 1158
max@0 1159 if( x.memptr() == y.memptr() )
max@0 1160 {
max@0 1161 return true;
max@0 1162 }
max@0 1163 }
max@0 1164
max@0 1165 return false;
max@0 1166 }
max@0 1167
max@0 1168
max@0 1169
max@0 1170 //! cube X = Y.subcube(...)
max@0 1171 template<typename eT>
max@0 1172 inline
max@0 1173 void
max@0 1174 subview_cube<eT>::extract(Cube<eT>& out, const subview_cube<eT>& in)
max@0 1175 {
max@0 1176 arma_extra_debug_sigprint();
max@0 1177
max@0 1178 // NOTE: we're assuming that the cube has already been set to the correct size and there is no aliasing;
max@0 1179 // size setting and alias checking is done by either the Cube contructor or operator=()
max@0 1180
max@0 1181 const uword n_rows = in.n_rows;
max@0 1182 const uword n_cols = in.n_cols;
max@0 1183 const uword n_slices = in.n_slices;
max@0 1184
max@0 1185 arma_extra_debug_print(arma_boost::format("out.n_rows = %d out.n_cols = %d out.n_slices = %d in.m.n_rows = %d in.m.n_cols = %d in.m.n_slices = %d") % out.n_rows % out.n_cols % out.n_slices % in.m.n_rows % in.m.n_cols % in.m.n_slices);
max@0 1186
max@0 1187
max@0 1188 for(uword slice = 0; slice < n_slices; ++slice)
max@0 1189 {
max@0 1190 for(uword col = 0; col < n_cols; ++col)
max@0 1191 {
max@0 1192 arrayops::copy( out.slice_colptr(slice,col), in.slice_colptr(slice,col), n_rows );
max@0 1193 }
max@0 1194 }
max@0 1195 }
max@0 1196
max@0 1197
max@0 1198
max@0 1199 //! cube X += Y.subcube(...)
max@0 1200 template<typename eT>
max@0 1201 inline
max@0 1202 void
max@0 1203 subview_cube<eT>::plus_inplace(Cube<eT>& out, const subview_cube<eT>& in)
max@0 1204 {
max@0 1205 arma_extra_debug_sigprint();
max@0 1206
max@0 1207 arma_debug_assert_same_size(out, in, "addition");
max@0 1208
max@0 1209 const uword n_rows = out.n_rows;
max@0 1210 const uword n_cols = out.n_cols;
max@0 1211 const uword n_slices = out.n_slices;
max@0 1212
max@0 1213 for(uword slice = 0; slice<n_slices; ++slice)
max@0 1214 {
max@0 1215 for(uword col = 0; col<n_cols; ++col)
max@0 1216 {
max@0 1217 arrayops::inplace_plus( out.slice_colptr(slice,col), in.slice_colptr(slice,col), n_rows );
max@0 1218 }
max@0 1219 }
max@0 1220 }
max@0 1221
max@0 1222
max@0 1223
max@0 1224 //! cube X -= Y.subcube(...)
max@0 1225 template<typename eT>
max@0 1226 inline
max@0 1227 void
max@0 1228 subview_cube<eT>::minus_inplace(Cube<eT>& out, const subview_cube<eT>& in)
max@0 1229 {
max@0 1230 arma_extra_debug_sigprint();
max@0 1231
max@0 1232 arma_debug_assert_same_size(out, in, "subtraction");
max@0 1233
max@0 1234 const uword n_rows = out.n_rows;
max@0 1235 const uword n_cols = out.n_cols;
max@0 1236 const uword n_slices = out.n_slices;
max@0 1237
max@0 1238 for(uword slice = 0; slice<n_slices; ++slice)
max@0 1239 {
max@0 1240 for(uword col = 0; col<n_cols; ++col)
max@0 1241 {
max@0 1242 arrayops::inplace_minus( out.slice_colptr(slice,col), in.slice_colptr(slice,col), n_rows );
max@0 1243 }
max@0 1244 }
max@0 1245 }
max@0 1246
max@0 1247
max@0 1248
max@0 1249 //! cube X %= Y.subcube(...)
max@0 1250 template<typename eT>
max@0 1251 inline
max@0 1252 void
max@0 1253 subview_cube<eT>::schur_inplace(Cube<eT>& out, const subview_cube<eT>& in)
max@0 1254 {
max@0 1255 arma_extra_debug_sigprint();
max@0 1256
max@0 1257 arma_debug_assert_same_size(out, in, "element-wise multiplication");
max@0 1258
max@0 1259 const uword n_rows = out.n_rows;
max@0 1260 const uword n_cols = out.n_cols;
max@0 1261 const uword n_slices = out.n_slices;
max@0 1262
max@0 1263 for(uword slice = 0; slice<n_slices; ++slice)
max@0 1264 {
max@0 1265 for(uword col = 0; col<n_cols; ++col)
max@0 1266 {
max@0 1267 arrayops::inplace_mul( out.slice_colptr(slice,col), in.slice_colptr(slice,col), n_rows );
max@0 1268 }
max@0 1269 }
max@0 1270 }
max@0 1271
max@0 1272
max@0 1273
max@0 1274 //! cube X /= Y.subcube(...)
max@0 1275 template<typename eT>
max@0 1276 inline
max@0 1277 void
max@0 1278 subview_cube<eT>::div_inplace(Cube<eT>& out, const subview_cube<eT>& in)
max@0 1279 {
max@0 1280 arma_extra_debug_sigprint();
max@0 1281
max@0 1282 arma_debug_assert_same_size(out, in, "element-wise division");
max@0 1283
max@0 1284 const uword n_rows = out.n_rows;
max@0 1285 const uword n_cols = out.n_cols;
max@0 1286 const uword n_slices = out.n_slices;
max@0 1287
max@0 1288 for(uword slice = 0; slice<n_slices; ++slice)
max@0 1289 {
max@0 1290 for(uword col = 0; col<n_cols; ++col)
max@0 1291 {
max@0 1292 arrayops::inplace_div( out.slice_colptr(slice,col), in.slice_colptr(slice,col), n_rows );
max@0 1293 }
max@0 1294 }
max@0 1295 }
max@0 1296
max@0 1297
max@0 1298
max@0 1299 //! mat X = Y.subcube(...)
max@0 1300 template<typename eT>
max@0 1301 inline
max@0 1302 void
max@0 1303 subview_cube<eT>::extract(Mat<eT>& out, const subview_cube<eT>& in)
max@0 1304 {
max@0 1305 arma_extra_debug_sigprint();
max@0 1306
max@0 1307 arma_debug_assert_cube_as_mat(out, in, "copy into matrix", false);
max@0 1308
max@0 1309 const uword in_n_rows = in.n_rows;
max@0 1310 const uword in_n_cols = in.n_cols;
max@0 1311 const uword in_n_slices = in.n_slices;
max@0 1312
max@0 1313 const uword out_vec_state = out.vec_state;
max@0 1314
max@0 1315 if(in_n_slices == 1)
max@0 1316 {
max@0 1317 out.set_size(in_n_rows, in_n_cols);
max@0 1318
max@0 1319 for(uword col=0; col < in_n_cols; ++col)
max@0 1320 {
max@0 1321 arrayops::copy( out.colptr(col), in.slice_colptr(0, col), in_n_rows );
max@0 1322 }
max@0 1323 }
max@0 1324 else
max@0 1325 {
max@0 1326 if(out_vec_state == 0)
max@0 1327 {
max@0 1328 if(in_n_cols == 1)
max@0 1329 {
max@0 1330 out.set_size(in_n_rows, in_n_slices);
max@0 1331
max@0 1332 for(uword i=0; i < in_n_slices; ++i)
max@0 1333 {
max@0 1334 arrayops::copy( out.colptr(i), in.slice_colptr(i, 0), in_n_rows );
max@0 1335 }
max@0 1336 }
max@0 1337 else
max@0 1338 if(in_n_rows == 1)
max@0 1339 {
max@0 1340 const Cube<eT>& Q = in.m;
max@0 1341
max@0 1342 const uword in_aux_row1 = in.aux_row1;
max@0 1343 const uword in_aux_col1 = in.aux_col1;
max@0 1344 const uword in_aux_slice1 = in.aux_slice1;
max@0 1345
max@0 1346 out.set_size(in_n_cols, in_n_slices);
max@0 1347
max@0 1348 for(uword slice=0; slice < in_n_slices; ++slice)
max@0 1349 {
max@0 1350 const uword mod_slice = in_aux_slice1 + slice;
max@0 1351
max@0 1352 eT* out_colptr = out.colptr(slice);
max@0 1353
max@0 1354 uword i,j;
max@0 1355 for(i=0, j=1; j < in_n_cols; i+=2, j+=2)
max@0 1356 {
max@0 1357 const eT tmp_i = Q.at(in_aux_row1, in_aux_col1 + i, mod_slice);
max@0 1358 const eT tmp_j = Q.at(in_aux_row1, in_aux_col1 + j, mod_slice);
max@0 1359
max@0 1360 out_colptr[i] = tmp_i;
max@0 1361 out_colptr[j] = tmp_j;
max@0 1362 }
max@0 1363
max@0 1364 if(i < in_n_cols)
max@0 1365 {
max@0 1366 out_colptr[i] = Q.at(in_aux_row1, in_aux_col1 + i, mod_slice);
max@0 1367 }
max@0 1368 }
max@0 1369 }
max@0 1370 }
max@0 1371 else
max@0 1372 {
max@0 1373 out.set_size(in_n_slices);
max@0 1374
max@0 1375 eT* out_mem = out.memptr();
max@0 1376
max@0 1377 const Cube<eT>& Q = in.m;
max@0 1378
max@0 1379 const uword in_aux_row1 = in.aux_row1;
max@0 1380 const uword in_aux_col1 = in.aux_col1;
max@0 1381 const uword in_aux_slice1 = in.aux_slice1;
max@0 1382
max@0 1383 for(uword i=0; i<in_n_slices; ++i)
max@0 1384 {
max@0 1385 out_mem[i] = Q.at(in_aux_row1, in_aux_col1, in_aux_slice1 + i);
max@0 1386 }
max@0 1387 }
max@0 1388 }
max@0 1389 }
max@0 1390
max@0 1391
max@0 1392
max@0 1393 //! mat X += Y.subcube(...)
max@0 1394 template<typename eT>
max@0 1395 inline
max@0 1396 void
max@0 1397 subview_cube<eT>::plus_inplace(Mat<eT>& out, const subview_cube<eT>& in)
max@0 1398 {
max@0 1399 arma_extra_debug_sigprint();
max@0 1400
max@0 1401 arma_debug_assert_cube_as_mat(out, in, "addition", true);
max@0 1402
max@0 1403 const uword in_n_rows = in.n_rows;
max@0 1404 const uword in_n_cols = in.n_cols;
max@0 1405 const uword in_n_slices = in.n_slices;
max@0 1406
max@0 1407 const uword out_n_rows = out.n_rows;
max@0 1408 const uword out_n_cols = out.n_cols;
max@0 1409 const uword out_vec_state = out.vec_state;
max@0 1410
max@0 1411 if(in_n_slices == 1)
max@0 1412 {
max@0 1413 for(uword col=0; col < in_n_cols; ++col)
max@0 1414 {
max@0 1415 arrayops::inplace_plus( out.colptr(col), in.slice_colptr(0, col), in_n_rows );
max@0 1416 }
max@0 1417 }
max@0 1418 else
max@0 1419 {
max@0 1420 if(out_vec_state == 0)
max@0 1421 {
max@0 1422 if( (in_n_rows == out_n_rows) && (in_n_cols == 1) && (in_n_slices == out_n_cols) )
max@0 1423 {
max@0 1424 for(uword i=0; i < in_n_slices; ++i)
max@0 1425 {
max@0 1426 arrayops::inplace_plus( out.colptr(i), in.slice_colptr(i, 0), in_n_rows );
max@0 1427 }
max@0 1428 }
max@0 1429 else
max@0 1430 if( (in_n_rows == 1) && (in_n_cols == out_n_rows) && (in_n_slices == out_n_cols) )
max@0 1431 {
max@0 1432 const Cube<eT>& Q = in.m;
max@0 1433
max@0 1434 const uword in_aux_row1 = in.aux_row1;
max@0 1435 const uword in_aux_col1 = in.aux_col1;
max@0 1436 const uword in_aux_slice1 = in.aux_slice1;
max@0 1437
max@0 1438 for(uword slice=0; slice < in_n_slices; ++slice)
max@0 1439 {
max@0 1440 const uword mod_slice = in_aux_slice1 + slice;
max@0 1441
max@0 1442 eT* out_colptr = out.colptr(slice);
max@0 1443
max@0 1444 uword i,j;
max@0 1445 for(i=0, j=1; j < in_n_cols; i+=2, j+=2)
max@0 1446 {
max@0 1447 const eT tmp_i = Q.at(in_aux_row1, in_aux_col1 + i, mod_slice);
max@0 1448 const eT tmp_j = Q.at(in_aux_row1, in_aux_col1 + j, mod_slice);
max@0 1449
max@0 1450 out_colptr[i] += tmp_i;
max@0 1451 out_colptr[j] += tmp_j;
max@0 1452 }
max@0 1453
max@0 1454 if(i < in_n_cols)
max@0 1455 {
max@0 1456 out_colptr[i] += Q.at(in_aux_row1, in_aux_col1 + i, mod_slice);
max@0 1457 }
max@0 1458 }
max@0 1459 }
max@0 1460 }
max@0 1461 else
max@0 1462 {
max@0 1463 eT* out_mem = out.memptr();
max@0 1464
max@0 1465 const Cube<eT>& Q = in.m;
max@0 1466
max@0 1467 const uword in_aux_row1 = in.aux_row1;
max@0 1468 const uword in_aux_col1 = in.aux_col1;
max@0 1469 const uword in_aux_slice1 = in.aux_slice1;
max@0 1470
max@0 1471 for(uword i=0; i<in_n_slices; ++i)
max@0 1472 {
max@0 1473 out_mem[i] += Q.at(in_aux_row1, in_aux_col1, in_aux_slice1 + i);
max@0 1474 }
max@0 1475 }
max@0 1476 }
max@0 1477 }
max@0 1478
max@0 1479
max@0 1480
max@0 1481 //! mat X -= Y.subcube(...)
max@0 1482 template<typename eT>
max@0 1483 inline
max@0 1484 void
max@0 1485 subview_cube<eT>::minus_inplace(Mat<eT>& out, const subview_cube<eT>& in)
max@0 1486 {
max@0 1487 arma_extra_debug_sigprint();
max@0 1488
max@0 1489 arma_debug_assert_cube_as_mat(out, in, "subtraction", true);
max@0 1490
max@0 1491 const uword in_n_rows = in.n_rows;
max@0 1492 const uword in_n_cols = in.n_cols;
max@0 1493 const uword in_n_slices = in.n_slices;
max@0 1494
max@0 1495 const uword out_n_rows = out.n_rows;
max@0 1496 const uword out_n_cols = out.n_cols;
max@0 1497 const uword out_vec_state = out.vec_state;
max@0 1498
max@0 1499 if(in_n_slices == 1)
max@0 1500 {
max@0 1501 for(uword col=0; col < in_n_cols; ++col)
max@0 1502 {
max@0 1503 arrayops::inplace_minus( out.colptr(col), in.slice_colptr(0, col), in_n_rows );
max@0 1504 }
max@0 1505 }
max@0 1506 else
max@0 1507 {
max@0 1508 if(out_vec_state == 0)
max@0 1509 {
max@0 1510 if( (in_n_rows == out_n_rows) && (in_n_cols == 1) && (in_n_slices == out_n_cols) )
max@0 1511 {
max@0 1512 for(uword i=0; i < in_n_slices; ++i)
max@0 1513 {
max@0 1514 arrayops::inplace_minus( out.colptr(i), in.slice_colptr(i, 0), in_n_rows );
max@0 1515 }
max@0 1516 }
max@0 1517 else
max@0 1518 if( (in_n_rows == 1) && (in_n_cols == out_n_rows) && (in_n_slices == out_n_cols) )
max@0 1519 {
max@0 1520 const Cube<eT>& Q = in.m;
max@0 1521
max@0 1522 const uword in_aux_row1 = in.aux_row1;
max@0 1523 const uword in_aux_col1 = in.aux_col1;
max@0 1524 const uword in_aux_slice1 = in.aux_slice1;
max@0 1525
max@0 1526 for(uword slice=0; slice < in_n_slices; ++slice)
max@0 1527 {
max@0 1528 const uword mod_slice = in_aux_slice1 + slice;
max@0 1529
max@0 1530 eT* out_colptr = out.colptr(slice);
max@0 1531
max@0 1532 uword i,j;
max@0 1533 for(i=0, j=1; j < in_n_cols; i+=2, j+=2)
max@0 1534 {
max@0 1535 const eT tmp_i = Q.at(in_aux_row1, in_aux_col1 + i, mod_slice);
max@0 1536 const eT tmp_j = Q.at(in_aux_row1, in_aux_col1 + j, mod_slice);
max@0 1537
max@0 1538 out_colptr[i] -= tmp_i;
max@0 1539 out_colptr[j] -= tmp_j;
max@0 1540 }
max@0 1541
max@0 1542 if(i < in_n_cols)
max@0 1543 {
max@0 1544 out_colptr[i] -= Q.at(in_aux_row1, in_aux_col1 + i, mod_slice);
max@0 1545 }
max@0 1546 }
max@0 1547 }
max@0 1548 }
max@0 1549 else
max@0 1550 {
max@0 1551 eT* out_mem = out.memptr();
max@0 1552
max@0 1553 const Cube<eT>& Q = in.m;
max@0 1554
max@0 1555 const uword in_aux_row1 = in.aux_row1;
max@0 1556 const uword in_aux_col1 = in.aux_col1;
max@0 1557 const uword in_aux_slice1 = in.aux_slice1;
max@0 1558
max@0 1559 for(uword i=0; i<in_n_slices; ++i)
max@0 1560 {
max@0 1561 out_mem[i] -= Q.at(in_aux_row1, in_aux_col1, in_aux_slice1 + i);
max@0 1562 }
max@0 1563 }
max@0 1564 }
max@0 1565 }
max@0 1566
max@0 1567
max@0 1568
max@0 1569 //! mat X %= Y.subcube(...)
max@0 1570 template<typename eT>
max@0 1571 inline
max@0 1572 void
max@0 1573 subview_cube<eT>::schur_inplace(Mat<eT>& out, const subview_cube<eT>& in)
max@0 1574 {
max@0 1575 arma_extra_debug_sigprint();
max@0 1576
max@0 1577 arma_debug_assert_cube_as_mat(out, in, "element-wise multiplication", true);
max@0 1578
max@0 1579 const uword in_n_rows = in.n_rows;
max@0 1580 const uword in_n_cols = in.n_cols;
max@0 1581 const uword in_n_slices = in.n_slices;
max@0 1582
max@0 1583 const uword out_n_rows = out.n_rows;
max@0 1584 const uword out_n_cols = out.n_cols;
max@0 1585 const uword out_vec_state = out.vec_state;
max@0 1586
max@0 1587 if(in_n_slices == 1)
max@0 1588 {
max@0 1589 for(uword col=0; col < in_n_cols; ++col)
max@0 1590 {
max@0 1591 arrayops::inplace_mul( out.colptr(col), in.slice_colptr(0, col), in_n_rows );
max@0 1592 }
max@0 1593 }
max@0 1594 else
max@0 1595 {
max@0 1596 if(out_vec_state == 0)
max@0 1597 {
max@0 1598 if( (in_n_rows == out_n_rows) && (in_n_cols == 1) && (in_n_slices == out_n_cols) )
max@0 1599 {
max@0 1600 for(uword i=0; i < in_n_slices; ++i)
max@0 1601 {
max@0 1602 arrayops::inplace_mul( out.colptr(i), in.slice_colptr(i, 0), in_n_rows );
max@0 1603 }
max@0 1604 }
max@0 1605 else
max@0 1606 if( (in_n_rows == 1) && (in_n_cols == out_n_rows) && (in_n_slices == out_n_cols) )
max@0 1607 {
max@0 1608 const Cube<eT>& Q = in.m;
max@0 1609
max@0 1610 const uword in_aux_row1 = in.aux_row1;
max@0 1611 const uword in_aux_col1 = in.aux_col1;
max@0 1612 const uword in_aux_slice1 = in.aux_slice1;
max@0 1613
max@0 1614 for(uword slice=0; slice < in_n_slices; ++slice)
max@0 1615 {
max@0 1616 const uword mod_slice = in_aux_slice1 + slice;
max@0 1617
max@0 1618 eT* out_colptr = out.colptr(slice);
max@0 1619
max@0 1620 uword i,j;
max@0 1621 for(i=0, j=1; j < in_n_cols; i+=2, j+=2)
max@0 1622 {
max@0 1623 const eT tmp_i = Q.at(in_aux_row1, in_aux_col1 + i, mod_slice);
max@0 1624 const eT tmp_j = Q.at(in_aux_row1, in_aux_col1 + j, mod_slice);
max@0 1625
max@0 1626 out_colptr[i] *= tmp_i;
max@0 1627 out_colptr[j] *= tmp_j;
max@0 1628 }
max@0 1629
max@0 1630 if(i < in_n_cols)
max@0 1631 {
max@0 1632 out_colptr[i] *= Q.at(in_aux_row1, in_aux_col1 + i, mod_slice);
max@0 1633 }
max@0 1634 }
max@0 1635 }
max@0 1636 }
max@0 1637 else
max@0 1638 {
max@0 1639 eT* out_mem = out.memptr();
max@0 1640
max@0 1641 const Cube<eT>& Q = in.m;
max@0 1642
max@0 1643 const uword in_aux_row1 = in.aux_row1;
max@0 1644 const uword in_aux_col1 = in.aux_col1;
max@0 1645 const uword in_aux_slice1 = in.aux_slice1;
max@0 1646
max@0 1647 for(uword i=0; i<in_n_slices; ++i)
max@0 1648 {
max@0 1649 out_mem[i] *= Q.at(in_aux_row1, in_aux_col1, in_aux_slice1 + i);
max@0 1650 }
max@0 1651 }
max@0 1652 }
max@0 1653 }
max@0 1654
max@0 1655
max@0 1656
max@0 1657 //! mat X /= Y.subcube(...)
max@0 1658 template<typename eT>
max@0 1659 inline
max@0 1660 void
max@0 1661 subview_cube<eT>::div_inplace(Mat<eT>& out, const subview_cube<eT>& in)
max@0 1662 {
max@0 1663 arma_extra_debug_sigprint();
max@0 1664
max@0 1665 arma_debug_assert_cube_as_mat(out, in, "element-wise division", true);
max@0 1666
max@0 1667 const uword in_n_rows = in.n_rows;
max@0 1668 const uword in_n_cols = in.n_cols;
max@0 1669 const uword in_n_slices = in.n_slices;
max@0 1670
max@0 1671 const uword out_n_rows = out.n_rows;
max@0 1672 const uword out_n_cols = out.n_cols;
max@0 1673 const uword out_vec_state = out.vec_state;
max@0 1674
max@0 1675 if(in_n_slices == 1)
max@0 1676 {
max@0 1677 for(uword col=0; col < in_n_cols; ++col)
max@0 1678 {
max@0 1679 arrayops::inplace_div( out.colptr(col), in.slice_colptr(0, col), in_n_rows );
max@0 1680 }
max@0 1681 }
max@0 1682 else
max@0 1683 {
max@0 1684 if(out_vec_state == 0)
max@0 1685 {
max@0 1686 if( (in_n_rows == out_n_rows) && (in_n_cols == 1) && (in_n_slices == out_n_cols) )
max@0 1687 {
max@0 1688 for(uword i=0; i < in_n_slices; ++i)
max@0 1689 {
max@0 1690 arrayops::inplace_div( out.colptr(i), in.slice_colptr(i, 0), in_n_rows );
max@0 1691 }
max@0 1692 }
max@0 1693 else
max@0 1694 if( (in_n_rows == 1) && (in_n_cols == out_n_rows) && (in_n_slices == out_n_cols) )
max@0 1695 {
max@0 1696 const Cube<eT>& Q = in.m;
max@0 1697
max@0 1698 const uword in_aux_row1 = in.aux_row1;
max@0 1699 const uword in_aux_col1 = in.aux_col1;
max@0 1700 const uword in_aux_slice1 = in.aux_slice1;
max@0 1701
max@0 1702 for(uword slice=0; slice < in_n_slices; ++slice)
max@0 1703 {
max@0 1704 const uword mod_slice = in_aux_slice1 + slice;
max@0 1705
max@0 1706 eT* out_colptr = out.colptr(slice);
max@0 1707
max@0 1708 uword i,j;
max@0 1709 for(i=0, j=1; j < in_n_cols; i+=2, j+=2)
max@0 1710 {
max@0 1711 const eT tmp_i = Q.at(in_aux_row1, in_aux_col1 + i, mod_slice);
max@0 1712 const eT tmp_j = Q.at(in_aux_row1, in_aux_col1 + j, mod_slice);
max@0 1713
max@0 1714 out_colptr[i] /= tmp_i;
max@0 1715 out_colptr[j] /= tmp_j;
max@0 1716 }
max@0 1717
max@0 1718 if(i < in_n_cols)
max@0 1719 {
max@0 1720 out_colptr[i] /= Q.at(in_aux_row1, in_aux_col1 + i, mod_slice);
max@0 1721 }
max@0 1722 }
max@0 1723 }
max@0 1724 }
max@0 1725 else
max@0 1726 {
max@0 1727 eT* out_mem = out.memptr();
max@0 1728
max@0 1729 const Cube<eT>& Q = in.m;
max@0 1730
max@0 1731 const uword in_aux_row1 = in.aux_row1;
max@0 1732 const uword in_aux_col1 = in.aux_col1;
max@0 1733 const uword in_aux_slice1 = in.aux_slice1;
max@0 1734
max@0 1735 for(uword i=0; i<in_n_slices; ++i)
max@0 1736 {
max@0 1737 out_mem[i] /= Q.at(in_aux_row1, in_aux_col1, in_aux_slice1 + i);
max@0 1738 }
max@0 1739 }
max@0 1740 }
max@0 1741 }
max@0 1742
max@0 1743
max@0 1744
max@0 1745 //! @}