Chris@49
|
1 // Copyright (C) 2008-2013 NICTA (www.nicta.com.au)
|
Chris@49
|
2 // Copyright (C) 2008-2013 Conrad Sanderson
|
Chris@49
|
3 //
|
Chris@49
|
4 // This Source Code Form is subject to the terms of the Mozilla Public
|
Chris@49
|
5 // License, v. 2.0. If a copy of the MPL was not distributed with this
|
Chris@49
|
6 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
Chris@49
|
7
|
Chris@49
|
8
|
Chris@49
|
9 //! \addtogroup Cube
|
Chris@49
|
10 //! @{
|
Chris@49
|
11
|
Chris@49
|
12
|
Chris@49
|
13
|
Chris@49
|
14 struct Cube_prealloc
|
Chris@49
|
15 {
|
Chris@49
|
16 static const uword mat_ptrs_size = 4;
|
Chris@49
|
17 static const uword mem_n_elem = 64;
|
Chris@49
|
18 };
|
Chris@49
|
19
|
Chris@49
|
20
|
Chris@49
|
21
|
Chris@49
|
22 //! Dense cube class
|
Chris@49
|
23
|
Chris@49
|
24 template<typename eT>
|
Chris@49
|
25 class Cube : public BaseCube< eT, Cube<eT> >
|
Chris@49
|
26 {
|
Chris@49
|
27 public:
|
Chris@49
|
28
|
Chris@49
|
29 typedef eT elem_type; //!< the type of elements stored in the cube
|
Chris@49
|
30 typedef typename get_pod_type<eT>::result pod_type; //!< if eT is non-complex, pod_type is same as eT. otherwise, pod_type is the underlying type used by std::complex
|
Chris@49
|
31
|
Chris@49
|
32 const uword n_rows; //!< number of rows in each slice (read-only)
|
Chris@49
|
33 const uword n_cols; //!< number of columns in each slice (read-only)
|
Chris@49
|
34 const uword n_elem_slice; //!< number of elements in each slice (read-only)
|
Chris@49
|
35 const uword n_slices; //!< number of slices in the cube (read-only)
|
Chris@49
|
36 const uword n_elem; //!< number of elements in the cube (read-only)
|
Chris@49
|
37 const uword mem_state;
|
Chris@49
|
38
|
Chris@49
|
39 // mem_state = 0: normal cube that can be resized;
|
Chris@49
|
40 // mem_state = 1: use auxiliary memory until change in the number of elements is requested;
|
Chris@49
|
41 // mem_state = 2: use auxiliary memory and don't allow the number of elements to be changed;
|
Chris@49
|
42 // mem_state = 3: fixed size (e.g. via template based size specification).
|
Chris@49
|
43
|
Chris@49
|
44
|
Chris@49
|
45 arma_aligned const Mat<eT>** const mat_ptrs; //!< pointer to an array containing pointers to Mat instances (one for each slice)
|
Chris@49
|
46 arma_aligned const eT* const mem; //!< pointer to the memory used by the cube (memory is read-only)
|
Chris@49
|
47
|
Chris@49
|
48 protected:
|
Chris@49
|
49 arma_align_mem Mat<eT>* mat_ptrs_local[ Cube_prealloc::mat_ptrs_size ];
|
Chris@49
|
50 arma_align_mem eT mem_local[ Cube_prealloc::mem_n_elem ];
|
Chris@49
|
51
|
Chris@49
|
52
|
Chris@49
|
53 public:
|
Chris@49
|
54
|
Chris@49
|
55 inline ~Cube();
|
Chris@49
|
56 inline Cube();
|
Chris@49
|
57
|
Chris@49
|
58 inline Cube(const uword in_rows, const uword in_cols, const uword in_slices);
|
Chris@49
|
59
|
Chris@49
|
60 inline Cube( eT* aux_mem, const uword aux_n_rows, const uword aux_n_cols, const uword aux_n_slices, const bool copy_aux_mem = true, const bool strict = true);
|
Chris@49
|
61 inline Cube(const eT* aux_mem, const uword aux_n_rows, const uword aux_n_cols, const uword aux_n_slices);
|
Chris@49
|
62
|
Chris@49
|
63 arma_inline const Cube& operator=(const eT val);
|
Chris@49
|
64 arma_inline const Cube& operator+=(const eT val);
|
Chris@49
|
65 arma_inline const Cube& operator-=(const eT val);
|
Chris@49
|
66 arma_inline const Cube& operator*=(const eT val);
|
Chris@49
|
67 arma_inline const Cube& operator/=(const eT val);
|
Chris@49
|
68
|
Chris@49
|
69 inline Cube(const Cube& m);
|
Chris@49
|
70 inline const Cube& operator=(const Cube& m);
|
Chris@49
|
71 inline const Cube& operator+=(const Cube& m);
|
Chris@49
|
72 inline const Cube& operator-=(const Cube& m);
|
Chris@49
|
73 inline const Cube& operator%=(const Cube& m);
|
Chris@49
|
74 inline const Cube& operator/=(const Cube& m);
|
Chris@49
|
75
|
Chris@49
|
76 template<typename T1, typename T2>
|
Chris@49
|
77 inline explicit Cube(const BaseCube<pod_type,T1>& A, const BaseCube<pod_type,T2>& B);
|
Chris@49
|
78
|
Chris@49
|
79 inline Cube(const subview_cube<eT>& X);
|
Chris@49
|
80 inline const Cube& operator=(const subview_cube<eT>& X);
|
Chris@49
|
81 inline const Cube& operator+=(const subview_cube<eT>& X);
|
Chris@49
|
82 inline const Cube& operator-=(const subview_cube<eT>& X);
|
Chris@49
|
83 inline const Cube& operator%=(const subview_cube<eT>& X);
|
Chris@49
|
84 inline const Cube& operator/=(const subview_cube<eT>& X);
|
Chris@49
|
85
|
Chris@49
|
86 arma_inline Mat<eT>& slice(const uword in_slice);
|
Chris@49
|
87 arma_inline const Mat<eT>& slice(const uword in_slice) const;
|
Chris@49
|
88
|
Chris@49
|
89 arma_inline subview_cube<eT> slices(const uword in_slice1, const uword in_slice2);
|
Chris@49
|
90 arma_inline const subview_cube<eT> slices(const uword in_slice1, const uword in_slice2) const;
|
Chris@49
|
91
|
Chris@49
|
92 arma_inline subview_cube<eT> subcube(const uword in_row1, const uword in_col1, const uword in_slice1, const uword in_row2, const uword in_col2, const uword in_slice2);
|
Chris@49
|
93 arma_inline const subview_cube<eT> subcube(const uword in_row1, const uword in_col1, const uword in_slice1, const uword in_row2, const uword in_col2, const uword in_slice2) const;
|
Chris@49
|
94
|
Chris@49
|
95 inline subview_cube<eT> subcube(const span& row_span, const span& col_span, const span& slice_span);
|
Chris@49
|
96 inline const subview_cube<eT> subcube(const span& row_span, const span& col_span, const span& slice_span) const;
|
Chris@49
|
97
|
Chris@49
|
98 inline subview_cube<eT> operator()(const span& row_span, const span& col_span, const span& slice_span);
|
Chris@49
|
99 inline const subview_cube<eT> operator()(const span& row_span, const span& col_span, const span& slice_span) const;
|
Chris@49
|
100
|
Chris@49
|
101
|
Chris@49
|
102 inline void shed_slice(const uword slice_num);
|
Chris@49
|
103
|
Chris@49
|
104 inline void shed_slices(const uword in_slice1, const uword in_slice2);
|
Chris@49
|
105
|
Chris@49
|
106 inline void insert_slices(const uword slice_num, const uword N, const bool set_to_zero = true);
|
Chris@49
|
107
|
Chris@49
|
108 template<typename T1>
|
Chris@49
|
109 inline void insert_slices(const uword row_num, const BaseCube<eT,T1>& X);
|
Chris@49
|
110
|
Chris@49
|
111
|
Chris@49
|
112 template<typename gen_type> inline Cube(const GenCube<eT, gen_type>& X);
|
Chris@49
|
113 template<typename gen_type> inline const Cube& operator=(const GenCube<eT, gen_type>& X);
|
Chris@49
|
114 template<typename gen_type> inline const Cube& operator+=(const GenCube<eT, gen_type>& X);
|
Chris@49
|
115 template<typename gen_type> inline const Cube& operator-=(const GenCube<eT, gen_type>& X);
|
Chris@49
|
116 template<typename gen_type> inline const Cube& operator%=(const GenCube<eT, gen_type>& X);
|
Chris@49
|
117 template<typename gen_type> inline const Cube& operator/=(const GenCube<eT, gen_type>& X);
|
Chris@49
|
118
|
Chris@49
|
119 template<typename T1, typename op_type> inline Cube(const OpCube<T1, op_type>& X);
|
Chris@49
|
120 template<typename T1, typename op_type> inline const Cube& operator=(const OpCube<T1, op_type>& X);
|
Chris@49
|
121 template<typename T1, typename op_type> inline const Cube& operator+=(const OpCube<T1, op_type>& X);
|
Chris@49
|
122 template<typename T1, typename op_type> inline const Cube& operator-=(const OpCube<T1, op_type>& X);
|
Chris@49
|
123 template<typename T1, typename op_type> inline const Cube& operator%=(const OpCube<T1, op_type>& X);
|
Chris@49
|
124 template<typename T1, typename op_type> inline const Cube& operator/=(const OpCube<T1, op_type>& X);
|
Chris@49
|
125
|
Chris@49
|
126 template<typename T1, typename eop_type> inline Cube(const eOpCube<T1, eop_type>& X);
|
Chris@49
|
127 template<typename T1, typename eop_type> inline const Cube& operator=(const eOpCube<T1, eop_type>& X);
|
Chris@49
|
128 template<typename T1, typename eop_type> inline const Cube& operator+=(const eOpCube<T1, eop_type>& X);
|
Chris@49
|
129 template<typename T1, typename eop_type> inline const Cube& operator-=(const eOpCube<T1, eop_type>& X);
|
Chris@49
|
130 template<typename T1, typename eop_type> inline const Cube& operator%=(const eOpCube<T1, eop_type>& X);
|
Chris@49
|
131 template<typename T1, typename eop_type> inline const Cube& operator/=(const eOpCube<T1, eop_type>& X);
|
Chris@49
|
132
|
Chris@49
|
133 template<typename T1, typename op_type> inline Cube(const mtOpCube<eT, T1, op_type>& X);
|
Chris@49
|
134 template<typename T1, typename op_type> inline const Cube& operator=(const mtOpCube<eT, T1, op_type>& X);
|
Chris@49
|
135 template<typename T1, typename op_type> inline const Cube& operator+=(const mtOpCube<eT, T1, op_type>& X);
|
Chris@49
|
136 template<typename T1, typename op_type> inline const Cube& operator-=(const mtOpCube<eT, T1, op_type>& X);
|
Chris@49
|
137 template<typename T1, typename op_type> inline const Cube& operator%=(const mtOpCube<eT, T1, op_type>& X);
|
Chris@49
|
138 template<typename T1, typename op_type> inline const Cube& operator/=(const mtOpCube<eT, T1, op_type>& X);
|
Chris@49
|
139
|
Chris@49
|
140 template<typename T1, typename T2, typename glue_type> inline Cube(const GlueCube<T1, T2, glue_type>& X);
|
Chris@49
|
141 template<typename T1, typename T2, typename glue_type> inline const Cube& operator=(const GlueCube<T1, T2, glue_type>& X);
|
Chris@49
|
142 template<typename T1, typename T2, typename glue_type> inline const Cube& operator+=(const GlueCube<T1, T2, glue_type>& X);
|
Chris@49
|
143 template<typename T1, typename T2, typename glue_type> inline const Cube& operator-=(const GlueCube<T1, T2, glue_type>& X);
|
Chris@49
|
144 template<typename T1, typename T2, typename glue_type> inline const Cube& operator%=(const GlueCube<T1, T2, glue_type>& X);
|
Chris@49
|
145 template<typename T1, typename T2, typename glue_type> inline const Cube& operator/=(const GlueCube<T1, T2, glue_type>& X);
|
Chris@49
|
146
|
Chris@49
|
147 template<typename T1, typename T2, typename eglue_type> inline Cube(const eGlueCube<T1, T2, eglue_type>& X);
|
Chris@49
|
148 template<typename T1, typename T2, typename eglue_type> inline const Cube& operator=(const eGlueCube<T1, T2, eglue_type>& X);
|
Chris@49
|
149 template<typename T1, typename T2, typename eglue_type> inline const Cube& operator+=(const eGlueCube<T1, T2, eglue_type>& X);
|
Chris@49
|
150 template<typename T1, typename T2, typename eglue_type> inline const Cube& operator-=(const eGlueCube<T1, T2, eglue_type>& X);
|
Chris@49
|
151 template<typename T1, typename T2, typename eglue_type> inline const Cube& operator%=(const eGlueCube<T1, T2, eglue_type>& X);
|
Chris@49
|
152 template<typename T1, typename T2, typename eglue_type> inline const Cube& operator/=(const eGlueCube<T1, T2, eglue_type>& X);
|
Chris@49
|
153
|
Chris@49
|
154 template<typename T1, typename T2, typename glue_type> inline Cube(const mtGlueCube<eT, T1, T2, glue_type>& X);
|
Chris@49
|
155 template<typename T1, typename T2, typename glue_type> inline const Cube& operator=(const mtGlueCube<eT, T1, T2, glue_type>& X);
|
Chris@49
|
156 template<typename T1, typename T2, typename glue_type> inline const Cube& operator+=(const mtGlueCube<eT, T1, T2, glue_type>& X);
|
Chris@49
|
157 template<typename T1, typename T2, typename glue_type> inline const Cube& operator-=(const mtGlueCube<eT, T1, T2, glue_type>& X);
|
Chris@49
|
158 template<typename T1, typename T2, typename glue_type> inline const Cube& operator%=(const mtGlueCube<eT, T1, T2, glue_type>& X);
|
Chris@49
|
159 template<typename T1, typename T2, typename glue_type> inline const Cube& operator/=(const mtGlueCube<eT, T1, T2, glue_type>& X);
|
Chris@49
|
160
|
Chris@49
|
161
|
Chris@49
|
162 arma_inline arma_warn_unused const eT& at_alt (const uword i) const;
|
Chris@49
|
163
|
Chris@49
|
164 arma_inline arma_warn_unused eT& operator[] (const uword i);
|
Chris@49
|
165 arma_inline arma_warn_unused const eT& operator[] (const uword i) const;
|
Chris@49
|
166
|
Chris@49
|
167 arma_inline arma_warn_unused eT& at(const uword i);
|
Chris@49
|
168 arma_inline arma_warn_unused const eT& at(const uword i) const;
|
Chris@49
|
169
|
Chris@49
|
170 arma_inline arma_warn_unused eT& operator() (const uword i);
|
Chris@49
|
171 arma_inline arma_warn_unused const eT& operator() (const uword i) const;
|
Chris@49
|
172
|
Chris@49
|
173 arma_inline arma_warn_unused eT& at (const uword in_row, const uword in_col, const uword in_slice);
|
Chris@49
|
174 arma_inline arma_warn_unused const eT& at (const uword in_row, const uword in_col, const uword in_slice) const;
|
Chris@49
|
175
|
Chris@49
|
176 arma_inline arma_warn_unused eT& operator() (const uword in_row, const uword in_col, const uword in_slice);
|
Chris@49
|
177 arma_inline arma_warn_unused const eT& operator() (const uword in_row, const uword in_col, const uword in_slice) const;
|
Chris@49
|
178
|
Chris@49
|
179 arma_inline const Cube& operator++();
|
Chris@49
|
180 arma_inline void operator++(int);
|
Chris@49
|
181
|
Chris@49
|
182 arma_inline const Cube& operator--();
|
Chris@49
|
183 arma_inline void operator--(int);
|
Chris@49
|
184
|
Chris@49
|
185 arma_inline arma_warn_unused bool is_finite() const;
|
Chris@49
|
186 arma_inline arma_warn_unused bool is_empty() const;
|
Chris@49
|
187
|
Chris@49
|
188 arma_inline arma_warn_unused bool in_range(const uword i) const;
|
Chris@49
|
189 arma_inline arma_warn_unused bool in_range(const span& x) const;
|
Chris@49
|
190
|
Chris@49
|
191 arma_inline arma_warn_unused bool in_range(const uword in_row, const uword in_col, const uword in_slice) const;
|
Chris@49
|
192 inline arma_warn_unused bool in_range(const span& row_span, const span& col_span, const span& slice_span) const;
|
Chris@49
|
193
|
Chris@49
|
194 arma_inline arma_warn_unused eT* memptr();
|
Chris@49
|
195 arma_inline arma_warn_unused const eT* memptr() const;
|
Chris@49
|
196
|
Chris@49
|
197 arma_inline arma_warn_unused eT* slice_memptr(const uword slice);
|
Chris@49
|
198 arma_inline arma_warn_unused const eT* slice_memptr(const uword slice) const;
|
Chris@49
|
199
|
Chris@49
|
200 arma_inline arma_warn_unused eT* slice_colptr(const uword in_slice, const uword in_col);
|
Chris@49
|
201 arma_inline arma_warn_unused const eT* slice_colptr(const uword in_slice, const uword in_col) const;
|
Chris@49
|
202
|
Chris@49
|
203 inline void impl_print(const std::string& extra_text) const;
|
Chris@49
|
204 inline void impl_print(std::ostream& user_stream, const std::string& extra_text) const;
|
Chris@49
|
205
|
Chris@49
|
206 inline void impl_raw_print(const std::string& extra_text) const;
|
Chris@49
|
207 inline void impl_raw_print(std::ostream& user_stream, const std::string& extra_text) const;
|
Chris@49
|
208
|
Chris@49
|
209 inline void set_size(const uword in_rows, const uword in_cols, const uword in_slices);
|
Chris@49
|
210 inline void reshape(const uword in_rows, const uword in_cols, const uword in_slices, const uword dim = 0);
|
Chris@49
|
211 inline void resize(const uword in_rows, const uword in_cols, const uword in_slices);
|
Chris@49
|
212
|
Chris@49
|
213 template<typename eT2> inline void copy_size(const Cube<eT2>& m);
|
Chris@49
|
214
|
Chris@49
|
215
|
Chris@49
|
216 template<typename functor>
|
Chris@49
|
217 inline const Cube& transform(functor F);
|
Chris@49
|
218
|
Chris@49
|
219 template<typename functor>
|
Chris@49
|
220 inline const Cube& imbue(functor F);
|
Chris@49
|
221
|
Chris@49
|
222
|
Chris@49
|
223 inline const Cube& fill(const eT val);
|
Chris@49
|
224
|
Chris@49
|
225 inline const Cube& zeros();
|
Chris@49
|
226 inline const Cube& zeros(const uword in_rows, const uword in_cols, const uword in_slices);
|
Chris@49
|
227
|
Chris@49
|
228 inline const Cube& ones();
|
Chris@49
|
229 inline const Cube& ones(const uword in_rows, const uword in_cols, const uword in_slices);
|
Chris@49
|
230
|
Chris@49
|
231 inline const Cube& randu();
|
Chris@49
|
232 inline const Cube& randu(const uword in_rows, const uword in_cols, const uword in_slices);
|
Chris@49
|
233
|
Chris@49
|
234 inline const Cube& randn();
|
Chris@49
|
235 inline const Cube& randn(const uword in_rows, const uword in_cols, const uword in_slices);
|
Chris@49
|
236
|
Chris@49
|
237 inline void reset();
|
Chris@49
|
238
|
Chris@49
|
239
|
Chris@49
|
240 template<typename T1> inline void set_real(const BaseCube<pod_type,T1>& X);
|
Chris@49
|
241 template<typename T1> inline void set_imag(const BaseCube<pod_type,T1>& X);
|
Chris@49
|
242
|
Chris@49
|
243
|
Chris@49
|
244 inline arma_warn_unused eT min() const;
|
Chris@49
|
245 inline arma_warn_unused eT max() const;
|
Chris@49
|
246
|
Chris@49
|
247 inline eT min(uword& index_of_min_val) const;
|
Chris@49
|
248 inline eT max(uword& index_of_max_val) const;
|
Chris@49
|
249
|
Chris@49
|
250 inline eT min(uword& row_of_min_val, uword& col_of_min_val, uword& slice_of_min_val) const;
|
Chris@49
|
251 inline eT max(uword& row_of_max_val, uword& col_of_max_val, uword& slice_of_max_val) const;
|
Chris@49
|
252
|
Chris@49
|
253
|
Chris@49
|
254 inline bool save(const std::string name, const file_type type = arma_binary, const bool print_status = true) const;
|
Chris@49
|
255 inline bool save( std::ostream& os, const file_type type = arma_binary, const bool print_status = true) const;
|
Chris@49
|
256
|
Chris@49
|
257 inline bool load(const std::string name, const file_type type = auto_detect, const bool print_status = true);
|
Chris@49
|
258 inline bool load( std::istream& is, const file_type type = auto_detect, const bool print_status = true);
|
Chris@49
|
259
|
Chris@49
|
260 inline bool quiet_save(const std::string name, const file_type type = arma_binary) const;
|
Chris@49
|
261 inline bool quiet_save( std::ostream& os, const file_type type = arma_binary) const;
|
Chris@49
|
262
|
Chris@49
|
263 inline bool quiet_load(const std::string name, const file_type type = auto_detect);
|
Chris@49
|
264 inline bool quiet_load( std::istream& is, const file_type type = auto_detect);
|
Chris@49
|
265
|
Chris@49
|
266
|
Chris@49
|
267 // iterators
|
Chris@49
|
268
|
Chris@49
|
269 typedef eT* iterator;
|
Chris@49
|
270 typedef const eT* const_iterator;
|
Chris@49
|
271
|
Chris@49
|
272 typedef eT* slice_iterator;
|
Chris@49
|
273 typedef const eT* const_slice_iterator;
|
Chris@49
|
274
|
Chris@49
|
275 inline iterator begin();
|
Chris@49
|
276 inline const_iterator begin() const;
|
Chris@49
|
277 inline const_iterator cbegin() const;
|
Chris@49
|
278
|
Chris@49
|
279 inline iterator end();
|
Chris@49
|
280 inline const_iterator end() const;
|
Chris@49
|
281 inline const_iterator cend() const;
|
Chris@49
|
282
|
Chris@49
|
283 inline slice_iterator begin_slice(const uword slice_num);
|
Chris@49
|
284 inline const_slice_iterator begin_slice(const uword slice_num) const;
|
Chris@49
|
285
|
Chris@49
|
286 inline slice_iterator end_slice(const uword slice_num);
|
Chris@49
|
287 inline const_slice_iterator end_slice(const uword slice_num) const;
|
Chris@49
|
288
|
Chris@49
|
289 inline void clear();
|
Chris@49
|
290 inline bool empty() const;
|
Chris@49
|
291 inline uword size() const;
|
Chris@49
|
292
|
Chris@49
|
293 // inline void swap(Cube& B); // TODO
|
Chris@49
|
294
|
Chris@49
|
295 inline void steal_mem(Cube& X); //!< don't use this unless you're writing code internal to Armadillo
|
Chris@49
|
296
|
Chris@49
|
297 template<uword fixed_n_rows, uword fixed_n_cols, uword fixed_n_slices> class fixed;
|
Chris@49
|
298
|
Chris@49
|
299
|
Chris@49
|
300 protected:
|
Chris@49
|
301
|
Chris@49
|
302 inline void init_cold();
|
Chris@49
|
303 inline void init_warm(const uword in_rows, const uword in_cols, const uword in_slices);
|
Chris@49
|
304
|
Chris@49
|
305 template<typename T1, typename T2>
|
Chris@49
|
306 inline void init(const BaseCube<pod_type,T1>& A, const BaseCube<pod_type,T2>& B);
|
Chris@49
|
307
|
Chris@49
|
308 inline void delete_mat();
|
Chris@49
|
309 inline void create_mat();
|
Chris@49
|
310
|
Chris@49
|
311 friend class glue_join;
|
Chris@49
|
312 friend class op_reshape;
|
Chris@49
|
313 friend class op_resize;
|
Chris@49
|
314
|
Chris@49
|
315
|
Chris@49
|
316 public:
|
Chris@49
|
317
|
Chris@49
|
318 #ifdef ARMA_EXTRA_CUBE_PROTO
|
Chris@49
|
319 #include ARMA_INCFILE_WRAP(ARMA_EXTRA_CUBE_PROTO)
|
Chris@49
|
320 #endif
|
Chris@49
|
321 };
|
Chris@49
|
322
|
Chris@49
|
323
|
Chris@49
|
324
|
Chris@49
|
325 template<typename eT>
|
Chris@49
|
326 template<uword fixed_n_rows, uword fixed_n_cols, uword fixed_n_slices>
|
Chris@49
|
327 class Cube<eT>::fixed : public Cube<eT>
|
Chris@49
|
328 {
|
Chris@49
|
329 private:
|
Chris@49
|
330
|
Chris@49
|
331 static const uword fixed_n_elem = fixed_n_rows * fixed_n_cols * fixed_n_slices;
|
Chris@49
|
332 static const uword fixed_n_elem_slice = fixed_n_rows * fixed_n_cols;
|
Chris@49
|
333
|
Chris@49
|
334 static const bool use_extra = (fixed_n_elem > Cube_prealloc::mem_n_elem);
|
Chris@49
|
335
|
Chris@49
|
336 arma_aligned Mat<eT>* mat_ptrs_local_extra[ (fixed_n_slices > Cube_prealloc::mat_ptrs_size) ? fixed_n_slices : 1 ];
|
Chris@49
|
337 arma_align_mem eT mem_local_extra [ use_extra ? fixed_n_elem : 1 ];
|
Chris@49
|
338
|
Chris@49
|
339 arma_inline void mem_setup();
|
Chris@49
|
340
|
Chris@49
|
341
|
Chris@49
|
342 public:
|
Chris@49
|
343
|
Chris@49
|
344 inline fixed() { mem_setup(); }
|
Chris@49
|
345
|
Chris@49
|
346 inline const Cube& operator=(const eT val) { mem_setup(); Cube<eT>::operator=(val); return *this; }
|
Chris@49
|
347
|
Chris@49
|
348 template<typename T1>
|
Chris@49
|
349 inline fixed(const BaseCube<eT,T1>& A) { mem_setup(); Cube<eT>::operator=(A.get_ref()); }
|
Chris@49
|
350
|
Chris@49
|
351 template<typename T1>
|
Chris@49
|
352 inline const Cube& operator=(const BaseCube<eT,T1>& A) { Cube<eT>::operator=(A.get_ref()); return *this; }
|
Chris@49
|
353
|
Chris@49
|
354 template<typename T1, typename T2>
|
Chris@49
|
355 inline explicit fixed(const BaseCube<pod_type,T1>& A, const BaseCube<pod_type,T2>& B) { mem_setup(); Cube<eT>::init(A,B); }
|
Chris@49
|
356
|
Chris@49
|
357
|
Chris@49
|
358 using Cube<eT>::operator();
|
Chris@49
|
359
|
Chris@49
|
360
|
Chris@49
|
361 arma_inline arma_warn_unused eT& operator[] (const uword i);
|
Chris@49
|
362 arma_inline arma_warn_unused const eT& operator[] (const uword i) const;
|
Chris@49
|
363
|
Chris@49
|
364 arma_inline arma_warn_unused eT& at (const uword i);
|
Chris@49
|
365 arma_inline arma_warn_unused const eT& at (const uword i) const;
|
Chris@49
|
366
|
Chris@49
|
367 arma_inline arma_warn_unused eT& operator() (const uword i);
|
Chris@49
|
368 arma_inline arma_warn_unused const eT& operator() (const uword i) const;
|
Chris@49
|
369
|
Chris@49
|
370 arma_inline arma_warn_unused eT& at (const uword in_row, const uword in_col, const uword in_slice);
|
Chris@49
|
371 arma_inline arma_warn_unused const eT& at (const uword in_row, const uword in_col, const uword in_slice) const;
|
Chris@49
|
372
|
Chris@49
|
373 arma_inline arma_warn_unused eT& operator() (const uword in_row, const uword in_col, const uword in_slice);
|
Chris@49
|
374 arma_inline arma_warn_unused const eT& operator() (const uword in_row, const uword in_col, const uword in_slice) const;
|
Chris@49
|
375 };
|
Chris@49
|
376
|
Chris@49
|
377
|
Chris@49
|
378
|
Chris@49
|
379 class Cube_aux
|
Chris@49
|
380 {
|
Chris@49
|
381 public:
|
Chris@49
|
382
|
Chris@49
|
383 template<typename eT> arma_inline static void prefix_pp(Cube<eT>& x);
|
Chris@49
|
384 template<typename T> arma_inline static void prefix_pp(Cube< std::complex<T> >& x);
|
Chris@49
|
385
|
Chris@49
|
386 template<typename eT> arma_inline static void postfix_pp(Cube<eT>& x);
|
Chris@49
|
387 template<typename T> arma_inline static void postfix_pp(Cube< std::complex<T> >& x);
|
Chris@49
|
388
|
Chris@49
|
389 template<typename eT> arma_inline static void prefix_mm(Cube<eT>& x);
|
Chris@49
|
390 template<typename T> arma_inline static void prefix_mm(Cube< std::complex<T> >& x);
|
Chris@49
|
391
|
Chris@49
|
392 template<typename eT> arma_inline static void postfix_mm(Cube<eT>& x);
|
Chris@49
|
393 template<typename T> arma_inline static void postfix_mm(Cube< std::complex<T> >& x);
|
Chris@49
|
394
|
Chris@49
|
395 template<typename eT, typename T1> inline static void set_real(Cube<eT>& out, const BaseCube<eT,T1>& X);
|
Chris@49
|
396 template<typename eT, typename T1> inline static void set_imag(Cube<eT>& out, const BaseCube<eT,T1>& X);
|
Chris@49
|
397
|
Chris@49
|
398 template<typename T, typename T1> inline static void set_real(Cube< std::complex<T> >& out, const BaseCube< T,T1>& X);
|
Chris@49
|
399 template<typename T, typename T1> inline static void set_imag(Cube< std::complex<T> >& out, const BaseCube< T,T1>& X);
|
Chris@49
|
400 };
|
Chris@49
|
401
|
Chris@49
|
402
|
Chris@49
|
403
|
Chris@49
|
404 //! @}
|