File: ProxyCube.hpp

package info (click to toggle)
armadillo 0.9.52-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 32,820 kB
  • ctags: 82,373
  • sloc: cpp: 32,312; makefile: 94; sh: 19
file content (251 lines) | stat: -rw-r--r-- 7,032 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
// Copyright (C) 2010 NICTA and the authors listed below
// http://nicta.com.au
// 
// Authors:
// - Conrad Sanderson (conradsand at ieee dot org)
// 
// This file is part of the Armadillo C++ library.
// It is provided without any warranty of fitness
// for any purpose. You can redistribute this file
// and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published
// by the Free Software Foundation, either version 3
// of the License or (at your option) any later version.
// (see http://www.opensource.org/licenses for more info)


//! \addtogroup ProxyCube
//! @{



template<typename T1>
class ProxyCube
  {
  public:
  inline ProxyCube(const T1& A)
    {
    arma_type_check< is_arma_type<T1>::value == false >::apply();
    }
  };



template<typename eT>
class ProxyCube< Cube<eT> >
  {
  public:
  
  typedef eT                                       elem_type;
  typedef typename get_pod_type<elem_type>::result pod_type;
  typedef Cube<eT>                                 stored_type;
  
  
  const Cube<eT>& Q;
  
  const u32 n_rows;
  const u32 n_cols;
  const u32 n_elem_slice;
  const u32 n_slices;
  const u32 n_elem;
  
  inline explicit ProxyCube(const Cube<eT>& A)
    : Q           (A)
    , n_rows      (A.n_rows)
    , n_cols      (A.n_cols)
    , n_elem_slice(A.n_elem_slice)
    , n_slices    (A.n_slices)
    , n_elem      (A.n_elem)
    {
    arma_extra_debug_sigprint();
    }
  
  inline explicit ProxyCube(const u32 in_n_rows, const u32 in_n_cols, const u32 in_n_slices)
    : Q           (Q)
    , n_rows      (in_n_rows)
    , n_cols      (in_n_cols)
    , n_elem_slice(in_n_rows*in_n_cols)
    , n_slices    (in_n_slices)
    , n_elem      (in_n_rows*in_n_cols*in_n_slices)
    {
    arma_extra_debug_sigprint();
    }
  
  arma_inline elem_type operator[] (const u32 i)                                   const { return Q[i];                  }
  arma_inline elem_type at         (const u32 row, const u32 col, const u32 slice) const { return Q.at(row, col, slice); }
  };



template<typename T1, typename op_type>
class ProxyCube< OpCube<T1, op_type> >
  {
  public:
  
  typedef typename T1::elem_type                   elem_type;
  typedef typename get_pod_type<elem_type>::result pod_type;
  typedef Cube<elem_type>                          stored_type;
  
  const Cube<elem_type> Q;
  
  const u32 n_rows;
  const u32 n_cols;
  const u32 n_elem_slice;
  const u32 n_slices;
  const u32 n_elem;
  
  inline explicit ProxyCube(const OpCube<T1, op_type>& A)
    : Q           (A)
    , n_rows      (Q.n_rows)
    , n_cols      (Q.n_cols)
    , n_elem_slice(Q.n_elem_slice)
    , n_slices    (Q.n_slices)
    , n_elem      (Q.n_elem)
    {
    arma_extra_debug_sigprint();
    }
  
  arma_inline elem_type operator[] (const u32 i)                                   const { return Q[i];                  }
  arma_inline elem_type at         (const u32 row, const u32 col, const u32 slice) const { return Q.at(row, col, slice); }
  };



template<typename T1, typename T2, typename glue_type>
class ProxyCube< GlueCube<T1, T2, glue_type> >
  {
  public:
  
  typedef typename T1::elem_type                   elem_type;
  typedef typename get_pod_type<elem_type>::result pod_type;
  typedef Cube<elem_type>                          stored_type;
  
  const Cube<elem_type> Q;
  
  const u32 n_rows;
  const u32 n_cols;
  const u32 n_elem_slice;
  const u32 n_slices;
  const u32 n_elem;
  
  inline explicit ProxyCube(const GlueCube<T1, T2, glue_type>& A)
    : Q           (A)
    , n_rows      (Q.n_rows)
    , n_cols      (Q.n_cols)
    , n_elem_slice(Q.n_elem_slice)
    , n_slices    (Q.n_slices)
    , n_elem      (Q.n_elem)
    {
    arma_extra_debug_sigprint();
    }

  arma_inline elem_type operator[] (const u32 i)                                   const { return Q[i];                  }
  arma_inline elem_type at         (const u32 row, const u32 col, const u32 slice) const { return Q.at(row, col, slice); }
  };



template<typename eT>
class ProxyCube< subview_cube<eT> >
  {
  public:
  
  typedef eT                                       elem_type;
  typedef typename get_pod_type<elem_type>::result pod_type;
  typedef subview_cube<eT>                         stored_type;
  
  const subview_cube<eT>& Q;
  
  const u32 n_rows;
  const u32 n_cols;
  const u32 n_elem_slice;
  const u32 n_slices;
  const u32 n_elem;
  
  inline explicit ProxyCube(const subview_cube<eT>& A)
    : Q           (A)
    , n_rows      (A.n_rows)
    , n_cols      (A.n_cols)
    , n_elem_slice(A.n_elem_slice)
    , n_slices    (A.n_slices)
    , n_elem      (A.n_elem)
    {
    arma_extra_debug_sigprint();
    }
  
  arma_inline elem_type operator[] (const u32 i)                                   const { return Q[i];                  }
  arma_inline elem_type at         (const u32 row, const u32 col, const u32 slice) const { return Q.at(row, col, slice); }
  };




template<typename T1, typename eop_type>
class ProxyCube< eOpCube<T1, eop_type > >
  {
  public:
  
  typedef typename T1::elem_type                   elem_type;
  typedef typename get_pod_type<elem_type>::result pod_type;
  typedef eOpCube<T1, eop_type>                    stored_type;
  
  const eOpCube<T1, eop_type>& Q;
  
  const u32 n_rows;
  const u32 n_cols;
  const u32 n_elem_slice;
  const u32 n_slices;
  const u32 n_elem;
  
  inline explicit ProxyCube(const eOpCube<T1, eop_type>& A)
    : Q           (A)
    , n_rows      (A.P.n_rows)
    , n_cols      (A.P.n_cols)
    , n_elem_slice(A.P.n_elem_slice)
    , n_slices    (A.P.n_slices)
    , n_elem      (A.P.n_elem)
    {
    arma_extra_debug_sigprint();
    }
  
  arma_inline elem_type operator[] (const u32 i)                                   const { return eop_type::get_elem(Q, i);               }
  arma_inline elem_type at         (const u32 row, const u32 col, const u32 slice) const { return eop_type::get_elem(Q, row, col, slice); }
  };



template<typename T1, typename T2, typename eglue_type>
class ProxyCube< eGlueCube<T1, T2, eglue_type > >
  {
  public:
  
  typedef typename T1::elem_type                   elem_type;
  typedef typename get_pod_type<elem_type>::result pod_type;
  typedef eGlueCube<T1, T2, eglue_type>            stored_type;
  
  const eGlueCube<T1, T2, eglue_type>& Q;
  
  const u32 n_rows;
  const u32 n_cols;
  const u32 n_elem_slice;
  const u32 n_slices;
  const u32 n_elem;
  
  inline explicit ProxyCube(const eGlueCube<T1, T2, eglue_type>& A)
    : Q           (A)
    , n_rows      (A.P1.n_rows)
    , n_cols      (A.P1.n_cols)
    , n_elem_slice(A.P1.n_elem_slice)
    , n_slices    (A.P1.n_slices)
    , n_elem      (A.P1.n_elem)
    {
    arma_extra_debug_sigprint();
    }
  
  arma_inline elem_type operator[] (const u32 i)                                   const { return eglue_type::get_elem(Q, i);               }
  arma_inline elem_type at         (const u32 row, const u32 col, const u32 slice) const { return eglue_type::get_elem(Q, row, col, slice); }
  };



//! @}