Mercurial > hg > segmenter-vamp-plugin
comparison armadillo-3.900.4/include/armadillo_bits/ProxyCube.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) 2010-2013 NICTA (www.nicta.com.au) | |
2 // Copyright (C) 2010-2013 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 ProxyCube | |
10 //! @{ | |
11 | |
12 | |
13 | |
14 template<typename T1> | |
15 class ProxyCube | |
16 { | |
17 public: | |
18 inline ProxyCube(const T1&) | |
19 { | |
20 arma_type_check(( is_arma_cube_type<T1>::value == false )); | |
21 } | |
22 }; | |
23 | |
24 | |
25 | |
26 // ea_type is the "element accessor" type, | |
27 // which can provide access to elements via operator[] | |
28 | |
29 template<typename eT> | |
30 class ProxyCube< Cube<eT> > | |
31 { | |
32 public: | |
33 | |
34 typedef eT elem_type; | |
35 typedef typename get_pod_type<elem_type>::result pod_type; | |
36 typedef Cube<eT> stored_type; | |
37 typedef const eT* ea_type; | |
38 typedef const Cube<eT>& aligned_ea_type; | |
39 | |
40 static const bool prefer_at_accessor = false; | |
41 static const bool has_subview = false; | |
42 | |
43 arma_aligned const Cube<eT>& Q; | |
44 | |
45 inline explicit ProxyCube(const Cube<eT>& A) | |
46 : Q(A) | |
47 { | |
48 arma_extra_debug_sigprint(); | |
49 } | |
50 | |
51 arma_inline uword get_n_rows() const { return Q.n_rows; } | |
52 arma_inline uword get_n_cols() const { return Q.n_cols; } | |
53 arma_inline uword get_n_elem_slice() const { return Q.n_elem_slice; } | |
54 arma_inline uword get_n_slices() const { return Q.n_slices; } | |
55 arma_inline uword get_n_elem() const { return Q.n_elem; } | |
56 | |
57 arma_inline elem_type operator[] (const uword i) const { return Q[i]; } | |
58 arma_inline elem_type at (const uword row, const uword col, const uword slice) const { return Q.at(row, col, slice); } | |
59 arma_inline elem_type at_alt (const uword i) const { return Q.at_alt(i); } | |
60 | |
61 arma_inline ea_type get_ea() const { return Q.memptr(); } | |
62 arma_inline aligned_ea_type get_aligned_ea() const { return Q; } | |
63 | |
64 template<typename eT2> | |
65 arma_inline bool is_alias(const Cube<eT2>& X) const { return (void_ptr(&Q) == void_ptr(&X)); } | |
66 | |
67 arma_inline bool is_aligned() const { return memory::is_aligned(Q.memptr()); } | |
68 }; | |
69 | |
70 | |
71 | |
72 template<typename eT, typename gen_type> | |
73 class ProxyCube< GenCube<eT, gen_type > > | |
74 { | |
75 public: | |
76 | |
77 typedef eT elem_type; | |
78 typedef typename get_pod_type<elem_type>::result pod_type; | |
79 typedef GenCube<eT, gen_type> stored_type; | |
80 typedef const GenCube<eT, gen_type>& ea_type; | |
81 typedef const GenCube<eT, gen_type>& aligned_ea_type; | |
82 | |
83 static const bool prefer_at_accessor = false; | |
84 static const bool has_subview = false; | |
85 | |
86 arma_aligned const GenCube<eT, gen_type>& Q; | |
87 | |
88 inline explicit ProxyCube(const GenCube<eT, gen_type>& A) | |
89 : Q(A) | |
90 { | |
91 arma_extra_debug_sigprint(); | |
92 } | |
93 | |
94 arma_inline uword get_n_rows() const { return Q.n_rows; } | |
95 arma_inline uword get_n_cols() const { return Q.n_cols; } | |
96 arma_inline uword get_n_elem_slice() const { return Q.n_rows*Q.n_cols; } | |
97 arma_inline uword get_n_slices() const { return Q.n_slices; } | |
98 arma_inline uword get_n_elem() const { return Q.n_rows*Q.n_cols*Q.n_slices; } | |
99 | |
100 arma_inline elem_type operator[] (const uword i) const { return Q[i]; } | |
101 arma_inline elem_type at (const uword row, const uword col, const uword slice) const { return Q.at(row, col, slice); } | |
102 arma_inline elem_type at_alt (const uword i) const { return Q[i]; } | |
103 | |
104 arma_inline ea_type get_ea() const { return Q; } | |
105 arma_inline aligned_ea_type get_aligned_ea() const { return Q; } | |
106 | |
107 template<typename eT2> | |
108 arma_inline bool is_alias(const Cube<eT2>&) const { return false; } | |
109 | |
110 arma_inline bool is_aligned() const { return GenCube<eT, gen_type>::is_simple; } | |
111 }; | |
112 | |
113 | |
114 | |
115 template<typename T1, typename op_type> | |
116 class ProxyCube< OpCube<T1, op_type> > | |
117 { | |
118 public: | |
119 | |
120 typedef typename T1::elem_type elem_type; | |
121 typedef typename get_pod_type<elem_type>::result pod_type; | |
122 typedef Cube<elem_type> stored_type; | |
123 typedef const elem_type* ea_type; | |
124 typedef const Cube<elem_type>& aligned_ea_type; | |
125 | |
126 static const bool prefer_at_accessor = false; | |
127 static const bool has_subview = false; | |
128 | |
129 arma_aligned const Cube<elem_type> Q; | |
130 | |
131 inline explicit ProxyCube(const OpCube<T1, op_type>& A) | |
132 : Q(A) | |
133 { | |
134 arma_extra_debug_sigprint(); | |
135 } | |
136 | |
137 arma_inline uword get_n_rows() const { return Q.n_rows; } | |
138 arma_inline uword get_n_cols() const { return Q.n_cols; } | |
139 arma_inline uword get_n_elem_slice() const { return Q.n_elem_slice; } | |
140 arma_inline uword get_n_slices() const { return Q.n_slices; } | |
141 arma_inline uword get_n_elem() const { return Q.n_elem; } | |
142 | |
143 arma_inline elem_type operator[] (const uword i) const { return Q[i]; } | |
144 arma_inline elem_type at (const uword row, const uword col, const uword slice) const { return Q.at(row, col, slice); } | |
145 arma_inline elem_type at_alt (const uword i) const { return Q.at_alt(i); } | |
146 | |
147 arma_inline ea_type get_ea() const { return Q.memptr(); } | |
148 arma_inline aligned_ea_type get_aligned_ea() const { return Q; } | |
149 | |
150 template<typename eT2> | |
151 arma_inline bool is_alias(const Cube<eT2>&) const { return false; } | |
152 | |
153 arma_inline bool is_aligned() const { return memory::is_aligned(Q.memptr()); } | |
154 }; | |
155 | |
156 | |
157 | |
158 template<typename T1, typename T2, typename glue_type> | |
159 class ProxyCube< GlueCube<T1, T2, glue_type> > | |
160 { | |
161 public: | |
162 | |
163 typedef typename T1::elem_type elem_type; | |
164 typedef typename get_pod_type<elem_type>::result pod_type; | |
165 typedef Cube<elem_type> stored_type; | |
166 typedef const elem_type* ea_type; | |
167 typedef const Cube<elem_type>& aligned_ea_type; | |
168 | |
169 static const bool prefer_at_accessor = false; | |
170 static const bool has_subview = false; | |
171 | |
172 arma_aligned const Cube<elem_type> Q; | |
173 | |
174 inline explicit ProxyCube(const GlueCube<T1, T2, glue_type>& A) | |
175 : Q(A) | |
176 { | |
177 arma_extra_debug_sigprint(); | |
178 } | |
179 | |
180 arma_inline uword get_n_rows() const { return Q.n_rows; } | |
181 arma_inline uword get_n_cols() const { return Q.n_cols; } | |
182 arma_inline uword get_n_elem_slice() const { return Q.n_elem_slice; } | |
183 arma_inline uword get_n_slices() const { return Q.n_slices; } | |
184 arma_inline uword get_n_elem() const { return Q.n_elem; } | |
185 | |
186 arma_inline elem_type operator[] (const uword i) const { return Q[i]; } | |
187 arma_inline elem_type at (const uword row, const uword col, const uword slice) const { return Q.at(row, col, slice); } | |
188 arma_inline elem_type at_alt (const uword i) const { return Q.at_alt(i); } | |
189 | |
190 arma_inline ea_type get_ea() const { return Q.memptr(); } | |
191 arma_inline aligned_ea_type get_aligned_ea() const { return Q; } | |
192 | |
193 template<typename eT2> | |
194 arma_inline bool is_alias(const Cube<eT2>&) const { return false; } | |
195 | |
196 arma_inline bool is_aligned() const { return memory::is_aligned(Q.memptr()); } | |
197 }; | |
198 | |
199 | |
200 | |
201 template<typename eT> | |
202 class ProxyCube< subview_cube<eT> > | |
203 { | |
204 public: | |
205 | |
206 typedef eT elem_type; | |
207 typedef typename get_pod_type<elem_type>::result pod_type; | |
208 typedef subview_cube<eT> stored_type; | |
209 typedef const subview_cube<eT>& ea_type; | |
210 typedef const subview_cube<eT>& aligned_ea_type; | |
211 | |
212 static const bool prefer_at_accessor = true; | |
213 static const bool has_subview = true; | |
214 | |
215 arma_aligned const subview_cube<eT>& Q; | |
216 | |
217 inline explicit ProxyCube(const subview_cube<eT>& A) | |
218 : Q(A) | |
219 { | |
220 arma_extra_debug_sigprint(); | |
221 } | |
222 | |
223 arma_inline uword get_n_rows() const { return Q.n_rows; } | |
224 arma_inline uword get_n_cols() const { return Q.n_cols; } | |
225 arma_inline uword get_n_elem_slice() const { return Q.n_elem_slice; } | |
226 arma_inline uword get_n_slices() const { return Q.n_slices; } | |
227 arma_inline uword get_n_elem() const { return Q.n_elem; } | |
228 | |
229 arma_inline elem_type operator[] (const uword i) const { return Q[i]; } | |
230 arma_inline elem_type at (const uword row, const uword col, const uword slice) const { return Q.at(row, col, slice); } | |
231 arma_inline elem_type at_alt (const uword i) const { return Q.at_alt(i); } | |
232 | |
233 arma_inline ea_type get_ea() const { return Q; } | |
234 arma_inline aligned_ea_type get_aligned_ea() const { return Q; } | |
235 | |
236 template<typename eT2> | |
237 arma_inline bool is_alias(const Cube<eT2>& X) const { return (void_ptr(&(Q.m)) == void_ptr(&X)); } | |
238 | |
239 arma_inline bool is_aligned() const { return false; } | |
240 }; | |
241 | |
242 | |
243 | |
244 template<typename T1, typename eop_type> | |
245 class ProxyCube< eOpCube<T1, eop_type > > | |
246 { | |
247 public: | |
248 | |
249 typedef typename T1::elem_type elem_type; | |
250 typedef typename get_pod_type<elem_type>::result pod_type; | |
251 typedef eOpCube<T1, eop_type> stored_type; | |
252 typedef const eOpCube<T1, eop_type>& ea_type; | |
253 typedef const eOpCube<T1, eop_type>& aligned_ea_type; | |
254 | |
255 static const bool prefer_at_accessor = eOpCube<T1, eop_type>::prefer_at_accessor; | |
256 static const bool has_subview = eOpCube<T1, eop_type>::has_subview; | |
257 | |
258 arma_aligned const eOpCube<T1, eop_type>& Q; | |
259 | |
260 inline explicit ProxyCube(const eOpCube<T1, eop_type>& A) | |
261 : Q(A) | |
262 { | |
263 arma_extra_debug_sigprint(); | |
264 } | |
265 | |
266 arma_inline uword get_n_rows() const { return Q.get_n_rows(); } | |
267 arma_inline uword get_n_cols() const { return Q.get_n_cols(); } | |
268 arma_inline uword get_n_elem_slice() const { return Q.get_n_elem_slice(); } | |
269 arma_inline uword get_n_slices() const { return Q.get_n_slices(); } | |
270 arma_inline uword get_n_elem() const { return Q.get_n_elem(); } | |
271 | |
272 arma_inline elem_type operator[] (const uword i) const { return Q[i]; } | |
273 arma_inline elem_type at (const uword row, const uword col, const uword slice) const { return Q.at(row, col, slice); } | |
274 arma_inline elem_type at_alt (const uword i) const { return Q.at_alt(i); } | |
275 | |
276 arma_inline ea_type get_ea() const { return Q; } | |
277 arma_inline aligned_ea_type get_aligned_ea() const { return Q; } | |
278 | |
279 template<typename eT2> | |
280 arma_inline bool is_alias(const Cube<eT2>& X) const { return Q.P.is_alias(X); } | |
281 | |
282 arma_inline bool is_aligned() const { return Q.P.is_aligned(); } | |
283 }; | |
284 | |
285 | |
286 | |
287 template<typename T1, typename T2, typename eglue_type> | |
288 class ProxyCube< eGlueCube<T1, T2, eglue_type > > | |
289 { | |
290 public: | |
291 | |
292 typedef typename T1::elem_type elem_type; | |
293 typedef typename get_pod_type<elem_type>::result pod_type; | |
294 typedef eGlueCube<T1, T2, eglue_type> stored_type; | |
295 typedef const eGlueCube<T1, T2, eglue_type>& ea_type; | |
296 typedef const eGlueCube<T1, T2, eglue_type>& aligned_ea_type; | |
297 | |
298 static const bool prefer_at_accessor = eGlueCube<T1, T2, eglue_type>::prefer_at_accessor; | |
299 static const bool has_subview = eGlueCube<T1, T2, eglue_type>::has_subview; | |
300 | |
301 arma_aligned const eGlueCube<T1, T2, eglue_type>& Q; | |
302 | |
303 inline explicit ProxyCube(const eGlueCube<T1, T2, eglue_type>& A) | |
304 : Q(A) | |
305 { | |
306 arma_extra_debug_sigprint(); | |
307 } | |
308 | |
309 arma_inline uword get_n_rows() const { return Q.get_n_rows(); } | |
310 arma_inline uword get_n_cols() const { return Q.get_n_cols(); } | |
311 arma_inline uword get_n_elem_slice() const { return Q.get_n_elem_slice(); } | |
312 arma_inline uword get_n_slices() const { return Q.get_n_slices(); } | |
313 arma_inline uword get_n_elem() const { return Q.get_n_elem(); } | |
314 | |
315 arma_inline elem_type operator[] (const uword i) const { return Q[i]; } | |
316 arma_inline elem_type at (const uword row, const uword col, const uword slice) const { return Q.at(row, col, slice); } | |
317 arma_inline elem_type at_alt (const uword i) const { return Q.at_alt(i); } | |
318 | |
319 arma_inline ea_type get_ea() const { return Q; } | |
320 arma_inline aligned_ea_type get_aligned_ea() const { return Q; } | |
321 | |
322 template<typename eT2> | |
323 arma_inline bool is_alias(const Cube<eT2>& X) const { return (Q.P1.is_alias(X) || Q.P2.is_alias(X)); } | |
324 | |
325 arma_inline bool is_aligned() const { return Q.P1.is_aligned() && Q.P2.is_aligned(); } | |
326 }; | |
327 | |
328 | |
329 | |
330 template<typename out_eT, typename T1, typename op_type> | |
331 class ProxyCube< mtOpCube<out_eT, T1, op_type> > | |
332 { | |
333 public: | |
334 | |
335 typedef out_eT elem_type; | |
336 typedef typename get_pod_type<out_eT>::result pod_type; | |
337 typedef Cube<out_eT> stored_type; | |
338 typedef const elem_type* ea_type; | |
339 typedef const Cube<out_eT>& aligned_ea_type; | |
340 | |
341 static const bool prefer_at_accessor = false; | |
342 static const bool has_subview = false; | |
343 | |
344 arma_aligned const Cube<out_eT> Q; | |
345 | |
346 inline explicit ProxyCube(const mtOpCube<out_eT, T1, op_type>& A) | |
347 : Q(A) | |
348 { | |
349 arma_extra_debug_sigprint(); | |
350 } | |
351 | |
352 arma_inline uword get_n_rows() const { return Q.n_rows; } | |
353 arma_inline uword get_n_cols() const { return Q.n_cols; } | |
354 arma_inline uword get_n_elem_slice() const { return Q.n_elem_slice; } | |
355 arma_inline uword get_n_slices() const { return Q.n_slices; } | |
356 arma_inline uword get_n_elem() const { return Q.n_elem; } | |
357 | |
358 arma_inline elem_type operator[] (const uword i) const { return Q[i]; } | |
359 arma_inline elem_type at (const uword row, const uword col, const uword slice) const { return Q.at(row, col, slice); } | |
360 arma_inline elem_type at_alt (const uword i) const { return Q.at_alt(i); } | |
361 | |
362 arma_inline ea_type get_ea() const { return Q.memptr(); } | |
363 arma_inline aligned_ea_type get_aligned_ea() const { return Q; } | |
364 | |
365 template<typename eT2> | |
366 arma_inline bool is_alias(const Cube<eT2>&) const { return false; } | |
367 | |
368 arma_inline bool is_aligned() const { return memory::is_aligned(Q.memptr()); } | |
369 }; | |
370 | |
371 | |
372 | |
373 template<typename out_eT, typename T1, typename T2, typename glue_type> | |
374 class ProxyCube< mtGlueCube<out_eT, T1, T2, glue_type > > | |
375 { | |
376 public: | |
377 | |
378 typedef out_eT elem_type; | |
379 typedef typename get_pod_type<out_eT>::result pod_type; | |
380 typedef Cube<out_eT> stored_type; | |
381 typedef const elem_type* ea_type; | |
382 typedef const Cube<out_eT>& aligned_ea_type; | |
383 | |
384 static const bool prefer_at_accessor = false; | |
385 static const bool has_subview = false; | |
386 | |
387 arma_aligned const Cube<out_eT> Q; | |
388 | |
389 inline explicit ProxyCube(const mtGlueCube<out_eT, T1, T2, glue_type>& A) | |
390 : Q(A) | |
391 { | |
392 arma_extra_debug_sigprint(); | |
393 } | |
394 | |
395 arma_inline uword get_n_rows() const { return Q.n_rows; } | |
396 arma_inline uword get_n_cols() const { return Q.n_cols; } | |
397 arma_inline uword get_n_elem_slice() const { return Q.n_elem_slice; } | |
398 arma_inline uword get_n_slices() const { return Q.n_slices; } | |
399 arma_inline uword get_n_elem() const { return Q.n_elem; } | |
400 | |
401 arma_inline elem_type operator[] (const uword i) const { return Q[i]; } | |
402 arma_inline elem_type at (const uword row, const uword col, const uword slice) const { return Q.at(row, col, slice); } | |
403 arma_inline elem_type at_alt (const uword i) const { return Q.at_alt(i); } | |
404 | |
405 arma_inline ea_type get_ea() const { return Q.memptr(); } | |
406 arma_inline aligned_ea_type get_aligned_ea() const { return Q; } | |
407 | |
408 template<typename eT2> | |
409 arma_inline bool is_alias(const Cube<eT2>&) const { return false; } | |
410 | |
411 arma_inline bool is_aligned() const { return memory::is_aligned(Q.memptr()); } | |
412 }; | |
413 | |
414 | |
415 | |
416 //! @} |