// Copyright (C) 2013 National ICT Australia (NICTA) // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. // ------------------------------------------------------------------- // // Written by Conrad Sanderson - http://conradsanderson.id.au //! \addtogroup glue_max //! @{ template inline void glue_max::apply(Mat& out, const Proxy& PA, const Proxy& PB) { arma_extra_debug_sigprint(); const uword n_rows = PA.get_n_rows(); const uword n_cols = PA.get_n_cols(); arma_debug_assert_same_size(n_rows, n_cols, PB.get_n_rows(), PB.get_n_cols(), "max(): given matrices must have the same size"); out.set_size(n_rows, n_cols); eT* out_mem = out.memptr(); if( (Proxy::prefer_at_accessor == false) && (Proxy::prefer_at_accessor == false) ) { typename Proxy::ea_type A = PA.get_ea(); typename Proxy::ea_type B = PB.get_ea(); const uword N = PA.get_n_elem(); for(uword i=0; i inline void glue_max::apply(Mat< std::complex >& out, const Proxy& PA, const Proxy& PB) { arma_extra_debug_sigprint(); typedef typename std::complex eT; const uword n_rows = PA.get_n_rows(); const uword n_cols = PA.get_n_cols(); arma_debug_assert_same_size(n_rows, n_cols, PB.get_n_rows(), PB.get_n_cols(), "max(): given matrices must have the same size"); out.set_size(n_rows, n_cols); eT* out_mem = out.memptr(); if( (Proxy::prefer_at_accessor == false) && (Proxy::prefer_at_accessor == false) ) { typename Proxy::ea_type A = PA.get_ea(); typename Proxy::ea_type B = PB.get_ea(); const uword N = PA.get_n_elem(); for(uword i=0; i std::abs(B_val) ) ? A_val : B_val; } } else { for(uword col=0; col < n_cols; ++col) for(uword row=0; row < n_rows; ++row) { const eT A_val = PA.at(row,col); const eT B_val = PB.at(row,col); *out_mem = ( std::abs(A_val) > std::abs(B_val) ) ? A_val : B_val; ++out_mem; } } } template inline void glue_max::apply(Mat& out, const Glue& X) { arma_extra_debug_sigprint(); typedef typename T1::elem_type eT; const Proxy PA(X.A); const Proxy PB(X.B); if(PA.is_alias(out) || PB.is_alias(out)) { Mat tmp; glue_max::apply(tmp, PA, PB); out.steal_mem(tmp); } else { glue_max::apply(out, PA, PB); } } //! @}