unwrap.hpp

Go to the documentation of this file.
00001 // Copyright (C) 2010 NICTA and the authors listed below
00002 // http://nicta.com.au
00003 // 
00004 // Authors:
00005 // - Conrad Sanderson (conradsand at ieee dot org)
00006 // 
00007 // This file is part of the Armadillo C++ library.
00008 // It is provided without any warranty of fitness
00009 // for any purpose. You can redistribute this file
00010 // and/or modify it under the terms of the GNU
00011 // Lesser General Public License (LGPL) as published
00012 // by the Free Software Foundation, either version 3
00013 // of the License or (at your option) any later version.
00014 // (see http://www.opensource.org/licenses for more info)
00015 
00016 
00017 //! \addtogroup unwrap
00018 //! @{
00019 
00020 
00021 
00022 template<typename T1>
00023 class unwrap
00024   {
00025   public:
00026   
00027   typedef typename T1::elem_type eT;
00028   
00029   inline unwrap(const T1& A)   // TODO: change this to Base ?
00030     : M(A)
00031     {
00032     arma_extra_debug_sigprint();
00033     }
00034   
00035   const Mat<eT> M;
00036   };
00037 
00038 
00039 
00040 template<typename eT>
00041 class unwrap< Mat<eT> >
00042   {
00043   public:
00044 
00045   inline unwrap(const Mat<eT>& A)
00046     : M(A)
00047     {
00048     arma_extra_debug_sigprint();
00049     }
00050 
00051   const Mat<eT>& M;
00052   };
00053 
00054 
00055 
00056 template<typename eT>
00057 class unwrap< Row<eT> >
00058   {
00059   public:
00060 
00061   inline unwrap(const Row<eT>& A)
00062     : M(A)
00063     {
00064     arma_extra_debug_sigprint();
00065     }
00066 
00067   const Row<eT>& M;
00068   };
00069 
00070 
00071 
00072 template<typename eT>
00073 class unwrap< Col<eT> >
00074   {
00075   public:
00076 
00077   inline unwrap(const Col<eT>& A)
00078     : M(A)
00079     {
00080     arma_extra_debug_sigprint();
00081     }
00082 
00083   const Col<eT>& M;
00084   };
00085 
00086 
00087 
00088 template<typename out_eT, typename T1, typename T2, typename glue_type>
00089 class unwrap< mtGlue<out_eT, T1, T2, glue_type> >
00090   {
00091   public:
00092   
00093   inline unwrap(const mtGlue<out_eT, T1, T2, glue_type>& A)
00094     : M(A)
00095     {
00096     arma_extra_debug_sigprint();
00097     }
00098   
00099   const Mat<out_eT> M;
00100   };
00101 
00102 
00103 template<typename out_eT, typename T1, typename op_type>
00104 class unwrap< mtOp<out_eT, T1, op_type> >
00105   {
00106   public:
00107   
00108   inline unwrap(const mtOp<out_eT, T1, op_type>& A)
00109     : M(A)
00110     {
00111     arma_extra_debug_sigprint();
00112     }
00113   
00114   const Mat<out_eT> M;
00115   };
00116 
00117 
00118 
00119 //
00120 //
00121 //
00122 
00123 
00124 template<typename T1>
00125 class unwrap_check
00126   {
00127   public:
00128   
00129   typedef typename T1::elem_type eT;
00130   
00131   inline
00132   unwrap_check(const T1& A, const Mat<eT>& B)
00133     : M(A)
00134     {
00135     arma_extra_debug_sigprint();
00136     }
00137   
00138   inline
00139   ~unwrap_check()
00140     {
00141     arma_extra_debug_sigprint();
00142     }
00143   
00144   const Mat<eT> M;
00145   };
00146 
00147 
00148 
00149 template<typename eT>
00150 class unwrap_check< Mat<eT> >
00151   {
00152   public:
00153 
00154   inline
00155   unwrap_check(const Mat<eT>& A, const Mat<eT>& B)
00156     : M_local( (&A == &B) ? new Mat<eT>(A) : 0 )
00157     , M      ( (&A == &B) ? (*M_local)     : A )
00158     {
00159     arma_extra_debug_sigprint();
00160     }
00161   
00162   
00163   inline
00164   ~unwrap_check()
00165     {
00166     arma_extra_debug_sigprint();
00167     
00168     if(M_local)
00169       {
00170       delete M_local;
00171       }
00172     }
00173   
00174   
00175   // the order below is important
00176   const Mat<eT>* M_local;
00177   const Mat<eT>& M;
00178   };
00179 
00180 
00181 
00182 template<typename eT>
00183 class unwrap_check< Row<eT> >
00184   {
00185   public:
00186 
00187   inline
00188   unwrap_check(const Row<eT>& A, const Mat<eT>& B)
00189     : M_local( (&A == reinterpret_cast<const Row<eT>*>(&B)) ? new Row<eT>(A) : 0 )
00190     , M      ( (&A == reinterpret_cast<const Row<eT>*>(&B)) ? (*M_local)     : A )
00191     {
00192     arma_extra_debug_sigprint();
00193     }
00194   
00195   
00196   inline
00197   ~unwrap_check()
00198     {
00199     arma_extra_debug_sigprint();
00200     
00201     if(M_local)
00202       {
00203       delete M_local;
00204       }
00205     }
00206   
00207   
00208   // the order below is important
00209   const Row<eT>* M_local;
00210   const Row<eT>& M;
00211   };
00212 
00213 
00214 
00215 template<typename eT>
00216 class unwrap_check< Col<eT> >
00217   {
00218   public:
00219 
00220   inline
00221   unwrap_check(const Col<eT>& A, const Mat<eT>& B)
00222     : M_local( (&A == reinterpret_cast<const Col<eT>*>(&B)) ? new Col<eT>(A) : 0 )
00223     , M      ( (&A == reinterpret_cast<const Col<eT>*>(&B)) ? (*M_local)     : A )
00224     {
00225     arma_extra_debug_sigprint();
00226     }
00227   
00228   
00229   inline
00230   ~unwrap_check()
00231     {
00232     arma_extra_debug_sigprint();
00233     
00234     if(M_local)
00235       {
00236       delete M_local;
00237       }
00238     }
00239   
00240   
00241   // the order below is important
00242   const Col<eT>* M_local;
00243   const Col<eT>& M;
00244   
00245   };
00246 
00247 
00248 
00249 //
00250 
00251 
00252 
00253 template<typename T1>
00254 class partial_unwrap
00255   {
00256   public:
00257   
00258   typedef typename T1::elem_type eT;
00259   
00260   inline partial_unwrap(const T1& A)  // TODO: change this to Base ?
00261     : do_trans(false)
00262     , do_times(false)
00263     , val     (1)
00264     , M       (A)
00265     {
00266     arma_extra_debug_sigprint();
00267     }
00268   
00269   
00270   inline
00271   ~partial_unwrap()
00272     {
00273     arma_extra_debug_sigprint();
00274     }
00275   
00276   const bool    do_trans;
00277   const bool    do_times;
00278   const eT      val;
00279   const Mat<eT> M;
00280   };
00281 
00282 
00283 
00284 template<typename T1>
00285 class partial_unwrap< Op<T1, op_trans> >
00286   {
00287   public:
00288   
00289   typedef typename T1::elem_type eT;
00290   
00291   inline
00292   partial_unwrap(const Op<T1,op_trans>& A)
00293     : do_trans(true)
00294     , do_times(false)
00295     , val     (1)
00296     , M       (A.m)
00297     {
00298     arma_extra_debug_sigprint();
00299     }
00300   
00301   inline
00302   ~partial_unwrap()
00303     {
00304     arma_extra_debug_sigprint();
00305     }
00306   
00307   const bool    do_trans;
00308   const bool    do_times;
00309   const eT      val;
00310   const Mat<eT> M;
00311   };
00312 
00313 
00314 
00315 template<typename T1>
00316 class partial_unwrap< Op<T1, op_trans2> >
00317   {
00318   public:
00319   
00320   typedef typename T1::elem_type eT;
00321   
00322   inline
00323   partial_unwrap(const Op<T1,op_trans2>& A)
00324     : do_trans(true)
00325     , do_times(true)
00326     , val     (A.aux)
00327     , M       (A.m)
00328     {
00329     arma_extra_debug_sigprint();
00330     }
00331   
00332   inline
00333   ~partial_unwrap()
00334     {
00335     arma_extra_debug_sigprint();
00336     }
00337   
00338   const bool    do_trans;
00339   const bool    do_times;
00340   const eT      val;
00341   const Mat<eT> M;
00342   };
00343 
00344 
00345 
00346 template<typename T1>
00347 class partial_unwrap< eOp<T1, eop_scalar_times> >
00348   {
00349   public:
00350   
00351   typedef typename T1::elem_type eT;
00352   
00353   inline
00354   partial_unwrap(const eOp<T1,eop_scalar_times>& A)
00355     : do_trans(false)
00356     , do_times(true)
00357     , val     (A.aux)
00358     , M       (A.P.Q)
00359     {
00360     arma_extra_debug_sigprint();
00361     }
00362   
00363   inline
00364   ~partial_unwrap()
00365     {
00366     arma_extra_debug_sigprint();
00367     }
00368   
00369   const bool    do_trans;
00370   const bool    do_times;
00371   const eT      val;
00372   const Mat<eT> M;
00373   };
00374 
00375 
00376 
00377 template<typename eT>
00378 class partial_unwrap< Mat<eT> >
00379   {
00380   public:
00381   
00382   inline
00383   partial_unwrap(const Mat<eT>& A)
00384     : do_trans(false)
00385     , do_times(false)
00386     , val     (1)
00387     , M       (A)
00388     {
00389     arma_extra_debug_sigprint();
00390     }
00391   
00392   
00393   inline
00394   ~partial_unwrap()
00395     {
00396     arma_extra_debug_sigprint();
00397     }
00398   
00399   
00400   const bool     do_trans;
00401   const bool     do_times;
00402   const eT       val;
00403   const Mat<eT>& M;
00404   };
00405 
00406 
00407 
00408 template<typename eT>
00409 class partial_unwrap< Op< Mat<eT>, op_trans> >
00410   {
00411   public:
00412   
00413   inline
00414   partial_unwrap(const Op< Mat<eT>, op_trans>& A)
00415     : do_trans(true)
00416     , do_times(false)
00417     , val     (1)
00418     , M       (A.m)
00419     {
00420     arma_extra_debug_sigprint();
00421     }
00422   
00423   inline
00424   ~partial_unwrap()
00425     {
00426     arma_extra_debug_sigprint();
00427     }
00428   
00429   
00430   const bool     do_trans;
00431   const bool     do_times;
00432   const eT       val;
00433   const Mat<eT>& M;
00434   };
00435 
00436 
00437 
00438 template<typename eT>
00439 class partial_unwrap< Op< Mat<eT>, op_trans2> >
00440   {
00441   public:
00442   
00443   inline
00444   partial_unwrap(const Op< Mat<eT>, op_trans2>& A)
00445     : do_trans(true)
00446     , do_times(true)
00447     , val     (A.aux)
00448     , M       (A.m)
00449     {
00450     arma_extra_debug_sigprint();
00451     }
00452   
00453   inline
00454   ~partial_unwrap()
00455     {
00456     arma_extra_debug_sigprint();
00457     }
00458   
00459   
00460   const bool     do_trans;
00461   const bool     do_times;
00462   const eT       val;
00463   const Mat<eT>& M;
00464   };
00465 
00466 
00467 
00468 template<typename eT>
00469 class partial_unwrap< eOp<Mat<eT>, eop_scalar_times> >
00470   {
00471   public:
00472   
00473   inline
00474   partial_unwrap(const eOp<Mat<eT>,eop_scalar_times>& A)
00475     : do_trans(false)
00476     , do_times(true)
00477     , val     (A.aux)
00478     , M       (A.P.Q)
00479     {
00480     arma_extra_debug_sigprint();
00481     }
00482   
00483   inline
00484   ~partial_unwrap()
00485     {
00486     arma_extra_debug_sigprint();
00487     }
00488   
00489   const bool     do_trans;
00490   const bool     do_times;
00491   const eT       val;
00492   const Mat<eT>& M;
00493   };
00494 
00495 
00496 
00497 template<typename eT>
00498 class partial_unwrap< Row<eT> >
00499   {
00500   public:
00501   
00502   inline
00503   partial_unwrap(const Row<eT>& A)
00504     : do_trans(false)
00505     , do_times(false)
00506     , val     (1)
00507     , M       (A)
00508     {
00509     arma_extra_debug_sigprint();
00510     }
00511   
00512   
00513   inline
00514   ~partial_unwrap()
00515     {
00516     arma_extra_debug_sigprint();
00517     }
00518   
00519   
00520   const bool     do_trans;
00521   const bool     do_times;
00522   const eT       val;
00523   const Mat<eT>& M;
00524   };
00525 
00526 
00527 
00528 template<typename eT>
00529 class partial_unwrap< Op< Row<eT>, op_trans> >
00530   {
00531   public:
00532   
00533   inline
00534   partial_unwrap(const Op< Row<eT>, op_trans>& A)
00535     : do_trans(true)
00536     , do_times(false)
00537     , val     (1)
00538     , M       (A.m)
00539     {
00540     arma_extra_debug_sigprint();
00541     }
00542   
00543   inline
00544   ~partial_unwrap()
00545     {
00546     arma_extra_debug_sigprint();
00547     }
00548   
00549   
00550   const bool     do_trans;
00551   const bool     do_times;
00552   const eT       val;
00553   const Mat<eT>& M;
00554   };
00555 
00556 
00557 
00558 template<typename eT>
00559 class partial_unwrap< Op< Row<eT>, op_trans2> >
00560   {
00561   public:
00562   
00563   inline
00564   partial_unwrap(const Op< Row<eT>, op_trans2>& A)
00565     : do_trans(true)
00566     , do_times(true)
00567     , val     (A.aux)
00568     , M       (A.m)
00569     {
00570     arma_extra_debug_sigprint();
00571     }
00572   
00573   inline
00574   ~partial_unwrap()
00575     {
00576     arma_extra_debug_sigprint();
00577     }
00578   
00579   
00580   const bool     do_trans;
00581   const bool     do_times;
00582   const eT       val;
00583   const Mat<eT>& M;
00584   };
00585 
00586 
00587 
00588 template<typename eT>
00589 class partial_unwrap< eOp<Row<eT>, eop_scalar_times> >
00590   {
00591   public:
00592   
00593   inline
00594   partial_unwrap(const eOp<Row<eT>,eop_scalar_times>& A)
00595     : do_trans(false)
00596     , do_times(true)
00597     , val     (A.aux)
00598     , M       (A.P.Q)
00599     {
00600     arma_extra_debug_sigprint();
00601     }
00602   
00603   inline
00604   ~partial_unwrap()
00605     {
00606     arma_extra_debug_sigprint();
00607     }
00608   
00609   const bool     do_trans;
00610   const bool     do_times;
00611   const eT       val;
00612   const Mat<eT>& M;
00613   };
00614 
00615 
00616 
00617 template<typename eT>
00618 class partial_unwrap< Col<eT> >
00619   {
00620   public:
00621   
00622   inline
00623   partial_unwrap(const Col<eT>& A)
00624     : do_trans(false)
00625     , do_times(false)
00626     , val     (1)
00627     , M       (A)
00628     {
00629     arma_extra_debug_sigprint();
00630     }
00631   
00632   
00633   inline
00634   ~partial_unwrap()
00635     {
00636     arma_extra_debug_sigprint();
00637     }
00638   
00639   
00640   const bool     do_trans;
00641   const bool     do_times;
00642   const eT       val;
00643   const Mat<eT>& M;
00644   };
00645 
00646 
00647 
00648 template<typename eT>
00649 class partial_unwrap< Op< Col<eT>, op_trans> >
00650   {
00651   public:
00652   
00653   inline
00654   partial_unwrap(const Op< Col<eT>, op_trans>& A)
00655     : do_trans(true)
00656     , do_times(false)
00657     , val     (1)
00658     , M       (A.m)
00659     {
00660     arma_extra_debug_sigprint();
00661     }
00662   
00663   inline
00664   ~partial_unwrap()
00665     {
00666     arma_extra_debug_sigprint();
00667     }
00668   
00669   
00670   const bool     do_trans;
00671   const bool     do_times;
00672   const eT       val;
00673   const Mat<eT>& M;
00674   };
00675 
00676 
00677 
00678 template<typename eT>
00679 class partial_unwrap< Op< Col<eT>, op_trans2> >
00680   {
00681   public:
00682   
00683   inline
00684   partial_unwrap(const Op< Col<eT>, op_trans2>& A)
00685     : do_trans(true)
00686     , do_times(true)
00687     , val     (A.aux)
00688     , M       (A.m)
00689     {
00690     arma_extra_debug_sigprint();
00691     }
00692   
00693   inline
00694   ~partial_unwrap()
00695     {
00696     arma_extra_debug_sigprint();
00697     }
00698   
00699   
00700   const bool     do_trans;
00701   const bool     do_times;
00702   const eT       val;
00703   const Mat<eT>& M;
00704   };
00705 
00706 
00707 
00708 template<typename eT>
00709 class partial_unwrap< eOp<Col<eT>, eop_scalar_times> >
00710   {
00711   public:
00712   
00713   inline
00714   partial_unwrap(const eOp<Col<eT>,eop_scalar_times>& A)
00715     : do_trans(false)
00716     , do_times(true)
00717     , val     (A.aux)
00718     , M       (A.P.Q)
00719     {
00720     arma_extra_debug_sigprint();
00721     }
00722   
00723   inline
00724   ~partial_unwrap()
00725     {
00726     arma_extra_debug_sigprint();
00727     }
00728   
00729   const bool     do_trans;
00730   const bool     do_times;
00731   const eT       val;
00732   const Mat<eT>& M;
00733   };
00734 
00735 
00736 
00737 //
00738 
00739 
00740 
00741 template<typename T1>
00742 class partial_unwrap_check
00743   {
00744   public:
00745   
00746   typedef typename T1::elem_type eT;
00747   
00748   inline partial_unwrap_check(const T1& A, const Mat<eT>& B)
00749     : do_trans(false)
00750     , do_times(false)
00751     , val     (1)
00752     , M       (A)
00753     {
00754     arma_extra_debug_sigprint();
00755     }
00756   
00757   
00758   inline
00759   ~partial_unwrap_check()
00760     {
00761     arma_extra_debug_sigprint();
00762     }
00763   
00764   const bool    do_trans;
00765   const bool    do_times;
00766   const eT      val;
00767   const Mat<eT> M;
00768   };
00769 
00770 
00771 
00772 template<typename T1>
00773 class partial_unwrap_check< Op<T1, op_trans> >
00774   {
00775   public:
00776   
00777   typedef typename T1::elem_type eT;
00778   
00779   inline
00780   partial_unwrap_check(const Op<T1,op_trans>& A, const Mat<eT>& B)
00781     : do_trans(true)
00782     , do_times(false)
00783     , val     (1)
00784     , M       (A.m)
00785     {
00786     arma_extra_debug_sigprint();
00787     }
00788   
00789   inline
00790   ~partial_unwrap_check()
00791     {
00792     arma_extra_debug_sigprint();
00793     }
00794   
00795   const bool    do_trans;
00796   const bool    do_times;
00797   const eT      val;
00798   const Mat<eT> M;
00799   };
00800 
00801 
00802 
00803 template<typename T1>
00804 class partial_unwrap_check< Op<T1, op_trans2> >
00805   {
00806   public:
00807   
00808   typedef typename T1::elem_type eT;
00809   
00810   inline
00811   partial_unwrap_check(const Op<T1,op_trans2>& A, const Mat<eT>& B)
00812     : do_trans(true)
00813     , do_times(true)
00814     , val     (A.aux)
00815     , M       (A.m)
00816     {
00817     arma_extra_debug_sigprint();
00818     }
00819   
00820   inline
00821   ~partial_unwrap_check()
00822     {
00823     arma_extra_debug_sigprint();
00824     }
00825   
00826   const bool    do_trans;
00827   const bool    do_times;
00828   const eT      val;
00829   const Mat<eT> M;
00830   };
00831 
00832 
00833 
00834 template<typename T1>
00835 class partial_unwrap_check< eOp<T1, eop_scalar_times> >
00836   {
00837   public:
00838   
00839   typedef typename T1::elem_type eT;
00840   
00841   inline
00842   partial_unwrap_check(const eOp<T1,eop_scalar_times>& A, const Mat<eT>& B)
00843     : do_trans(false)
00844     , do_times(true)
00845     , val     (A.aux)
00846     , M       (A.P.Q)
00847     {
00848     arma_extra_debug_sigprint();
00849     }
00850   
00851   inline
00852   ~partial_unwrap_check()
00853     {
00854     arma_extra_debug_sigprint();
00855     }
00856   
00857   const bool    do_trans;
00858   const bool    do_times;
00859   const eT      val;
00860   const Mat<eT> M;
00861   };
00862 
00863 
00864 
00865 template<typename eT>
00866 class partial_unwrap_check< Mat<eT> >
00867   {
00868   public:
00869   
00870   inline
00871   partial_unwrap_check(const Mat<eT>& A, const Mat<eT>& B)
00872     : do_trans(false)
00873     , do_times(false)
00874     , val     (1)
00875     , M_local ( (&A == &B) ? new Mat<eT>(A) : 0 )
00876     , M       ( (&A == &B) ? (*M_local)     : A )
00877     {
00878     arma_extra_debug_sigprint();
00879     }
00880   
00881   
00882   inline
00883   ~partial_unwrap_check()
00884     {
00885     arma_extra_debug_sigprint();
00886     
00887     if(M_local)
00888       {
00889       delete M_local;
00890       }
00891     }
00892   
00893   
00894   // the order below is important
00895   const bool     do_trans;
00896   const bool     do_times;
00897   const eT       val;
00898   const Mat<eT>* M_local;
00899   const Mat<eT>& M;
00900   };
00901 
00902 
00903 
00904 template<typename eT>
00905 class partial_unwrap_check< Op< Mat<eT>, op_trans> >
00906   {
00907   public:
00908   
00909   inline
00910   partial_unwrap_check(const Op< Mat<eT>, op_trans>& A, const Mat<eT>& B)
00911     : do_trans(true)
00912     , do_times(false)
00913     , val     (1)
00914     , M_local ( (&A.m == &B) ? new Mat<eT>(A.m) : 0   )
00915     , M       ( (&A.m == &B) ? (*M_local)       : A.m )
00916     {
00917     arma_extra_debug_sigprint();
00918     }
00919   
00920   inline
00921   ~partial_unwrap_check()
00922     {
00923     arma_extra_debug_sigprint();
00924     
00925     if(M_local)
00926       {
00927       delete M_local;
00928       }
00929     }
00930   
00931   
00932   // the order below is important
00933   const bool     do_trans;
00934   const bool     do_times;
00935   const eT       val;
00936   const Mat<eT>* M_local;
00937   const Mat<eT>& M;
00938   };
00939 
00940 
00941 
00942 template<typename eT>
00943 class partial_unwrap_check< Op< Mat<eT>, op_trans2> >
00944   {
00945   public:
00946   
00947   inline
00948   partial_unwrap_check(const Op< Mat<eT>, op_trans2>& A, const Mat<eT>& B)
00949     : do_trans(true)
00950     , do_times(true)
00951     , val     (A.aux)
00952     , M_local ( (&A.m == &B) ? new Mat<eT>(A.m) : 0   )
00953     , M       ( (&A.m == &B) ? (*M_local)       : A.m )
00954     {
00955     arma_extra_debug_sigprint();
00956     }
00957   
00958   inline
00959   ~partial_unwrap_check()
00960     {
00961     arma_extra_debug_sigprint();
00962     
00963     if(M_local)
00964       {
00965       delete M_local;
00966       }
00967     }
00968   
00969   
00970   // the order below is important
00971   const bool     do_trans;
00972   const bool     do_times;
00973   const eT       val;
00974   const Mat<eT>* M_local;
00975   const Mat<eT>& M;
00976   };
00977 
00978 
00979 
00980 template<typename eT>
00981 class partial_unwrap_check< eOp<Mat<eT>, eop_scalar_times> >
00982   {
00983   public:
00984   
00985   inline
00986   partial_unwrap_check(const eOp<Mat<eT>,eop_scalar_times>& A, const Mat<eT>& B)
00987     : do_trans(false)
00988     , do_times(true)
00989     , val     (A.aux)
00990     , M       (A.P.Q)
00991     {
00992     arma_extra_debug_sigprint();
00993     }
00994   
00995   inline
00996   ~partial_unwrap_check()
00997     {
00998     arma_extra_debug_sigprint();
00999     }
01000   
01001   const bool     do_trans;
01002   const bool     do_times;
01003   const eT       val;
01004   const Mat<eT>& M;
01005   };
01006 
01007 
01008 
01009 template<typename eT>
01010 class partial_unwrap_check< Row<eT> >
01011   {
01012   public:
01013   
01014   inline
01015   partial_unwrap_check(const Row<eT>& A, const Mat<eT>& B)
01016     : do_trans(false)
01017     , do_times(false)
01018     , val     (1)
01019     , M_local ( (&A == &B) ? new Mat<eT>(A) : 0 )
01020     , M       ( (&A == &B) ? (*M_local)     : A )
01021     {
01022     arma_extra_debug_sigprint();
01023     }
01024   
01025   
01026   inline
01027   ~partial_unwrap_check()
01028     {
01029     arma_extra_debug_sigprint();
01030     
01031     if(M_local)
01032       {
01033       delete M_local;
01034       }
01035     }
01036   
01037   
01038   // the order below is important
01039   const bool     do_trans;
01040   const bool     do_times;
01041   const eT       val;
01042   const Mat<eT>* M_local;
01043   const Mat<eT>& M;
01044   };
01045 
01046 
01047 
01048 template<typename eT>
01049 class partial_unwrap_check< Op< Row<eT>, op_trans> >
01050   {
01051   public:
01052   
01053   inline
01054   partial_unwrap_check(const Op< Row<eT>, op_trans>& A, const Mat<eT>& B)
01055     : do_trans(true)
01056     , do_times(false)
01057     , val     (1)
01058     , M_local ( (&A.m == &B) ? new Mat<eT>(A.m) : 0   )
01059     , M       ( (&A.m == &B) ? (*M_local)       : A.m )
01060     {
01061     arma_extra_debug_sigprint();
01062     }
01063   
01064   inline
01065   ~partial_unwrap_check()
01066     {
01067     arma_extra_debug_sigprint();
01068     
01069     if(M_local)
01070       {
01071       delete M_local;
01072       }
01073     }
01074   
01075   
01076   // the order below is important
01077   const bool     do_trans;
01078   const bool     do_times;
01079   const eT       val;
01080   const Mat<eT>* M_local;
01081   const Mat<eT>& M;
01082   };
01083 
01084 
01085 
01086 template<typename eT>
01087 class partial_unwrap_check< Op< Row<eT>, op_trans2> >
01088   {
01089   public:
01090   
01091   inline
01092   partial_unwrap_check(const Op< Row<eT>, op_trans2>& A, const Mat<eT>& B)
01093     : do_trans(true)
01094     , do_times(true)
01095     , val     (A.aux)
01096     , M_local ( (&A.m == &B) ? new Mat<eT>(A.m) : 0   )
01097     , M       ( (&A.m == &B) ? (*M_local)       : A.m )
01098     {
01099     arma_extra_debug_sigprint();
01100     }
01101   
01102   inline
01103   ~partial_unwrap_check()
01104     {
01105     arma_extra_debug_sigprint();
01106     
01107     if(M_local)
01108       {
01109       delete M_local;
01110       }
01111     }
01112   
01113   
01114   // the order below is important
01115   const bool     do_trans;
01116   const bool     do_times;
01117   const eT       val;
01118   const Mat<eT>* M_local;
01119   const Mat<eT>& M;
01120   };
01121 
01122 
01123 
01124 template<typename eT>
01125 class partial_unwrap_check< eOp<Row<eT>, eop_scalar_times> >
01126   {
01127   public:
01128   
01129   inline
01130   partial_unwrap_check(const eOp<Row<eT>,eop_scalar_times>& A, const Mat<eT>& B)
01131     : do_trans(false)
01132     , do_times(true)
01133     , val     (A.aux)
01134     , M       (A.P.Q)
01135     {
01136     arma_extra_debug_sigprint();
01137     }
01138   
01139   inline
01140   ~partial_unwrap_check()
01141     {
01142     arma_extra_debug_sigprint();
01143     }
01144   
01145   const bool     do_trans;
01146   const bool     do_times;
01147   const eT       val;
01148   const Mat<eT>& M;
01149   };
01150 
01151 
01152 
01153 template<typename eT>
01154 class partial_unwrap_check< Col<eT> >
01155   {
01156   public:
01157   
01158   inline
01159   partial_unwrap_check(const Col<eT>& A, const Mat<eT>& B)
01160     : do_trans(false)
01161     , do_times(false)
01162     , val     (1)
01163     , M_local ( (&A == &B) ? new Mat<eT>(A) : 0 )
01164     , M       ( (&A == &B) ? (*M_local)     : A )
01165     {
01166     arma_extra_debug_sigprint();
01167     }
01168   
01169   
01170   inline
01171   ~partial_unwrap_check()
01172     {
01173     arma_extra_debug_sigprint();
01174     
01175     if(M_local)
01176       {
01177       delete M_local;
01178       }
01179     }
01180   
01181   
01182   // the order below is important
01183   const bool     do_trans;
01184   const bool     do_times;
01185   const eT       val;
01186   const Mat<eT>* M_local;
01187   const Mat<eT>& M;
01188   };
01189 
01190 
01191 
01192 template<typename eT>
01193 class partial_unwrap_check< Op< Col<eT>, op_trans> >
01194   {
01195   public:
01196   
01197   inline
01198   partial_unwrap_check(const Op< Col<eT>, op_trans>& A, const Mat<eT>& B)
01199     : do_trans(true)
01200     , do_times(false)
01201     , val     (1)
01202     , M_local ( (&A.m == &B) ? new Mat<eT>(A.m) : 0   )
01203     , M       ( (&A.m == &B) ? (*M_local)       : A.m )
01204     {
01205     arma_extra_debug_sigprint();
01206     }
01207   
01208   inline
01209   ~partial_unwrap_check()
01210     {
01211     arma_extra_debug_sigprint();
01212     
01213     if(M_local)
01214       {
01215       delete M_local;
01216       }
01217     }
01218   
01219   
01220   // the order below is important
01221   const bool     do_trans;
01222   const bool     do_times;
01223   const eT       val;
01224   const Mat<eT>* M_local;
01225   const Mat<eT>& M;
01226   };
01227 
01228 
01229 
01230 template<typename eT>
01231 class partial_unwrap_check< Op< Col<eT>, op_trans2> >
01232   {
01233   public:
01234   
01235   inline
01236   partial_unwrap_check(const Op< Mat<eT>, op_trans2>& A, const Mat<eT>& B)
01237     : do_trans(true)
01238     , do_times(true)
01239     , val     (A.aux)
01240     , M_local ( (&A.m == &B) ? new Mat<eT>(A.m) : 0   )
01241     , M       ( (&A.m == &B) ? (*M_local)       : A.m )
01242     {
01243     arma_extra_debug_sigprint();
01244     }
01245   
01246   inline
01247   ~partial_unwrap_check()
01248     {
01249     arma_extra_debug_sigprint();
01250     
01251     if(M_local)
01252       {
01253       delete M_local;
01254       }
01255     }
01256   
01257   
01258   // the order below is important
01259   const bool     do_trans;
01260   const bool     do_times;
01261   const eT       val;
01262   const Mat<eT>* M_local;
01263   const Mat<eT>& M;
01264   };
01265 
01266 
01267 
01268 template<typename eT>
01269 class partial_unwrap_check< eOp<Col<eT>, eop_scalar_times> >
01270   {
01271   public:
01272   
01273   inline
01274   partial_unwrap_check(const eOp<Col<eT>,eop_scalar_times>& A, const Mat<eT>& B)
01275     : do_trans(false)
01276     , do_times(true)
01277     , val     (A.aux)
01278     , M       (A.P.Q)
01279     {
01280     arma_extra_debug_sigprint();
01281     }
01282   
01283   inline
01284   ~partial_unwrap_check()
01285     {
01286     arma_extra_debug_sigprint();
01287     }
01288   
01289   const bool     do_trans;
01290   const bool     do_times;
01291   const eT       val;
01292   const Mat<eT>& M;
01293   };
01294 
01295 
01296 
01297 //! @}