Mercurial > hg > segmenter-vamp-plugin
comparison armadillo-2.4.4/include/armadillo_bits/Mat_bones.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) 2008-2011 NICTA (www.nicta.com.au) | |
2 // Copyright (C) 2008-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 | |
14 //! \addtogroup Mat | |
15 //! @{ | |
16 | |
17 | |
18 | |
19 //! Dense matrix class | |
20 | |
21 template<typename eT> | |
22 class Mat : public Base< eT, Mat<eT> > | |
23 { | |
24 public: | |
25 | |
26 typedef eT elem_type; //!< the type of elements stored in the matrix | |
27 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 | |
28 | |
29 const uword n_rows; //!< number of rows in the matrix (read-only) | |
30 const uword n_cols; //!< number of columns in the matrix (read-only) | |
31 const uword n_elem; //!< number of elements in the matrix (read-only) | |
32 const uhword vec_state; //!< 0: matrix layout; 1: column vector layout; 2: row vector layout | |
33 const uhword mem_state; | |
34 | |
35 // mem_state = 0: normal matrix that can be resized; | |
36 // mem_state = 1: use auxiliary memory until change in the number of elements is requested; | |
37 // mem_state = 2: use auxiliary memory and don't allow the number of elements to be changed; | |
38 // mem_state = 3: fixed size (e.g. via template based size specification). | |
39 | |
40 arma_aligned const eT* const mem; //!< pointer to the memory used by the matrix (memory is read-only) | |
41 | |
42 protected: | |
43 arma_aligned eT mem_local[ arma_config::mat_prealloc ]; | |
44 | |
45 | |
46 public: | |
47 | |
48 inline ~Mat(); | |
49 inline Mat(); | |
50 | |
51 inline Mat(const uword in_rows, const uword in_cols); | |
52 | |
53 inline Mat(const char* text); | |
54 inline const Mat& operator=(const char* text); | |
55 | |
56 inline Mat(const std::string& text); | |
57 inline const Mat& operator=(const std::string& text); | |
58 | |
59 #if defined(ARMA_USE_CXX11) | |
60 inline Mat(const std::initializer_list<eT>& list); | |
61 inline const Mat& operator=(const std::initializer_list<eT>& list); | |
62 #endif | |
63 | |
64 inline Mat( eT* aux_mem, const uword aux_n_rows, const uword aux_n_cols, const bool copy_aux_mem = true, const bool strict = true); | |
65 inline Mat(const eT* aux_mem, const uword aux_n_rows, const uword aux_n_cols); | |
66 | |
67 arma_inline const Mat& operator=(const eT val); | |
68 arma_inline const Mat& operator+=(const eT val); | |
69 arma_inline const Mat& operator-=(const eT val); | |
70 arma_inline const Mat& operator*=(const eT val); | |
71 arma_inline const Mat& operator/=(const eT val); | |
72 | |
73 inline Mat(const Mat& m); | |
74 inline const Mat& operator=(const Mat& m); | |
75 inline const Mat& operator+=(const Mat& m); | |
76 inline const Mat& operator-=(const Mat& m); | |
77 inline const Mat& operator*=(const Mat& m); | |
78 inline const Mat& operator%=(const Mat& m); | |
79 inline const Mat& operator/=(const Mat& m); | |
80 | |
81 template<typename T1> inline Mat(const BaseCube<eT,T1>& X); | |
82 template<typename T1> inline const Mat& operator=(const BaseCube<eT,T1>& X); | |
83 template<typename T1> inline const Mat& operator+=(const BaseCube<eT,T1>& X); | |
84 template<typename T1> inline const Mat& operator-=(const BaseCube<eT,T1>& X); | |
85 template<typename T1> inline const Mat& operator*=(const BaseCube<eT,T1>& X); | |
86 template<typename T1> inline const Mat& operator%=(const BaseCube<eT,T1>& X); | |
87 template<typename T1> inline const Mat& operator/=(const BaseCube<eT,T1>& X); | |
88 | |
89 template<typename T1, typename T2> | |
90 inline explicit Mat(const Base<pod_type,T1>& A, const Base<pod_type,T2>& B); | |
91 | |
92 inline Mat(const subview<eT>& X); | |
93 inline const Mat& operator=(const subview<eT>& X); | |
94 inline const Mat& operator+=(const subview<eT>& X); | |
95 inline const Mat& operator-=(const subview<eT>& X); | |
96 inline const Mat& operator*=(const subview<eT>& X); | |
97 inline const Mat& operator%=(const subview<eT>& X); | |
98 inline const Mat& operator/=(const subview<eT>& X); | |
99 | |
100 //inline explicit Mat(const subview_cube<eT>& X); | |
101 inline Mat(const subview_cube<eT>& X); | |
102 inline const Mat& operator=(const subview_cube<eT>& X); | |
103 inline const Mat& operator+=(const subview_cube<eT>& X); | |
104 inline const Mat& operator-=(const subview_cube<eT>& X); | |
105 inline const Mat& operator*=(const subview_cube<eT>& X); | |
106 inline const Mat& operator%=(const subview_cube<eT>& X); | |
107 inline const Mat& operator/=(const subview_cube<eT>& X); | |
108 | |
109 //inline explicit Mat(const diagview<eT>& X); | |
110 inline Mat(const diagview<eT>& X); | |
111 inline const Mat& operator=(const diagview<eT>& X); | |
112 inline const Mat& operator+=(const diagview<eT>& X); | |
113 inline const Mat& operator-=(const diagview<eT>& X); | |
114 inline const Mat& operator*=(const diagview<eT>& X); | |
115 inline const Mat& operator%=(const diagview<eT>& X); | |
116 inline const Mat& operator/=(const diagview<eT>& X); | |
117 | |
118 template<typename T1> inline Mat(const subview_elem1<eT,T1>& X); | |
119 template<typename T1> inline const Mat& operator= (const subview_elem1<eT,T1>& X); | |
120 template<typename T1> inline const Mat& operator+=(const subview_elem1<eT,T1>& X); | |
121 template<typename T1> inline const Mat& operator-=(const subview_elem1<eT,T1>& X); | |
122 template<typename T1> inline const Mat& operator*=(const subview_elem1<eT,T1>& X); | |
123 template<typename T1> inline const Mat& operator%=(const subview_elem1<eT,T1>& X); | |
124 template<typename T1> inline const Mat& operator/=(const subview_elem1<eT,T1>& X); | |
125 | |
126 | |
127 inline mat_injector<Mat> operator<<(const eT val); | |
128 inline mat_injector<Mat> operator<<(const injector_end_of_row& x); | |
129 | |
130 | |
131 arma_inline subview_row<eT> row(const uword row_num); | |
132 arma_inline const subview_row<eT> row(const uword row_num) const; | |
133 | |
134 inline subview_row<eT> operator()(const uword row_num, const span& col_span); | |
135 inline const subview_row<eT> operator()(const uword row_num, const span& col_span) const; | |
136 | |
137 | |
138 arma_inline subview_col<eT> col(const uword col_num); | |
139 arma_inline const subview_col<eT> col(const uword col_num) const; | |
140 | |
141 inline subview_col<eT> operator()(const span& row_span, const uword col_num); | |
142 inline const subview_col<eT> operator()(const span& row_span, const uword col_num) const; | |
143 | |
144 inline Col<eT> unsafe_col(const uword col_num); | |
145 inline const Col<eT> unsafe_col(const uword col_num) const; | |
146 | |
147 | |
148 arma_inline subview<eT> rows(const uword in_row1, const uword in_row2); | |
149 arma_inline const subview<eT> rows(const uword in_row1, const uword in_row2) const; | |
150 | |
151 arma_inline subview<eT> cols(const uword in_col1, const uword in_col2); | |
152 arma_inline const subview<eT> cols(const uword in_col1, const uword in_col2) const; | |
153 | |
154 arma_inline subview<eT> submat(const uword in_row1, const uword in_col1, const uword in_row2, const uword in_col2); | |
155 arma_inline const subview<eT> submat(const uword in_row1, const uword in_col1, const uword in_row2, const uword in_col2) const; | |
156 | |
157 | |
158 inline subview<eT> submat (const span& row_span, const span& col_span); | |
159 inline const subview<eT> submat (const span& row_span, const span& col_span) const; | |
160 | |
161 inline subview<eT> operator()(const span& row_span, const span& col_span); | |
162 inline const subview<eT> operator()(const span& row_span, const span& col_span) const; | |
163 | |
164 | |
165 template<typename T1> arma_inline subview_elem1<eT,T1> elem(const Base<uword,T1>& a); | |
166 template<typename T1> arma_inline const subview_elem1<eT,T1> elem(const Base<uword,T1>& a) const; | |
167 | |
168 // template<typename T1, typename T2> arma_inline subview_elem2<eT,T1,T2> submat(const Base<uword,T1>& a, const Base<uword,T2>& b); | |
169 // template<typename T1, typename T2> arma_inline const subview_elem2<eT,T1,T2> submat(const Base<uword,T1>& a, const Base<uword,T2>& b) const; | |
170 | |
171 | |
172 arma_inline diagview<eT> diag(const sword in_id = 0); | |
173 arma_inline const diagview<eT> diag(const sword in_id = 0) const; | |
174 | |
175 | |
176 inline void swap_rows(const uword in_row1, const uword in_row2); | |
177 inline void swap_cols(const uword in_col1, const uword in_col2); | |
178 | |
179 inline void shed_row(const uword row_num); | |
180 inline void shed_col(const uword col_num); | |
181 | |
182 inline void shed_rows(const uword in_row1, const uword in_row2); | |
183 inline void shed_cols(const uword in_col1, const uword in_col2); | |
184 | |
185 inline void insert_rows(const uword row_num, const uword N, const bool set_to_zero = true); | |
186 inline void insert_cols(const uword col_num, const uword N, const bool set_to_zero = true); | |
187 | |
188 template<typename T1> inline void insert_rows(const uword row_num, const Base<eT,T1>& X); | |
189 template<typename T1> inline void insert_cols(const uword col_num, const Base<eT,T1>& X); | |
190 | |
191 | |
192 template<typename gen_type> inline Mat(const Gen<eT, gen_type>& X); | |
193 template<typename gen_type> inline const Mat& operator=(const Gen<eT, gen_type>& X); | |
194 template<typename gen_type> inline const Mat& operator+=(const Gen<eT, gen_type>& X); | |
195 template<typename gen_type> inline const Mat& operator-=(const Gen<eT, gen_type>& X); | |
196 template<typename gen_type> inline const Mat& operator*=(const Gen<eT, gen_type>& X); | |
197 template<typename gen_type> inline const Mat& operator%=(const Gen<eT, gen_type>& X); | |
198 template<typename gen_type> inline const Mat& operator/=(const Gen<eT, gen_type>& X); | |
199 | |
200 template<typename T1, typename op_type> inline Mat(const Op<T1, op_type>& X); | |
201 template<typename T1, typename op_type> inline const Mat& operator=(const Op<T1, op_type>& X); | |
202 template<typename T1, typename op_type> inline const Mat& operator+=(const Op<T1, op_type>& X); | |
203 template<typename T1, typename op_type> inline const Mat& operator-=(const Op<T1, op_type>& X); | |
204 template<typename T1, typename op_type> inline const Mat& operator*=(const Op<T1, op_type>& X); | |
205 template<typename T1, typename op_type> inline const Mat& operator%=(const Op<T1, op_type>& X); | |
206 template<typename T1, typename op_type> inline const Mat& operator/=(const Op<T1, op_type>& X); | |
207 | |
208 template<typename T1, typename eop_type> inline Mat(const eOp<T1, eop_type>& X); | |
209 template<typename T1, typename eop_type> inline const Mat& operator=(const eOp<T1, eop_type>& X); | |
210 template<typename T1, typename eop_type> inline const Mat& operator+=(const eOp<T1, eop_type>& X); | |
211 template<typename T1, typename eop_type> inline const Mat& operator-=(const eOp<T1, eop_type>& X); | |
212 template<typename T1, typename eop_type> inline const Mat& operator*=(const eOp<T1, eop_type>& X); | |
213 template<typename T1, typename eop_type> inline const Mat& operator%=(const eOp<T1, eop_type>& X); | |
214 template<typename T1, typename eop_type> inline const Mat& operator/=(const eOp<T1, eop_type>& X); | |
215 | |
216 template<typename T1, typename op_type> inline Mat(const mtOp<eT, T1, op_type>& X); | |
217 template<typename T1, typename op_type> inline const Mat& operator=(const mtOp<eT, T1, op_type>& X); | |
218 template<typename T1, typename op_type> inline const Mat& operator+=(const mtOp<eT, T1, op_type>& X); | |
219 template<typename T1, typename op_type> inline const Mat& operator-=(const mtOp<eT, T1, op_type>& X); | |
220 template<typename T1, typename op_type> inline const Mat& operator*=(const mtOp<eT, T1, op_type>& X); | |
221 template<typename T1, typename op_type> inline const Mat& operator%=(const mtOp<eT, T1, op_type>& X); | |
222 template<typename T1, typename op_type> inline const Mat& operator/=(const mtOp<eT, T1, op_type>& X); | |
223 | |
224 template<typename T1, typename T2, typename glue_type> inline Mat(const Glue<T1, T2, glue_type>& X); | |
225 template<typename T1, typename T2, typename glue_type> inline const Mat& operator=(const Glue<T1, T2, glue_type>& X); | |
226 template<typename T1, typename T2, typename glue_type> inline const Mat& operator+=(const Glue<T1, T2, glue_type>& X); | |
227 template<typename T1, typename T2, typename glue_type> inline const Mat& operator-=(const Glue<T1, T2, glue_type>& X); | |
228 template<typename T1, typename T2, typename glue_type> inline const Mat& operator*=(const Glue<T1, T2, glue_type>& X); | |
229 template<typename T1, typename T2, typename glue_type> inline const Mat& operator%=(const Glue<T1, T2, glue_type>& X); | |
230 template<typename T1, typename T2, typename glue_type> inline const Mat& operator/=(const Glue<T1, T2, glue_type>& X); | |
231 | |
232 template<typename T1, typename T2> inline const Mat& operator+=(const Glue<T1, T2, glue_times>& X); | |
233 template<typename T1, typename T2> inline const Mat& operator-=(const Glue<T1, T2, glue_times>& X); | |
234 | |
235 template<typename T1, typename T2, typename eglue_type> inline Mat(const eGlue<T1, T2, eglue_type>& X); | |
236 template<typename T1, typename T2, typename eglue_type> inline const Mat& operator=(const eGlue<T1, T2, eglue_type>& X); | |
237 template<typename T1, typename T2, typename eglue_type> inline const Mat& operator+=(const eGlue<T1, T2, eglue_type>& X); | |
238 template<typename T1, typename T2, typename eglue_type> inline const Mat& operator-=(const eGlue<T1, T2, eglue_type>& X); | |
239 template<typename T1, typename T2, typename eglue_type> inline const Mat& operator*=(const eGlue<T1, T2, eglue_type>& X); | |
240 template<typename T1, typename T2, typename eglue_type> inline const Mat& operator%=(const eGlue<T1, T2, eglue_type>& X); | |
241 template<typename T1, typename T2, typename eglue_type> inline const Mat& operator/=(const eGlue<T1, T2, eglue_type>& X); | |
242 | |
243 template<typename T1, typename T2, typename glue_type> inline Mat(const mtGlue<eT, T1, T2, glue_type>& X); | |
244 template<typename T1, typename T2, typename glue_type> inline const Mat& operator=(const mtGlue<eT, T1, T2, glue_type>& X); | |
245 template<typename T1, typename T2, typename glue_type> inline const Mat& operator+=(const mtGlue<eT, T1, T2, glue_type>& X); | |
246 template<typename T1, typename T2, typename glue_type> inline const Mat& operator-=(const mtGlue<eT, T1, T2, glue_type>& X); | |
247 template<typename T1, typename T2, typename glue_type> inline const Mat& operator*=(const mtGlue<eT, T1, T2, glue_type>& X); | |
248 template<typename T1, typename T2, typename glue_type> inline const Mat& operator%=(const mtGlue<eT, T1, T2, glue_type>& X); | |
249 template<typename T1, typename T2, typename glue_type> inline const Mat& operator/=(const mtGlue<eT, T1, T2, glue_type>& X); | |
250 | |
251 | |
252 arma_inline arma_warn_unused eT& operator[] (const uword i); | |
253 arma_inline arma_warn_unused eT operator[] (const uword i) const; | |
254 arma_inline arma_warn_unused eT& at (const uword i); | |
255 arma_inline arma_warn_unused eT at (const uword i) const; | |
256 arma_inline arma_warn_unused eT& operator() (const uword i); | |
257 arma_inline arma_warn_unused eT operator() (const uword i) const; | |
258 | |
259 arma_inline arma_warn_unused eT& at (const uword in_row, const uword in_col); | |
260 arma_inline arma_warn_unused eT at (const uword in_row, const uword in_col) const; | |
261 arma_inline arma_warn_unused eT& operator() (const uword in_row, const uword in_col); | |
262 arma_inline arma_warn_unused eT operator() (const uword in_row, const uword in_col) const; | |
263 | |
264 arma_inline const Mat& operator++(); | |
265 arma_inline void operator++(int); | |
266 | |
267 arma_inline const Mat& operator--(); | |
268 arma_inline void operator--(int); | |
269 | |
270 arma_inline arma_warn_unused bool is_empty() const; | |
271 arma_inline arma_warn_unused bool is_vec() const; | |
272 arma_inline arma_warn_unused bool is_rowvec() const; | |
273 arma_inline arma_warn_unused bool is_colvec() const; | |
274 arma_inline arma_warn_unused bool is_square() const; | |
275 inline arma_warn_unused bool is_finite() const; | |
276 | |
277 arma_inline arma_warn_unused bool in_range(const uword i) const; | |
278 arma_inline arma_warn_unused bool in_range(const span& x) const; | |
279 | |
280 arma_inline arma_warn_unused bool in_range(const uword in_row, const uword in_col) const; | |
281 arma_inline arma_warn_unused bool in_range(const span& row_span, const uword in_col) const; | |
282 arma_inline arma_warn_unused bool in_range(const uword in_row, const span& col_span) const; | |
283 arma_inline arma_warn_unused bool in_range(const span& row_span, const span& col_span) const; | |
284 | |
285 arma_inline arma_warn_unused eT* colptr(const uword in_col); | |
286 arma_inline arma_warn_unused const eT* colptr(const uword in_col) const; | |
287 | |
288 arma_inline arma_warn_unused eT* memptr(); | |
289 arma_inline arma_warn_unused const eT* memptr() const; | |
290 | |
291 | |
292 inline void impl_print(const std::string& extra_text) const; | |
293 inline void impl_print(std::ostream& user_stream, const std::string& extra_text) const; | |
294 | |
295 inline void impl_print_trans(const std::string& extra_text) const; | |
296 inline void impl_print_trans(std::ostream& user_stream, const std::string& extra_text) const; | |
297 | |
298 inline void impl_raw_print(const std::string& extra_text) const; | |
299 inline void impl_raw_print(std::ostream& user_stream, const std::string& extra_text) const; | |
300 | |
301 inline void impl_raw_print_trans(const std::string& extra_text) const; | |
302 inline void impl_raw_print_trans(std::ostream& user_stream, const std::string& extra_text) const; | |
303 | |
304 | |
305 template<typename eT2> | |
306 inline void copy_size(const Mat<eT2>& m); | |
307 | |
308 inline void set_size(const uword in_elem); | |
309 inline void set_size(const uword in_rows, const uword in_cols); | |
310 | |
311 inline void resize(const uword in_elem); | |
312 inline void resize(const uword in_rows, const uword in_cols); | |
313 inline void reshape(const uword in_rows, const uword in_cols, const uword dim = 0); | |
314 | |
315 | |
316 arma_hot inline const Mat& fill(const eT val); | |
317 | |
318 inline const Mat& zeros(); | |
319 inline const Mat& zeros(const uword in_elem); | |
320 inline const Mat& zeros(const uword in_rows, const uword in_cols); | |
321 | |
322 inline const Mat& ones(); | |
323 inline const Mat& ones(const uword in_elem); | |
324 inline const Mat& ones(const uword in_rows, const uword in_cols); | |
325 | |
326 inline const Mat& randu(); | |
327 inline const Mat& randu(const uword in_elem); | |
328 inline const Mat& randu(const uword in_rows, const uword in_cols); | |
329 | |
330 inline const Mat& randn(); | |
331 inline const Mat& randn(const uword in_elem); | |
332 inline const Mat& randn(const uword in_rows, const uword in_cols); | |
333 | |
334 inline const Mat& eye(); | |
335 inline const Mat& eye(const uword in_rows, const uword in_cols); | |
336 | |
337 inline void reset(); | |
338 | |
339 | |
340 template<typename T1> inline void set_real(const Base<pod_type,T1>& X); | |
341 template<typename T1> inline void set_imag(const Base<pod_type,T1>& X); | |
342 | |
343 | |
344 inline arma_warn_unused eT min() const; | |
345 inline arma_warn_unused eT max() const; | |
346 | |
347 inline eT min(uword& index_of_min_val) const; | |
348 inline eT max(uword& index_of_max_val) const; | |
349 | |
350 inline eT min(uword& row_of_min_val, uword& col_of_min_val) const; | |
351 inline eT max(uword& row_of_max_val, uword& col_of_max_val) const; | |
352 | |
353 | |
354 inline bool save(const std::string name, const file_type type = arma_binary, const bool print_status = true) const; | |
355 inline bool save( std::ostream& os, const file_type type = arma_binary, const bool print_status = true) const; | |
356 | |
357 inline bool load(const std::string name, const file_type type = auto_detect, const bool print_status = true); | |
358 inline bool load( std::istream& is, const file_type type = auto_detect, const bool print_status = true); | |
359 | |
360 inline bool quiet_save(const std::string name, const file_type type = arma_binary) const; | |
361 inline bool quiet_save( std::ostream& os, const file_type type = arma_binary) const; | |
362 | |
363 inline bool quiet_load(const std::string name, const file_type type = auto_detect); | |
364 inline bool quiet_load( std::istream& is, const file_type type = auto_detect); | |
365 | |
366 | |
367 // for container-like functionality | |
368 | |
369 typedef eT value_type; | |
370 typedef uword size_type; | |
371 | |
372 typedef eT* iterator; | |
373 typedef const eT* const_iterator; | |
374 | |
375 typedef eT* col_iterator; | |
376 typedef const eT* const_col_iterator; | |
377 | |
378 class row_iterator | |
379 { | |
380 public: | |
381 | |
382 inline row_iterator(Mat<eT>& in_M, const uword in_row); | |
383 | |
384 inline eT& operator* (); | |
385 | |
386 inline row_iterator& operator++(); | |
387 inline void operator++(int); | |
388 | |
389 inline row_iterator& operator--(); | |
390 inline void operator--(int); | |
391 | |
392 inline bool operator!=(const row_iterator& X) const; | |
393 inline bool operator==(const row_iterator& X) const; | |
394 | |
395 arma_aligned Mat<eT>& M; | |
396 arma_aligned uword row; | |
397 arma_aligned uword col; | |
398 }; | |
399 | |
400 | |
401 class const_row_iterator | |
402 { | |
403 public: | |
404 | |
405 const_row_iterator(const Mat<eT>& in_M, const uword in_row); | |
406 const_row_iterator(const row_iterator& X); | |
407 | |
408 inline eT operator*() const; | |
409 | |
410 inline const_row_iterator& operator++(); | |
411 inline void operator++(int); | |
412 | |
413 inline const_row_iterator& operator--(); | |
414 inline void operator--(int); | |
415 | |
416 inline bool operator!=(const const_row_iterator& X) const; | |
417 inline bool operator==(const const_row_iterator& X) const; | |
418 | |
419 arma_aligned const Mat<eT>& M; | |
420 arma_aligned uword row; | |
421 arma_aligned uword col; | |
422 }; | |
423 | |
424 inline iterator begin(); | |
425 inline const_iterator begin() const; | |
426 | |
427 inline iterator end(); | |
428 inline const_iterator end() const; | |
429 | |
430 inline col_iterator begin_col(const uword col_num); | |
431 inline const_col_iterator begin_col(const uword col_num) const; | |
432 | |
433 inline col_iterator end_col (const uword col_num); | |
434 inline const_col_iterator end_col (const uword col_num) const; | |
435 | |
436 inline row_iterator begin_row(const uword row_num); | |
437 inline const_row_iterator begin_row(const uword row_num) const; | |
438 | |
439 inline row_iterator end_row (const uword row_num); | |
440 inline const_row_iterator end_row (const uword row_num) const; | |
441 | |
442 inline void clear(); | |
443 inline bool empty() const; | |
444 inline uword size() const; | |
445 | |
446 template<uword fixed_n_rows, uword fixed_n_cols> | |
447 class fixed : public Mat<eT> | |
448 { | |
449 private: | |
450 | |
451 static const uword fixed_n_elem = fixed_n_rows * fixed_n_cols; | |
452 static const bool use_extra = (fixed_n_elem > arma_config::mat_prealloc); | |
453 | |
454 arma_aligned eT mem_local_extra[ (use_extra) ? fixed_n_elem : 1 ]; | |
455 | |
456 arma_inline void mem_setup(); | |
457 | |
458 | |
459 public: | |
460 | |
461 static const uword n_rows = fixed_n_rows; | |
462 static const uword n_cols = fixed_n_cols; | |
463 static const uword n_elem = fixed_n_elem; | |
464 | |
465 | |
466 arma_inline fixed(); | |
467 arma_inline fixed(const fixed<fixed_n_rows, fixed_n_cols>& X); | |
468 | |
469 template<typename T1> inline fixed(const Base<eT,T1>& A); | |
470 template<typename T1, typename T2> inline fixed(const Base<pod_type,T1>& A, const Base<pod_type,T2>& B); | |
471 | |
472 inline fixed( eT* aux_mem, const bool copy_aux_mem = true); | |
473 inline fixed(const eT* aux_mem); | |
474 | |
475 inline fixed(const char* text); | |
476 inline fixed(const std::string& text); | |
477 | |
478 // TODO: handling of initializer_list ? | |
479 | |
480 template<typename T1> inline const Mat& operator=(const Base<eT,T1>& A); | |
481 | |
482 inline const Mat& operator=(const eT val); | |
483 inline const Mat& operator=(const char* text); | |
484 inline const Mat& operator=(const std::string& text); | |
485 | |
486 | |
487 inline subview_row<eT> operator()(const uword row_num, const span& col_span); | |
488 inline const subview_row<eT> operator()(const uword row_num, const span& col_span) const; | |
489 | |
490 inline subview_col<eT> operator()(const span& row_span, const uword col_num); | |
491 inline const subview_col<eT> operator()(const span& row_span, const uword col_num) const; | |
492 | |
493 inline subview<eT> operator()(const span& row_span, const span& col_span); | |
494 inline const subview<eT> operator()(const span& row_span, const span& col_span) const; | |
495 | |
496 | |
497 arma_inline arma_warn_unused eT& operator[] (const uword i); | |
498 arma_inline arma_warn_unused eT operator[] (const uword i) const; | |
499 arma_inline arma_warn_unused eT& at (const uword i); | |
500 arma_inline arma_warn_unused eT at (const uword i) const; | |
501 arma_inline arma_warn_unused eT& operator() (const uword i); | |
502 arma_inline arma_warn_unused eT operator() (const uword i) const; | |
503 | |
504 arma_inline arma_warn_unused eT& at (const uword in_row, const uword in_col); | |
505 arma_inline arma_warn_unused eT at (const uword in_row, const uword in_col) const; | |
506 arma_inline arma_warn_unused eT& operator() (const uword in_row, const uword in_col); | |
507 arma_inline arma_warn_unused eT operator() (const uword in_row, const uword in_col) const; | |
508 | |
509 | |
510 arma_hot inline const Mat<eT>& fill(const eT val); | |
511 arma_hot inline const Mat<eT>& zeros(); | |
512 arma_hot inline const Mat<eT>& ones(); | |
513 }; | |
514 | |
515 | |
516 protected: | |
517 | |
518 inline void init_cold(); | |
519 inline void init_warm(uword in_rows, uword in_cols); | |
520 | |
521 inline void init(const std::string& text); | |
522 | |
523 #if defined(ARMA_USE_CXX11) | |
524 inline void init(const std::initializer_list<eT>& list); | |
525 #endif | |
526 | |
527 template<typename T1, typename T2> | |
528 inline void init(const Base<pod_type,T1>& A, const Base<pod_type,T2>& B); | |
529 | |
530 inline void steal_mem(Mat& X); | |
531 | |
532 inline Mat(const char junk, const eT* aux_mem, const uword aux_n_rows, const uword aux_n_cols); | |
533 | |
534 friend class Cube<eT>; | |
535 friend class glue_join; | |
536 friend class op_strans; | |
537 friend class op_htrans; | |
538 friend class op_resize; | |
539 | |
540 | |
541 public: | |
542 | |
543 #ifdef ARMA_EXTRA_MAT_PROTO | |
544 #include ARMA_INCFILE_WRAP(ARMA_EXTRA_MAT_PROTO) | |
545 #endif | |
546 }; | |
547 | |
548 | |
549 | |
550 class Mat_aux | |
551 { | |
552 public: | |
553 | |
554 template<typename eT> arma_inline static void prefix_pp(Mat<eT>& x); | |
555 template<typename T> arma_inline static void prefix_pp(Mat< std::complex<T> >& x); | |
556 | |
557 template<typename eT> arma_inline static void postfix_pp(Mat<eT>& x); | |
558 template<typename T> arma_inline static void postfix_pp(Mat< std::complex<T> >& x); | |
559 | |
560 template<typename eT> arma_inline static void prefix_mm(Mat<eT>& x); | |
561 template<typename T> arma_inline static void prefix_mm(Mat< std::complex<T> >& x); | |
562 | |
563 template<typename eT> arma_inline static void postfix_mm(Mat<eT>& x); | |
564 template<typename T> arma_inline static void postfix_mm(Mat< std::complex<T> >& x); | |
565 | |
566 template<typename eT, typename T1> inline static void set_real(Mat<eT>& out, const Base<eT,T1>& X); | |
567 template<typename T, typename T1> inline static void set_real(Mat< std::complex<T> >& out, const Base< T,T1>& X); | |
568 | |
569 template<typename eT, typename T1> inline static void set_imag(Mat<eT>& out, const Base<eT,T1>& X); | |
570 template<typename T, typename T1> inline static void set_imag(Mat< std::complex<T> >& out, const Base< T,T1>& X); | |
571 }; | |
572 | |
573 | |
574 | |
575 //! @} |