Mercurial > hg > segmenter-vamp-plugin
comparison armadillo-2.4.4/include/armadillo_bits/ProxyCube.hpp @ 0:8b6102e2a9b0
Armadillo Library
author | maxzanoni76 <max.zanoni@eecs.qmul.ac.uk> |
---|---|
date | Wed, 11 Apr 2012 09:27:06 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:8b6102e2a9b0 |
---|---|
1 // Copyright (C) 2010-2012 NICTA (www.nicta.com.au) | |
2 // Copyright (C) 2010-2012 Conrad Sanderson | |
3 // | |
4 // This file is part of the Armadillo C++ library. | |
5 // It is provided without any warranty of fitness | |
6 // for any purpose. You can redistribute this file | |
7 // and/or modify it under the terms of the GNU | |
8 // Lesser General Public License (LGPL) as published | |
9 // by the Free Software Foundation, either version 3 | |
10 // of the License or (at your option) any later version. | |
11 // (see http://www.opensource.org/licenses for more info) | |
12 | |
13 | |
14 //! \addtogroup ProxyCube | |
15 //! @{ | |
16 | |
17 | |
18 | |
19 template<typename T1> | |
20 class ProxyCube | |
21 { | |
22 public: | |
23 inline ProxyCube(const T1& A) | |
24 { | |
25 arma_type_check(( is_arma_cube_type<T1>::value == false )); | |
26 } | |
27 }; | |
28 | |
29 | |
30 | |
31 // ea_type is the "element accessor" type, | |
32 // which can provide access to elements via operator[] | |
33 | |
34 template<typename eT> | |
35 class ProxyCube< Cube<eT> > | |
36 { | |
37 public: | |
38 | |
39 typedef eT elem_type; | |
40 typedef typename get_pod_type<elem_type>::result pod_type; | |
41 typedef Cube<eT> stored_type; | |
42 typedef const eT* ea_type; | |
43 | |
44 static const bool prefer_at_accessor = false; | |
45 static const bool has_subview = false; | |
46 | |
47 arma_aligned const Cube<eT>& Q; | |
48 | |
49 inline explicit ProxyCube(const Cube<eT>& A) | |
50 : Q(A) | |
51 { | |
52 arma_extra_debug_sigprint(); | |
53 } | |
54 | |
55 arma_inline uword get_n_rows() const { return Q.n_rows; } | |
56 arma_inline uword get_n_cols() const { return Q.n_cols; } | |
57 arma_inline uword get_n_elem_slice() const { return Q.n_elem_slice; } | |
58 arma_inline uword get_n_slices() const { return Q.n_slices; } | |
59 arma_inline uword get_n_elem() const { return Q.n_elem; } | |
60 | |
61 arma_inline elem_type operator[] (const uword i) const { return Q[i]; } | |
62 arma_inline elem_type at (const uword row, const uword col, const uword slice) const { return Q.at(row, col, slice); } | |
63 | |
64 arma_inline ea_type get_ea() const { return Q.memptr(); } | |
65 | |
66 template<typename eT2> | |
67 arma_inline bool is_alias(const Cube<eT2>& X) const { return (void_ptr(&Q) == void_ptr(&X)); } | |
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 | |
82 static const bool prefer_at_accessor = false; | |
83 static const bool has_subview = false; | |
84 | |
85 arma_aligned const GenCube<eT, gen_type>& Q; | |
86 | |
87 inline explicit ProxyCube(const GenCube<eT, gen_type>& A) | |
88 : Q(A) | |
89 { | |
90 arma_extra_debug_sigprint(); | |
91 } | |
92 | |
93 arma_inline uword get_n_rows() const { return Q.n_rows; } | |
94 arma_inline uword get_n_cols() const { return Q.n_cols; } | |
95 arma_inline uword get_n_elem_slice() const { return Q.n_rows*Q.n_cols; } | |
96 arma_inline uword get_n_slices() const { return Q.n_slices; } | |
97 arma_inline uword get_n_elem() const { return Q.n_rows*Q.n_cols*Q.n_slices; } | |
98 | |
99 arma_inline elem_type operator[] (const uword i) const { return Q[i]; } | |
100 arma_inline elem_type at (const uword row, const uword col, const uword slice) const { return Q.at(row, col, slice); } | |
101 | |
102 arma_inline ea_type get_ea() const { return Q; } | |
103 | |
104 template<typename eT2> | |
105 arma_inline bool is_alias(const Cube<eT2>&) const { return false; } | |
106 }; | |
107 | |
108 | |
109 | |
110 template<typename T1, typename op_type> | |
111 class ProxyCube< OpCube<T1, op_type> > | |
112 { | |
113 public: | |
114 | |
115 typedef typename T1::elem_type elem_type; | |
116 typedef typename get_pod_type<elem_type>::result pod_type; | |
117 typedef Cube<elem_type> stored_type; | |
118 typedef const elem_type* ea_type; | |
119 | |
120 static const bool prefer_at_accessor = false; | |
121 static const bool has_subview = false; | |
122 | |
123 arma_aligned const Cube<elem_type> Q; | |
124 | |
125 inline explicit ProxyCube(const OpCube<T1, op_type>& A) | |
126 : Q(A) | |
127 { | |
128 arma_extra_debug_sigprint(); | |
129 } | |
130 | |
131 arma_inline uword get_n_rows() const { return Q.n_rows; } | |
132 arma_inline uword get_n_cols() const { return Q.n_cols; } | |
133 arma_inline uword get_n_elem_slice() const { return Q.n_elem_slice; } | |
134 arma_inline uword get_n_slices() const { return Q.n_slices; } | |
135 arma_inline uword get_n_elem() const { return Q.n_elem; } | |
136 | |
137 arma_inline elem_type operator[] (const uword i) const { return Q[i]; } | |
138 arma_inline elem_type at (const uword row, const uword col, const uword slice) const { return Q.at(row, col, slice); } | |
139 | |
140 arma_inline ea_type get_ea() const { return Q.memptr(); } | |
141 | |
142 template<typename eT2> | |
143 arma_inline bool is_alias(const Cube<eT2>&) const { return false; } | |
144 }; | |
145 | |
146 | |
147 | |
148 template<typename T1, typename T2, typename glue_type> | |
149 class ProxyCube< GlueCube<T1, T2, glue_type> > | |
150 { | |
151 public: | |
152 | |
153 typedef typename T1::elem_type elem_type; | |
154 typedef typename get_pod_type<elem_type>::result pod_type; | |
155 typedef Cube<elem_type> stored_type; | |
156 typedef const elem_type* ea_type; | |
157 | |
158 static const bool prefer_at_accessor = false; | |
159 static const bool has_subview = false; | |
160 | |
161 arma_aligned const Cube<elem_type> Q; | |
162 | |
163 inline explicit ProxyCube(const GlueCube<T1, T2, glue_type>& A) | |
164 : Q(A) | |
165 { | |
166 arma_extra_debug_sigprint(); | |
167 } | |
168 | |
169 arma_inline uword get_n_rows() const { return Q.n_rows; } | |
170 arma_inline uword get_n_cols() const { return Q.n_cols; } | |
171 arma_inline uword get_n_elem_slice() const { return Q.n_elem_slice; } | |
172 arma_inline uword get_n_slices() const { return Q.n_slices; } | |
173 arma_inline uword get_n_elem() const { return Q.n_elem; } | |
174 | |
175 arma_inline elem_type operator[] (const uword i) const { return Q[i]; } | |
176 arma_inline elem_type at (const uword row, const uword col, const uword slice) const { return Q.at(row, col, slice); } | |
177 | |
178 arma_inline ea_type get_ea() const { return Q.memptr(); } | |
179 | |
180 template<typename eT2> | |
181 arma_inline bool is_alias(const Cube<eT2>&) const { return false; } | |
182 }; | |
183 | |
184 | |
185 | |
186 template<typename eT> | |
187 class ProxyCube< subview_cube<eT> > | |
188 { | |
189 public: | |
190 | |
191 typedef eT elem_type; | |
192 typedef typename get_pod_type<elem_type>::result pod_type; | |
193 typedef subview_cube<eT> stored_type; | |
194 typedef const subview_cube<eT>& ea_type; | |
195 | |
196 static const bool prefer_at_accessor = true; | |
197 static const bool has_subview = true; | |
198 | |
199 arma_aligned const subview_cube<eT>& Q; | |
200 | |
201 inline explicit ProxyCube(const subview_cube<eT>& A) | |
202 : Q(A) | |
203 { | |
204 arma_extra_debug_sigprint(); | |
205 } | |
206 | |
207 arma_inline uword get_n_rows() const { return Q.n_rows; } | |
208 arma_inline uword get_n_cols() const { return Q.n_cols; } | |
209 arma_inline uword get_n_elem_slice() const { return Q.n_elem_slice; } | |
210 arma_inline uword get_n_slices() const { return Q.n_slices; } | |
211 arma_inline uword get_n_elem() const { return Q.n_elem; } | |
212 | |
213 arma_inline elem_type operator[] (const uword i) const { return Q[i]; } | |
214 arma_inline elem_type at (const uword row, const uword col, const uword slice) const { return Q.at(row, col, slice); } | |
215 | |
216 arma_inline ea_type get_ea() const { return Q; } | |
217 | |
218 template<typename eT2> | |
219 arma_inline bool is_alias(const Cube<eT2>& X) const { return (void_ptr(&(Q.m)) == void_ptr(&X)); } | |
220 }; | |
221 | |
222 | |
223 | |
224 template<typename T1, typename eop_type> | |
225 class ProxyCube< eOpCube<T1, eop_type > > | |
226 { | |
227 public: | |
228 | |
229 typedef typename T1::elem_type elem_type; | |
230 typedef typename get_pod_type<elem_type>::result pod_type; | |
231 typedef eOpCube<T1, eop_type> stored_type; | |
232 typedef const eOpCube<T1, eop_type>& ea_type; | |
233 | |
234 static const bool prefer_at_accessor = eOpCube<T1, eop_type>::prefer_at_accessor; | |
235 static const bool has_subview = eOpCube<T1, eop_type>::has_subview; | |
236 | |
237 arma_aligned const eOpCube<T1, eop_type>& Q; | |
238 | |
239 inline explicit ProxyCube(const eOpCube<T1, eop_type>& A) | |
240 : Q(A) | |
241 { | |
242 arma_extra_debug_sigprint(); | |
243 } | |
244 | |
245 arma_inline uword get_n_rows() const { return Q.get_n_rows(); } | |
246 arma_inline uword get_n_cols() const { return Q.get_n_cols(); } | |
247 arma_inline uword get_n_elem_slice() const { return Q.get_n_elem_slice(); } | |
248 arma_inline uword get_n_slices() const { return Q.get_n_slices(); } | |
249 arma_inline uword get_n_elem() const { return Q.get_n_elem(); } | |
250 | |
251 arma_inline elem_type operator[] (const uword i) const { return Q[i]; } | |
252 arma_inline elem_type at (const uword row, const uword col, const uword slice) const { return Q.at(row, col, slice); } | |
253 | |
254 arma_inline ea_type get_ea() const { return Q; } | |
255 | |
256 template<typename eT2> | |
257 arma_inline bool is_alias(const Cube<eT2>& X) const { return Q.P.is_alias(X); } | |
258 }; | |
259 | |
260 | |
261 | |
262 template<typename T1, typename T2, typename eglue_type> | |
263 class ProxyCube< eGlueCube<T1, T2, eglue_type > > | |
264 { | |
265 public: | |
266 | |
267 typedef typename T1::elem_type elem_type; | |
268 typedef typename get_pod_type<elem_type>::result pod_type; | |
269 typedef eGlueCube<T1, T2, eglue_type> stored_type; | |
270 typedef const eGlueCube<T1, T2, eglue_type>& ea_type; | |
271 | |
272 static const bool prefer_at_accessor = eGlueCube<T1, T2, eglue_type>::prefer_at_accessor; | |
273 static const bool has_subview = eGlueCube<T1, T2, eglue_type>::has_subview; | |
274 | |
275 arma_aligned const eGlueCube<T1, T2, eglue_type>& Q; | |
276 | |
277 inline explicit ProxyCube(const eGlueCube<T1, T2, eglue_type>& A) | |
278 : Q(A) | |
279 { | |
280 arma_extra_debug_sigprint(); | |
281 } | |
282 | |
283 arma_inline uword get_n_rows() const { return Q.get_n_rows(); } | |
284 arma_inline uword get_n_cols() const { return Q.get_n_cols(); } | |
285 arma_inline uword get_n_elem_slice() const { return Q.get_n_elem_slice(); } | |
286 arma_inline uword get_n_slices() const { return Q.get_n_slices(); } | |
287 arma_inline uword get_n_elem() const { return Q.get_n_elem(); } | |
288 | |
289 arma_inline elem_type operator[] (const uword i) const { return Q[i]; } | |
290 arma_inline elem_type at (const uword row, const uword col, const uword slice) const { return Q.at(row, col, slice); } | |
291 | |
292 arma_inline ea_type get_ea() const { return Q; } | |
293 | |
294 template<typename eT2> | |
295 arma_inline bool is_alias(const Cube<eT2>& X) const { return (Q.P1.is_alias(X) || Q.P2.is_alias(X)); } | |
296 }; | |
297 | |
298 | |
299 | |
300 template<typename out_eT, typename T1, typename op_type> | |
301 class ProxyCube< mtOpCube<out_eT, T1, op_type> > | |
302 { | |
303 public: | |
304 | |
305 typedef out_eT elem_type; | |
306 typedef typename get_pod_type<out_eT>::result pod_type; | |
307 typedef Cube<out_eT> stored_type; | |
308 typedef const elem_type* ea_type; | |
309 | |
310 static const bool prefer_at_accessor = false; | |
311 static const bool has_subview = false; | |
312 | |
313 arma_aligned const Cube<out_eT> Q; | |
314 | |
315 inline explicit ProxyCube(const mtOpCube<out_eT, T1, op_type>& A) | |
316 : Q(A) | |
317 { | |
318 arma_extra_debug_sigprint(); | |
319 } | |
320 | |
321 arma_inline uword get_n_rows() const { return Q.n_rows; } | |
322 arma_inline uword get_n_cols() const { return Q.n_cols; } | |
323 arma_inline uword get_n_elem_slice() const { return Q.n_elem_slice; } | |
324 arma_inline uword get_n_slices() const { return Q.n_slices; } | |
325 arma_inline uword get_n_elem() const { return Q.n_elem; } | |
326 | |
327 arma_inline elem_type operator[] (const uword i) const { return Q[i]; } | |
328 arma_inline elem_type at (const uword row, const uword col, const uword slice) const { return Q.at(row, col, slice); } | |
329 | |
330 arma_inline ea_type get_ea() const { return Q.memptr(); } | |
331 | |
332 template<typename eT2> | |
333 arma_inline bool is_alias(const Cube<eT2>&) const { return false; } | |
334 }; | |
335 | |
336 | |
337 | |
338 template<typename out_eT, typename T1, typename T2, typename glue_type> | |
339 class ProxyCube< mtGlueCube<out_eT, T1, T2, glue_type > > | |
340 { | |
341 public: | |
342 | |
343 typedef out_eT elem_type; | |
344 typedef typename get_pod_type<out_eT>::result pod_type; | |
345 typedef Cube<out_eT> stored_type; | |
346 typedef const elem_type* ea_type; | |
347 | |
348 static const bool prefer_at_accessor = false; | |
349 static const bool has_subview = false; | |
350 | |
351 arma_aligned const Cube<out_eT> Q; | |
352 | |
353 inline explicit ProxyCube(const mtGlueCube<out_eT, T1, T2, glue_type>& A) | |
354 : Q(A) | |
355 { | |
356 arma_extra_debug_sigprint(); | |
357 } | |
358 | |
359 arma_inline uword get_n_rows() const { return Q.n_rows; } | |
360 arma_inline uword get_n_cols() const { return Q.n_cols; } | |
361 arma_inline uword get_n_elem_slice() const { return Q.n_elem_slice; } | |
362 arma_inline uword get_n_slices() const { return Q.n_slices; } | |
363 arma_inline uword get_n_elem() const { return Q.n_elem; } | |
364 | |
365 arma_inline elem_type operator[] (const uword i) const { return Q[i]; } | |
366 arma_inline elem_type at (const uword row, const uword col, const uword slice) const { return Q.at(row, col, slice); } | |
367 | |
368 arma_inline ea_type get_ea() const { return Q.memptr(); } | |
369 | |
370 template<typename eT2> | |
371 arma_inline bool is_alias(const Cube<eT2>&) const { return false; } | |
372 }; | |
373 | |
374 | |
375 | |
376 //! @} |