max@0: // Copyright (C) 2010-2011 NICTA (www.nicta.com.au) max@0: // Copyright (C) 2010-2011 Conrad Sanderson max@0: // max@0: // This file is part of the Armadillo C++ library. max@0: // It is provided without any warranty of fitness max@0: // for any purpose. You can redistribute this file max@0: // and/or modify it under the terms of the GNU max@0: // Lesser General Public License (LGPL) as published max@0: // by the Free Software Foundation, either version 3 max@0: // of the License or (at your option) any later version. max@0: // (see http://www.opensource.org/licenses for more info) max@0: max@0: max@0: //! \addtogroup eGlue max@0: //! @{ max@0: max@0: max@0: max@0: template max@0: arma_inline max@0: eGlue::~eGlue() max@0: { max@0: arma_extra_debug_sigprint(); max@0: } max@0: max@0: max@0: max@0: template max@0: arma_inline max@0: eGlue::eGlue(const T1& in_A, const T2& in_B) max@0: : P1(in_A) max@0: , P2(in_B) max@0: { max@0: arma_extra_debug_sigprint(); max@0: max@0: // arma_debug_assert_same_size( P1, P2, eglue_type::text() ); max@0: arma_debug_assert_same_size max@0: ( max@0: P1.get_n_rows(), P1.get_n_cols(), max@0: P2.get_n_rows(), P2.get_n_cols(), max@0: eglue_type::text() max@0: ); max@0: } max@0: max@0: max@0: max@0: template max@0: arma_inline max@0: uword max@0: eGlue::get_n_rows() const max@0: { max@0: return P1.get_n_rows(); max@0: } max@0: max@0: max@0: max@0: template max@0: arma_inline max@0: uword max@0: eGlue::get_n_cols() const max@0: { max@0: return P1.get_n_cols(); max@0: } max@0: max@0: max@0: max@0: template max@0: arma_inline max@0: uword max@0: eGlue::get_n_elem() const max@0: { max@0: return P1.get_n_elem(); max@0: } max@0: max@0: max@0: max@0: template max@0: arma_inline max@0: typename T1::elem_type max@0: eGlue::operator[] (const uword i) const max@0: { max@0: typedef typename T1::elem_type eT; max@0: max@0: // the optimiser will keep only one return statement max@0: max@0: if(is_same_type::value == true) { return P1[i] + P2[i]; } max@0: else if(is_same_type::value == true) { return P1[i] - P2[i]; } max@0: else if(is_same_type::value == true) { return P1[i] / P2[i]; } max@0: else if(is_same_type::value == true) { return P1[i] * P2[i]; } max@0: } max@0: max@0: max@0: template max@0: arma_inline max@0: typename T1::elem_type max@0: eGlue::at(const uword row, const uword col) const max@0: { max@0: typedef typename T1::elem_type eT; max@0: max@0: // the optimiser will keep only one return statement max@0: max@0: if(is_same_type::value == true) { return P1.at(row,col) + P2.at(row,col); } max@0: else if(is_same_type::value == true) { return P1.at(row,col) - P2.at(row,col); } max@0: else if(is_same_type::value == true) { return P1.at(row,col) / P2.at(row,col); } max@0: else if(is_same_type::value == true) { return P1.at(row,col) * P2.at(row,col); } max@0: } max@0: max@0: max@0: max@0: max@0: //! @}