comparison armadillo-3.900.4/include/armadillo_bits/spop_strans_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_strans
10 //! @{
11
12
13
14 template<typename T1>
15 arma_hot
16 inline
17 void
18 spop_strans::apply_proxy(SpMat<typename T1::elem_type>& out, const T1& X)
19 {
20 arma_extra_debug_sigprint();
21
22 const SpProxy<T1> p(X);
23
24 if(p.is_alias(out) == false)
25 {
26 out.set_size( p.get_n_cols(), p.get_n_rows() );
27
28 out.mem_resize(p.get_n_nonzero());
29
30 typename SpProxy<T1>::const_row_iterator_type it = p.begin_row();
31
32 while(it.pos() < p.get_n_nonzero())
33 {
34 access::rw(out.values[it.pos()]) = (*it);
35 access::rw(out.row_indices[it.pos()]) = it.col(); // transpose
36 ++access::rw(out.col_ptrs[it.row() + 1]);
37
38 ++it;
39 }
40
41 // Fix column pointers.
42 const uword out_n_cols = out.n_cols;
43
44 for(uword c = 1; c <= out_n_cols; ++c)
45 {
46 access::rw(out.col_ptrs[c]) += out.col_ptrs[c - 1];
47 }
48 }
49 else
50 {
51 SpMat<typename T1::elem_type> result( p.get_n_cols(), p.get_n_rows() );
52
53 result.mem_resize(p.get_n_nonzero());
54
55 typename SpProxy<T1>::const_row_iterator_type it = p.begin_row();
56
57 while(it.pos() < p.get_n_nonzero())
58 {
59 access::rw(result.values[it.pos()]) = (*it);
60 access::rw(result.row_indices[it.pos()]) = it.col(); // transpose
61 ++access::rw(result.col_ptrs[it.row() + 1]);
62
63 ++it;
64 }
65
66 // Fix column pointers.
67 const uword result_n_cols = result.n_cols;
68
69 for(uword c = 1; c <= result_n_cols; ++c)
70 {
71 access::rw(result.col_ptrs[c]) += result.col_ptrs[c - 1];
72 }
73
74 out.steal_mem(result);
75 }
76 }
77
78
79
80 template<typename T1>
81 arma_hot
82 inline
83 void
84 spop_strans::apply(SpMat<typename T1::elem_type>& out, const SpOp<T1,spop_strans>& in)
85 {
86 arma_extra_debug_sigprint();
87
88 spop_strans::apply_proxy(out, in.m);
89 }
90
91
92
93 //! @}