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 eGlueCube Chris@49: //! @{ Chris@49: Chris@49: Chris@49: Chris@49: template Chris@49: arma_inline Chris@49: eGlueCube::~eGlueCube() 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: eGlueCube::eGlueCube(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 Chris@49: ( Chris@49: P1.get_n_rows(), P1.get_n_cols(), P1.get_n_slices(), Chris@49: P2.get_n_rows(), P2.get_n_cols(), P2.get_n_slices(), 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: eGlueCube::get_n_rows() const Chris@49: { Chris@49: return P1.get_n_rows(); Chris@49: } Chris@49: Chris@49: Chris@49: Chris@49: template Chris@49: arma_inline Chris@49: uword Chris@49: eGlueCube::get_n_cols() const Chris@49: { Chris@49: return P1.get_n_cols(); Chris@49: } Chris@49: Chris@49: Chris@49: Chris@49: template Chris@49: arma_inline Chris@49: uword Chris@49: eGlueCube::get_n_slices() const Chris@49: { Chris@49: return P1.get_n_slices(); Chris@49: } Chris@49: Chris@49: Chris@49: Chris@49: template Chris@49: arma_inline Chris@49: uword Chris@49: eGlueCube::get_n_elem_slice() const Chris@49: { Chris@49: return P1.get_n_elem_slice(); Chris@49: } Chris@49: Chris@49: Chris@49: Chris@49: template Chris@49: arma_inline Chris@49: uword Chris@49: eGlueCube::get_n_elem() const Chris@49: { Chris@49: return 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: eGlueCube::operator[] (const uword i) 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[i] + P2[i]; } Chris@49: else if(is_same_type::value == true) { return P1[i] - P2[i]; } Chris@49: else if(is_same_type::value == true) { return P1[i] / P2[i]; } Chris@49: else if(is_same_type::value == true) { return P1[i] * P2[i]; } Chris@49: else return eT(0); Chris@49: } Chris@49: Chris@49: Chris@49: template Chris@49: arma_inline Chris@49: typename T1::elem_type Chris@49: eGlueCube::at(const uword row, const uword col, const uword slice) 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,slice) + P2.at(row,col,slice); } Chris@49: else if(is_same_type::value == true) { return P1.at(row,col,slice) - P2.at(row,col,slice); } Chris@49: else if(is_same_type::value == true) { return P1.at(row,col,slice) / P2.at(row,col,slice); } Chris@49: else if(is_same_type::value == true) { return P1.at(row,col,slice) * P2.at(row,col,slice); } 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: eGlueCube::at_alt(const uword i) 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(i) + P2.at_alt(i); } Chris@49: else if(is_same_type::value == true) { return P1.at_alt(i) - P2.at_alt(i); } Chris@49: else if(is_same_type::value == true) { return P1.at_alt(i) / P2.at_alt(i); } Chris@49: else if(is_same_type::value == true) { return P1.at_alt(i) * P2.at_alt(i); } Chris@49: else return eT(0); Chris@49: } Chris@49: Chris@49: Chris@49: //! @}