Mercurial > hg > segmenter-vamp-plugin
comparison armadillo-3.900.4/include/armadillo_bits/spop_sum_meat.hpp @ 49:1ec0e2823891
Switch to using subrepo copies of qm-dsp, nnls-chroma, vamp-plugin-sdk; update Armadillo version; assume build without external BLAS/LAPACK
author | Chris Cannam |
---|---|
date | Thu, 13 Jun 2013 10:25:24 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
48:69251e11a913 | 49:1ec0e2823891 |
---|---|
1 // Copyright (C) 2012 Ryan Curtin | |
2 // Copyright (C) 2012 Conrad Sanderson | |
3 // | |
4 // This Source Code Form is subject to the terms of the Mozilla Public | |
5 // License, v. 2.0. If a copy of the MPL was not distributed with this | |
6 // file, You can obtain one at http://mozilla.org/MPL/2.0/. | |
7 | |
8 | |
9 //! \addtogroup spop_sum | |
10 //! @{ | |
11 | |
12 | |
13 | |
14 template<typename T1> | |
15 arma_hot | |
16 inline | |
17 void | |
18 spop_sum::apply(SpMat<typename T1::elem_type>& out, const SpOp<T1,spop_sum>& in) | |
19 { | |
20 arma_extra_debug_sigprint(); | |
21 | |
22 typedef typename T1::elem_type eT; | |
23 | |
24 const uword dim = in.aux_uword_a; | |
25 arma_debug_check((dim > 1), "sum(): incorrect usage. dim must be 0 or 1"); | |
26 | |
27 const SpProxy<T1> p(in.m); | |
28 | |
29 if(p.is_alias(out) == false) | |
30 { | |
31 spop_sum::apply_noalias(out, p, dim); | |
32 } | |
33 else | |
34 { | |
35 SpMat<eT> tmp; | |
36 | |
37 spop_sum::apply_noalias(tmp, p, dim); | |
38 | |
39 out.steal_mem(tmp); | |
40 } | |
41 } | |
42 | |
43 | |
44 | |
45 template<typename T1> | |
46 arma_hot | |
47 inline | |
48 void | |
49 spop_sum::apply_noalias(SpMat<typename T1::elem_type>& out, const SpProxy<T1>& p, const uword dim) | |
50 { | |
51 arma_extra_debug_sigprint(); | |
52 | |
53 if(dim == 0) // find the sum in each column | |
54 { | |
55 out.zeros(1, p.get_n_cols()); | |
56 | |
57 typename SpProxy<T1>::const_iterator_type it = p.begin(); | |
58 typename SpProxy<T1>::const_iterator_type it_end = p.end(); | |
59 | |
60 while(it != it_end) | |
61 { | |
62 out.at(0, it.col()) += (*it); | |
63 ++it; | |
64 } | |
65 } | |
66 else // find the sum in each row | |
67 { | |
68 out.zeros(p.get_n_rows(), 1); | |
69 | |
70 typename SpProxy<T1>::const_iterator_type it = p.begin(); | |
71 typename SpProxy<T1>::const_iterator_type it_end = p.end(); | |
72 | |
73 while(it != it_end) | |
74 { | |
75 out.at(it.row(), 0) += (*it); | |
76 ++it; | |
77 } | |
78 } | |
79 } | |
80 | |
81 | |
82 | |
83 //! @} |