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_cube 00018 //! @{ 00019 00020 00021 00022 template<typename T1> 00023 class unwrap_cube 00024 { 00025 public: 00026 00027 typedef typename T1::elem_type eT; 00028 00029 inline 00030 unwrap_cube(const T1& A) 00031 : M(A) 00032 { 00033 arma_extra_debug_sigprint(); 00034 } 00035 00036 const Cube<eT> M; 00037 }; 00038 00039 00040 00041 template<typename eT> 00042 class unwrap_cube< Cube<eT> > 00043 { 00044 public: 00045 00046 inline 00047 unwrap_cube(const Cube<eT>& A) 00048 : M(A) 00049 { 00050 arma_extra_debug_sigprint(); 00051 } 00052 00053 const Cube<eT>& M; 00054 }; 00055 00056 00057 00058 // 00059 // 00060 // 00061 00062 00063 00064 template<typename T1> 00065 class unwrap_cube_check 00066 { 00067 typedef typename T1::elem_type eT; 00068 00069 inline 00070 unwrap_cube_check(const T1& A, const Cube<eT>& B) 00071 : M(A) 00072 { 00073 arma_extra_debug_sigprint(); 00074 00075 arma_type_check< is_arma_cube_type<T1>::value == false >::apply(); 00076 } 00077 00078 const Cube<eT> M; 00079 }; 00080 00081 00082 00083 template<typename eT> 00084 class unwrap_cube_check< Cube<eT> > 00085 { 00086 public: 00087 00088 inline 00089 unwrap_cube_check(const Cube<eT>& A, const Cube<eT>& B) 00090 : M_local( (&A == &B) ? new Cube<eT>(A) : 0 ) 00091 , M ( (&A == &B) ? (*M_local) : A ) 00092 { 00093 arma_extra_debug_sigprint(); 00094 } 00095 00096 00097 inline 00098 ~unwrap_cube_check() 00099 { 00100 arma_extra_debug_sigprint(); 00101 00102 if(M_local) 00103 { 00104 delete M_local; 00105 } 00106 } 00107 00108 00109 // the order below is important 00110 const Cube<eT>* M_local; 00111 const Cube<eT>& M; 00112 00113 }; 00114 00115 00116 00117 //! @}