00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 template<typename T1>
00021 class unwrap
00022 {
00023 public:
00024 inline unwrap(const T1& A)
00025 {
00026 arma_type_check< is_arma_type<T1>::value == false >::apply();
00027 }
00028 };
00029
00030
00031
00032
00033 template<typename eT>
00034 class unwrap< Mat<eT> >
00035 {
00036 public:
00037
00038 inline unwrap(const Mat<eT>& A)
00039 : M(A)
00040 {
00041 arma_extra_debug_sigprint();
00042 }
00043
00044 const Mat<eT>& M;
00045
00046 };
00047
00048
00049
00050
00051 template<typename eT>
00052 class unwrap< Row<eT> >
00053 {
00054 public:
00055
00056 inline unwrap(const Row<eT>& A)
00057 : M(A)
00058 {
00059 arma_extra_debug_sigprint();
00060 }
00061
00062 const Row<eT>& M;
00063
00064 };
00065
00066
00067
00068
00069 template<typename eT>
00070 class unwrap< Col<eT> >
00071 {
00072 public:
00073
00074 inline unwrap(const Col<eT>& A)
00075 : M(A)
00076 {
00077 arma_extra_debug_sigprint();
00078 }
00079
00080 const Col<eT>& M;
00081
00082 };
00083
00084
00085
00086 template<typename T1, typename op_type>
00087 class unwrap< Op<T1, op_type> >
00088 {
00089 public:
00090
00091 inline unwrap(const Op<T1, op_type>& A)
00092 : M(A)
00093 {
00094 arma_extra_debug_sigprint();
00095 }
00096
00097 typedef typename T1::elem_type elem_type;
00098 const Mat<elem_type> M;
00099
00100 };
00101
00102
00103
00104 template<typename T1, typename T2, typename glue_type>
00105 class unwrap< Glue<T1, T2, glue_type> >
00106 {
00107 public:
00108
00109 inline unwrap(const Glue<T1, T2, glue_type>& A)
00110 : M(A)
00111 {
00112 arma_extra_debug_sigprint();
00113 }
00114
00115 typedef typename T1::elem_type elem_type;
00116 const Mat<elem_type> M;
00117
00118 };
00119
00120
00121
00122 template<typename eT>
00123 class unwrap< subview<eT> >
00124 {
00125 public:
00126
00127 inline unwrap(const subview<eT>& A)
00128 : M(A)
00129 {
00130 arma_extra_debug_sigprint();
00131 }
00132
00133 const Mat<eT> M;
00134
00135 };
00136
00137
00138
00139 template<typename eT>
00140 class unwrap< diagview<eT> >
00141 {
00142 public:
00143
00144 inline unwrap(const diagview<eT> & A)
00145 : M(A)
00146 {
00147 arma_extra_debug_sigprint();
00148 }
00149
00150 const Mat<eT> M;
00151
00152 };
00153
00154
00155
00156
00157
00158
00159
00160
00161 template<typename T1>
00162 class unwrap_to_elem_access
00163 {
00164 public:
00165 inline unwrap_to_elem_access(const T1& A)
00166 {
00167 arma_type_check< is_arma_type<T1>::value == false >::apply();
00168 }
00169 };
00170
00171
00172
00173
00174 template<typename eT>
00175 class unwrap_to_elem_access< Mat<eT> >
00176 {
00177 public:
00178
00179 inline unwrap_to_elem_access(const Mat<eT>& A)
00180 : M(A)
00181 {
00182 arma_extra_debug_sigprint();
00183 }
00184
00185 inline eT operator[](const u32 i) const { return M[i]; }
00186 inline eT operator()(const u32 i) const { return M(i); }
00187
00188 inline eT operator()(const u32 in_row, const u32 in_col) const { return M(in_row,in_col); }
00189 inline eT at(const u32 in_row, const u32 in_col) const { return M.at(in_row,in_col); }
00190
00191
00192 const Mat<eT>& M;
00193
00194 };
00195
00196
00197
00198
00199 template<typename eT>
00200 class unwrap_to_elem_access< Row<eT> >
00201 {
00202 public:
00203
00204 inline unwrap_to_elem_access(const Row<eT>& A)
00205 : M(A)
00206 {
00207 arma_extra_debug_sigprint();
00208 }
00209
00210 inline eT operator[](const u32 i) const { return M[i]; }
00211 inline eT operator()(const u32 i) const { return M(i); }
00212
00213 inline eT operator()(const u32 in_row, const u32 in_col) const { return M(in_row,in_col); }
00214 inline eT at(const u32 in_row, const u32 in_col) const { return M.at(in_row,in_col); }
00215
00216 const Row<eT>& M;
00217
00218 };
00219
00220
00221
00222
00223 template<typename eT>
00224 class unwrap_to_elem_access< Op< Row<eT>, op_trans> >
00225 {
00226 public:
00227
00228
00229
00230
00231 inline unwrap_to_elem_access(const Op<Row<eT>, op_trans>& A)
00232 : M(A.m)
00233 {
00234 arma_extra_debug_sigprint();
00235 }
00236
00237 inline eT operator[](const u32 i) const { return M[i]; }
00238 inline eT operator()(const u32 i) const { return M(i); }
00239
00240 inline eT operator()(const u32 in_row, const u32 in_col) const { return M(in_row,in_col); }
00241 inline eT at(const u32 in_row, const u32 in_col) const { return M.at(in_row,in_col); }
00242
00243 const Row<eT>& M;
00244
00245 };
00246
00247
00248
00249
00250 template<typename eT>
00251 class unwrap_to_elem_access< Col<eT> >
00252 {
00253 public:
00254
00255 inline unwrap_to_elem_access(const Col<eT>& A)
00256 : M(A)
00257 {
00258 arma_extra_debug_sigprint();
00259 }
00260
00261 inline eT operator[](const u32 i) const { return M[i]; }
00262 inline eT operator()(const u32 i) const { return M(i); }
00263
00264 inline eT operator()(const u32 in_row, const u32 in_col) const { return M(in_row,in_col); }
00265 inline eT at(const u32 in_row, const u32 in_col) const { return M.at(in_row,in_col); }
00266
00267 const Col<eT>& M;
00268
00269 };
00270
00271
00272
00273
00274 template<typename eT>
00275 class unwrap_to_elem_access< Op<Col<eT>, op_trans> >
00276 {
00277 public:
00278
00279 inline unwrap_to_elem_access(const Op<Col<eT>, op_trans>& A)
00280 : M(A.m)
00281 {
00282 arma_extra_debug_sigprint();
00283 }
00284
00285 inline eT operator[](const u32 i) const { return M[i]; }
00286 inline eT operator()(const u32 i) const { return M(i); }
00287
00288
00289 inline eT at(const u32 in_row, const u32 in_col) const { return M.at(in_col,in_row); }
00290 inline eT operator()(const u32 in_row, const u32 in_col) const { return M(in_col,in_row); }
00291
00292 const Col<eT>& M;
00293
00294 };
00295
00296
00297
00298 template<typename T1, typename op_type>
00299 class unwrap_to_elem_access< Op<T1, op_type> >
00300 {
00301 public:
00302 typedef typename T1::elem_type elem_type;
00303
00304 inline unwrap_to_elem_access(const Op<T1, op_type>& A)
00305 : M(A)
00306 {
00307 arma_extra_debug_sigprint();
00308 }
00309
00310 inline elem_type operator[](const u32 i) const { return M[i]; }
00311 inline elem_type operator()(const u32 i) const { return M(i); }
00312
00313 inline elem_type operator()(const u32 in_row, const u32 in_col) const { return M(in_row,in_col); }
00314 inline elem_type at(const u32 in_row, const u32 in_col) const { return M.at(in_row,in_col); }
00315
00316 const Mat<elem_type> M;
00317
00318 };
00319
00320
00321
00322 template<typename T1, typename T2, typename glue_type>
00323 class unwrap_to_elem_access< Glue<T1, T2, glue_type> >
00324 {
00325 public:
00326 typedef typename T1::elem_type elem_type;
00327
00328 inline unwrap_to_elem_access(const Glue<T1, T2, glue_type>& A)
00329 : M(A)
00330 {
00331 arma_extra_debug_sigprint();
00332 }
00333
00334 inline elem_type operator[](const u32 i) const { return M[i]; }
00335 inline elem_type operator()(const u32 i) const { return M(i); }
00336
00337 inline elem_type operator()(const u32 in_row, const u32 in_col) const { return M(in_row,in_col); }
00338 inline elem_type at(const u32 in_row, const u32 in_col) const { return M.at(in_row,in_col); }
00339
00340 const Mat<elem_type> M;
00341
00342 };
00343
00344
00345
00346 template<typename eT>
00347 class unwrap_to_elem_access< subview<eT> >
00348 {
00349 public:
00350
00351 inline unwrap_to_elem_access(const subview<eT>& A)
00352 : M(A)
00353 {
00354 arma_extra_debug_sigprint();
00355 }
00356
00357 inline eT operator[](const u32 i) const { return M[i]; }
00358 inline eT operator()(const u32 i) const { return M(i); }
00359
00360 inline eT operator()(const u32 in_row, const u32 in_col) const { return M(in_row,in_col); }
00361 inline eT at(const u32 in_row, const u32 in_col) const { return M.at(in_row,in_col); }
00362
00363 const subview<eT>& M;
00364
00365 };
00366
00367
00368
00369
00370
00371
00372 template<typename T1>
00373 class unwrap_check
00374 {
00375 private:
00376 template<typename eT> inline unwrap_check(const T1& A, const Mat<eT>& B);
00377 template<typename eT> inline unwrap_check(const T1& A, const Row<eT>& B);
00378 template<typename eT> inline unwrap_check(const T1& A, const Col<eT>& B);
00379 template<typename eT> inline unwrap_check(const T1& A, const subview<eT>& B);
00380 template<typename eT> inline unwrap_check(const T1& A, const diagview<eT>& B);
00381 };
00382
00383
00384
00385 template<typename eT>
00386 class unwrap_check< Mat<eT> >
00387 {
00388 public:
00389
00390 inline
00391 unwrap_check(const Mat<eT>& A, const Mat<eT>& B)
00392 : M_local( (&A == reinterpret_cast<const Mat<eT>*>(&B)) ? new Mat<eT>(A) : 0 )
00393 , M ( (&A == reinterpret_cast<const Mat<eT>*>(&B)) ? (*M_local) : A )
00394 {
00395 arma_extra_debug_sigprint();
00396 }
00397
00398
00399 inline
00400 unwrap_check(const Mat<eT>& A, const Row<eT>& B)
00401 : M_local( (&A == reinterpret_cast<const Mat<eT>*>(&B)) ? new Mat<eT>(A) : 0 )
00402 , M ( (&A == reinterpret_cast<const Mat<eT>*>(&B)) ? (*M_local) : A )
00403 {
00404 arma_extra_debug_sigprint();
00405 }
00406
00407
00408 inline
00409 unwrap_check(const Mat<eT>& A, const Col<eT>& B)
00410 : M_local( (&A == reinterpret_cast<const Mat<eT>*>(&B)) ? new Mat<eT>(A) : 0 )
00411 , M ( (&A == reinterpret_cast<const Mat<eT>*>(&B)) ? (*M_local) : A )
00412 {
00413 arma_extra_debug_sigprint();
00414 }
00415
00416
00417 inline
00418 unwrap_check(const Mat<eT>& A, const subview<eT>& B)
00419 : M_local( (&A == reinterpret_cast<const Mat<eT>*>(&B.m)) ? new Mat<eT>(A) : 0 )
00420 , M ( (&A == reinterpret_cast<const Mat<eT>*>(&B.m)) ? (*M_local) : A )
00421 {
00422 arma_extra_debug_sigprint();
00423 }
00424
00425
00426 inline
00427 unwrap_check(const Mat<eT>& A, const diagview<eT>& B)
00428 : M_local( (&A == reinterpret_cast<const Mat<eT>*>(&B.m)) ? new Mat<eT>(A) : 0 )
00429 , M ( (&A == reinterpret_cast<const Mat<eT>*>(&B.m)) ? (*M_local) : A )
00430 {
00431 arma_extra_debug_sigprint();
00432 }
00433
00434
00435 inline
00436 ~unwrap_check()
00437 {
00438 arma_extra_debug_sigprint();
00439
00440 if(M_local)
00441 {
00442 delete M_local;
00443 }
00444 }
00445
00446
00447
00448 const Mat<eT>* M_local;
00449 const Mat<eT>& M;
00450
00451 };
00452
00453
00454
00455
00456 template<typename eT>
00457 class unwrap_check< Row<eT> >
00458 {
00459 public:
00460
00461 inline
00462 unwrap_check(const Row<eT>& A, const Mat<eT>& B)
00463 : M_local( (&A == reinterpret_cast<const Row<eT>*>(&B)) ? new Row<eT>(A) : 0 )
00464 , M ( (&A == reinterpret_cast<const Row<eT>*>(&B)) ? (*M_local) : A )
00465 {
00466 arma_extra_debug_sigprint();
00467 }
00468
00469
00470 inline
00471 unwrap_check(const Row<eT>& A, const Row<eT>& B)
00472 : M_local( (&A == reinterpret_cast<const Row<eT>*>(&B)) ? new Row<eT>(A) : 0 )
00473 , M ( (&A == reinterpret_cast<const Row<eT>*>(&B)) ? (*M_local) : A )
00474 {
00475 arma_extra_debug_sigprint();
00476 }
00477
00478 inline
00479 unwrap_check(const Row<eT>& A, const Col<eT>& B)
00480 : M_local( (&A == reinterpret_cast<const Row<eT>*>(&B)) ? new Row<eT>(A) : 0 )
00481 , M ( (&A == reinterpret_cast<const Row<eT>*>(&B)) ? (*M_local) : A )
00482 {
00483 arma_extra_debug_sigprint();
00484 }
00485
00486
00487 inline
00488 unwrap_check(const Row<eT>& A, const subview<eT>& B)
00489 : M_local( (&A == reinterpret_cast<const Row<eT>*>(&B.m)) ? new Row<eT>(A) : 0 )
00490 , M ( (&A == reinterpret_cast<const Row<eT>*>(&B.m)) ? (*M_local) : A )
00491 {
00492 arma_extra_debug_sigprint();
00493 }
00494
00495
00496 inline
00497 unwrap_check(const Row<eT>& A, const diagview<eT>& B)
00498 : M_local( (&A == reinterpret_cast<const Row<eT>*>(&B.m)) ? new Row<eT>(A) : 0 )
00499 , M ( (&A == reinterpret_cast<const Row<eT>*>(&B.m)) ? (*M_local) : A )
00500 {
00501 arma_extra_debug_sigprint();
00502 }
00503
00504
00505 inline
00506 ~unwrap_check()
00507 {
00508 arma_extra_debug_sigprint();
00509
00510 if(M_local)
00511 delete M_local;
00512 }
00513
00514
00515
00516 const Row<eT>* M_local;
00517 const Row<eT>& M;
00518
00519 };
00520
00521
00522
00523
00524
00525 template<typename eT>
00526 class unwrap_check< Col<eT> >
00527 {
00528 public:
00529
00530 inline
00531 unwrap_check(const Col<eT>& A, const Mat<eT>& B)
00532 : M_local( (&A == reinterpret_cast<const Col<eT>*>(&B)) ? new Col<eT>(A) : 0 )
00533 , M ( (&A == reinterpret_cast<const Col<eT>*>(&B)) ? (*M_local) : A )
00534 {
00535 arma_extra_debug_sigprint();
00536 }
00537
00538
00539 inline
00540 unwrap_check(const Col<eT>& A, const Row<eT>& B)
00541 : M_local( (&A == reinterpret_cast<const Col<eT>*>(&B)) ? new Col<eT>(A) : 0 )
00542 , M ( (&A == reinterpret_cast<const Col<eT>*>(&B)) ? (*M_local) : A )
00543 {
00544 arma_extra_debug_sigprint();
00545 }
00546
00547
00548 inline
00549 unwrap_check(const Col<eT>& A, const Col<eT>& B)
00550 : M_local( (&A == reinterpret_cast<const Col<eT>*>(&B)) ? new Col<eT>(A) : 0 )
00551 , M ( (&A == reinterpret_cast<const Col<eT>*>(&B)) ? (*M_local) : A )
00552 {
00553 arma_extra_debug_sigprint();
00554 }
00555
00556
00557 inline
00558 unwrap_check(const Col<eT>& A, const subview<eT>& B)
00559 : M_local( (&A == reinterpret_cast<const Col<eT>*>(&B.m)) ? new Col<eT>(A) : 0 )
00560 , M ( (&A == reinterpret_cast<const Col<eT>*>(&B.m)) ? (*M_local) : A )
00561 {
00562 arma_extra_debug_sigprint();
00563 }
00564
00565
00566 inline
00567 unwrap_check(const Col<eT>& A, const diagview<eT>& B)
00568 : M_local( (&A == reinterpret_cast<const Col<eT>*>(&B.m)) ? new Col<eT>(A) : 0 )
00569 , M ( (&A == reinterpret_cast<const Col<eT>*>(&B.m)) ? (*M_local) : A )
00570 {
00571 arma_extra_debug_sigprint();
00572 }
00573
00574
00575 inline
00576 ~unwrap_check()
00577 {
00578 arma_extra_debug_sigprint();
00579
00580 if(M_local)
00581 delete M_local;
00582 }
00583
00584
00585
00586 const Col<eT>* M_local;
00587 const Col<eT>& M;
00588
00589 };
00590
00591
00592
00593 template<typename T1, typename op_type>
00594 class unwrap_check< Op<T1, op_type> >
00595 {
00596 public:
00597 typedef typename T1::elem_type elem_type;
00598
00599
00600 inline
00601 unwrap_check(const Op<T1,op_type>& A, const Mat<elem_type>& B)
00602 : M(A)
00603 {
00604 arma_extra_debug_sigprint();
00605 }
00606
00607
00608
00609 inline
00610 unwrap_check(const Op<T1,op_type>& A, const Row<elem_type>& B)
00611 : M(A)
00612 {
00613 arma_extra_debug_sigprint();
00614 }
00615
00616
00617 inline
00618 unwrap_check(const Op<T1,op_type>& A, const Col<elem_type>& B)
00619 : M(A)
00620 {
00621 arma_extra_debug_sigprint();
00622 }
00623
00624
00625 inline
00626 ~unwrap_check()
00627 {
00628 arma_extra_debug_sigprint();
00629
00630 }
00631
00632 const Mat<elem_type> M;
00633
00634 };
00635
00636
00637
00638 template<typename T1, typename T2, typename glue_type>
00639 class unwrap_check< Glue<T1, T2, glue_type> >
00640 {
00641 public:
00642 typedef typename T1::elem_type elem_type;
00643
00644 inline
00645 unwrap_check(const Glue<T1, T2, glue_type>& A, const Mat<elem_type>& B)
00646 : M(A)
00647 {
00648 arma_extra_debug_sigprint();
00649 }
00650
00651
00652 inline
00653 unwrap_check(const Glue<T1, T2, glue_type>& A, const Row<elem_type>& B)
00654 : M(A)
00655 {
00656 arma_extra_debug_sigprint();
00657 }
00658
00659
00660 inline
00661 unwrap_check(const Glue<T1, T2, glue_type>& A, const Col<elem_type>& B)
00662 : M(A)
00663 {
00664 arma_extra_debug_sigprint();
00665 }
00666
00667
00668 inline
00669 ~unwrap_check()
00670 {
00671 arma_extra_debug_sigprint();
00672
00673 }
00674
00675
00676 const Mat<elem_type> M;
00677
00678 };
00679
00680
00681
00682
00683
00684 template<typename eT>
00685 class unwrap_check< subview<eT> >
00686 {
00687 public:
00688
00689 template<typename T2>
00690 inline unwrap_check(const subview<eT>& A, const T2& junk)
00691 : M(A)
00692 {
00693 arma_extra_debug_sigprint();
00694 }
00695
00696 const Mat<eT> M;
00697
00698 };
00699
00700
00701
00702 template<typename eT>
00703 class unwrap_check< diagview<eT> >
00704 {
00705 public:
00706
00707 template<typename T2>
00708 inline unwrap_check(const diagview<eT> & A, const T2& junk)
00709 : M(A)
00710 {
00711 arma_extra_debug_sigprint();
00712 }
00713
00714 const Mat<eT> M;
00715
00716 };
00717
00718
00719