Chris@49: // Copyright (C) 2010-2013 NICTA (www.nicta.com.au) Chris@49: // Copyright (C) 2010-2013 Conrad Sanderson Chris@49: // Chris@49: // This Source Code Form is subject to the terms of the Mozilla Public Chris@49: // License, v. 2.0. If a copy of the MPL was not distributed with this Chris@49: // file, You can obtain one at http://mozilla.org/MPL/2.0/. Chris@49: Chris@49: Chris@49: //! \addtogroup eGlue Chris@49: //! @{ Chris@49: Chris@49: Chris@49: Chris@49: template Chris@49: arma_inline Chris@49: eGlue::~eGlue() Chris@49: { Chris@49: arma_extra_debug_sigprint(); Chris@49: } Chris@49: Chris@49: Chris@49: Chris@49: template Chris@49: arma_inline Chris@49: eGlue::eGlue(const T1& in_A, const T2& in_B) Chris@49: : P1(in_A) Chris@49: , P2(in_B) Chris@49: { Chris@49: arma_extra_debug_sigprint(); Chris@49: Chris@49: // arma_debug_assert_same_size( P1, P2, eglue_type::text() ); Chris@49: arma_debug_assert_same_size Chris@49: ( Chris@49: P1.get_n_rows(), P1.get_n_cols(), Chris@49: P2.get_n_rows(), P2.get_n_cols(), Chris@49: eglue_type::text() Chris@49: ); Chris@49: } Chris@49: Chris@49: Chris@49: Chris@49: template Chris@49: arma_inline Chris@49: uword Chris@49: eGlue::get_n_rows() const Chris@49: { Chris@49: return is_row ? 1 : ( Proxy::is_fixed ? P1.get_n_rows() : ( Proxy::is_fixed ? P2.get_n_rows() : P1.get_n_rows() ) ); Chris@49: } Chris@49: Chris@49: Chris@49: Chris@49: template Chris@49: arma_inline Chris@49: uword Chris@49: eGlue::get_n_cols() const Chris@49: { Chris@49: return is_col ? 1 : ( Proxy::is_fixed ? P1.get_n_cols() : ( Proxy::is_fixed ? P2.get_n_cols() : P1.get_n_cols() ) ); Chris@49: } Chris@49: Chris@49: Chris@49: Chris@49: template Chris@49: arma_inline Chris@49: uword Chris@49: eGlue::get_n_elem() const Chris@49: { Chris@49: return Proxy::is_fixed ? P1.get_n_elem() : ( Proxy::is_fixed ? P2.get_n_elem() : P1.get_n_elem() ) ; Chris@49: } Chris@49: Chris@49: Chris@49: Chris@49: template Chris@49: arma_inline Chris@49: typename T1::elem_type Chris@49: eGlue::operator[] (const uword ii) const Chris@49: { Chris@49: // the optimiser will keep only one return statement Chris@49: Chris@49: typedef typename T1::elem_type eT; Chris@49: Chris@49: if(is_same_type::value == true) { return P1[ii] + P2[ii]; } Chris@49: else if(is_same_type::value == true) { return P1[ii] - P2[ii]; } Chris@49: else if(is_same_type::value == true) { return P1[ii] / P2[ii]; } Chris@49: else if(is_same_type::value == true) { return P1[ii] * P2[ii]; } Chris@49: else return eT(0); Chris@49: } Chris@49: Chris@49: Chris@49: Chris@49: template Chris@49: arma_inline Chris@49: typename T1::elem_type Chris@49: eGlue::at(const uword row, const uword col) const Chris@49: { Chris@49: // the optimiser will keep only one return statement Chris@49: Chris@49: typedef typename T1::elem_type eT; Chris@49: Chris@49: if(is_same_type::value == true) { return P1.at(row,col) + P2.at(row,col); } Chris@49: else if(is_same_type::value == true) { return P1.at(row,col) - P2.at(row,col); } Chris@49: else if(is_same_type::value == true) { return P1.at(row,col) / P2.at(row,col); } Chris@49: else if(is_same_type::value == true) { return P1.at(row,col) * P2.at(row,col); } Chris@49: else return eT(0); Chris@49: } Chris@49: Chris@49: Chris@49: Chris@49: template Chris@49: arma_inline Chris@49: typename T1::elem_type Chris@49: eGlue::at_alt(const uword ii) const Chris@49: { Chris@49: // the optimiser will keep only one return statement Chris@49: Chris@49: typedef typename T1::elem_type eT; Chris@49: Chris@49: if(is_same_type::value == true) { return P1.at_alt(ii) + P2.at_alt(ii); } Chris@49: else if(is_same_type::value == true) { return P1.at_alt(ii) - P2.at_alt(ii); } Chris@49: else if(is_same_type::value == true) { return P1.at_alt(ii) / P2.at_alt(ii); } Chris@49: else if(is_same_type::value == true) { return P1.at_alt(ii) * P2.at_alt(ii); } Chris@49: else return eT(0); Chris@49: } Chris@49: Chris@49: Chris@49: Chris@49: //! @}