// Copyright (C) 2015 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 op_nonzeros //! @{ template inline void op_nonzeros::apply_noalias(Mat& out, const Proxy& P) { arma_extra_debug_sigprint(); typedef typename T1::elem_type eT; const uword N_max = P.get_n_elem(); Mat tmp(N_max, 1); eT* tmp_mem = tmp.memptr(); uword N_nz = 0; if(Proxy::prefer_at_accessor == false) { typename Proxy::ea_type Pea = P.get_ea(); for(uword i=0; i inline void op_nonzeros::apply(Mat& out, const Op& X) { arma_extra_debug_sigprint(); typedef typename T1::elem_type eT; const Proxy P(X.m); if(P.get_n_elem() == 0) { out.set_size(0,1); return; } if(P.is_alias(out)) { Mat out2; op_nonzeros::apply_noalias(out2, P); out.steal_mem(out2); } else { op_nonzeros::apply_noalias(out, P); } } template inline void op_nonzeros::apply_noalias(Mat& out, const SpBase& X) { arma_extra_debug_sigprint(); typedef typename T1::elem_type eT; const SpProxy P(X.get_ref()); const uword N = P.get_n_nonzero(); out.set_size(N,1); if(N > 0) { if(is_SpMat::stored_type>::value) { const unwrap_spmat::stored_type> U(P.Q); arrayops::copy(out.memptr(), U.M.values, N); } else { eT* out_mem = out.memptr(); typename SpProxy::const_iterator_type it = P.begin(); for(uword i=0; i