annotate armadillo-3.900.4/include/armadillo_bits/unwrap.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) 2008-2013 NICTA (www.nicta.com.au)
Chris@49 2 // Copyright (C) 2008-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 unwrap
Chris@49 10 //! @{
Chris@49 11
Chris@49 12
Chris@49 13
Chris@49 14 template<typename T1>
Chris@49 15 struct unwrap_default
Chris@49 16 {
Chris@49 17 typedef typename T1::elem_type eT;
Chris@49 18 typedef Mat<eT> stored_type;
Chris@49 19
Chris@49 20 inline
Chris@49 21 unwrap_default(const T1& A)
Chris@49 22 : M(A)
Chris@49 23 {
Chris@49 24 arma_extra_debug_sigprint();
Chris@49 25 }
Chris@49 26
Chris@49 27 const Mat<eT> M;
Chris@49 28 };
Chris@49 29
Chris@49 30
Chris@49 31
Chris@49 32 template<typename T1>
Chris@49 33 struct unwrap_fixed
Chris@49 34 {
Chris@49 35 typedef T1 stored_type;
Chris@49 36
Chris@49 37 inline explicit
Chris@49 38 unwrap_fixed(const T1& A)
Chris@49 39 : M(A)
Chris@49 40 {
Chris@49 41 arma_extra_debug_sigprint();
Chris@49 42 }
Chris@49 43
Chris@49 44 const T1& M;
Chris@49 45 };
Chris@49 46
Chris@49 47
Chris@49 48
Chris@49 49 template<typename T1, bool condition>
Chris@49 50 struct unwrap_redirect {};
Chris@49 51
Chris@49 52 template<typename T1>
Chris@49 53 struct unwrap_redirect<T1, false> { typedef unwrap_default<T1> result; };
Chris@49 54
Chris@49 55 template<typename T1>
Chris@49 56 struct unwrap_redirect<T1, true> { typedef unwrap_fixed<T1> result; };
Chris@49 57
Chris@49 58
Chris@49 59 template<typename T1>
Chris@49 60 struct unwrap : public unwrap_redirect<T1, is_Mat_fixed<T1>::value >::result
Chris@49 61 {
Chris@49 62 inline
Chris@49 63 unwrap(const T1& A)
Chris@49 64 : unwrap_redirect< T1, is_Mat_fixed<T1>::value >::result(A)
Chris@49 65 {
Chris@49 66 }
Chris@49 67 };
Chris@49 68
Chris@49 69
Chris@49 70
Chris@49 71 template<typename eT>
Chris@49 72 struct unwrap< Mat<eT> >
Chris@49 73 {
Chris@49 74 typedef Mat<eT> stored_type;
Chris@49 75
Chris@49 76 inline
Chris@49 77 unwrap(const Mat<eT>& A)
Chris@49 78 : M(A)
Chris@49 79 {
Chris@49 80 arma_extra_debug_sigprint();
Chris@49 81 }
Chris@49 82
Chris@49 83 const Mat<eT>& M;
Chris@49 84 };
Chris@49 85
Chris@49 86
Chris@49 87
Chris@49 88 template<typename eT>
Chris@49 89 struct unwrap< Row<eT> >
Chris@49 90 {
Chris@49 91 typedef Row<eT> stored_type;
Chris@49 92
Chris@49 93 inline
Chris@49 94 unwrap(const Row<eT>& A)
Chris@49 95 : M(A)
Chris@49 96 {
Chris@49 97 arma_extra_debug_sigprint();
Chris@49 98 }
Chris@49 99
Chris@49 100 const Row<eT>& M;
Chris@49 101 };
Chris@49 102
Chris@49 103
Chris@49 104
Chris@49 105 template<typename eT>
Chris@49 106 struct unwrap< Col<eT> >
Chris@49 107 {
Chris@49 108 typedef Col<eT> stored_type;
Chris@49 109
Chris@49 110 inline
Chris@49 111 unwrap(const Col<eT>& A)
Chris@49 112 : M(A)
Chris@49 113 {
Chris@49 114 arma_extra_debug_sigprint();
Chris@49 115 }
Chris@49 116
Chris@49 117 const Col<eT>& M;
Chris@49 118 };
Chris@49 119
Chris@49 120
Chris@49 121
Chris@49 122 template<typename out_eT, typename T1, typename T2, typename glue_type>
Chris@49 123 struct unwrap< mtGlue<out_eT, T1, T2, glue_type> >
Chris@49 124 {
Chris@49 125 typedef Mat<out_eT> stored_type;
Chris@49 126
Chris@49 127 inline
Chris@49 128 unwrap(const mtGlue<out_eT, T1, T2, glue_type>& A)
Chris@49 129 : M(A)
Chris@49 130 {
Chris@49 131 arma_extra_debug_sigprint();
Chris@49 132 }
Chris@49 133
Chris@49 134 const Mat<out_eT> M;
Chris@49 135 };
Chris@49 136
Chris@49 137
Chris@49 138
Chris@49 139 template<typename out_eT, typename T1, typename op_type>
Chris@49 140 struct unwrap< mtOp<out_eT, T1, op_type> >
Chris@49 141 {
Chris@49 142 typedef Mat<out_eT> stored_type;
Chris@49 143
Chris@49 144 inline
Chris@49 145 unwrap(const mtOp<out_eT, T1, op_type>& A)
Chris@49 146 : M(A)
Chris@49 147 {
Chris@49 148 arma_extra_debug_sigprint();
Chris@49 149 }
Chris@49 150
Chris@49 151 const Mat<out_eT> M;
Chris@49 152 };
Chris@49 153
Chris@49 154
Chris@49 155
Chris@49 156 //
Chris@49 157 //
Chris@49 158 //
Chris@49 159
Chris@49 160
Chris@49 161
Chris@49 162 template<typename T1>
Chris@49 163 struct quasi_unwrap_default
Chris@49 164 {
Chris@49 165 typedef typename T1::elem_type eT;
Chris@49 166
Chris@49 167 static const bool has_subview = false;
Chris@49 168
Chris@49 169 inline
Chris@49 170 quasi_unwrap_default(const T1& A)
Chris@49 171 : M(A)
Chris@49 172 {
Chris@49 173 arma_extra_debug_sigprint();
Chris@49 174 }
Chris@49 175
Chris@49 176 // NOTE: DO NOT DIRECTLY CHECK FOR ALIASING BY TAKING THE ADDRESS OF THE "M" OBJECT IN ANY quasi_unwrap CLASS !!!
Chris@49 177 const Mat<eT> M;
Chris@49 178
Chris@49 179 template<typename eT2>
Chris@49 180 arma_inline bool is_alias(const Mat<eT2>&) const { return false; }
Chris@49 181 };
Chris@49 182
Chris@49 183
Chris@49 184
Chris@49 185 template<typename T1>
Chris@49 186 struct quasi_unwrap_fixed
Chris@49 187 {
Chris@49 188 typedef typename T1::elem_type eT;
Chris@49 189
Chris@49 190 static const bool has_subview = false;
Chris@49 191
Chris@49 192 inline explicit
Chris@49 193 quasi_unwrap_fixed(const T1& A)
Chris@49 194 : M(A)
Chris@49 195 {
Chris@49 196 arma_extra_debug_sigprint();
Chris@49 197 }
Chris@49 198
Chris@49 199 const Mat<eT>& M;
Chris@49 200
Chris@49 201 template<typename eT2>
Chris@49 202 arma_inline bool is_alias(const Mat<eT2>& X) const { return (void_ptr(&M) == void_ptr(&X)); }
Chris@49 203 };
Chris@49 204
Chris@49 205
Chris@49 206
Chris@49 207 template<typename T1, bool condition>
Chris@49 208 struct quasi_unwrap_redirect {};
Chris@49 209
Chris@49 210 template<typename T1>
Chris@49 211 struct quasi_unwrap_redirect<T1, false> { typedef quasi_unwrap_default<T1> result; };
Chris@49 212
Chris@49 213 template<typename T1>
Chris@49 214 struct quasi_unwrap_redirect<T1, true> { typedef quasi_unwrap_fixed<T1> result; };
Chris@49 215
Chris@49 216
Chris@49 217 template<typename T1>
Chris@49 218 struct quasi_unwrap : public quasi_unwrap_redirect<T1, is_Mat_fixed<T1>::value >::result
Chris@49 219 {
Chris@49 220 typedef typename quasi_unwrap_redirect<T1, is_Mat_fixed<T1>::value >::result quasi_unwrap_extra;
Chris@49 221
Chris@49 222 static const bool has_subview = quasi_unwrap_extra::has_subview;
Chris@49 223
Chris@49 224 inline
Chris@49 225 quasi_unwrap(const T1& A)
Chris@49 226 : quasi_unwrap_extra(A)
Chris@49 227 {
Chris@49 228 }
Chris@49 229
Chris@49 230 using quasi_unwrap_extra::M;
Chris@49 231 using quasi_unwrap_extra::is_alias;
Chris@49 232 };
Chris@49 233
Chris@49 234
Chris@49 235
Chris@49 236 template<typename eT>
Chris@49 237 struct quasi_unwrap< Mat<eT> >
Chris@49 238 {
Chris@49 239 static const bool has_subview = false;
Chris@49 240
Chris@49 241 inline
Chris@49 242 quasi_unwrap(const Mat<eT>& A)
Chris@49 243 : M(A)
Chris@49 244 {
Chris@49 245 arma_extra_debug_sigprint();
Chris@49 246 }
Chris@49 247
Chris@49 248 const Mat<eT>& M;
Chris@49 249
Chris@49 250 template<typename eT2>
Chris@49 251 arma_inline bool is_alias(const Mat<eT2>& X) const { return (void_ptr(&M) == void_ptr(&X)); }
Chris@49 252 };
Chris@49 253
Chris@49 254
Chris@49 255
Chris@49 256 template<typename eT>
Chris@49 257 struct quasi_unwrap< Row<eT> >
Chris@49 258 {
Chris@49 259 static const bool has_subview = false;
Chris@49 260
Chris@49 261 inline
Chris@49 262 quasi_unwrap(const Row<eT>& A)
Chris@49 263 : M(A)
Chris@49 264 {
Chris@49 265 arma_extra_debug_sigprint();
Chris@49 266 }
Chris@49 267
Chris@49 268 const Row<eT>& M;
Chris@49 269
Chris@49 270 template<typename eT2>
Chris@49 271 arma_inline bool is_alias(const Mat<eT2>& X) const { return (void_ptr(&M) == void_ptr(&X)); }
Chris@49 272 };
Chris@49 273
Chris@49 274
Chris@49 275
Chris@49 276 template<typename eT>
Chris@49 277 struct quasi_unwrap< Col<eT> >
Chris@49 278 {
Chris@49 279 static const bool has_subview = false;
Chris@49 280
Chris@49 281 inline
Chris@49 282 quasi_unwrap(const Col<eT>& A)
Chris@49 283 : M(A)
Chris@49 284 {
Chris@49 285 arma_extra_debug_sigprint();
Chris@49 286 }
Chris@49 287
Chris@49 288 const Col<eT>& M;
Chris@49 289
Chris@49 290 template<typename eT2>
Chris@49 291 arma_inline bool is_alias(const Mat<eT2>& X) const { return (void_ptr(&M) == void_ptr(&X)); }
Chris@49 292 };
Chris@49 293
Chris@49 294
Chris@49 295
Chris@49 296 template<typename eT>
Chris@49 297 struct quasi_unwrap< subview_col<eT> >
Chris@49 298 {
Chris@49 299 static const bool has_subview = true;
Chris@49 300
Chris@49 301 inline
Chris@49 302 quasi_unwrap(const subview_col<eT>& A)
Chris@49 303 : M ( const_cast<eT*>( A.colptr(0) ), A.n_rows, 1, false, false )
Chris@49 304 , src( A.m )
Chris@49 305 {
Chris@49 306 arma_extra_debug_sigprint();
Chris@49 307 }
Chris@49 308
Chris@49 309 const Mat<eT> M;
Chris@49 310 const Mat<eT>& src;
Chris@49 311
Chris@49 312 template<typename eT2>
Chris@49 313 arma_inline bool is_alias(const Mat<eT2>& X) const { return (void_ptr(&src) == void_ptr(&X)); }
Chris@49 314 };
Chris@49 315
Chris@49 316
Chris@49 317
Chris@49 318 template<typename out_eT, typename T1, typename T2, typename glue_type>
Chris@49 319 struct quasi_unwrap< mtGlue<out_eT, T1, T2, glue_type> >
Chris@49 320 {
Chris@49 321 static const bool has_subview = false;
Chris@49 322
Chris@49 323 inline
Chris@49 324 quasi_unwrap(const mtGlue<out_eT, T1, T2, glue_type>& A)
Chris@49 325 : M(A)
Chris@49 326 {
Chris@49 327 arma_extra_debug_sigprint();
Chris@49 328 }
Chris@49 329
Chris@49 330 const Mat<out_eT> M;
Chris@49 331
Chris@49 332 template<typename eT2>
Chris@49 333 arma_inline bool is_alias(const Mat<eT2>&) const { return false; }
Chris@49 334 };
Chris@49 335
Chris@49 336
Chris@49 337
Chris@49 338 template<typename out_eT, typename T1, typename op_type>
Chris@49 339 struct quasi_unwrap< mtOp<out_eT, T1, op_type> >
Chris@49 340 {
Chris@49 341 static const bool has_subview = false;
Chris@49 342
Chris@49 343 inline
Chris@49 344 quasi_unwrap(const mtOp<out_eT, T1, op_type>& A)
Chris@49 345 : M(A)
Chris@49 346 {
Chris@49 347 arma_extra_debug_sigprint();
Chris@49 348 }
Chris@49 349
Chris@49 350 const Mat<out_eT> M;
Chris@49 351
Chris@49 352 template<typename eT2>
Chris@49 353 arma_inline bool is_alias(const Mat<eT2>&) const { return false; }
Chris@49 354 };
Chris@49 355
Chris@49 356
Chris@49 357
Chris@49 358 //
Chris@49 359 //
Chris@49 360 //
Chris@49 361
Chris@49 362
Chris@49 363
Chris@49 364 template<typename T1>
Chris@49 365 struct unwrap_check_default
Chris@49 366 {
Chris@49 367 typedef typename T1::elem_type eT;
Chris@49 368 typedef Mat<eT> stored_type;
Chris@49 369
Chris@49 370 inline
Chris@49 371 unwrap_check_default(const T1& A, const Mat<eT>&)
Chris@49 372 : M(A)
Chris@49 373 {
Chris@49 374 arma_extra_debug_sigprint();
Chris@49 375 }
Chris@49 376
Chris@49 377 inline
Chris@49 378 unwrap_check_default(const T1& A, const bool)
Chris@49 379 : M(A)
Chris@49 380 {
Chris@49 381 arma_extra_debug_sigprint();
Chris@49 382 }
Chris@49 383
Chris@49 384 const Mat<eT> M;
Chris@49 385 };
Chris@49 386
Chris@49 387
Chris@49 388
Chris@49 389 template<typename T1>
Chris@49 390 struct unwrap_check_fixed
Chris@49 391 {
Chris@49 392 typedef typename T1::elem_type eT;
Chris@49 393 typedef T1 stored_type;
Chris@49 394
Chris@49 395 inline
Chris@49 396 unwrap_check_fixed(const T1& A, const Mat<eT>& B)
Chris@49 397 : M_local( (&A == &B) ? new T1(A) : 0 )
Chris@49 398 , M ( (&A == &B) ? *M_local : A )
Chris@49 399 {
Chris@49 400 arma_extra_debug_sigprint();
Chris@49 401 }
Chris@49 402
Chris@49 403 inline
Chris@49 404 unwrap_check_fixed(const T1& A, const bool is_alias)
Chris@49 405 : M_local( is_alias ? new T1(A) : 0 )
Chris@49 406 , M ( is_alias ? *M_local : A )
Chris@49 407 {
Chris@49 408 arma_extra_debug_sigprint();
Chris@49 409 }
Chris@49 410
Chris@49 411 inline
Chris@49 412 ~unwrap_check_fixed()
Chris@49 413 {
Chris@49 414 arma_extra_debug_sigprint();
Chris@49 415
Chris@49 416 if(M_local) { delete M_local; }
Chris@49 417 }
Chris@49 418
Chris@49 419
Chris@49 420 // the order below is important
Chris@49 421 const T1* M_local;
Chris@49 422 const T1& M;
Chris@49 423 };
Chris@49 424
Chris@49 425
Chris@49 426
Chris@49 427 template<typename T1, bool condition>
Chris@49 428 struct unwrap_check_redirect {};
Chris@49 429
Chris@49 430 template<typename T1>
Chris@49 431 struct unwrap_check_redirect<T1, false> { typedef unwrap_check_default<T1> result; };
Chris@49 432
Chris@49 433 template<typename T1>
Chris@49 434 struct unwrap_check_redirect<T1, true> { typedef unwrap_check_fixed<T1> result; };
Chris@49 435
Chris@49 436
Chris@49 437 template<typename T1>
Chris@49 438 struct unwrap_check : public unwrap_check_redirect<T1, is_Mat_fixed<T1>::value >::result
Chris@49 439 {
Chris@49 440 inline unwrap_check(const T1& A, const Mat<typename T1::elem_type>& B)
Chris@49 441 : unwrap_check_redirect< T1, is_Mat_fixed<T1>::value >::result(A, B)
Chris@49 442 {
Chris@49 443 }
Chris@49 444
Chris@49 445 inline unwrap_check(const T1& A, const bool is_alias)
Chris@49 446 : unwrap_check_redirect< T1, is_Mat_fixed<T1>::value >::result(A, is_alias)
Chris@49 447 {
Chris@49 448 }
Chris@49 449 };
Chris@49 450
Chris@49 451
Chris@49 452
Chris@49 453 template<typename eT>
Chris@49 454 struct unwrap_check< Mat<eT> >
Chris@49 455 {
Chris@49 456 typedef Mat<eT> stored_type;
Chris@49 457
Chris@49 458 inline
Chris@49 459 unwrap_check(const Mat<eT>& A, const Mat<eT>& B)
Chris@49 460 : M_local( (&A == &B) ? new Mat<eT>(A) : 0 )
Chris@49 461 , M ( (&A == &B) ? (*M_local) : A )
Chris@49 462 {
Chris@49 463 arma_extra_debug_sigprint();
Chris@49 464 }
Chris@49 465
Chris@49 466 unwrap_check(const Mat<eT>& A, const bool is_alias)
Chris@49 467 : M_local( is_alias ? new Mat<eT>(A) : 0 )
Chris@49 468 , M ( is_alias ? (*M_local) : A )
Chris@49 469 {
Chris@49 470 arma_extra_debug_sigprint();
Chris@49 471 }
Chris@49 472
Chris@49 473 inline
Chris@49 474 ~unwrap_check()
Chris@49 475 {
Chris@49 476 arma_extra_debug_sigprint();
Chris@49 477
Chris@49 478 if(M_local) { delete M_local; }
Chris@49 479 }
Chris@49 480
Chris@49 481
Chris@49 482 // the order below is important
Chris@49 483 const Mat<eT>* M_local;
Chris@49 484 const Mat<eT>& M;
Chris@49 485 };
Chris@49 486
Chris@49 487
Chris@49 488
Chris@49 489 template<typename eT>
Chris@49 490 struct unwrap_check< Row<eT> >
Chris@49 491 {
Chris@49 492 typedef Row<eT> stored_type;
Chris@49 493
Chris@49 494 inline
Chris@49 495 unwrap_check(const Row<eT>& A, const Mat<eT>& B)
Chris@49 496 : M_local( (&A == &B) ? new Row<eT>(A) : 0 )
Chris@49 497 , M ( (&A == &B) ? (*M_local) : A )
Chris@49 498 {
Chris@49 499 arma_extra_debug_sigprint();
Chris@49 500 }
Chris@49 501
Chris@49 502 unwrap_check(const Row<eT>& A, const bool is_alias)
Chris@49 503 : M_local( is_alias ? new Row<eT>(A) : 0 )
Chris@49 504 , M ( is_alias ? (*M_local) : A )
Chris@49 505 {
Chris@49 506 arma_extra_debug_sigprint();
Chris@49 507 }
Chris@49 508
Chris@49 509 inline
Chris@49 510 ~unwrap_check()
Chris@49 511 {
Chris@49 512 arma_extra_debug_sigprint();
Chris@49 513
Chris@49 514 if(M_local) { delete M_local; }
Chris@49 515 }
Chris@49 516
Chris@49 517
Chris@49 518 // the order below is important
Chris@49 519 const Row<eT>* M_local;
Chris@49 520 const Row<eT>& M;
Chris@49 521 };
Chris@49 522
Chris@49 523
Chris@49 524
Chris@49 525 template<typename eT>
Chris@49 526 struct unwrap_check< Col<eT> >
Chris@49 527 {
Chris@49 528 typedef Col<eT> stored_type;
Chris@49 529
Chris@49 530 inline
Chris@49 531 unwrap_check(const Col<eT>& A, const Mat<eT>& B)
Chris@49 532 : M_local( (&A == &B) ? new Col<eT>(A) : 0 )
Chris@49 533 , M ( (&A == &B) ? (*M_local) : A )
Chris@49 534 {
Chris@49 535 arma_extra_debug_sigprint();
Chris@49 536 }
Chris@49 537
Chris@49 538 unwrap_check(const Col<eT>& A, const bool is_alias)
Chris@49 539 : M_local( is_alias ? new Col<eT>(A) : 0 )
Chris@49 540 , M ( is_alias ? (*M_local) : A )
Chris@49 541 {
Chris@49 542 arma_extra_debug_sigprint();
Chris@49 543 }
Chris@49 544
Chris@49 545 inline
Chris@49 546 ~unwrap_check()
Chris@49 547 {
Chris@49 548 arma_extra_debug_sigprint();
Chris@49 549
Chris@49 550 if(M_local) { delete M_local; }
Chris@49 551 }
Chris@49 552
Chris@49 553
Chris@49 554 // the order below is important
Chris@49 555 const Col<eT>* M_local;
Chris@49 556 const Col<eT>& M;
Chris@49 557 };
Chris@49 558
Chris@49 559
Chris@49 560
Chris@49 561 //
Chris@49 562 //
Chris@49 563 //
Chris@49 564
Chris@49 565
Chris@49 566
Chris@49 567 template<typename T1>
Chris@49 568 struct unwrap_check_mixed
Chris@49 569 {
Chris@49 570 typedef typename T1::elem_type eT1;
Chris@49 571
Chris@49 572 template<typename eT2>
Chris@49 573 inline
Chris@49 574 unwrap_check_mixed(const T1& A, const Mat<eT2>&)
Chris@49 575 : M(A)
Chris@49 576 {
Chris@49 577 arma_extra_debug_sigprint();
Chris@49 578 }
Chris@49 579
Chris@49 580 template<typename eT2>
Chris@49 581 inline
Chris@49 582 unwrap_check_mixed(const T1& A, const bool)
Chris@49 583 : M(A)
Chris@49 584 {
Chris@49 585 arma_extra_debug_sigprint();
Chris@49 586 }
Chris@49 587
Chris@49 588 const Mat<eT1> M;
Chris@49 589 };
Chris@49 590
Chris@49 591
Chris@49 592
Chris@49 593 template<typename eT1>
Chris@49 594 struct unwrap_check_mixed< Mat<eT1> >
Chris@49 595 {
Chris@49 596 template<typename eT2>
Chris@49 597 inline
Chris@49 598 unwrap_check_mixed(const Mat<eT1>& A, const Mat<eT2>& B)
Chris@49 599 : M_local( (void_ptr(&A) == void_ptr(&B)) ? new Mat<eT1>(A) : 0 )
Chris@49 600 , M ( (void_ptr(&A) == void_ptr(&B)) ? (*M_local) : A )
Chris@49 601 {
Chris@49 602 arma_extra_debug_sigprint();
Chris@49 603 }
Chris@49 604
Chris@49 605 template<typename eT2>
Chris@49 606 inline
Chris@49 607 unwrap_check_mixed(const Mat<eT1>& A, const bool is_alias)
Chris@49 608 : M_local( is_alias ? new Mat<eT1>(A) : 0 )
Chris@49 609 , M ( is_alias ? (*M_local) : A )
Chris@49 610 {
Chris@49 611 arma_extra_debug_sigprint();
Chris@49 612 }
Chris@49 613
Chris@49 614 inline
Chris@49 615 ~unwrap_check_mixed()
Chris@49 616 {
Chris@49 617 arma_extra_debug_sigprint();
Chris@49 618
Chris@49 619 if(M_local) { delete M_local; }
Chris@49 620 }
Chris@49 621
Chris@49 622
Chris@49 623 // the order below is important
Chris@49 624 const Mat<eT1>* M_local;
Chris@49 625 const Mat<eT1>& M;
Chris@49 626 };
Chris@49 627
Chris@49 628
Chris@49 629
Chris@49 630 template<typename eT1>
Chris@49 631 struct unwrap_check_mixed< Row<eT1> >
Chris@49 632 {
Chris@49 633 template<typename eT2>
Chris@49 634 inline
Chris@49 635 unwrap_check_mixed(const Row<eT1>& A, const Mat<eT2>& B)
Chris@49 636 : M_local( (void_ptr(&A) == void_ptr(&B)) ? new Row<eT1>(A) : 0 )
Chris@49 637 , M ( (void_ptr(&A) == void_ptr(&B)) ? (*M_local) : A )
Chris@49 638 {
Chris@49 639 arma_extra_debug_sigprint();
Chris@49 640 }
Chris@49 641
Chris@49 642
Chris@49 643 template<typename eT2>
Chris@49 644 inline
Chris@49 645 unwrap_check_mixed(const Row<eT1>& A, const bool is_alias)
Chris@49 646 : M_local( is_alias ? new Row<eT1>(A) : 0 )
Chris@49 647 , M ( is_alias ? (*M_local) : A )
Chris@49 648 {
Chris@49 649 arma_extra_debug_sigprint();
Chris@49 650 }
Chris@49 651
Chris@49 652 inline
Chris@49 653 ~unwrap_check_mixed()
Chris@49 654 {
Chris@49 655 arma_extra_debug_sigprint();
Chris@49 656
Chris@49 657 if(M_local) { delete M_local; }
Chris@49 658 }
Chris@49 659
Chris@49 660
Chris@49 661 // the order below is important
Chris@49 662 const Row<eT1>* M_local;
Chris@49 663 const Row<eT1>& M;
Chris@49 664 };
Chris@49 665
Chris@49 666
Chris@49 667
Chris@49 668 template<typename eT1>
Chris@49 669 struct unwrap_check_mixed< Col<eT1> >
Chris@49 670 {
Chris@49 671 template<typename eT2>
Chris@49 672 inline
Chris@49 673 unwrap_check_mixed(const Col<eT1>& A, const Mat<eT2>& B)
Chris@49 674 : M_local( (void_ptr(&A) == void_ptr(&B)) ? new Col<eT1>(A) : 0 )
Chris@49 675 , M ( (void_ptr(&A) == void_ptr(&B)) ? (*M_local) : A )
Chris@49 676 {
Chris@49 677 arma_extra_debug_sigprint();
Chris@49 678 }
Chris@49 679
Chris@49 680 template<typename eT2>
Chris@49 681 inline
Chris@49 682 unwrap_check_mixed(const Col<eT1>& A, const bool is_alias)
Chris@49 683 : M_local( is_alias ? new Col<eT1>(A) : 0 )
Chris@49 684 , M ( is_alias ? (*M_local) : A )
Chris@49 685 {
Chris@49 686 arma_extra_debug_sigprint();
Chris@49 687 }
Chris@49 688
Chris@49 689 inline
Chris@49 690 ~unwrap_check_mixed()
Chris@49 691 {
Chris@49 692 arma_extra_debug_sigprint();
Chris@49 693
Chris@49 694 if(M_local) { delete M_local; }
Chris@49 695 }
Chris@49 696
Chris@49 697
Chris@49 698 // the order below is important
Chris@49 699 const Col<eT1>* M_local;
Chris@49 700 const Col<eT1>& M;
Chris@49 701 };
Chris@49 702
Chris@49 703
Chris@49 704
Chris@49 705 //
Chris@49 706 //
Chris@49 707 //
Chris@49 708
Chris@49 709
Chris@49 710
Chris@49 711 template<typename T1>
Chris@49 712 struct partial_unwrap_default
Chris@49 713 {
Chris@49 714 typedef typename T1::elem_type eT;
Chris@49 715 typedef Mat<eT> stored_type;
Chris@49 716
Chris@49 717 inline
Chris@49 718 partial_unwrap_default(const T1& A)
Chris@49 719 : M(A)
Chris@49 720 {
Chris@49 721 arma_extra_debug_sigprint();
Chris@49 722 }
Chris@49 723
Chris@49 724 arma_hot arma_inline eT get_val() const { return eT(1); }
Chris@49 725
Chris@49 726 static const bool do_trans = false;
Chris@49 727 static const bool do_times = false;
Chris@49 728
Chris@49 729 const Mat<eT> M;
Chris@49 730 };
Chris@49 731
Chris@49 732
Chris@49 733 template<typename T1>
Chris@49 734 struct partial_unwrap_fixed
Chris@49 735 {
Chris@49 736 typedef typename T1::elem_type eT;
Chris@49 737 typedef T1 stored_type;
Chris@49 738
Chris@49 739 inline explicit
Chris@49 740 partial_unwrap_fixed(const T1& A)
Chris@49 741 : M(A)
Chris@49 742 {
Chris@49 743 arma_extra_debug_sigprint();
Chris@49 744 }
Chris@49 745
Chris@49 746 arma_hot arma_inline eT get_val() const { return eT(1); }
Chris@49 747
Chris@49 748 static const bool do_trans = false;
Chris@49 749 static const bool do_times = false;
Chris@49 750
Chris@49 751 const T1& M;
Chris@49 752 };
Chris@49 753
Chris@49 754
Chris@49 755
Chris@49 756 template<typename T1, bool condition>
Chris@49 757 struct partial_unwrap_redirect {};
Chris@49 758
Chris@49 759 template<typename T1>
Chris@49 760 struct partial_unwrap_redirect<T1, false> { typedef partial_unwrap_default<T1> result; };
Chris@49 761
Chris@49 762 template<typename T1>
Chris@49 763 struct partial_unwrap_redirect<T1, true> { typedef partial_unwrap_fixed<T1> result; };
Chris@49 764
Chris@49 765 template<typename T1>
Chris@49 766 struct partial_unwrap : public partial_unwrap_redirect<T1, is_Mat_fixed<T1>::value >::result
Chris@49 767 {
Chris@49 768 inline
Chris@49 769 partial_unwrap(const T1& A)
Chris@49 770 : partial_unwrap_redirect< T1, is_Mat_fixed<T1>::value >::result(A)
Chris@49 771 {
Chris@49 772 }
Chris@49 773 };
Chris@49 774
Chris@49 775
Chris@49 776
Chris@49 777 template<typename eT>
Chris@49 778 struct partial_unwrap< Mat<eT> >
Chris@49 779 {
Chris@49 780 typedef Mat<eT> stored_type;
Chris@49 781
Chris@49 782 inline
Chris@49 783 partial_unwrap(const Mat<eT>& A)
Chris@49 784 : M(A)
Chris@49 785 {
Chris@49 786 arma_extra_debug_sigprint();
Chris@49 787 }
Chris@49 788
Chris@49 789 inline eT get_val() const { return eT(1); }
Chris@49 790
Chris@49 791 static const bool do_trans = false;
Chris@49 792 static const bool do_times = false;
Chris@49 793
Chris@49 794 const Mat<eT>& M;
Chris@49 795 };
Chris@49 796
Chris@49 797
Chris@49 798
Chris@49 799 template<typename eT>
Chris@49 800 struct partial_unwrap< Row<eT> >
Chris@49 801 {
Chris@49 802 typedef Row<eT> stored_type;
Chris@49 803
Chris@49 804 inline
Chris@49 805 partial_unwrap(const Row<eT>& A)
Chris@49 806 : M(A)
Chris@49 807 {
Chris@49 808 arma_extra_debug_sigprint();
Chris@49 809 }
Chris@49 810
Chris@49 811 inline eT get_val() const { return eT(1); }
Chris@49 812
Chris@49 813 static const bool do_trans = false;
Chris@49 814 static const bool do_times = false;
Chris@49 815
Chris@49 816 const Row<eT>& M;
Chris@49 817 };
Chris@49 818
Chris@49 819
Chris@49 820
Chris@49 821 template<typename eT>
Chris@49 822 struct partial_unwrap< Col<eT> >
Chris@49 823 {
Chris@49 824 typedef Col<eT> stored_type;
Chris@49 825
Chris@49 826 inline
Chris@49 827 partial_unwrap(const Col<eT>& A)
Chris@49 828 : M(A)
Chris@49 829 {
Chris@49 830 arma_extra_debug_sigprint();
Chris@49 831 }
Chris@49 832
Chris@49 833 inline eT get_val() const { return eT(1); }
Chris@49 834
Chris@49 835 static const bool do_trans = false;
Chris@49 836 static const bool do_times = false;
Chris@49 837
Chris@49 838 const Col<eT>& M;
Chris@49 839 };
Chris@49 840
Chris@49 841
Chris@49 842
Chris@49 843 // NOTE: we can get away with this shortcut as the partial_unwrap class is only used by as_scalar(),
Chris@49 844 // NOTE: which doesn't need to check for aliasing (ie. it doesn't need to compare the address of M with another matrix)
Chris@49 845 template<typename eT>
Chris@49 846 struct partial_unwrap< subview_col<eT> >
Chris@49 847 {
Chris@49 848 typedef Col<eT> stored_type;
Chris@49 849
Chris@49 850 inline
Chris@49 851 partial_unwrap(const subview_col<eT>& A)
Chris@49 852 : M ( const_cast<eT*>( A.colptr(0) ), A.n_rows, false, false )
Chris@49 853 {
Chris@49 854 arma_extra_debug_sigprint();
Chris@49 855 }
Chris@49 856
Chris@49 857 inline eT get_val() const { return eT(1); }
Chris@49 858
Chris@49 859 static const bool do_trans = false;
Chris@49 860 static const bool do_times = false;
Chris@49 861
Chris@49 862 const Col<eT> M;
Chris@49 863 };
Chris@49 864
Chris@49 865
Chris@49 866
Chris@49 867 template<typename T1>
Chris@49 868 struct partial_unwrap_htrans_default
Chris@49 869 {
Chris@49 870 typedef typename T1::elem_type eT;
Chris@49 871 typedef Mat<eT> stored_type;
Chris@49 872
Chris@49 873 inline
Chris@49 874 partial_unwrap_htrans_default(const Op<T1, op_htrans>& A)
Chris@49 875 : M(A.m)
Chris@49 876 {
Chris@49 877 arma_extra_debug_sigprint();
Chris@49 878 }
Chris@49 879
Chris@49 880 arma_hot arma_inline eT get_val() const { return eT(1); }
Chris@49 881
Chris@49 882 static const bool do_trans = true;
Chris@49 883 static const bool do_times = false;
Chris@49 884
Chris@49 885 const Mat<eT> M;
Chris@49 886 };
Chris@49 887
Chris@49 888
Chris@49 889 template<typename T1>
Chris@49 890 struct partial_unwrap_htrans_fixed
Chris@49 891 {
Chris@49 892 typedef typename T1::elem_type eT;
Chris@49 893 typedef T1 stored_type;
Chris@49 894
Chris@49 895 inline explicit
Chris@49 896 partial_unwrap_htrans_fixed(const Op<T1, op_htrans>& A)
Chris@49 897 : M(A.m)
Chris@49 898 {
Chris@49 899 arma_extra_debug_sigprint();
Chris@49 900 }
Chris@49 901
Chris@49 902 arma_hot arma_inline eT get_val() const { return eT(1); }
Chris@49 903
Chris@49 904 static const bool do_trans = true;
Chris@49 905 static const bool do_times = false;
Chris@49 906
Chris@49 907 const T1& M;
Chris@49 908 };
Chris@49 909
Chris@49 910
Chris@49 911
Chris@49 912 template<typename T1, bool condition>
Chris@49 913 struct partial_unwrap_htrans_redirect {};
Chris@49 914
Chris@49 915 template<typename T1>
Chris@49 916 struct partial_unwrap_htrans_redirect<T1, false> { typedef partial_unwrap_htrans_default<T1> result; };
Chris@49 917
Chris@49 918 template<typename T1>
Chris@49 919 struct partial_unwrap_htrans_redirect<T1, true> { typedef partial_unwrap_htrans_fixed<T1> result; };
Chris@49 920
Chris@49 921 template<typename T1>
Chris@49 922 struct partial_unwrap< Op<T1, op_htrans> > : public partial_unwrap_htrans_redirect<T1, is_Mat_fixed<T1>::value >::result
Chris@49 923 {
Chris@49 924 inline partial_unwrap(const Op<T1, op_htrans>& A)
Chris@49 925 : partial_unwrap_htrans_redirect< T1, is_Mat_fixed<T1>::value >::result(A)
Chris@49 926 {
Chris@49 927 }
Chris@49 928 };
Chris@49 929
Chris@49 930
Chris@49 931
Chris@49 932 template<typename eT>
Chris@49 933 struct partial_unwrap< Op< Mat<eT>, op_htrans> >
Chris@49 934 {
Chris@49 935 typedef Mat<eT> stored_type;
Chris@49 936
Chris@49 937 inline
Chris@49 938 partial_unwrap(const Op< Mat<eT>, op_htrans>& A)
Chris@49 939 : M(A.m)
Chris@49 940 {
Chris@49 941 arma_extra_debug_sigprint();
Chris@49 942 }
Chris@49 943
Chris@49 944 arma_inline eT get_val() const { return eT(1); }
Chris@49 945
Chris@49 946 static const bool do_trans = true;
Chris@49 947 static const bool do_times = false;
Chris@49 948
Chris@49 949 const Mat<eT>& M;
Chris@49 950 };
Chris@49 951
Chris@49 952
Chris@49 953
Chris@49 954 template<typename eT>
Chris@49 955 struct partial_unwrap< Op< Row<eT>, op_htrans> >
Chris@49 956 {
Chris@49 957 typedef Row<eT> stored_type;
Chris@49 958
Chris@49 959 inline
Chris@49 960 partial_unwrap(const Op< Row<eT>, op_htrans>& A)
Chris@49 961 : M(A.m)
Chris@49 962 {
Chris@49 963 arma_extra_debug_sigprint();
Chris@49 964 }
Chris@49 965
Chris@49 966 arma_inline eT get_val() const { return eT(1); }
Chris@49 967
Chris@49 968 static const bool do_trans = true;
Chris@49 969 static const bool do_times = false;
Chris@49 970
Chris@49 971 const Row<eT>& M;
Chris@49 972 };
Chris@49 973
Chris@49 974
Chris@49 975
Chris@49 976 template<typename eT>
Chris@49 977 struct partial_unwrap< Op< Col<eT>, op_htrans> >
Chris@49 978 {
Chris@49 979 typedef Col<eT> stored_type;
Chris@49 980
Chris@49 981 inline
Chris@49 982 partial_unwrap(const Op< Col<eT>, op_htrans>& A)
Chris@49 983 : M(A.m)
Chris@49 984 {
Chris@49 985 arma_extra_debug_sigprint();
Chris@49 986 }
Chris@49 987
Chris@49 988 arma_inline eT get_val() const { return eT(1); }
Chris@49 989
Chris@49 990 static const bool do_trans = true;
Chris@49 991 static const bool do_times = false;
Chris@49 992
Chris@49 993 const Col<eT>& M;
Chris@49 994 };
Chris@49 995
Chris@49 996
Chris@49 997
Chris@49 998 // NOTE: we can get away with this shortcut as the partial_unwrap class is only used by as_scalar(),
Chris@49 999 // NOTE: which doesn't need to check for aliasing (ie. it doesn't need to compare the address of M with another matrix)
Chris@49 1000 template<typename eT>
Chris@49 1001 struct partial_unwrap< Op< subview_col<eT>, op_htrans> >
Chris@49 1002 {
Chris@49 1003 typedef Col<eT> stored_type;
Chris@49 1004
Chris@49 1005 inline
Chris@49 1006 partial_unwrap(const Op< subview_col<eT>, op_htrans>& A)
Chris@49 1007 : M ( const_cast<eT*>( A.m.colptr(0) ), A.m.n_rows, false, false )
Chris@49 1008 {
Chris@49 1009 arma_extra_debug_sigprint();
Chris@49 1010 }
Chris@49 1011
Chris@49 1012 arma_inline eT get_val() const { return eT(1); }
Chris@49 1013
Chris@49 1014 static const bool do_trans = true;
Chris@49 1015 static const bool do_times = false;
Chris@49 1016
Chris@49 1017 const Col<eT> M;
Chris@49 1018 };
Chris@49 1019
Chris@49 1020
Chris@49 1021
Chris@49 1022 template<typename T1>
Chris@49 1023 struct partial_unwrap_htrans2_default
Chris@49 1024 {
Chris@49 1025 typedef typename T1::elem_type eT;
Chris@49 1026 typedef Mat<eT> stored_type;
Chris@49 1027
Chris@49 1028 inline
Chris@49 1029 partial_unwrap_htrans2_default(const Op<T1, op_htrans2>& A)
Chris@49 1030 : val(A.aux)
Chris@49 1031 , M (A.m)
Chris@49 1032 {
Chris@49 1033 arma_extra_debug_sigprint();
Chris@49 1034 }
Chris@49 1035
Chris@49 1036 arma_inline eT get_val() const { return val; }
Chris@49 1037
Chris@49 1038 static const bool do_trans = true;
Chris@49 1039 static const bool do_times = true;
Chris@49 1040
Chris@49 1041 const eT val;
Chris@49 1042 const Mat<eT> M;
Chris@49 1043 };
Chris@49 1044
Chris@49 1045
Chris@49 1046 template<typename T1>
Chris@49 1047 struct partial_unwrap_htrans2_fixed
Chris@49 1048 {
Chris@49 1049 typedef typename T1::elem_type eT;
Chris@49 1050 typedef T1 stored_type;
Chris@49 1051
Chris@49 1052 inline explicit
Chris@49 1053 partial_unwrap_htrans2_fixed(const Op<T1, op_htrans2>& A)
Chris@49 1054 : val(A.aux)
Chris@49 1055 , M (A.m)
Chris@49 1056 {
Chris@49 1057 arma_extra_debug_sigprint();
Chris@49 1058 }
Chris@49 1059
Chris@49 1060 arma_inline eT get_val() const { return val; }
Chris@49 1061
Chris@49 1062 static const bool do_trans = true;
Chris@49 1063 static const bool do_times = true;
Chris@49 1064
Chris@49 1065 const eT val;
Chris@49 1066 const T1& M;
Chris@49 1067 };
Chris@49 1068
Chris@49 1069
Chris@49 1070
Chris@49 1071 template<typename T1, bool condition>
Chris@49 1072 struct partial_unwrap_htrans2_redirect {};
Chris@49 1073
Chris@49 1074 template<typename T1>
Chris@49 1075 struct partial_unwrap_htrans2_redirect<T1, false> { typedef partial_unwrap_htrans2_default<T1> result; };
Chris@49 1076
Chris@49 1077 template<typename T1>
Chris@49 1078 struct partial_unwrap_htrans2_redirect<T1, true> { typedef partial_unwrap_htrans2_fixed<T1> result; };
Chris@49 1079
Chris@49 1080 template<typename T1>
Chris@49 1081 struct partial_unwrap< Op<T1, op_htrans2> > : public partial_unwrap_htrans2_redirect<T1, is_Mat_fixed<T1>::value >::result
Chris@49 1082 {
Chris@49 1083 inline partial_unwrap(const Op<T1, op_htrans2>& A)
Chris@49 1084 : partial_unwrap_htrans2_redirect< T1, is_Mat_fixed<T1>::value >::result(A)
Chris@49 1085 {
Chris@49 1086 }
Chris@49 1087 };
Chris@49 1088
Chris@49 1089
Chris@49 1090
Chris@49 1091 template<typename eT>
Chris@49 1092 struct partial_unwrap< Op< Mat<eT>, op_htrans2> >
Chris@49 1093 {
Chris@49 1094 typedef Mat<eT> stored_type;
Chris@49 1095
Chris@49 1096 inline
Chris@49 1097 partial_unwrap(const Op< Mat<eT>, op_htrans2>& A)
Chris@49 1098 : val(A.aux)
Chris@49 1099 , M (A.m)
Chris@49 1100 {
Chris@49 1101 arma_extra_debug_sigprint();
Chris@49 1102 }
Chris@49 1103
Chris@49 1104 inline eT get_val() const { return val; }
Chris@49 1105
Chris@49 1106 static const bool do_trans = true;
Chris@49 1107 static const bool do_times = true;
Chris@49 1108
Chris@49 1109 const eT val;
Chris@49 1110 const Mat<eT>& M;
Chris@49 1111 };
Chris@49 1112
Chris@49 1113
Chris@49 1114
Chris@49 1115 template<typename eT>
Chris@49 1116 struct partial_unwrap< Op< Row<eT>, op_htrans2> >
Chris@49 1117 {
Chris@49 1118 typedef Row<eT> stored_type;
Chris@49 1119
Chris@49 1120 inline
Chris@49 1121 partial_unwrap(const Op< Row<eT>, op_htrans2>& A)
Chris@49 1122 : val(A.aux)
Chris@49 1123 , M (A.m)
Chris@49 1124 {
Chris@49 1125 arma_extra_debug_sigprint();
Chris@49 1126 }
Chris@49 1127
Chris@49 1128 inline eT get_val() const { return val; }
Chris@49 1129
Chris@49 1130 static const bool do_trans = true;
Chris@49 1131 static const bool do_times = true;
Chris@49 1132
Chris@49 1133 const eT val;
Chris@49 1134 const Row<eT>& M;
Chris@49 1135 };
Chris@49 1136
Chris@49 1137
Chris@49 1138
Chris@49 1139 template<typename eT>
Chris@49 1140 struct partial_unwrap< Op< Col<eT>, op_htrans2> >
Chris@49 1141 {
Chris@49 1142 typedef Col<eT> stored_type;
Chris@49 1143
Chris@49 1144 inline
Chris@49 1145 partial_unwrap(const Op< Col<eT>, op_htrans2>& A)
Chris@49 1146 : val(A.aux)
Chris@49 1147 , M (A.m)
Chris@49 1148 {
Chris@49 1149 arma_extra_debug_sigprint();
Chris@49 1150 }
Chris@49 1151
Chris@49 1152 inline eT get_val() const { return val; }
Chris@49 1153
Chris@49 1154 static const bool do_trans = true;
Chris@49 1155 static const bool do_times = true;
Chris@49 1156
Chris@49 1157 const eT val;
Chris@49 1158 const Col<eT>& M;
Chris@49 1159 };
Chris@49 1160
Chris@49 1161
Chris@49 1162
Chris@49 1163 // NOTE: we can get away with this shortcut as the partial_unwrap class is only used by as_scalar(),
Chris@49 1164 // NOTE: which doesn't need to check for aliasing (ie. it doesn't need to compare the address of M with another matrix)
Chris@49 1165 template<typename eT>
Chris@49 1166 struct partial_unwrap< Op< subview_col<eT>, op_htrans2> >
Chris@49 1167 {
Chris@49 1168 typedef Col<eT> stored_type;
Chris@49 1169
Chris@49 1170 inline
Chris@49 1171 partial_unwrap(const Op< subview_col<eT>, op_htrans2>& A)
Chris@49 1172 : val( A.aux )
Chris@49 1173 , M ( const_cast<eT*>( A.m.colptr(0) ), A.m.n_rows, false, false )
Chris@49 1174 {
Chris@49 1175 arma_extra_debug_sigprint();
Chris@49 1176 }
Chris@49 1177
Chris@49 1178 inline eT get_val() const { return val; }
Chris@49 1179
Chris@49 1180 static const bool do_trans = true;
Chris@49 1181 static const bool do_times = true;
Chris@49 1182
Chris@49 1183 const eT val;
Chris@49 1184 const Col<eT> M;
Chris@49 1185 };
Chris@49 1186
Chris@49 1187
Chris@49 1188
Chris@49 1189 template<typename T1>
Chris@49 1190 struct partial_unwrap_scalar_times_default
Chris@49 1191 {
Chris@49 1192 typedef typename T1::elem_type eT;
Chris@49 1193 typedef Mat<eT> stored_type;
Chris@49 1194
Chris@49 1195 inline
Chris@49 1196 partial_unwrap_scalar_times_default(const eOp<T1, eop_scalar_times>& A)
Chris@49 1197 : val(A.aux)
Chris@49 1198 , M (A.P.Q)
Chris@49 1199 {
Chris@49 1200 arma_extra_debug_sigprint();
Chris@49 1201 }
Chris@49 1202
Chris@49 1203 arma_hot arma_inline eT get_val() const { return val; }
Chris@49 1204
Chris@49 1205 static const bool do_trans = false;
Chris@49 1206 static const bool do_times = true;
Chris@49 1207
Chris@49 1208 const eT val;
Chris@49 1209 const Mat<eT> M;
Chris@49 1210 };
Chris@49 1211
Chris@49 1212
Chris@49 1213
Chris@49 1214 template<typename T1>
Chris@49 1215 struct partial_unwrap_scalar_times_fixed
Chris@49 1216 {
Chris@49 1217 typedef typename T1::elem_type eT;
Chris@49 1218 typedef T1 stored_type;
Chris@49 1219
Chris@49 1220 inline explicit
Chris@49 1221 partial_unwrap_scalar_times_fixed(const eOp<T1, eop_scalar_times>& A)
Chris@49 1222 : val(A.aux)
Chris@49 1223 , M (A.P.Q)
Chris@49 1224 {
Chris@49 1225 arma_extra_debug_sigprint();
Chris@49 1226 }
Chris@49 1227
Chris@49 1228 arma_hot arma_inline eT get_val() const { return val; }
Chris@49 1229
Chris@49 1230 static const bool do_trans = false;
Chris@49 1231 static const bool do_times = true;
Chris@49 1232
Chris@49 1233 const eT val;
Chris@49 1234 const T1& M;
Chris@49 1235 };
Chris@49 1236
Chris@49 1237
Chris@49 1238
Chris@49 1239 template<typename T1, bool condition>
Chris@49 1240 struct partial_unwrap_scalar_times_redirect {};
Chris@49 1241
Chris@49 1242 template<typename T1>
Chris@49 1243 struct partial_unwrap_scalar_times_redirect<T1, false> { typedef partial_unwrap_scalar_times_default<T1> result; };
Chris@49 1244
Chris@49 1245 template<typename T1>
Chris@49 1246 struct partial_unwrap_scalar_times_redirect<T1, true> { typedef partial_unwrap_scalar_times_fixed<T1> result; };
Chris@49 1247
Chris@49 1248
Chris@49 1249 template<typename T1>
Chris@49 1250 struct partial_unwrap< eOp<T1, eop_scalar_times> > : public partial_unwrap_scalar_times_redirect<T1, is_Mat_fixed<T1>::value >::result
Chris@49 1251 {
Chris@49 1252 typedef typename T1::elem_type eT;
Chris@49 1253
Chris@49 1254 inline
Chris@49 1255 partial_unwrap(const eOp<T1, eop_scalar_times>& A)
Chris@49 1256 : partial_unwrap_scalar_times_redirect< T1, is_Mat_fixed<T1>::value >::result(A)
Chris@49 1257 {
Chris@49 1258 }
Chris@49 1259 };
Chris@49 1260
Chris@49 1261
Chris@49 1262
Chris@49 1263 template<typename eT>
Chris@49 1264 struct partial_unwrap< eOp<Mat<eT>, eop_scalar_times> >
Chris@49 1265 {
Chris@49 1266 typedef Mat<eT> stored_type;
Chris@49 1267
Chris@49 1268 inline
Chris@49 1269 partial_unwrap(const eOp<Mat<eT>,eop_scalar_times>& A)
Chris@49 1270 : val(A.aux)
Chris@49 1271 , M (A.P.Q)
Chris@49 1272 {
Chris@49 1273 arma_extra_debug_sigprint();
Chris@49 1274 }
Chris@49 1275
Chris@49 1276 inline eT get_val() const { return val; }
Chris@49 1277
Chris@49 1278 static const bool do_trans = false;
Chris@49 1279 static const bool do_times = true;
Chris@49 1280
Chris@49 1281 const eT val;
Chris@49 1282 const Mat<eT>& M;
Chris@49 1283 };
Chris@49 1284
Chris@49 1285
Chris@49 1286
Chris@49 1287 template<typename eT>
Chris@49 1288 struct partial_unwrap< eOp<Row<eT>, eop_scalar_times> >
Chris@49 1289 {
Chris@49 1290 typedef Row<eT> stored_type;
Chris@49 1291
Chris@49 1292 inline
Chris@49 1293 partial_unwrap(const eOp<Row<eT>,eop_scalar_times>& A)
Chris@49 1294 : val(A.aux)
Chris@49 1295 , M (A.P.Q)
Chris@49 1296 {
Chris@49 1297 arma_extra_debug_sigprint();
Chris@49 1298 }
Chris@49 1299
Chris@49 1300 inline eT get_val() const { return val; }
Chris@49 1301
Chris@49 1302 static const bool do_trans = false;
Chris@49 1303 static const bool do_times = true;
Chris@49 1304
Chris@49 1305 const eT val;
Chris@49 1306 const Row<eT>& M;
Chris@49 1307 };
Chris@49 1308
Chris@49 1309
Chris@49 1310
Chris@49 1311 template<typename eT>
Chris@49 1312 struct partial_unwrap< eOp<Col<eT>, eop_scalar_times> >
Chris@49 1313 {
Chris@49 1314 typedef Col<eT> stored_type;
Chris@49 1315
Chris@49 1316 inline
Chris@49 1317 partial_unwrap(const eOp<Col<eT>,eop_scalar_times>& A)
Chris@49 1318 : val(A.aux)
Chris@49 1319 , M (A.P.Q)
Chris@49 1320 {
Chris@49 1321 arma_extra_debug_sigprint();
Chris@49 1322 }
Chris@49 1323
Chris@49 1324 inline eT get_val() const { return val; }
Chris@49 1325
Chris@49 1326 static const bool do_trans = false;
Chris@49 1327 static const bool do_times = true;
Chris@49 1328
Chris@49 1329 const eT val;
Chris@49 1330 const Col<eT>& M;
Chris@49 1331 };
Chris@49 1332
Chris@49 1333
Chris@49 1334
Chris@49 1335 // TODO: struct partial_unwrap< eOp<subview_col<eT>, eop_scalar_times> >
Chris@49 1336
Chris@49 1337
Chris@49 1338
Chris@49 1339 template<typename T1>
Chris@49 1340 struct partial_unwrap_neg_default
Chris@49 1341 {
Chris@49 1342 typedef typename T1::elem_type eT;
Chris@49 1343 typedef Mat<eT> stored_type;
Chris@49 1344
Chris@49 1345 inline
Chris@49 1346 partial_unwrap_neg_default(const eOp<T1, eop_neg>& A)
Chris@49 1347 : M(A.P.Q)
Chris@49 1348 {
Chris@49 1349 arma_extra_debug_sigprint();
Chris@49 1350 }
Chris@49 1351
Chris@49 1352 arma_hot arma_inline eT get_val() const { return eT(-1); }
Chris@49 1353
Chris@49 1354 static const bool do_trans = false;
Chris@49 1355 static const bool do_times = true;
Chris@49 1356
Chris@49 1357 const Mat<eT> M;
Chris@49 1358 };
Chris@49 1359
Chris@49 1360
Chris@49 1361
Chris@49 1362 template<typename T1>
Chris@49 1363 struct partial_unwrap_neg_fixed
Chris@49 1364 {
Chris@49 1365 typedef typename T1::elem_type eT;
Chris@49 1366 typedef T1 stored_type;
Chris@49 1367
Chris@49 1368 inline explicit
Chris@49 1369 partial_unwrap_neg_fixed(const eOp<T1, eop_neg>& A)
Chris@49 1370 : M(A.P.Q)
Chris@49 1371 {
Chris@49 1372 arma_extra_debug_sigprint();
Chris@49 1373 }
Chris@49 1374
Chris@49 1375 arma_hot arma_inline eT get_val() const { return eT(-1); }
Chris@49 1376
Chris@49 1377 static const bool do_trans = false;
Chris@49 1378 static const bool do_times = true;
Chris@49 1379
Chris@49 1380 const T1& M;
Chris@49 1381 };
Chris@49 1382
Chris@49 1383
Chris@49 1384
Chris@49 1385 template<typename T1, bool condition>
Chris@49 1386 struct partial_unwrap_neg_redirect {};
Chris@49 1387
Chris@49 1388 template<typename T1>
Chris@49 1389 struct partial_unwrap_neg_redirect<T1, false> { typedef partial_unwrap_neg_default<T1> result; };
Chris@49 1390
Chris@49 1391 template<typename T1>
Chris@49 1392 struct partial_unwrap_neg_redirect<T1, true> { typedef partial_unwrap_neg_fixed<T1> result; };
Chris@49 1393
Chris@49 1394
Chris@49 1395 template<typename T1>
Chris@49 1396 struct partial_unwrap< eOp<T1, eop_neg> > : public partial_unwrap_neg_redirect<T1, is_Mat_fixed<T1>::value >::result
Chris@49 1397 {
Chris@49 1398 typedef typename T1::elem_type eT;
Chris@49 1399
Chris@49 1400 inline
Chris@49 1401 partial_unwrap(const eOp<T1, eop_neg>& A)
Chris@49 1402 : partial_unwrap_neg_redirect< T1, is_Mat_fixed<T1>::value >::result(A)
Chris@49 1403 {
Chris@49 1404 }
Chris@49 1405 };
Chris@49 1406
Chris@49 1407
Chris@49 1408
Chris@49 1409 template<typename eT>
Chris@49 1410 struct partial_unwrap< eOp<Mat<eT>, eop_neg> >
Chris@49 1411 {
Chris@49 1412 typedef Mat<eT> stored_type;
Chris@49 1413
Chris@49 1414 inline
Chris@49 1415 partial_unwrap(const eOp<Mat<eT>,eop_neg>& A)
Chris@49 1416 : M(A.P.Q)
Chris@49 1417 {
Chris@49 1418 arma_extra_debug_sigprint();
Chris@49 1419 }
Chris@49 1420
Chris@49 1421 inline eT get_val() const { return eT(-1); }
Chris@49 1422
Chris@49 1423 static const bool do_trans = false;
Chris@49 1424 static const bool do_times = true;
Chris@49 1425
Chris@49 1426 const Mat<eT>& M;
Chris@49 1427 };
Chris@49 1428
Chris@49 1429
Chris@49 1430
Chris@49 1431 template<typename eT>
Chris@49 1432 struct partial_unwrap< eOp<Row<eT>, eop_neg> >
Chris@49 1433 {
Chris@49 1434 typedef Row<eT> stored_type;
Chris@49 1435
Chris@49 1436 inline
Chris@49 1437 partial_unwrap(const eOp<Row<eT>,eop_neg>& A)
Chris@49 1438 : M(A.P.Q)
Chris@49 1439 {
Chris@49 1440 arma_extra_debug_sigprint();
Chris@49 1441 }
Chris@49 1442
Chris@49 1443 inline eT get_val() const { return eT(-1); }
Chris@49 1444
Chris@49 1445 static const bool do_trans = false;
Chris@49 1446 static const bool do_times = true;
Chris@49 1447
Chris@49 1448 const Row<eT>& M;
Chris@49 1449 };
Chris@49 1450
Chris@49 1451
Chris@49 1452
Chris@49 1453 template<typename eT>
Chris@49 1454 struct partial_unwrap< eOp<Col<eT>, eop_neg> >
Chris@49 1455 {
Chris@49 1456 typedef Col<eT> stored_type;
Chris@49 1457
Chris@49 1458 inline
Chris@49 1459 partial_unwrap(const eOp<Col<eT>,eop_neg>& A)
Chris@49 1460 : M(A.P.Q)
Chris@49 1461 {
Chris@49 1462 arma_extra_debug_sigprint();
Chris@49 1463 }
Chris@49 1464
Chris@49 1465 inline eT get_val() const { return eT(-1); }
Chris@49 1466
Chris@49 1467 static const bool do_trans = false;
Chris@49 1468 static const bool do_times = true;
Chris@49 1469
Chris@49 1470 const Col<eT>& M;
Chris@49 1471 };
Chris@49 1472
Chris@49 1473
Chris@49 1474
Chris@49 1475 // TODO: struct partial_unwrap< eOp<subview_col<eT>, eop_neg> >
Chris@49 1476
Chris@49 1477
Chris@49 1478
Chris@49 1479 //
Chris@49 1480
Chris@49 1481
Chris@49 1482
Chris@49 1483 template<typename T1>
Chris@49 1484 struct partial_unwrap_check_default
Chris@49 1485 {
Chris@49 1486 typedef typename T1::elem_type eT;
Chris@49 1487 typedef Mat<eT> stored_type;
Chris@49 1488
Chris@49 1489 inline
Chris@49 1490 partial_unwrap_check_default(const T1& A, const Mat<eT>&)
Chris@49 1491 : M(A)
Chris@49 1492 {
Chris@49 1493 arma_extra_debug_sigprint();
Chris@49 1494 }
Chris@49 1495
Chris@49 1496 arma_hot arma_inline eT get_val() const { return eT(1); }
Chris@49 1497
Chris@49 1498 static const bool do_trans = false;
Chris@49 1499 static const bool do_times = false;
Chris@49 1500
Chris@49 1501 const Mat<eT> M;
Chris@49 1502 };
Chris@49 1503
Chris@49 1504
Chris@49 1505 template<typename T1>
Chris@49 1506 struct partial_unwrap_check_fixed
Chris@49 1507 {
Chris@49 1508 typedef typename T1::elem_type eT;
Chris@49 1509 typedef T1 stored_type;
Chris@49 1510
Chris@49 1511 inline explicit
Chris@49 1512 partial_unwrap_check_fixed(const T1& A, const Mat<eT>& B)
Chris@49 1513 : M_local( (&A == &B) ? new T1(A) : 0 )
Chris@49 1514 , M ( (&A == &B) ? (*M_local) : A )
Chris@49 1515 {
Chris@49 1516 arma_extra_debug_sigprint();
Chris@49 1517 }
Chris@49 1518
Chris@49 1519 inline
Chris@49 1520 ~partial_unwrap_check_fixed()
Chris@49 1521 {
Chris@49 1522 arma_extra_debug_sigprint();
Chris@49 1523
Chris@49 1524 if(M_local) { delete M_local; }
Chris@49 1525 }
Chris@49 1526
Chris@49 1527 arma_hot arma_inline eT get_val() const { return eT(1); }
Chris@49 1528
Chris@49 1529 static const bool do_trans = false;
Chris@49 1530 static const bool do_times = false;
Chris@49 1531
Chris@49 1532 const T1* M_local;
Chris@49 1533 const T1& M;
Chris@49 1534 };
Chris@49 1535
Chris@49 1536
Chris@49 1537
Chris@49 1538 template<typename T1, bool condition>
Chris@49 1539 struct partial_unwrap_check_redirect {};
Chris@49 1540
Chris@49 1541 template<typename T1>
Chris@49 1542 struct partial_unwrap_check_redirect<T1, false> { typedef partial_unwrap_check_default<T1> result; };
Chris@49 1543
Chris@49 1544 template<typename T1>
Chris@49 1545 struct partial_unwrap_check_redirect<T1, true> { typedef partial_unwrap_check_fixed<T1> result; };
Chris@49 1546
Chris@49 1547 template<typename T1>
Chris@49 1548 struct partial_unwrap_check : public partial_unwrap_check_redirect<T1, is_Mat_fixed<T1>::value >::result
Chris@49 1549 {
Chris@49 1550 typedef typename T1::elem_type eT;
Chris@49 1551
Chris@49 1552 inline partial_unwrap_check(const T1& A, const Mat<eT>& B)
Chris@49 1553 : partial_unwrap_check_redirect< T1, is_Mat_fixed<T1>::value >::result(A, B)
Chris@49 1554 {
Chris@49 1555 }
Chris@49 1556 };
Chris@49 1557
Chris@49 1558
Chris@49 1559
Chris@49 1560 template<typename eT>
Chris@49 1561 struct partial_unwrap_check< Mat<eT> >
Chris@49 1562 {
Chris@49 1563 typedef Mat<eT> stored_type;
Chris@49 1564
Chris@49 1565 arma_hot inline
Chris@49 1566 partial_unwrap_check(const Mat<eT>& A, const Mat<eT>& B)
Chris@49 1567 : M_local ( (&A == &B) ? new Mat<eT>(A) : 0 )
Chris@49 1568 , M ( (&A == &B) ? (*M_local) : A )
Chris@49 1569 {
Chris@49 1570 arma_extra_debug_sigprint();
Chris@49 1571 }
Chris@49 1572
Chris@49 1573
Chris@49 1574 inline
Chris@49 1575 ~partial_unwrap_check()
Chris@49 1576 {
Chris@49 1577 arma_extra_debug_sigprint();
Chris@49 1578
Chris@49 1579 if(M_local) { delete M_local; }
Chris@49 1580 }
Chris@49 1581
Chris@49 1582 arma_hot arma_inline eT get_val() const { return eT(1); }
Chris@49 1583
Chris@49 1584 static const bool do_trans = false;
Chris@49 1585 static const bool do_times = false;
Chris@49 1586
Chris@49 1587 // the order below is important
Chris@49 1588 const Mat<eT>* M_local;
Chris@49 1589 const Mat<eT>& M;
Chris@49 1590 };
Chris@49 1591
Chris@49 1592
Chris@49 1593
Chris@49 1594 template<typename eT>
Chris@49 1595 struct partial_unwrap_check< Row<eT> >
Chris@49 1596 {
Chris@49 1597 typedef Row<eT> stored_type;
Chris@49 1598
Chris@49 1599 arma_hot inline
Chris@49 1600 partial_unwrap_check(const Row<eT>& A, const Mat<eT>& B)
Chris@49 1601 : M_local ( (&A == &B) ? new Row<eT>(A) : 0 )
Chris@49 1602 , M ( (&A == &B) ? (*M_local) : A )
Chris@49 1603 {
Chris@49 1604 arma_extra_debug_sigprint();
Chris@49 1605 }
Chris@49 1606
Chris@49 1607
Chris@49 1608 inline
Chris@49 1609 ~partial_unwrap_check()
Chris@49 1610 {
Chris@49 1611 arma_extra_debug_sigprint();
Chris@49 1612
Chris@49 1613 if(M_local) { delete M_local; }
Chris@49 1614 }
Chris@49 1615
Chris@49 1616 arma_hot arma_inline eT get_val() const { return eT(1); }
Chris@49 1617
Chris@49 1618 static const bool do_trans = false;
Chris@49 1619 static const bool do_times = false;
Chris@49 1620
Chris@49 1621 // the order below is important
Chris@49 1622 const Row<eT>* M_local;
Chris@49 1623 const Row<eT>& M;
Chris@49 1624 };
Chris@49 1625
Chris@49 1626
Chris@49 1627
Chris@49 1628 template<typename eT>
Chris@49 1629 struct partial_unwrap_check< Col<eT> >
Chris@49 1630 {
Chris@49 1631 typedef Col<eT> stored_type;
Chris@49 1632
Chris@49 1633 arma_hot inline
Chris@49 1634 partial_unwrap_check(const Col<eT>& A, const Mat<eT>& B)
Chris@49 1635 : M_local ( (&A == &B) ? new Col<eT>(A) : 0 )
Chris@49 1636 , M ( (&A == &B) ? (*M_local) : A )
Chris@49 1637 {
Chris@49 1638 arma_extra_debug_sigprint();
Chris@49 1639 }
Chris@49 1640
Chris@49 1641
Chris@49 1642 inline
Chris@49 1643 ~partial_unwrap_check()
Chris@49 1644 {
Chris@49 1645 arma_extra_debug_sigprint();
Chris@49 1646
Chris@49 1647 if(M_local) { delete M_local; }
Chris@49 1648 }
Chris@49 1649
Chris@49 1650 arma_hot arma_inline eT get_val() const { return eT(1); }
Chris@49 1651
Chris@49 1652 static const bool do_trans = false;
Chris@49 1653 static const bool do_times = false;
Chris@49 1654
Chris@49 1655 // the order below is important
Chris@49 1656 const Col<eT>* M_local;
Chris@49 1657 const Col<eT>& M;
Chris@49 1658 };
Chris@49 1659
Chris@49 1660
Chris@49 1661
Chris@49 1662 // NOTE: we can get away with this shortcut as the partial_unwrap_check class is only used by the glue_times class,
Chris@49 1663 // NOTE: which relies on partial_unwrap_check to check for aliasing
Chris@49 1664 template<typename eT>
Chris@49 1665 struct partial_unwrap_check< subview_col<eT> >
Chris@49 1666 {
Chris@49 1667 typedef Col<eT> stored_type;
Chris@49 1668
Chris@49 1669 arma_hot inline
Chris@49 1670 partial_unwrap_check(const subview_col<eT>& A, const Mat<eT>& B)
Chris@49 1671 : M ( const_cast<eT*>( A.colptr(0) ), A.n_rows, (&(A.m) == &B), false )
Chris@49 1672 {
Chris@49 1673 arma_extra_debug_sigprint();
Chris@49 1674 }
Chris@49 1675
Chris@49 1676 arma_hot arma_inline eT get_val() const { return eT(1); }
Chris@49 1677
Chris@49 1678 static const bool do_trans = false;
Chris@49 1679 static const bool do_times = false;
Chris@49 1680
Chris@49 1681 const Col<eT> M;
Chris@49 1682 };
Chris@49 1683
Chris@49 1684
Chris@49 1685
Chris@49 1686 template<typename T1>
Chris@49 1687 struct partial_unwrap_check_htrans_default
Chris@49 1688 {
Chris@49 1689 typedef typename T1::elem_type eT;
Chris@49 1690 typedef Mat<eT> stored_type;
Chris@49 1691
Chris@49 1692 inline
Chris@49 1693 partial_unwrap_check_htrans_default(const Op<T1, op_htrans>& A, const Mat<eT>&)
Chris@49 1694 : M(A.m)
Chris@49 1695 {
Chris@49 1696 arma_extra_debug_sigprint();
Chris@49 1697 }
Chris@49 1698
Chris@49 1699 arma_hot arma_inline eT get_val() const { return eT(1); }
Chris@49 1700
Chris@49 1701 static const bool do_trans = true;
Chris@49 1702 static const bool do_times = false;
Chris@49 1703
Chris@49 1704 const Mat<eT> M;
Chris@49 1705 };
Chris@49 1706
Chris@49 1707
Chris@49 1708 template<typename T1>
Chris@49 1709 struct partial_unwrap_check_htrans_fixed
Chris@49 1710 {
Chris@49 1711 typedef typename T1::elem_type eT;
Chris@49 1712 typedef T1 stored_type;
Chris@49 1713
Chris@49 1714 inline explicit
Chris@49 1715 partial_unwrap_check_htrans_fixed(const Op<T1, op_htrans>& A, const Mat<eT>& B)
Chris@49 1716 : M_local( (&(A.m) == &B) ? new T1(A.m) : 0 )
Chris@49 1717 , M ( (&(A.m) == &B) ? (*M_local) : A.m )
Chris@49 1718 {
Chris@49 1719 arma_extra_debug_sigprint();
Chris@49 1720 }
Chris@49 1721
Chris@49 1722 inline
Chris@49 1723 ~partial_unwrap_check_htrans_fixed()
Chris@49 1724 {
Chris@49 1725 arma_extra_debug_sigprint();
Chris@49 1726
Chris@49 1727 if(M_local) { delete M_local; }
Chris@49 1728 }
Chris@49 1729
Chris@49 1730 arma_hot arma_inline eT get_val() const { return eT(1); }
Chris@49 1731
Chris@49 1732 static const bool do_trans = true;
Chris@49 1733 static const bool do_times = false;
Chris@49 1734
Chris@49 1735 const T1* M_local;
Chris@49 1736 const T1& M;
Chris@49 1737 };
Chris@49 1738
Chris@49 1739
Chris@49 1740
Chris@49 1741 template<typename T1, bool condition>
Chris@49 1742 struct partial_unwrap_check_htrans_redirect {};
Chris@49 1743
Chris@49 1744 template<typename T1>
Chris@49 1745 struct partial_unwrap_check_htrans_redirect<T1, false> { typedef partial_unwrap_check_htrans_default<T1> result; };
Chris@49 1746
Chris@49 1747 template<typename T1>
Chris@49 1748 struct partial_unwrap_check_htrans_redirect<T1, true> { typedef partial_unwrap_check_htrans_fixed<T1> result; };
Chris@49 1749
Chris@49 1750
Chris@49 1751 template<typename T1>
Chris@49 1752 struct partial_unwrap_check< Op<T1, op_htrans> > : public partial_unwrap_check_htrans_redirect<T1, is_Mat_fixed<T1>::value >::result
Chris@49 1753 {
Chris@49 1754 typedef typename T1::elem_type eT;
Chris@49 1755
Chris@49 1756 inline partial_unwrap_check(const Op<T1, op_htrans>& A, const Mat<eT>& B)
Chris@49 1757 : partial_unwrap_check_htrans_redirect< T1, is_Mat_fixed<T1>::value >::result(A, B)
Chris@49 1758 {
Chris@49 1759 }
Chris@49 1760 };
Chris@49 1761
Chris@49 1762
Chris@49 1763
Chris@49 1764 template<typename eT>
Chris@49 1765 struct partial_unwrap_check< Op< Mat<eT>, op_htrans> >
Chris@49 1766 {
Chris@49 1767 typedef Mat<eT> stored_type;
Chris@49 1768
Chris@49 1769 arma_hot inline
Chris@49 1770 partial_unwrap_check(const Op< Mat<eT>, op_htrans>& A, const Mat<eT>& B)
Chris@49 1771 : M_local ( (&A.m == &B) ? new Mat<eT>(A.m) : 0 )
Chris@49 1772 , M ( (&A.m == &B) ? (*M_local) : A.m )
Chris@49 1773 {
Chris@49 1774 arma_extra_debug_sigprint();
Chris@49 1775 }
Chris@49 1776
Chris@49 1777 inline
Chris@49 1778 ~partial_unwrap_check()
Chris@49 1779 {
Chris@49 1780 arma_extra_debug_sigprint();
Chris@49 1781
Chris@49 1782 if(M_local) { delete M_local; }
Chris@49 1783 }
Chris@49 1784
Chris@49 1785 arma_hot arma_inline eT get_val() const { return eT(1); }
Chris@49 1786
Chris@49 1787 static const bool do_trans = true;
Chris@49 1788 static const bool do_times = false;
Chris@49 1789
Chris@49 1790 // the order below is important
Chris@49 1791 const Mat<eT>* M_local;
Chris@49 1792 const Mat<eT>& M;
Chris@49 1793 };
Chris@49 1794
Chris@49 1795
Chris@49 1796
Chris@49 1797 template<typename eT>
Chris@49 1798 struct partial_unwrap_check< Op< Row<eT>, op_htrans> >
Chris@49 1799 {
Chris@49 1800 typedef Row<eT> stored_type;
Chris@49 1801
Chris@49 1802 arma_hot inline
Chris@49 1803 partial_unwrap_check(const Op< Row<eT>, op_htrans>& A, const Mat<eT>& B)
Chris@49 1804 : M_local ( (&A.m == &B) ? new Row<eT>(A.m) : 0 )
Chris@49 1805 , M ( (&A.m == &B) ? (*M_local) : A.m )
Chris@49 1806 {
Chris@49 1807 arma_extra_debug_sigprint();
Chris@49 1808 }
Chris@49 1809
Chris@49 1810 inline
Chris@49 1811 ~partial_unwrap_check()
Chris@49 1812 {
Chris@49 1813 arma_extra_debug_sigprint();
Chris@49 1814
Chris@49 1815 if(M_local) { delete M_local; }
Chris@49 1816 }
Chris@49 1817
Chris@49 1818 arma_hot arma_inline eT get_val() const { return eT(1); }
Chris@49 1819
Chris@49 1820 static const bool do_trans = true;
Chris@49 1821 static const bool do_times = false;
Chris@49 1822
Chris@49 1823 // the order below is important
Chris@49 1824 const Row<eT>* M_local;
Chris@49 1825 const Row<eT>& M;
Chris@49 1826 };
Chris@49 1827
Chris@49 1828
Chris@49 1829
Chris@49 1830 template<typename eT>
Chris@49 1831 struct partial_unwrap_check< Op< Col<eT>, op_htrans> >
Chris@49 1832 {
Chris@49 1833 typedef Col<eT> stored_type;
Chris@49 1834
Chris@49 1835 arma_hot inline
Chris@49 1836 partial_unwrap_check(const Op< Col<eT>, op_htrans>& A, const Mat<eT>& B)
Chris@49 1837 : M_local ( (&A.m == &B) ? new Col<eT>(A.m) : 0 )
Chris@49 1838 , M ( (&A.m == &B) ? (*M_local) : A.m )
Chris@49 1839 {
Chris@49 1840 arma_extra_debug_sigprint();
Chris@49 1841 }
Chris@49 1842
Chris@49 1843 inline
Chris@49 1844 ~partial_unwrap_check()
Chris@49 1845 {
Chris@49 1846 arma_extra_debug_sigprint();
Chris@49 1847
Chris@49 1848 if(M_local) { delete M_local; }
Chris@49 1849 }
Chris@49 1850
Chris@49 1851 arma_hot arma_inline eT get_val() const { return eT(1); }
Chris@49 1852
Chris@49 1853 static const bool do_trans = true;
Chris@49 1854 static const bool do_times = false;
Chris@49 1855
Chris@49 1856 // the order below is important
Chris@49 1857 const Col<eT>* M_local;
Chris@49 1858 const Col<eT>& M;
Chris@49 1859 };
Chris@49 1860
Chris@49 1861
Chris@49 1862
Chris@49 1863 // NOTE: we can get away with this shortcut as the partial_unwrap_check class is only used by the glue_times class,
Chris@49 1864 // NOTE: which relies on partial_unwrap_check to check for aliasing
Chris@49 1865 template<typename eT>
Chris@49 1866 struct partial_unwrap_check< Op< subview_col<eT>, op_htrans> >
Chris@49 1867 {
Chris@49 1868 typedef Col<eT> stored_type;
Chris@49 1869
Chris@49 1870 arma_hot inline
Chris@49 1871 partial_unwrap_check(const Op< subview_col<eT>, op_htrans>& A, const Mat<eT>& B)
Chris@49 1872 : M ( const_cast<eT*>( A.m.colptr(0) ), A.m.n_rows, (&(A.m.m) == &B), false )
Chris@49 1873 {
Chris@49 1874 arma_extra_debug_sigprint();
Chris@49 1875 }
Chris@49 1876
Chris@49 1877 arma_hot arma_inline eT get_val() const { return eT(1); }
Chris@49 1878
Chris@49 1879 static const bool do_trans = true;
Chris@49 1880 static const bool do_times = false;
Chris@49 1881
Chris@49 1882 const Col<eT> M;
Chris@49 1883 };
Chris@49 1884
Chris@49 1885
Chris@49 1886
Chris@49 1887 template<typename T1>
Chris@49 1888 struct partial_unwrap_check_htrans2_default
Chris@49 1889 {
Chris@49 1890 typedef typename T1::elem_type eT;
Chris@49 1891 typedef Mat<eT> stored_type;
Chris@49 1892
Chris@49 1893 inline
Chris@49 1894 partial_unwrap_check_htrans2_default(const Op<T1, op_htrans2>& A, const Mat<eT>&)
Chris@49 1895 : val(A.aux)
Chris@49 1896 , M (A.m)
Chris@49 1897 {
Chris@49 1898 arma_extra_debug_sigprint();
Chris@49 1899 }
Chris@49 1900
Chris@49 1901 arma_hot arma_inline eT get_val() const { return val; }
Chris@49 1902
Chris@49 1903 static const bool do_trans = true;
Chris@49 1904 static const bool do_times = true;
Chris@49 1905
Chris@49 1906 const eT val;
Chris@49 1907 const Mat<eT> M;
Chris@49 1908 };
Chris@49 1909
Chris@49 1910
Chris@49 1911
Chris@49 1912 template<typename T1>
Chris@49 1913 struct partial_unwrap_check_htrans2_fixed
Chris@49 1914 {
Chris@49 1915 typedef typename T1::elem_type eT;
Chris@49 1916 typedef T1 stored_type;
Chris@49 1917
Chris@49 1918 inline explicit
Chris@49 1919 partial_unwrap_check_htrans2_fixed(const Op<T1, op_htrans2>& A, const Mat<eT>& B)
Chris@49 1920 : val (A.aux)
Chris@49 1921 , M_local( (&(A.m) == &B) ? new T1(A.m) : 0 )
Chris@49 1922 , M ( (&(A.m) == &B) ? (*M_local) : A.m )
Chris@49 1923 {
Chris@49 1924 arma_extra_debug_sigprint();
Chris@49 1925 }
Chris@49 1926
Chris@49 1927 inline
Chris@49 1928 ~partial_unwrap_check_htrans2_fixed()
Chris@49 1929 {
Chris@49 1930 arma_extra_debug_sigprint();
Chris@49 1931
Chris@49 1932 if(M_local) { delete M_local; }
Chris@49 1933 }
Chris@49 1934
Chris@49 1935 arma_hot arma_inline eT get_val() const { return val; }
Chris@49 1936
Chris@49 1937 static const bool do_trans = true;
Chris@49 1938 static const bool do_times = true;
Chris@49 1939
Chris@49 1940 const eT val;
Chris@49 1941 const T1* M_local;
Chris@49 1942 const T1& M;
Chris@49 1943 };
Chris@49 1944
Chris@49 1945
Chris@49 1946
Chris@49 1947 template<typename T1, bool condition>
Chris@49 1948 struct partial_unwrap_check_htrans2_redirect {};
Chris@49 1949
Chris@49 1950 template<typename T1>
Chris@49 1951 struct partial_unwrap_check_htrans2_redirect<T1, false> { typedef partial_unwrap_check_htrans2_default<T1> result; };
Chris@49 1952
Chris@49 1953 template<typename T1>
Chris@49 1954 struct partial_unwrap_check_htrans2_redirect<T1, true> { typedef partial_unwrap_check_htrans2_fixed<T1> result; };
Chris@49 1955
Chris@49 1956
Chris@49 1957 template<typename T1>
Chris@49 1958 struct partial_unwrap_check< Op<T1, op_htrans2> > : public partial_unwrap_check_htrans2_redirect<T1, is_Mat_fixed<T1>::value >::result
Chris@49 1959 {
Chris@49 1960 typedef typename T1::elem_type eT;
Chris@49 1961
Chris@49 1962 inline partial_unwrap_check(const Op<T1, op_htrans2>& A, const Mat<eT>& B)
Chris@49 1963 : partial_unwrap_check_htrans2_redirect< T1, is_Mat_fixed<T1>::value >::result(A, B)
Chris@49 1964 {
Chris@49 1965 }
Chris@49 1966 };
Chris@49 1967
Chris@49 1968
Chris@49 1969
Chris@49 1970 template<typename eT>
Chris@49 1971 struct partial_unwrap_check< Op< Mat<eT>, op_htrans2> >
Chris@49 1972 {
Chris@49 1973 typedef Mat<eT> stored_type;
Chris@49 1974
Chris@49 1975 arma_hot inline
Chris@49 1976 partial_unwrap_check(const Op< Mat<eT>, op_htrans2>& A, const Mat<eT>& B)
Chris@49 1977 : val (A.aux)
Chris@49 1978 , M_local ( (&A.m == &B) ? new Mat<eT>(A.m) : 0 )
Chris@49 1979 , M ( (&A.m == &B) ? (*M_local) : A.m )
Chris@49 1980 {
Chris@49 1981 arma_extra_debug_sigprint();
Chris@49 1982 }
Chris@49 1983
Chris@49 1984 inline
Chris@49 1985 ~partial_unwrap_check()
Chris@49 1986 {
Chris@49 1987 arma_extra_debug_sigprint();
Chris@49 1988
Chris@49 1989 if(M_local) { delete M_local; }
Chris@49 1990 }
Chris@49 1991
Chris@49 1992 arma_hot arma_inline eT get_val() const { return val; }
Chris@49 1993
Chris@49 1994 static const bool do_trans = true;
Chris@49 1995 static const bool do_times = true;
Chris@49 1996
Chris@49 1997 // the order below is important
Chris@49 1998 const eT val;
Chris@49 1999 const Mat<eT>* M_local;
Chris@49 2000 const Mat<eT>& M;
Chris@49 2001 };
Chris@49 2002
Chris@49 2003
Chris@49 2004
Chris@49 2005 template<typename eT>
Chris@49 2006 struct partial_unwrap_check< Op< Row<eT>, op_htrans2> >
Chris@49 2007 {
Chris@49 2008 typedef Row<eT> stored_type;
Chris@49 2009
Chris@49 2010 arma_hot inline
Chris@49 2011 partial_unwrap_check(const Op< Row<eT>, op_htrans2>& A, const Mat<eT>& B)
Chris@49 2012 : val (A.aux)
Chris@49 2013 , M_local ( (&A.m == &B) ? new Row<eT>(A.m) : 0 )
Chris@49 2014 , M ( (&A.m == &B) ? (*M_local) : A.m )
Chris@49 2015 {
Chris@49 2016 arma_extra_debug_sigprint();
Chris@49 2017 }
Chris@49 2018
Chris@49 2019 inline
Chris@49 2020 ~partial_unwrap_check()
Chris@49 2021 {
Chris@49 2022 arma_extra_debug_sigprint();
Chris@49 2023
Chris@49 2024 if(M_local) { delete M_local; }
Chris@49 2025 }
Chris@49 2026
Chris@49 2027 arma_hot arma_inline eT get_val() const { return val; }
Chris@49 2028
Chris@49 2029 static const bool do_trans = true;
Chris@49 2030 static const bool do_times = true;
Chris@49 2031
Chris@49 2032 // the order below is important
Chris@49 2033 const eT val;
Chris@49 2034 const Row<eT>* M_local;
Chris@49 2035 const Row<eT>& M;
Chris@49 2036 };
Chris@49 2037
Chris@49 2038
Chris@49 2039
Chris@49 2040 template<typename eT>
Chris@49 2041 struct partial_unwrap_check< Op< Col<eT>, op_htrans2> >
Chris@49 2042 {
Chris@49 2043 typedef Col<eT> stored_type;
Chris@49 2044
Chris@49 2045 arma_hot inline
Chris@49 2046 partial_unwrap_check(const Op< Col<eT>, op_htrans2>& A, const Mat<eT>& B)
Chris@49 2047 : val (A.aux)
Chris@49 2048 , M_local ( (&A.m == &B) ? new Col<eT>(A.m) : 0 )
Chris@49 2049 , M ( (&A.m == &B) ? (*M_local) : A.m )
Chris@49 2050 {
Chris@49 2051 arma_extra_debug_sigprint();
Chris@49 2052 }
Chris@49 2053
Chris@49 2054 inline
Chris@49 2055 ~partial_unwrap_check()
Chris@49 2056 {
Chris@49 2057 arma_extra_debug_sigprint();
Chris@49 2058
Chris@49 2059 if(M_local) { delete M_local; }
Chris@49 2060 }
Chris@49 2061
Chris@49 2062 arma_hot arma_inline eT get_val() const { return val; }
Chris@49 2063
Chris@49 2064 static const bool do_trans = true;
Chris@49 2065 static const bool do_times = true;
Chris@49 2066
Chris@49 2067 // the order below is important
Chris@49 2068 const eT val;
Chris@49 2069 const Col<eT>* M_local;
Chris@49 2070 const Col<eT>& M;
Chris@49 2071 };
Chris@49 2072
Chris@49 2073
Chris@49 2074
Chris@49 2075 // NOTE: we can get away with this shortcut as the partial_unwrap_check class is only used by the glue_times class,
Chris@49 2076 // NOTE: which relies on partial_unwrap_check to check for aliasing
Chris@49 2077 template<typename eT>
Chris@49 2078 struct partial_unwrap_check< Op< subview_col<eT>, op_htrans2> >
Chris@49 2079 {
Chris@49 2080 typedef Col<eT> stored_type;
Chris@49 2081
Chris@49 2082 arma_hot inline
Chris@49 2083 partial_unwrap_check(const Op< subview_col<eT>, op_htrans2>& A, const Mat<eT>& B)
Chris@49 2084 : val( A.aux )
Chris@49 2085 , M ( const_cast<eT*>( A.m.colptr(0) ), A.m.n_rows, (&(A.m.m) == &B), false )
Chris@49 2086 {
Chris@49 2087 arma_extra_debug_sigprint();
Chris@49 2088 }
Chris@49 2089
Chris@49 2090 arma_hot arma_inline eT get_val() const { return val; }
Chris@49 2091
Chris@49 2092 static const bool do_trans = true;
Chris@49 2093 static const bool do_times = true;
Chris@49 2094
Chris@49 2095 const eT val;
Chris@49 2096 const Col<eT> M;
Chris@49 2097 };
Chris@49 2098
Chris@49 2099
Chris@49 2100
Chris@49 2101 template<typename T1>
Chris@49 2102 struct partial_unwrap_check_scalar_times_default
Chris@49 2103 {
Chris@49 2104 typedef typename T1::elem_type eT;
Chris@49 2105 typedef Mat<eT> stored_type;
Chris@49 2106
Chris@49 2107 inline
Chris@49 2108 partial_unwrap_check_scalar_times_default(const eOp<T1, eop_scalar_times>& A, const Mat<eT>&)
Chris@49 2109 : val(A.aux)
Chris@49 2110 , M (A.P.Q)
Chris@49 2111 {
Chris@49 2112 arma_extra_debug_sigprint();
Chris@49 2113 }
Chris@49 2114
Chris@49 2115 arma_hot arma_inline eT get_val() const { return val; }
Chris@49 2116
Chris@49 2117 static const bool do_trans = false;
Chris@49 2118 static const bool do_times = true;
Chris@49 2119
Chris@49 2120 const eT val;
Chris@49 2121 const Mat<eT> M;
Chris@49 2122 };
Chris@49 2123
Chris@49 2124
Chris@49 2125
Chris@49 2126 template<typename T1>
Chris@49 2127 struct partial_unwrap_check_scalar_times_fixed
Chris@49 2128 {
Chris@49 2129 typedef typename T1::elem_type eT;
Chris@49 2130 typedef T1 stored_type;
Chris@49 2131
Chris@49 2132 inline explicit
Chris@49 2133 partial_unwrap_check_scalar_times_fixed(const eOp<T1, eop_scalar_times>& A, const Mat<eT>& B)
Chris@49 2134 : val ( A.aux )
Chris@49 2135 , M_local( (&(A.P.Q) == &B) ? new T1(A.P.Q) : 0 )
Chris@49 2136 , M ( (&(A.P.Q) == &B) ? (*M_local) : A.P.Q )
Chris@49 2137 {
Chris@49 2138 arma_extra_debug_sigprint();
Chris@49 2139 }
Chris@49 2140
Chris@49 2141 inline
Chris@49 2142 ~partial_unwrap_check_scalar_times_fixed()
Chris@49 2143 {
Chris@49 2144 arma_extra_debug_sigprint();
Chris@49 2145
Chris@49 2146 if(M_local) { delete M_local; }
Chris@49 2147 }
Chris@49 2148
Chris@49 2149 arma_hot arma_inline eT get_val() const { return val; }
Chris@49 2150
Chris@49 2151 static const bool do_trans = false;
Chris@49 2152 static const bool do_times = true;
Chris@49 2153
Chris@49 2154 const eT val;
Chris@49 2155 const T1* M_local;
Chris@49 2156 const T1& M;
Chris@49 2157 };
Chris@49 2158
Chris@49 2159
Chris@49 2160
Chris@49 2161 template<typename T1, bool condition>
Chris@49 2162 struct partial_unwrap_check_scalar_times_redirect {};
Chris@49 2163
Chris@49 2164 template<typename T1>
Chris@49 2165 struct partial_unwrap_check_scalar_times_redirect<T1, false> { typedef partial_unwrap_check_scalar_times_default<T1> result; };
Chris@49 2166
Chris@49 2167 template<typename T1>
Chris@49 2168 struct partial_unwrap_check_scalar_times_redirect<T1, true> { typedef partial_unwrap_check_scalar_times_fixed<T1> result; };
Chris@49 2169
Chris@49 2170
Chris@49 2171 template<typename T1>
Chris@49 2172 struct partial_unwrap_check< eOp<T1, eop_scalar_times> > : public partial_unwrap_check_scalar_times_redirect<T1, is_Mat_fixed<T1>::value >::result
Chris@49 2173 {
Chris@49 2174 typedef typename T1::elem_type eT;
Chris@49 2175
Chris@49 2176 inline partial_unwrap_check(const eOp<T1, eop_scalar_times>& A, const Mat<eT>& B)
Chris@49 2177 : partial_unwrap_check_scalar_times_redirect< T1, is_Mat_fixed<T1>::value >::result(A, B)
Chris@49 2178 {
Chris@49 2179 }
Chris@49 2180 };
Chris@49 2181
Chris@49 2182
Chris@49 2183
Chris@49 2184 template<typename eT>
Chris@49 2185 struct partial_unwrap_check< eOp<Mat<eT>, eop_scalar_times> >
Chris@49 2186 {
Chris@49 2187 typedef Mat<eT> stored_type;
Chris@49 2188
Chris@49 2189 arma_hot inline
Chris@49 2190 partial_unwrap_check(const eOp<Mat<eT>,eop_scalar_times>& A, const Mat<eT>& B)
Chris@49 2191 : val (A.aux)
Chris@49 2192 , M_local( (&(A.P.Q) == &B) ? new Mat<eT>(A.P.Q) : 0 )
Chris@49 2193 , M ( (&(A.P.Q) == &B) ? *M_local : A.P.Q )
Chris@49 2194 {
Chris@49 2195 arma_extra_debug_sigprint();
Chris@49 2196 }
Chris@49 2197
Chris@49 2198 inline
Chris@49 2199 ~partial_unwrap_check()
Chris@49 2200 {
Chris@49 2201 arma_extra_debug_sigprint();
Chris@49 2202
Chris@49 2203 if(M_local) { delete M_local; }
Chris@49 2204 }
Chris@49 2205
Chris@49 2206 arma_hot arma_inline eT get_val() const { return val; }
Chris@49 2207
Chris@49 2208 static const bool do_trans = false;
Chris@49 2209 static const bool do_times = true;
Chris@49 2210
Chris@49 2211 const eT val;
Chris@49 2212 const Mat<eT>* M_local;
Chris@49 2213 const Mat<eT>& M;
Chris@49 2214 };
Chris@49 2215
Chris@49 2216
Chris@49 2217
Chris@49 2218 template<typename eT>
Chris@49 2219 struct partial_unwrap_check< eOp<Row<eT>, eop_scalar_times> >
Chris@49 2220 {
Chris@49 2221 typedef Row<eT> stored_type;
Chris@49 2222
Chris@49 2223 arma_hot inline
Chris@49 2224 partial_unwrap_check(const eOp<Row<eT>,eop_scalar_times>& A, const Mat<eT>& B)
Chris@49 2225 : val(A.aux)
Chris@49 2226 , M_local( (&(A.P.Q) == &B) ? new Row<eT>(A.P.Q) : 0 )
Chris@49 2227 , M ( (&(A.P.Q) == &B) ? *M_local : A.P.Q )
Chris@49 2228 {
Chris@49 2229 arma_extra_debug_sigprint();
Chris@49 2230 }
Chris@49 2231
Chris@49 2232 inline
Chris@49 2233 ~partial_unwrap_check()
Chris@49 2234 {
Chris@49 2235 arma_extra_debug_sigprint();
Chris@49 2236
Chris@49 2237 if(M_local) { delete M_local; }
Chris@49 2238 }
Chris@49 2239
Chris@49 2240 arma_hot arma_inline eT get_val() const { return val; }
Chris@49 2241
Chris@49 2242 static const bool do_trans = false;
Chris@49 2243 static const bool do_times = true;
Chris@49 2244
Chris@49 2245 const eT val;
Chris@49 2246 const Row<eT>* M_local;
Chris@49 2247 const Row<eT>& M;
Chris@49 2248 };
Chris@49 2249
Chris@49 2250
Chris@49 2251
Chris@49 2252 template<typename eT>
Chris@49 2253 struct partial_unwrap_check< eOp<Col<eT>, eop_scalar_times> >
Chris@49 2254 {
Chris@49 2255 typedef Col<eT> stored_type;
Chris@49 2256
Chris@49 2257 arma_hot inline
Chris@49 2258 partial_unwrap_check(const eOp<Col<eT>,eop_scalar_times>& A, const Mat<eT>& B)
Chris@49 2259 : val ( A.aux )
Chris@49 2260 , M_local( (&(A.P.Q) == &B) ? new Col<eT>(A.P.Q) : 0 )
Chris@49 2261 , M ( (&(A.P.Q) == &B) ? *M_local : A.P.Q )
Chris@49 2262 {
Chris@49 2263 arma_extra_debug_sigprint();
Chris@49 2264 }
Chris@49 2265
Chris@49 2266 inline
Chris@49 2267 ~partial_unwrap_check()
Chris@49 2268 {
Chris@49 2269 arma_extra_debug_sigprint();
Chris@49 2270
Chris@49 2271 if(M_local) { delete M_local; }
Chris@49 2272 }
Chris@49 2273
Chris@49 2274 arma_hot arma_inline eT get_val() const { return val; }
Chris@49 2275
Chris@49 2276 static const bool do_trans = false;
Chris@49 2277 static const bool do_times = true;
Chris@49 2278
Chris@49 2279 const eT val;
Chris@49 2280 const Col<eT>* M_local;
Chris@49 2281 const Col<eT>& M;
Chris@49 2282 };
Chris@49 2283
Chris@49 2284
Chris@49 2285
Chris@49 2286 // NOTE: we can get away with this shortcut as the partial_unwrap_check class is only used by the glue_times class,
Chris@49 2287 // NOTE: which relies on partial_unwrap_check to check for aliasing
Chris@49 2288 template<typename eT>
Chris@49 2289 struct partial_unwrap_check< eOp<subview_col<eT>, eop_scalar_times> >
Chris@49 2290 {
Chris@49 2291 typedef Col<eT> stored_type;
Chris@49 2292
Chris@49 2293 arma_hot inline
Chris@49 2294 partial_unwrap_check(const eOp<subview_col<eT>,eop_scalar_times>& A, const Mat<eT>& B)
Chris@49 2295 : val( A.aux )
Chris@49 2296 , M ( const_cast<eT*>( A.P.Q.colptr(0) ), A.P.Q.n_rows, (&(A.P.Q.m) == &B), false )
Chris@49 2297 {
Chris@49 2298 arma_extra_debug_sigprint();
Chris@49 2299 }
Chris@49 2300
Chris@49 2301 arma_hot arma_inline eT get_val() const { return val; }
Chris@49 2302
Chris@49 2303 static const bool do_trans = false;
Chris@49 2304 static const bool do_times = true;
Chris@49 2305
Chris@49 2306 const eT val;
Chris@49 2307 const Col<eT> M;
Chris@49 2308 };
Chris@49 2309
Chris@49 2310
Chris@49 2311
Chris@49 2312 template<typename T1>
Chris@49 2313 struct partial_unwrap_check_neg_default
Chris@49 2314 {
Chris@49 2315 typedef typename T1::elem_type eT;
Chris@49 2316 typedef Mat<eT> stored_type;
Chris@49 2317
Chris@49 2318 inline
Chris@49 2319 partial_unwrap_check_neg_default(const eOp<T1, eop_neg>& A, const Mat<eT>&)
Chris@49 2320 : M(A.P.Q)
Chris@49 2321 {
Chris@49 2322 arma_extra_debug_sigprint();
Chris@49 2323 }
Chris@49 2324
Chris@49 2325 arma_hot arma_inline eT get_val() const { return eT(-1); }
Chris@49 2326
Chris@49 2327 static const bool do_trans = false;
Chris@49 2328 static const bool do_times = true;
Chris@49 2329
Chris@49 2330 const Mat<eT> M;
Chris@49 2331 };
Chris@49 2332
Chris@49 2333
Chris@49 2334
Chris@49 2335 template<typename T1>
Chris@49 2336 struct partial_unwrap_check_neg_fixed
Chris@49 2337 {
Chris@49 2338 typedef typename T1::elem_type eT;
Chris@49 2339 typedef T1 stored_type;
Chris@49 2340
Chris@49 2341 inline explicit
Chris@49 2342 partial_unwrap_check_neg_fixed(const eOp<T1, eop_neg>& A, const Mat<eT>& B)
Chris@49 2343 : M_local( (&(A.P.Q) == &B) ? new T1(A.P.Q) : 0 )
Chris@49 2344 , M ( (&(A.P.Q) == &B) ? (*M_local) : A.P.Q )
Chris@49 2345 {
Chris@49 2346 arma_extra_debug_sigprint();
Chris@49 2347 }
Chris@49 2348
Chris@49 2349 inline
Chris@49 2350 ~partial_unwrap_check_neg_fixed()
Chris@49 2351 {
Chris@49 2352 arma_extra_debug_sigprint();
Chris@49 2353
Chris@49 2354 if(M_local) { delete M_local; }
Chris@49 2355 }
Chris@49 2356
Chris@49 2357 arma_hot arma_inline eT get_val() const { return eT(-1); }
Chris@49 2358
Chris@49 2359 static const bool do_trans = false;
Chris@49 2360 static const bool do_times = true;
Chris@49 2361
Chris@49 2362 const T1* M_local;
Chris@49 2363 const T1& M;
Chris@49 2364 };
Chris@49 2365
Chris@49 2366
Chris@49 2367
Chris@49 2368 template<typename T1, bool condition>
Chris@49 2369 struct partial_unwrap_check_neg_redirect {};
Chris@49 2370
Chris@49 2371 template<typename T1>
Chris@49 2372 struct partial_unwrap_check_neg_redirect<T1, false> { typedef partial_unwrap_check_neg_default<T1> result; };
Chris@49 2373
Chris@49 2374 template<typename T1>
Chris@49 2375 struct partial_unwrap_check_neg_redirect<T1, true> { typedef partial_unwrap_check_neg_fixed<T1> result; };
Chris@49 2376
Chris@49 2377
Chris@49 2378 template<typename T1>
Chris@49 2379 struct partial_unwrap_check< eOp<T1, eop_neg> > : public partial_unwrap_check_neg_redirect<T1, is_Mat_fixed<T1>::value >::result
Chris@49 2380 {
Chris@49 2381 typedef typename T1::elem_type eT;
Chris@49 2382
Chris@49 2383 inline partial_unwrap_check(const eOp<T1, eop_neg>& A, const Mat<eT>& B)
Chris@49 2384 : partial_unwrap_check_neg_redirect< T1, is_Mat_fixed<T1>::value >::result(A, B)
Chris@49 2385 {
Chris@49 2386 }
Chris@49 2387 };
Chris@49 2388
Chris@49 2389
Chris@49 2390
Chris@49 2391 template<typename eT>
Chris@49 2392 struct partial_unwrap_check< eOp<Mat<eT>, eop_neg> >
Chris@49 2393 {
Chris@49 2394 typedef Mat<eT> stored_type;
Chris@49 2395
Chris@49 2396 arma_hot inline
Chris@49 2397 partial_unwrap_check(const eOp<Mat<eT>,eop_neg>& A, const Mat<eT>& B)
Chris@49 2398 : M_local( (&(A.P.Q) == &B) ? new Mat<eT>(A.P.Q) : 0 )
Chris@49 2399 , M ( (&(A.P.Q) == &B) ? *M_local : A.P.Q )
Chris@49 2400 {
Chris@49 2401 arma_extra_debug_sigprint();
Chris@49 2402 }
Chris@49 2403
Chris@49 2404 inline
Chris@49 2405 ~partial_unwrap_check()
Chris@49 2406 {
Chris@49 2407 arma_extra_debug_sigprint();
Chris@49 2408
Chris@49 2409 if(M_local) { delete M_local; }
Chris@49 2410 }
Chris@49 2411
Chris@49 2412 arma_hot arma_inline eT get_val() const { return eT(-1); }
Chris@49 2413
Chris@49 2414 static const bool do_trans = false;
Chris@49 2415 static const bool do_times = true;
Chris@49 2416
Chris@49 2417 const Mat<eT>* M_local;
Chris@49 2418 const Mat<eT>& M;
Chris@49 2419 };
Chris@49 2420
Chris@49 2421
Chris@49 2422
Chris@49 2423 template<typename eT>
Chris@49 2424 struct partial_unwrap_check< eOp<Row<eT>, eop_neg> >
Chris@49 2425 {
Chris@49 2426 typedef Row<eT> stored_type;
Chris@49 2427
Chris@49 2428 arma_hot inline
Chris@49 2429 partial_unwrap_check(const eOp<Row<eT>,eop_neg>& A, const Mat<eT>& B)
Chris@49 2430 : M_local( (&(A.P.Q) == &B) ? new Row<eT>(A.P.Q) : 0 )
Chris@49 2431 , M ( (&(A.P.Q) == &B) ? *M_local : A.P.Q )
Chris@49 2432 {
Chris@49 2433 arma_extra_debug_sigprint();
Chris@49 2434 }
Chris@49 2435
Chris@49 2436 inline
Chris@49 2437 ~partial_unwrap_check()
Chris@49 2438 {
Chris@49 2439 arma_extra_debug_sigprint();
Chris@49 2440
Chris@49 2441 if(M_local) { delete M_local; }
Chris@49 2442 }
Chris@49 2443
Chris@49 2444 arma_hot arma_inline eT get_val() const { return eT(-1); }
Chris@49 2445
Chris@49 2446 static const bool do_trans = false;
Chris@49 2447 static const bool do_times = true;
Chris@49 2448
Chris@49 2449 const Row<eT>* M_local;
Chris@49 2450 const Row<eT>& M;
Chris@49 2451 };
Chris@49 2452
Chris@49 2453
Chris@49 2454
Chris@49 2455 template<typename eT>
Chris@49 2456 struct partial_unwrap_check< eOp<Col<eT>, eop_neg> >
Chris@49 2457 {
Chris@49 2458 typedef Col<eT> stored_type;
Chris@49 2459
Chris@49 2460 arma_hot inline
Chris@49 2461 partial_unwrap_check(const eOp<Col<eT>,eop_neg>& A, const Mat<eT>& B)
Chris@49 2462 : M_local( (&(A.P.Q) == &B) ? new Col<eT>(A.P.Q) : 0 )
Chris@49 2463 , M ( (&(A.P.Q) == &B) ? *M_local : A.P.Q )
Chris@49 2464 {
Chris@49 2465 arma_extra_debug_sigprint();
Chris@49 2466 }
Chris@49 2467
Chris@49 2468 inline
Chris@49 2469 ~partial_unwrap_check()
Chris@49 2470 {
Chris@49 2471 arma_extra_debug_sigprint();
Chris@49 2472
Chris@49 2473 if(M_local) { delete M_local; }
Chris@49 2474 }
Chris@49 2475
Chris@49 2476 arma_hot arma_inline eT get_val() const { return eT(-1); }
Chris@49 2477
Chris@49 2478 static const bool do_trans = false;
Chris@49 2479 static const bool do_times = true;
Chris@49 2480
Chris@49 2481 const Col<eT>* M_local;
Chris@49 2482 const Col<eT>& M;
Chris@49 2483 };
Chris@49 2484
Chris@49 2485
Chris@49 2486
Chris@49 2487 // NOTE: we can get away with this shortcut as the partial_unwrap_check class is only used by the glue_times class,
Chris@49 2488 // NOTE: which relies on partial_unwrap_check to check for aliasing
Chris@49 2489 template<typename eT>
Chris@49 2490 struct partial_unwrap_check< eOp<subview_col<eT>, eop_neg> >
Chris@49 2491 {
Chris@49 2492 typedef Col<eT> stored_type;
Chris@49 2493
Chris@49 2494 arma_hot inline
Chris@49 2495 partial_unwrap_check(const eOp<subview_col<eT>,eop_neg>& A, const Mat<eT>& B)
Chris@49 2496 : M ( const_cast<eT*>( A.P.Q.colptr(0) ), A.P.Q.n_rows, (&(A.P.Q.m) == &B), false )
Chris@49 2497 {
Chris@49 2498 arma_extra_debug_sigprint();
Chris@49 2499 }
Chris@49 2500
Chris@49 2501 arma_hot arma_inline eT get_val() const { return eT(-1); }
Chris@49 2502
Chris@49 2503 static const bool do_trans = false;
Chris@49 2504 static const bool do_times = true;
Chris@49 2505
Chris@49 2506 const Col<eT> M;
Chris@49 2507 };
Chris@49 2508
Chris@49 2509
Chris@49 2510
Chris@49 2511 //! @}