$search
00001 // Copyright (C) 2010-2011 NICTA (www.nicta.com.au) 00002 // Copyright (C) 2010-2011 Conrad Sanderson 00003 // 00004 // This file is part of the Armadillo C++ library. 00005 // It is provided without any warranty of fitness 00006 // for any purpose. You can redistribute this file 00007 // and/or modify it under the terms of the GNU 00008 // Lesser General Public License (LGPL) as published 00009 // by the Free Software Foundation, either version 3 00010 // of the License or (at your option) any later version. 00011 // (see http://www.opensource.org/licenses for more info) 00012 00013 00016 00017 00018 00019 template<typename T1, typename T2, typename eglue_type> 00020 arma_inline 00021 eGlueCube<T1,T2,eglue_type>::~eGlueCube() 00022 { 00023 arma_extra_debug_sigprint(); 00024 } 00025 00026 00027 00028 template<typename T1, typename T2, typename eglue_type> 00029 arma_inline 00030 eGlueCube<T1,T2,eglue_type>::eGlueCube(const T1& in_A, const T2& in_B) 00031 : P1(in_A) 00032 , P2(in_B) 00033 { 00034 arma_extra_debug_sigprint(); 00035 00036 arma_assert_same_size 00037 ( 00038 P1.get_n_rows(), P1.get_n_cols(), P1.get_n_slices(), 00039 P2.get_n_rows(), P2.get_n_cols(), P2.get_n_slices(), 00040 eglue_type::text() 00041 ); 00042 } 00043 00044 00045 00046 template<typename T1, typename T2, typename eglue_type> 00047 arma_inline 00048 uword 00049 eGlueCube<T1,T2,eglue_type>::get_n_rows() const 00050 { 00051 return P1.get_n_rows(); 00052 } 00053 00054 00055 00056 template<typename T1, typename T2, typename eglue_type> 00057 arma_inline 00058 uword 00059 eGlueCube<T1,T2,eglue_type>::get_n_cols() const 00060 { 00061 return P1.get_n_cols(); 00062 } 00063 00064 00065 00066 template<typename T1, typename T2, typename eglue_type> 00067 arma_inline 00068 uword 00069 eGlueCube<T1,T2,eglue_type>::get_n_slices() const 00070 { 00071 return P1.get_n_slices(); 00072 } 00073 00074 00075 00076 template<typename T1, typename T2, typename eglue_type> 00077 arma_inline 00078 uword 00079 eGlueCube<T1,T2,eglue_type>::get_n_elem_slice() const 00080 { 00081 return P1.get_n_elem_slice(); 00082 } 00083 00084 00085 00086 template<typename T1, typename T2, typename eglue_type> 00087 arma_inline 00088 uword 00089 eGlueCube<T1,T2,eglue_type>::get_n_elem() const 00090 { 00091 return P1.get_n_elem(); 00092 } 00093 00094 00095 00096 template<typename T1, typename T2, typename eglue_type> 00097 arma_inline 00098 typename T1::elem_type 00099 eGlueCube<T1,T2,eglue_type>::operator[] (const uword i) const 00100 { 00101 typedef typename T1::elem_type eT; 00102 00103 // the optimiser will keep only one return statement 00104 00105 if(is_same_type<eglue_type, eglue_plus >::value == true) { return P1[i] + P2[i]; } 00106 else if(is_same_type<eglue_type, eglue_minus>::value == true) { return P1[i] - P2[i]; } 00107 else if(is_same_type<eglue_type, eglue_div >::value == true) { return P1[i] / P2[i]; } 00108 else if(is_same_type<eglue_type, eglue_schur>::value == true) { return P1[i] * P2[i]; } 00109 } 00110 00111 00112 template<typename T1, typename T2, typename eglue_type> 00113 arma_inline 00114 typename T1::elem_type 00115 eGlueCube<T1,T2,eglue_type>::at(const uword row, const uword col, const uword slice) const 00116 { 00117 typedef typename T1::elem_type eT; 00118 00119 // the optimiser will keep only one return statement 00120 00121 if(is_same_type<eglue_type, eglue_plus >::value == true) { return P1.at(row,col,slice) + P2.at(row,col,slice); } 00122 else if(is_same_type<eglue_type, eglue_minus>::value == true) { return P1.at(row,col,slice) - P2.at(row,col,slice); } 00123 else if(is_same_type<eglue_type, eglue_div >::value == true) { return P1.at(row,col,slice) / P2.at(row,col,slice); } 00124 else if(is_same_type<eglue_type, eglue_schur>::value == true) { return P1.at(row,col,slice) * P2.at(row,col,slice); } 00125 } 00126 00127 00128