ProxyCube.hpp
Go to the documentation of this file.
1 // Copyright (C) 2010-2011 NICTA (www.nicta.com.au)
2 // Copyright (C) 2010-2011 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 
16 
17 
18 
19 template<typename T1>
20 class ProxyCube
21  {
22  public:
23  inline ProxyCube(const T1& A)
24  {
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;
42  typedef const eT* ea_type;
43 
44  static const bool prefer_at_accessor = false;
45  static const bool has_subview = false;
46 
48 
49  inline explicit ProxyCube(const Cube<eT>& A)
50  : Q(A)
51  {
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  arma_inline bool is_alias(const Cube<elem_type>& X) const { return (&Q == &X); }
66  };
67 
68 
69 
70 template<typename eT, typename gen_type>
71 class ProxyCube< GenCube<eT, gen_type > >
72  {
73  public:
74 
75  typedef eT elem_type;
79 
80  static const bool prefer_at_accessor = false;
81  static const bool has_subview = false;
82 
84 
85  inline explicit ProxyCube(const GenCube<eT, gen_type>& A)
86  : Q(A)
87  {
89  }
90 
91  arma_inline uword get_n_rows() const { return Q.n_rows; }
92  arma_inline uword get_n_cols() const { return Q.n_cols; }
93  arma_inline uword get_n_elem_slice() const { return Q.n_rows*Q.n_cols; }
94  arma_inline uword get_n_slices() const { return Q.n_slices; }
95  arma_inline uword get_n_elem() const { return Q.n_rows*Q.n_cols*Q.n_slices; }
96 
97  arma_inline elem_type operator[] (const uword i) const { return Q[i]; }
98  arma_inline elem_type at (const uword row, const uword col, const uword slice) const { return Q.at(row, col, slice); }
99 
100  arma_inline ea_type get_ea() const { return Q; }
101  arma_inline bool is_alias(const Cube<elem_type>&) const { return false; }
102  };
103 
104 
105 
106 template<typename T1, typename op_type>
107 class ProxyCube< OpCube<T1, op_type> >
108  {
109  public:
110 
111  typedef typename T1::elem_type elem_type;
114  typedef const elem_type* ea_type;
115 
116  static const bool prefer_at_accessor = false;
117  static const bool has_subview = false;
118 
120 
121  inline explicit ProxyCube(const OpCube<T1, op_type>& A)
122  : Q(A)
123  {
125  }
126 
127  arma_inline uword get_n_rows() const { return Q.n_rows; }
128  arma_inline uword get_n_cols() const { return Q.n_cols; }
129  arma_inline uword get_n_elem_slice() const { return Q.n_elem_slice; }
130  arma_inline uword get_n_slices() const { return Q.n_slices; }
131  arma_inline uword get_n_elem() const { return Q.n_elem; }
132 
133  arma_inline elem_type operator[] (const uword i) const { return Q[i]; }
134  arma_inline elem_type at (const uword row, const uword col, const uword slice) const { return Q.at(row, col, slice); }
135 
136  arma_inline ea_type get_ea() const { return Q.memptr(); }
137  arma_inline bool is_alias(const Cube<elem_type>&) const { return false; }
138  };
139 
140 
141 
142 template<typename T1, typename T2, typename glue_type>
143 class ProxyCube< GlueCube<T1, T2, glue_type> >
144  {
145  public:
146 
147  typedef typename T1::elem_type elem_type;
150  typedef const elem_type* ea_type;
151 
152  static const bool prefer_at_accessor = false;
153  static const bool has_subview = false;
154 
156 
157  inline explicit ProxyCube(const GlueCube<T1, T2, glue_type>& A)
158  : Q(A)
159  {
161  }
162 
163  arma_inline uword get_n_rows() const { return Q.n_rows; }
164  arma_inline uword get_n_cols() const { return Q.n_cols; }
165  arma_inline uword get_n_elem_slice() const { return Q.n_elem_slice; }
166  arma_inline uword get_n_slices() const { return Q.n_slices; }
167  arma_inline uword get_n_elem() const { return Q.n_elem; }
168 
169  arma_inline elem_type operator[] (const uword i) const { return Q[i]; }
170  arma_inline elem_type at (const uword row, const uword col, const uword slice) const { return Q.at(row, col, slice); }
171 
172  arma_inline ea_type get_ea() const { return Q.memptr(); }
173  arma_inline bool is_alias(const Cube<elem_type>&) const { return false; }
174  };
175 
176 
177 
178 template<typename eT>
180  {
181  public:
182 
183  typedef eT elem_type;
186  typedef const subview_cube<eT>& ea_type;
187 
188  static const bool prefer_at_accessor = true;
189  static const bool has_subview = true;
190 
192 
193  inline explicit ProxyCube(const subview_cube<eT>& A)
194  : Q(A)
195  {
197  }
198 
199  arma_inline uword get_n_rows() const { return Q.n_rows; }
200  arma_inline uword get_n_cols() const { return Q.n_cols; }
201  arma_inline uword get_n_elem_slice() const { return Q.n_elem_slice; }
202  arma_inline uword get_n_slices() const { return Q.n_slices; }
203  arma_inline uword get_n_elem() const { return Q.n_elem; }
204 
205  arma_inline elem_type operator[] (const uword i) const { return Q[i]; }
206  arma_inline elem_type at (const uword row, const uword col, const uword slice) const { return Q.at(row, col, slice); }
207 
208  arma_inline ea_type get_ea() const { return Q; }
209  arma_inline bool is_alias(const Cube<elem_type>& X) const { return (&(Q.m) == &X); }
210  };
211 
212 
213 
214 template<typename T1, typename eop_type>
215 class ProxyCube< eOpCube<T1, eop_type > >
216  {
217  public:
218 
219  typedef typename T1::elem_type elem_type;
223 
224  static const bool prefer_at_accessor = eOpCube<T1, eop_type>::prefer_at_accessor;
225  static const bool has_subview = eOpCube<T1, eop_type>::has_subview;
226 
228 
229  inline explicit ProxyCube(const eOpCube<T1, eop_type>& A)
230  : Q(A)
231  {
233  }
234 
235  arma_inline uword get_n_rows() const { return Q.get_n_rows(); }
236  arma_inline uword get_n_cols() const { return Q.get_n_cols(); }
237  arma_inline uword get_n_elem_slice() const { return Q.get_n_elem_slice(); }
238  arma_inline uword get_n_slices() const { return Q.get_n_slices(); }
239  arma_inline uword get_n_elem() const { return Q.get_n_elem(); }
240 
241  arma_inline elem_type operator[] (const uword i) const { return Q[i]; }
242  arma_inline elem_type at (const uword row, const uword col, const uword slice) const { return Q.at(row, col, slice); }
243 
244  arma_inline ea_type get_ea() const { return Q; }
245  arma_inline bool is_alias(const Cube<elem_type>& X) const { return Q.P.is_alias(X); }
246  };
247 
248 
249 
250 template<typename T1, typename T2, typename eglue_type>
251 class ProxyCube< eGlueCube<T1, T2, eglue_type > >
252  {
253  public:
254 
255  typedef typename T1::elem_type elem_type;
259 
260  static const bool prefer_at_accessor = eGlueCube<T1, T2, eglue_type>::prefer_at_accessor;
261  static const bool has_subview = eGlueCube<T1, T2, eglue_type>::has_subview;
262 
264 
265  inline explicit ProxyCube(const eGlueCube<T1, T2, eglue_type>& A)
266  : Q(A)
267  {
269  }
270 
271  arma_inline uword get_n_rows() const { return Q.get_n_rows(); }
272  arma_inline uword get_n_cols() const { return Q.get_n_cols(); }
273  arma_inline uword get_n_elem_slice() const { return Q.get_n_elem_slice(); }
274  arma_inline uword get_n_slices() const { return Q.get_n_slices(); }
275  arma_inline uword get_n_elem() const { return Q.get_n_elem(); }
276 
277  arma_inline elem_type operator[] (const uword i) const { return Q[i]; }
278  arma_inline elem_type at (const uword row, const uword col, const uword slice) const { return Q.at(row, col, slice); }
279 
280  arma_inline ea_type get_ea() const { return Q; }
281  arma_inline bool is_alias(const Cube<elem_type>& X) const { return (Q.P1.is_alias(X) || Q.P2.is_alias(X)); }
282  };
283 
284 
285 
286 template<typename out_eT, typename T1, typename op_type>
287 class ProxyCube< mtOpCube<out_eT, T1, op_type> >
288  {
289  public:
290 
291  typedef out_eT elem_type;
294  typedef const elem_type* ea_type;
295 
296  static const bool prefer_at_accessor = false;
297  static const bool has_subview = false;
298 
300 
301  inline explicit ProxyCube(const mtOpCube<out_eT, T1, op_type>& A)
302  : Q(A)
303  {
305  }
306 
307  arma_inline uword get_n_rows() const { return Q.n_rows; }
308  arma_inline uword get_n_cols() const { return Q.n_cols; }
309  arma_inline uword get_n_elem_slice() const { return Q.n_elem_slice; }
310  arma_inline uword get_n_slices() const { return Q.n_slices; }
311  arma_inline uword get_n_elem() const { return Q.n_elem; }
312 
313  arma_inline elem_type operator[] (const uword i) const { return Q[i]; }
314  arma_inline elem_type at (const uword row, const uword col, const uword slice) const { return Q.at(row, col, slice); }
315 
316  arma_inline ea_type get_ea() const { return Q.memptr(); }
317  arma_inline bool is_alias(const Cube<out_eT>&) const { return false; }
318  };
319 
320 
321 
322 template<typename out_eT, typename T1, typename T2, typename glue_type>
323 class ProxyCube< mtGlueCube<out_eT, T1, T2, glue_type > >
324  {
325  public:
326 
327  typedef out_eT elem_type;
330  typedef const elem_type* ea_type;
331 
332  static const bool prefer_at_accessor = false;
333  static const bool has_subview = false;
334 
336 
338  : Q(A)
339  {
341  }
342 
343  arma_inline uword get_n_rows() const { return Q.n_rows; }
344  arma_inline uword get_n_cols() const { return Q.n_cols; }
345  arma_inline uword get_n_elem_slice() const { return Q.n_elem_slice; }
346  arma_inline uword get_n_slices() const { return Q.n_slices; }
347  arma_inline uword get_n_elem() const { return Q.n_elem; }
348 
349  arma_inline elem_type operator[] (const uword i) const { return Q[i]; }
350  arma_inline elem_type at (const uword row, const uword col, const uword slice) const { return Q.at(row, col, slice); }
351 
352  arma_inline ea_type get_ea() const { return Q.memptr(); }
353  arma_inline bool is_alias(const Cube<out_eT>&) const { return false; }
354  };
355 
356 
357 
arma_inline elem_type at(const uword row, const uword col, const uword slice) const
Definition: ProxyCube.hpp:206
get_pod_type< elem_type >::result pod_type
Definition: ProxyCube.hpp:76
support class for generator functions (eg. zeros, randu, randn, ...)
arma_inline uword get_n_rows() const
Definition: ProxyCube.hpp:55
get_pod_type< elem_type >::result pod_type
Definition: ProxyCube.hpp:220
arma_inline uword get_n_elem() const
Definition: ProxyCube.hpp:167
get_pod_type< elem_type >::result pod_type
Definition: ProxyCube.hpp:256
arma_aligned const subview_cube< eT > & Q
Definition: ProxyCube.hpp:191
arma_inline elem_type at(const uword row, const uword col, const uword slice) const
Definition: ProxyCube.hpp:134
arma_inline bool is_alias(const Cube< elem_type > &X) const
Definition: ProxyCube.hpp:209
arma_inline uword get_n_rows() const
Definition: ProxyCube.hpp:91
arma_inline uword get_n_cols() const
Definition: ProxyCube.hpp:164
arma_inline elem_type at(const uword row, const uword col, const uword slice) const
Definition: ProxyCube.hpp:170
arma_inline bool is_alias(const Cube< elem_type > &) const
Definition: ProxyCube.hpp:101
ProxyCube(const GlueCube< T1, T2, glue_type > &A)
Definition: ProxyCube.hpp:157
arma_inline ea_type get_ea() const
Definition: ProxyCube.hpp:172
arma_inline uword get_n_elem() const
Definition: ProxyCube.hpp:311
ProxyCube(const subview_cube< eT > &A)
Definition: ProxyCube.hpp:193
arma_inline bool is_alias(const Cube< out_eT > &) const
Definition: ProxyCube.hpp:317
arma_inline elem_type at(const uword row, const uword col, const uword slice) const
Definition: ProxyCube.hpp:98
arma_inline elem_type at(const uword row, const uword col, const uword slice) const
Definition: ProxyCube.hpp:278
arma_inline uword get_n_slices() const
Definition: ProxyCube.hpp:310
ProxyCube(const eOpCube< T1, eop_type > &A)
Definition: ProxyCube.hpp:229
arma_inline uword get_n_rows() const
Definition: ProxyCube.hpp:163
arma_inline uword get_n_cols() const
Definition: ProxyCube.hpp:128
arma_aligned const GenCube< eT, gen_type > & Q
Definition: ProxyCube.hpp:83
arma_inline uword get_n_elem_slice() const
Definition: ProxyCube.hpp:93
const GenCube< eT, gen_type > & ea_type
Definition: ProxyCube.hpp:78
arma_inline uword get_n_slices() const
Definition: ProxyCube.hpp:166
arma_inline uword get_n_elem_slice() const
Definition: ProxyCube.hpp:273
arma_inline uword get_n_slices() const
Definition: ProxyCube.hpp:130
arma_inline uword get_n_elem() const
Definition: ProxyCube.hpp:239
arma_inline uword get_n_slices() const
Definition: ProxyCube.hpp:202
arma_aligned const eOpCube< T1, eop_type > & Q
Definition: ProxyCube.hpp:227
u32 uword
Definition: typedef.hpp:85
arma_inline ea_type get_ea() const
Definition: ProxyCube.hpp:244
arma_aligned const Cube< elem_type > Q
Definition: ProxyCube.hpp:119
#define arma_type_check(condition)
arma_inline uword get_n_rows() const
Definition: ProxyCube.hpp:307
arma_inline bool is_alias(const Cube< out_eT > &) const
Definition: ProxyCube.hpp:353
eGlueCube< T1, T2, eglue_type > stored_type
Definition: ProxyCube.hpp:257
arma_inline uword get_n_elem_slice() const
Definition: ProxyCube.hpp:201
arma_inline uword get_n_elem() const
Definition: ProxyCube.hpp:203
arma_inline bool is_alias(const Cube< elem_type > &X) const
Definition: ProxyCube.hpp:281
arma_inline uword get_n_slices() const
Definition: ProxyCube.hpp:94
get_pod_type< elem_type >::result pod_type
Definition: ProxyCube.hpp:112
const eGlueCube< T1, T2, eglue_type > & ea_type
Definition: ProxyCube.hpp:258
arma_inline uword get_n_cols() const
Definition: ProxyCube.hpp:92
ProxyCube(const mtGlueCube< out_eT, T1, T2, glue_type > &A)
Definition: ProxyCube.hpp:337
arma_inline bool is_alias(const Cube< elem_type > &) const
Definition: ProxyCube.hpp:137
get_pod_type< elem_type >::result pod_type
Definition: ProxyCube.hpp:184
get_pod_type< elem_type >::result pod_type
Definition: ProxyCube.hpp:40
arma_aligned const eGlueCube< T1, T2, eglue_type > & Q
Definition: ProxyCube.hpp:263
arma_inline uword get_n_slices() const
Definition: ProxyCube.hpp:274
arma_inline bool is_alias(const Cube< elem_type > &X) const
Definition: ProxyCube.hpp:65
arma_inline ea_type get_ea() const
Definition: ProxyCube.hpp:280
arma_inline elem_type at(const uword row, const uword col, const uword slice) const
Definition: ProxyCube.hpp:350
arma_aligned const Cube< eT > & Q
Definition: ProxyCube.hpp:47
arma_aligned const Cube< elem_type > Q
Definition: ProxyCube.hpp:155
arma_inline uword get_n_elem() const
Definition: ProxyCube.hpp:275
Dense cube class.
Definition: Cube_bones.hpp:30
ProxyCube(const OpCube< T1, op_type > &A)
Definition: ProxyCube.hpp:121
get_pod_type< out_eT >::result pod_type
Definition: ProxyCube.hpp:292
arma_inline uword get_n_elem() const
Definition: ProxyCube.hpp:131
const eOpCube< T1, eop_type > & ea_type
Definition: ProxyCube.hpp:222
arma_inline ea_type get_ea() const
Definition: ProxyCube.hpp:100
arma_inline ea_type get_ea() const
Definition: ProxyCube.hpp:316
eOpCube< T1, eop_type > stored_type
Definition: ProxyCube.hpp:221
arma_inline uword get_n_elem_slice() const
Definition: ProxyCube.hpp:57
arma_inline uword get_n_rows() const
Definition: ProxyCube.hpp:271
#define arma_aligned
arma_aligned const Cube< out_eT > Q
Definition: ProxyCube.hpp:299
arma_inline uword get_n_slices() const
Definition: ProxyCube.hpp:58
#define arma_extra_debug_sigprint
Definition: debug.hpp:1116
ProxyCube(const T1 &A)
Definition: ProxyCube.hpp:23
Analog of the Op class, intended for cubes.
arma_inline bool is_alias(const Cube< elem_type > &) const
Definition: ProxyCube.hpp:173
arma_inline uword get_n_elem() const
Definition: ProxyCube.hpp:59
ProxyCube(const GenCube< eT, gen_type > &A)
Definition: ProxyCube.hpp:85
arma_inline uword get_n_rows() const
Definition: ProxyCube.hpp:199
arma_inline elem_type at(const uword row, const uword col, const uword slice) const
Definition: ProxyCube.hpp:314
arma_inline elem_type at(const uword row, const uword col, const uword slice) const
Definition: ProxyCube.hpp:242
arma_inline uword get_n_elem_slice() const
Definition: ProxyCube.hpp:309
subview_cube< eT > stored_type
Definition: ProxyCube.hpp:185
arma_inline uword get_n_elem() const
Definition: ProxyCube.hpp:95
#define arma_inline
ProxyCube(const mtOpCube< out_eT, T1, op_type > &A)
Definition: ProxyCube.hpp:301
arma_inline elem_type at(const uword row, const uword col, const uword slice) const
Definition: ProxyCube.hpp:62
arma_inline uword get_n_cols() const
Definition: ProxyCube.hpp:200
arma_inline uword get_n_elem_slice() const
Definition: ProxyCube.hpp:165
arma_inline uword get_n_rows() const
Definition: ProxyCube.hpp:235
arma_inline uword get_n_cols() const
Definition: ProxyCube.hpp:308
const subview_cube< eT > & ea_type
Definition: ProxyCube.hpp:186
arma_inline uword get_n_slices() const
Definition: ProxyCube.hpp:238
arma_inline uword get_n_rows() const
Definition: ProxyCube.hpp:127
ProxyCube(const Cube< eT > &A)
Definition: ProxyCube.hpp:49
arma_inline uword get_n_cols() const
Definition: ProxyCube.hpp:236
arma_inline ea_type get_ea() const
Definition: ProxyCube.hpp:208
get_pod_type< elem_type >::result pod_type
Definition: ProxyCube.hpp:148
arma_inline uword get_n_cols() const
Definition: ProxyCube.hpp:272
arma_inline uword get_n_elem_slice() const
Definition: ProxyCube.hpp:237
arma_inline bool is_alias(const Cube< elem_type > &X) const
Definition: ProxyCube.hpp:245
arma_inline ea_type get_ea() const
Definition: ProxyCube.hpp:136
analog of the Glue class, intended for Cube objects
arma_inline ea_type get_ea() const
Definition: ProxyCube.hpp:64
arma_inline uword get_n_elem_slice() const
Definition: ProxyCube.hpp:129
GenCube< eT, gen_type > stored_type
Definition: ProxyCube.hpp:77
arma_inline uword get_n_cols() const
Definition: ProxyCube.hpp:56
ProxyCube(const eGlueCube< T1, T2, eglue_type > &A)
Definition: ProxyCube.hpp:265


armadillo_matrix
Author(s):
autogenerated on Fri Apr 16 2021 02:31:58