Mercurial > hg > segmenter-vamp-plugin
comparison armadillo-3.900.4/include/armadillo_bits/SpProxy.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 //! \addtogroup SpProxy | |
9 //! @{ | |
10 | |
11 | |
12 | |
13 template<typename eT> | |
14 class SpProxy< SpMat<eT> > | |
15 { | |
16 public: | |
17 | |
18 typedef eT elem_type; | |
19 typedef typename get_pod_type<elem_type>::result pod_type; | |
20 typedef SpMat<eT> stored_type; | |
21 | |
22 typedef typename SpMat<eT>::const_iterator const_iterator_type; | |
23 typedef typename SpMat<eT>::const_row_iterator const_row_iterator_type; | |
24 | |
25 static const bool must_use_iterator = false; | |
26 static const bool Q_created_by_proxy = false; | |
27 | |
28 static const bool is_row = false; | |
29 static const bool is_col = false; | |
30 | |
31 arma_aligned const SpMat<eT>& Q; | |
32 | |
33 inline explicit SpProxy(const SpMat<eT>& A) | |
34 : Q(A) | |
35 { | |
36 arma_extra_debug_sigprint(); | |
37 } | |
38 | |
39 arma_inline uword get_n_rows() const { return Q.n_rows; } | |
40 arma_inline uword get_n_cols() const { return Q.n_cols; } | |
41 arma_inline uword get_n_elem() const { return Q.n_elem; } | |
42 arma_inline uword get_n_nonzero() const { return Q.n_nonzero; } | |
43 | |
44 arma_inline elem_type operator[](const uword i) const { return Q[i]; } | |
45 arma_inline elem_type at (const uword row, const uword col) const { return Q.at(row, col); } | |
46 | |
47 arma_inline const eT* get_values() const { return Q.values; } | |
48 arma_inline const uword* get_row_indices() const { return Q.row_indices; } | |
49 arma_inline const uword* get_col_ptrs() const { return Q.col_ptrs; } | |
50 | |
51 arma_inline const_iterator_type begin() const { return Q.begin(); } | |
52 arma_inline const_iterator_type begin_col(const uword col_num) const { return Q.begin_col(col_num); } | |
53 arma_inline const_row_iterator_type begin_row(const uword row_num = 0) const { return Q.begin_row(row_num); } | |
54 | |
55 arma_inline const_iterator_type end() const { return Q.end(); } | |
56 arma_inline const_row_iterator_type end_row() const { return Q.end_row(); } | |
57 arma_inline const_row_iterator_type end_row(const uword row_num) const { return Q.end_row(row_num); } | |
58 | |
59 template<typename eT2> | |
60 arma_inline bool is_alias(const SpMat<eT2>& X) const { return (void_ptr(&Q) == void_ptr(&X)); } | |
61 }; | |
62 | |
63 | |
64 | |
65 template<typename eT> | |
66 class SpProxy< SpCol<eT> > | |
67 { | |
68 public: | |
69 | |
70 typedef eT elem_type; | |
71 typedef typename get_pod_type<elem_type>::result pod_type; | |
72 typedef SpCol<eT> stored_type; | |
73 | |
74 typedef typename SpCol<eT>::const_iterator const_iterator_type; | |
75 typedef typename SpCol<eT>::const_row_iterator const_row_iterator_type; | |
76 | |
77 static const bool must_use_iterator = false; | |
78 static const bool Q_created_by_proxy = false; | |
79 | |
80 static const bool is_row = false; | |
81 static const bool is_col = true; | |
82 | |
83 arma_aligned const SpCol<eT>& Q; | |
84 | |
85 inline explicit SpProxy(const SpCol<eT>& A) | |
86 : Q(A) | |
87 { | |
88 arma_extra_debug_sigprint(); | |
89 } | |
90 | |
91 arma_inline uword get_n_rows() const { return Q.n_rows; } | |
92 arma_inline uword get_n_cols() const { return 1; } | |
93 arma_inline uword get_n_elem() const { return Q.n_elem; } | |
94 arma_inline uword get_n_nonzero() const { return Q.n_nonzero; } | |
95 | |
96 arma_inline elem_type operator[](const uword i) const { return Q[i]; } | |
97 arma_inline elem_type at (const uword row, const uword col) const { return Q.at(row, col); } | |
98 | |
99 arma_inline const eT* get_values() const { return Q.values; } | |
100 arma_inline const uword* get_row_indices() const { return Q.row_indices; } | |
101 arma_inline const uword* get_col_ptrs() const { return Q.col_ptrs; } | |
102 | |
103 arma_inline const_iterator_type begin() const { return Q.begin(); } | |
104 arma_inline const_iterator_type begin_col(const uword col_num) const { return Q.begin(); } | |
105 arma_inline const_row_iterator_type begin_row(const uword row_num = 0) const { return Q.begin_row(row_num); } | |
106 | |
107 arma_inline const_iterator_type end() const { return Q.end(); } | |
108 arma_inline const_row_iterator_type end_row() const { return Q.end_row(); } | |
109 arma_inline const_row_iterator_type end_row(const uword row_num) const { return Q.end_row(row_num); } | |
110 | |
111 template<typename eT2> | |
112 arma_inline bool is_alias(const SpMat<eT2>& X) const { return (void_ptr(&Q) == void_ptr(&X)); } | |
113 }; | |
114 | |
115 | |
116 | |
117 template<typename eT> | |
118 class SpProxy< SpRow<eT> > | |
119 { | |
120 public: | |
121 | |
122 typedef eT elem_type; | |
123 typedef typename get_pod_type<elem_type>::result pod_type; | |
124 typedef SpRow<eT> stored_type; | |
125 | |
126 typedef typename SpRow<eT>::const_iterator const_iterator_type; | |
127 typedef typename SpRow<eT>::const_row_iterator const_row_iterator_type; | |
128 | |
129 static const bool must_use_iterator = false; | |
130 static const bool Q_created_by_proxy = false; | |
131 | |
132 static const bool is_row = true; | |
133 static const bool is_col = false; | |
134 | |
135 arma_aligned const SpRow<eT>& Q; | |
136 | |
137 inline explicit SpProxy(const SpRow<eT>& A) | |
138 : Q(A) | |
139 { | |
140 arma_extra_debug_sigprint(); | |
141 } | |
142 | |
143 arma_inline uword get_n_rows() const { return 1; } | |
144 arma_inline uword get_n_cols() const { return Q.n_cols; } | |
145 arma_inline uword get_n_elem() const { return Q.n_elem; } | |
146 arma_inline uword get_n_nonzero() const { return Q.n_nonzero; } | |
147 | |
148 arma_inline elem_type operator[](const uword i) const { return Q[i]; } | |
149 arma_inline elem_type at (const uword row, const uword col) const { return Q.at(row, col); } | |
150 | |
151 arma_inline const eT* get_values() const { return Q.values; } | |
152 arma_inline const uword* get_row_indices() const { return Q.row_indices; } | |
153 arma_inline const uword* get_col_ptrs() const { return Q.col_ptrs; } | |
154 | |
155 arma_inline const_iterator_type begin() const { return Q.begin(); } | |
156 arma_inline const_iterator_type begin_col(const uword col_num) const { return Q.begin_col(col_num); } | |
157 arma_inline const_row_iterator_type begin_row(const uword row_num = 0) const { return Q.begin_row(row_num); } | |
158 | |
159 arma_inline const_iterator_type end() const { return Q.end(); } | |
160 arma_inline const_row_iterator_type end_row() const { return Q.end_row(); } | |
161 arma_inline const_row_iterator_type end_row(const uword row_num) const { return Q.end_row(row_num); } | |
162 | |
163 template<typename eT2> | |
164 arma_inline bool is_alias(const SpMat<eT2>& X) const { return (void_ptr(&Q) == void_ptr(&X)); } | |
165 }; | |
166 | |
167 | |
168 | |
169 template<typename eT> | |
170 class SpProxy< SpSubview<eT> > | |
171 { | |
172 public: | |
173 | |
174 typedef eT elem_type; | |
175 typedef typename get_pod_type<elem_type>::result pod_type; | |
176 typedef SpSubview<eT> stored_type; | |
177 | |
178 typedef typename SpSubview<eT>::const_iterator const_iterator_type; | |
179 typedef typename SpSubview<eT>::const_row_iterator const_row_iterator_type; | |
180 | |
181 static const bool must_use_iterator = true; | |
182 static const bool Q_created_by_proxy = false; | |
183 | |
184 static const bool is_row = false; | |
185 static const bool is_col = false; | |
186 | |
187 arma_aligned const SpSubview<eT>& Q; | |
188 | |
189 inline explicit SpProxy(const SpSubview<eT>& A) | |
190 : Q(A) | |
191 { | |
192 arma_extra_debug_sigprint(); | |
193 } | |
194 | |
195 arma_inline uword get_n_rows() const { return Q.n_rows; } | |
196 arma_inline uword get_n_cols() const { return Q.n_cols; } | |
197 arma_inline uword get_n_elem() const { return Q.n_elem; } | |
198 arma_inline uword get_n_nonzero() const { return Q.n_nonzero; } | |
199 | |
200 arma_inline elem_type operator[](const uword i) const { return Q[i]; } | |
201 arma_inline elem_type at (const uword row, const uword col) const { return Q.at(row, col); } | |
202 | |
203 arma_inline const eT* get_values() const { return Q.m.values; } | |
204 arma_inline const uword* get_row_indices() const { return Q.m.row_indices; } | |
205 arma_inline const uword* get_col_ptrs() const { return Q.m.col_ptrs; } | |
206 | |
207 arma_inline const_iterator_type begin() const { return Q.begin(); } | |
208 arma_inline const_iterator_type begin_col(const uword col_num) const { return Q.begin_col(col_num); } | |
209 arma_inline const_row_iterator_type begin_row(const uword row_num = 0) const { return Q.begin_row(row_num); } | |
210 | |
211 arma_inline const_iterator_type end() const { return Q.end(); } | |
212 arma_inline const_row_iterator_type end_row() const { return Q.end_row(); } | |
213 arma_inline const_row_iterator_type end_row(const uword row_num) const { return Q.end_row(row_num); } | |
214 | |
215 template<typename eT2> | |
216 arma_inline bool is_alias(const SpMat<eT2>& X) const { return (void_ptr(&Q.m) == void_ptr(&X)); } | |
217 }; | |
218 | |
219 | |
220 | |
221 template<typename T1, typename spop_type> | |
222 class SpProxy< SpOp<T1, spop_type> > | |
223 { | |
224 public: | |
225 | |
226 typedef typename T1::elem_type elem_type; | |
227 typedef typename T1::elem_type eT; | |
228 typedef typename get_pod_type<elem_type>::result pod_type; | |
229 typedef SpMat<eT> stored_type; | |
230 | |
231 typedef typename SpMat<eT>::const_iterator const_iterator_type; | |
232 typedef typename SpMat<eT>::const_row_iterator const_row_iterator_type; | |
233 | |
234 static const bool must_use_iterator = false; | |
235 static const bool Q_created_by_proxy = true; | |
236 | |
237 static const bool is_row = SpOp<T1, spop_type>::is_row; | |
238 static const bool is_col = SpOp<T1, spop_type>::is_col; | |
239 | |
240 arma_aligned const SpMat<eT> Q; | |
241 | |
242 inline explicit SpProxy(const SpOp<T1, spop_type>& A) | |
243 : Q(A) | |
244 { | |
245 arma_extra_debug_sigprint(); | |
246 } | |
247 | |
248 arma_inline uword get_n_rows() const { return is_row ? 1 : Q.n_rows; } | |
249 arma_inline uword get_n_cols() const { return is_col ? 1 : Q.n_cols; } | |
250 arma_inline uword get_n_elem() const { return Q.n_elem; } | |
251 arma_inline uword get_n_nonzero() const { return Q.n_nonzero; } | |
252 | |
253 arma_inline elem_type operator[](const uword i) const { return Q[i]; } | |
254 arma_inline elem_type at (const uword row, const uword col) const { return Q.at(row, col); } | |
255 | |
256 arma_inline const eT* get_values() const { return Q.values; } | |
257 arma_inline const uword* get_row_indices() const { return Q.row_indices; } | |
258 arma_inline const uword* get_col_ptrs() const { return Q.col_ptrs; } | |
259 | |
260 arma_inline const_iterator_type begin() const { return Q.begin(); } | |
261 arma_inline const_iterator_type begin_col(const uword col_num) const { return Q.begin_col(col_num); } | |
262 arma_inline const_row_iterator_type begin_row(const uword row_num = 0) const { return Q.begin_row(row_num); } | |
263 | |
264 arma_inline const_iterator_type end() const { return Q.end(); } | |
265 arma_inline const_row_iterator_type end_row() const { return Q.end_row(); } | |
266 arma_inline const_row_iterator_type end_row(const uword row_num) const { return Q.end_row(row_num); } | |
267 | |
268 template<typename eT2> | |
269 arma_inline bool is_alias(const SpMat<eT2>&) const { return false; } | |
270 }; | |
271 | |
272 | |
273 | |
274 template<typename T1, typename T2, typename spglue_type> | |
275 class SpProxy< SpGlue<T1, T2, spglue_type> > | |
276 { | |
277 public: | |
278 | |
279 typedef typename T1::elem_type elem_type; | |
280 typedef typename T1::elem_type eT; | |
281 typedef typename get_pod_type<elem_type>::result pod_type; | |
282 typedef SpMat<eT> stored_type; | |
283 | |
284 typedef typename SpMat<eT>::const_iterator const_iterator_type; | |
285 typedef typename SpMat<eT>::const_row_iterator const_row_iterator_type; | |
286 | |
287 static const bool must_use_iterator = false; | |
288 static const bool Q_created_by_proxy = true; | |
289 | |
290 static const bool is_row = SpGlue<T1, T2, spglue_type>::is_row; | |
291 static const bool is_col = SpGlue<T1, T2, spglue_type>::is_col; | |
292 | |
293 arma_aligned const SpMat<eT> Q; | |
294 | |
295 inline explicit SpProxy(const SpGlue<T1, T2, spglue_type>& A) | |
296 : Q(A) | |
297 { | |
298 arma_extra_debug_sigprint(); | |
299 } | |
300 | |
301 arma_inline uword get_n_rows() const { return is_row ? 1 : Q.n_rows; } | |
302 arma_inline uword get_n_cols() const { return is_col ? 1 : Q.n_cols; } | |
303 arma_inline uword get_n_elem() const { return Q.n_elem; } | |
304 arma_inline uword get_n_nonzero() const { return Q.n_nonzero; } | |
305 | |
306 arma_inline elem_type operator[](const uword i) const { return Q[i]; } | |
307 arma_inline elem_type at (const uword row, const uword col) const { return Q.at(row, col); } | |
308 | |
309 arma_inline const eT* get_values() const { return Q.values; } | |
310 arma_inline const uword* get_row_indices() const { return Q.row_indices; } | |
311 arma_inline const uword* get_col_ptrs() const { return Q.col_ptrs; } | |
312 | |
313 arma_inline const_iterator_type begin() const { return Q.begin(); } | |
314 arma_inline const_iterator_type begin_col(const uword col_num) const { return Q.begin_col(col_num); } | |
315 arma_inline const_row_iterator_type begin_row(const uword row_num = 0) const { return Q.begin_row(row_num); } | |
316 | |
317 arma_inline const_iterator_type end() const { return Q.end(); } | |
318 arma_inline const_row_iterator_type end_row() const { return Q.end_row(); } | |
319 arma_inline const_row_iterator_type end_row(const uword row_num) const { return Q.end_row(row_num); } | |
320 | |
321 template<typename eT2> | |
322 arma_inline bool is_alias(const SpMat<eT2>&) const { return false; } | |
323 }; | |
324 | |
325 | |
326 | |
327 template<typename out_eT, typename T1, typename spop_type> | |
328 class SpProxy< mtSpOp<out_eT, T1, spop_type> > | |
329 { | |
330 public: | |
331 | |
332 typedef out_eT elem_type; | |
333 typedef typename T1::elem_type eT; | |
334 typedef typename get_pod_type<elem_type>::result pod_type; | |
335 typedef SpMat<out_eT> stored_type; | |
336 | |
337 typedef typename SpMat<out_eT>::const_iterator const_iterator_type; | |
338 typedef typename SpMat<out_eT>::const_row_iterator const_row_iterator_type; | |
339 | |
340 static const bool must_use_iterator = false; | |
341 static const bool Q_created_by_proxy = true; | |
342 | |
343 static const bool is_row = mtSpOp<out_eT, T1, spop_type>::is_row; | |
344 static const bool is_col = mtSpOp<out_eT, T1, spop_type>::is_col; | |
345 | |
346 arma_aligned const SpMat<out_eT> Q; | |
347 | |
348 inline explicit SpProxy(const mtSpOp<out_eT, T1, spop_type>& A) | |
349 : Q(A) | |
350 { | |
351 arma_extra_debug_sigprint(); | |
352 } | |
353 | |
354 arma_inline uword get_n_rows() const { return is_row ? 1 : Q.n_rows; } | |
355 arma_inline uword get_n_cols() const { return is_col ? 1 : Q.n_cols; } | |
356 arma_inline uword get_n_elem() const { return Q.n_elem; } | |
357 arma_inline uword get_n_nonzero() const { return Q.n_nonzero; } | |
358 | |
359 arma_inline elem_type operator[](const uword i) const { return Q[i]; } | |
360 arma_inline elem_type at (const uword row, const uword col) const { return Q.at(row, col); } | |
361 | |
362 arma_inline const eT* get_values() const { return Q.values; } | |
363 arma_inline const uword* get_row_indices() const { return Q.row_indices; } | |
364 arma_inline const uword* get_col_ptrs() const { return Q.col_ptrs; } | |
365 | |
366 arma_inline const_iterator_type begin() const { return Q.begin(); } | |
367 arma_inline const_iterator_type begin_col(const uword col_num) const { return Q.begin_col(col_num); } | |
368 arma_inline const_row_iterator_type begin_row(const uword row_num = 0) const { return Q.begin_row(row_num); } | |
369 | |
370 arma_inline const_iterator_type end() const { return Q.end(); } | |
371 arma_inline const_row_iterator_type end_row() const { return Q.end_row(); } | |
372 arma_inline const_row_iterator_type end_row(const uword row_num) const { return Q.end_row(row_num); } | |
373 | |
374 template<typename eT2> | |
375 arma_inline bool is_alias(const SpMat<eT2>&) const { return false; } | |
376 }; | |
377 | |
378 | |
379 | |
380 //! @} |