$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 eGlue<T1,T2,eglue_type>::~eGlue() 00022 { 00023 arma_extra_debug_sigprint(); 00024 } 00025 00026 00027 00028 template<typename T1, typename T2, typename eglue_type> 00029 arma_inline 00030 eGlue<T1,T2,eglue_type>::eGlue(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_debug_assert_same_size( P1, P2, eglue_type::text() ); 00037 arma_debug_assert_same_size 00038 ( 00039 P1.get_n_rows(), P1.get_n_cols(), 00040 P2.get_n_rows(), P2.get_n_cols(), 00041 eglue_type::text() 00042 ); 00043 } 00044 00045 00046 00047 template<typename T1, typename T2, typename eglue_type> 00048 arma_inline 00049 uword 00050 eGlue<T1,T2,eglue_type>::get_n_rows() const 00051 { 00052 return P1.get_n_rows(); 00053 } 00054 00055 00056 00057 template<typename T1, typename T2, typename eglue_type> 00058 arma_inline 00059 uword 00060 eGlue<T1,T2,eglue_type>::get_n_cols() const 00061 { 00062 return P1.get_n_cols(); 00063 } 00064 00065 00066 00067 template<typename T1, typename T2, typename eglue_type> 00068 arma_inline 00069 uword 00070 eGlue<T1,T2,eglue_type>::get_n_elem() const 00071 { 00072 return P1.get_n_elem(); 00073 } 00074 00075 00076 00077 template<typename T1, typename T2, typename eglue_type> 00078 arma_inline 00079 typename T1::elem_type 00080 eGlue<T1,T2,eglue_type>::operator[] (const uword i) const 00081 { 00082 typedef typename T1::elem_type eT; 00083 00084 // the optimiser will keep only one return statement 00085 00086 if(is_same_type<eglue_type, eglue_plus >::value == true) { return P1[i] + P2[i]; } 00087 else if(is_same_type<eglue_type, eglue_minus>::value == true) { return P1[i] - P2[i]; } 00088 else if(is_same_type<eglue_type, eglue_div >::value == true) { return P1[i] / P2[i]; } 00089 else if(is_same_type<eglue_type, eglue_schur>::value == true) { return P1[i] * P2[i]; } 00090 } 00091 00092 00093 template<typename T1, typename T2, typename eglue_type> 00094 arma_inline 00095 typename T1::elem_type 00096 eGlue<T1,T2,eglue_type>::at(const uword row, const uword col) const 00097 { 00098 typedef typename T1::elem_type eT; 00099 00100 // the optimiser will keep only one return statement 00101 00102 if(is_same_type<eglue_type, eglue_plus >::value == true) { return P1.at(row,col) + P2.at(row,col); } 00103 else if(is_same_type<eglue_type, eglue_minus>::value == true) { return P1.at(row,col) - P2.at(row,col); } 00104 else if(is_same_type<eglue_type, eglue_div >::value == true) { return P1.at(row,col) / P2.at(row,col); } 00105 else if(is_same_type<eglue_type, eglue_schur>::value == true) { return P1.at(row,col) * P2.at(row,col); } 00106 } 00107 00108 00109 00110