Mercurial > hg > segmenter-vamp-plugin
comparison armadillo-3.900.4/include/armadillo_bits/Mat_bones.hpp @ 49:1ec0e2823891
Switch to using subrepo copies of qm-dsp, nnls-chroma, vamp-plugin-sdk; update Armadillo version; assume build without external BLAS/LAPACK
author | Chris Cannam |
---|---|
date | Thu, 13 Jun 2013 10:25:24 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
48:69251e11a913 | 49:1ec0e2823891 |
---|---|
1 // Copyright (C) 2008-2013 NICTA (www.nicta.com.au) | |
2 // Copyright (C) 2008-2013 Conrad Sanderson | |
3 // Copyright (C) 2012 Ryan Curtin | |
4 // | |
5 // This Source Code Form is subject to the terms of the Mozilla Public | |
6 // License, v. 2.0. If a copy of the MPL was not distributed with this | |
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/. | |
8 | |
9 | |
10 //! \addtogroup Mat | |
11 //! @{ | |
12 | |
13 | |
14 | |
15 //! Dense matrix class | |
16 | |
17 template<typename eT> | |
18 class Mat : public Base< eT, Mat<eT> > | |
19 { | |
20 public: | |
21 | |
22 typedef eT elem_type; //!< the type of elements stored in the matrix | |
23 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 | |
24 | |
25 const uword n_rows; //!< number of rows in the matrix (read-only) | |
26 const uword n_cols; //!< number of columns in the matrix (read-only) | |
27 const uword n_elem; //!< number of elements in the matrix (read-only) | |
28 const uhword vec_state; //!< 0: matrix layout; 1: column vector layout; 2: row vector layout | |
29 const uhword mem_state; | |
30 | |
31 // mem_state = 0: normal matrix that can be resized; | |
32 // mem_state = 1: use auxiliary memory until change in the number of elements is requested; | |
33 // mem_state = 2: use auxiliary memory and don't allow the number of elements to be changed; | |
34 // mem_state = 3: fixed size (e.g. via template based size specification). | |
35 | |
36 arma_aligned const eT* const mem; //!< pointer to the memory used by the matrix (memory is read-only) | |
37 | |
38 protected: | |
39 arma_align_mem eT mem_local[ arma_config::mat_prealloc ]; | |
40 | |
41 | |
42 public: | |
43 | |
44 static const bool is_col = false; | |
45 static const bool is_row = false; | |
46 | |
47 inline ~Mat(); | |
48 inline Mat(); | |
49 | |
50 inline Mat(const uword in_rows, const uword in_cols); | |
51 | |
52 inline Mat(const char* text); | |
53 inline const Mat& operator=(const char* text); | |
54 | |
55 inline Mat(const std::string& text); | |
56 inline const Mat& operator=(const std::string& text); | |
57 | |
58 inline Mat(const std::vector<eT>& x); | |
59 inline const Mat& operator=(const std::vector<eT>& x); | |
60 | |
61 #if defined(ARMA_USE_CXX11) | |
62 inline Mat(const std::initializer_list<eT>& list); | |
63 inline const Mat& operator=(const std::initializer_list<eT>& list); | |
64 #endif | |
65 | |
66 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); | |
67 inline Mat(const eT* aux_mem, const uword aux_n_rows, const uword aux_n_cols); | |
68 | |
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 arma_inline const Mat& operator*=(const eT val); | |
73 arma_inline const Mat& operator/=(const eT val); | |
74 | |
75 inline Mat(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 inline const Mat& operator%=(const Mat& m); | |
81 inline const Mat& operator/=(const Mat& m); | |
82 | |
83 template<typename T1> inline Mat(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 template<typename T1> inline const Mat& operator%=(const BaseCube<eT,T1>& X); | |
89 template<typename T1> inline const Mat& operator/=(const BaseCube<eT,T1>& X); | |
90 | |
91 template<typename T1, typename T2> | |
92 inline explicit Mat(const Base<pod_type,T1>& A, const Base<pod_type,T2>& B); | |
93 | |
94 inline Mat(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 inline const Mat& operator%=(const subview<eT>& X); | |
100 inline const Mat& operator/=(const subview<eT>& X); | |
101 | |
102 inline Mat(const subview_row_strans<eT>& X); // subview_row_strans can only be generated by the Proxy class | |
103 inline Mat(const subview_row_htrans<eT>& X); // subview_row_htrans can only be generated by the Proxy class | |
104 inline Mat(const xvec_htrans<eT>& X); // xvec_htrans can only be generated by the Proxy class | |
105 | |
106 //inline explicit Mat(const subview_cube<eT>& X); | |
107 inline Mat(const subview_cube<eT>& X); | |
108 inline const Mat& operator=(const subview_cube<eT>& X); | |
109 inline const Mat& operator+=(const subview_cube<eT>& X); | |
110 inline const Mat& operator-=(const subview_cube<eT>& X); | |
111 inline const Mat& operator*=(const subview_cube<eT>& X); | |
112 inline const Mat& operator%=(const subview_cube<eT>& X); | |
113 inline const Mat& operator/=(const subview_cube<eT>& X); | |
114 | |
115 //inline explicit Mat(const diagview<eT>& X); | |
116 inline Mat(const diagview<eT>& X); | |
117 inline const Mat& operator=(const diagview<eT>& X); | |
118 inline const Mat& operator+=(const diagview<eT>& X); | |
119 inline const Mat& operator-=(const diagview<eT>& X); | |
120 inline const Mat& operator*=(const diagview<eT>& X); | |
121 inline const Mat& operator%=(const diagview<eT>& X); | |
122 inline const Mat& operator/=(const diagview<eT>& X); | |
123 | |
124 template<typename T1> inline Mat(const subview_elem1<eT,T1>& X); | |
125 template<typename T1> inline const Mat& operator= (const subview_elem1<eT,T1>& X); | |
126 template<typename T1> inline const Mat& operator+=(const subview_elem1<eT,T1>& X); | |
127 template<typename T1> inline const Mat& operator-=(const subview_elem1<eT,T1>& X); | |
128 template<typename T1> inline const Mat& operator*=(const subview_elem1<eT,T1>& X); | |
129 template<typename T1> inline const Mat& operator%=(const subview_elem1<eT,T1>& X); | |
130 template<typename T1> inline const Mat& operator/=(const subview_elem1<eT,T1>& X); | |
131 | |
132 template<typename T1, typename T2> inline Mat(const subview_elem2<eT,T1,T2>& X); | |
133 template<typename T1, typename T2> inline const Mat& operator= (const subview_elem2<eT,T1,T2>& X); | |
134 template<typename T1, typename T2> inline const Mat& operator+=(const subview_elem2<eT,T1,T2>& X); | |
135 template<typename T1, typename T2> inline const Mat& operator-=(const subview_elem2<eT,T1,T2>& X); | |
136 template<typename T1, typename T2> inline const Mat& operator*=(const subview_elem2<eT,T1,T2>& X); | |
137 template<typename T1, typename T2> inline const Mat& operator%=(const subview_elem2<eT,T1,T2>& X); | |
138 template<typename T1, typename T2> inline const Mat& operator/=(const subview_elem2<eT,T1,T2>& X); | |
139 | |
140 // Operators on sparse matrices (and subviews). | |
141 template<typename T1> inline explicit Mat(const SpBase<eT, T1>& m); | |
142 template<typename T1> inline const Mat& operator=(const SpBase<eT, T1>& m); | |
143 template<typename T1> inline const Mat& operator+=(const SpBase<eT, T1>& m); | |
144 template<typename T1> inline const Mat& operator-=(const SpBase<eT, T1>& m); | |
145 template<typename T1> inline const Mat& operator*=(const SpBase<eT, T1>& m); | |
146 template<typename T1> inline const Mat& operator%=(const SpBase<eT, T1>& m); | |
147 template<typename T1> inline const Mat& operator/=(const SpBase<eT, T1>& m); | |
148 | |
149 inline mat_injector<Mat> operator<<(const eT val); | |
150 inline mat_injector<Mat> operator<<(const injector_end_of_row<>& x); | |
151 | |
152 | |
153 arma_inline subview_row<eT> row(const uword row_num); | |
154 arma_inline const subview_row<eT> row(const uword row_num) const; | |
155 | |
156 inline subview_row<eT> operator()(const uword row_num, const span& col_span); | |
157 inline const subview_row<eT> operator()(const uword row_num, const span& col_span) const; | |
158 | |
159 | |
160 arma_inline subview_col<eT> col(const uword col_num); | |
161 arma_inline const subview_col<eT> col(const uword col_num) const; | |
162 | |
163 inline subview_col<eT> operator()(const span& row_span, const uword col_num); | |
164 inline const subview_col<eT> operator()(const span& row_span, const uword col_num) const; | |
165 | |
166 inline Col<eT> unsafe_col(const uword col_num); | |
167 inline const Col<eT> unsafe_col(const uword col_num) const; | |
168 | |
169 | |
170 arma_inline subview<eT> rows(const uword in_row1, const uword in_row2); | |
171 arma_inline const subview<eT> rows(const uword in_row1, const uword in_row2) const; | |
172 | |
173 arma_inline subview<eT> cols(const uword in_col1, const uword in_col2); | |
174 arma_inline const subview<eT> cols(const uword in_col1, const uword in_col2) const; | |
175 | |
176 arma_inline subview<eT> submat(const uword in_row1, const uword in_col1, const uword in_row2, const uword in_col2); | |
177 arma_inline const subview<eT> submat(const uword in_row1, const uword in_col1, const uword in_row2, const uword in_col2) const; | |
178 | |
179 | |
180 inline subview<eT> submat (const span& row_span, const span& col_span); | |
181 inline const subview<eT> submat (const span& row_span, const span& col_span) const; | |
182 | |
183 inline subview<eT> operator()(const span& row_span, const span& col_span); | |
184 inline const subview<eT> operator()(const span& row_span, const span& col_span) const; | |
185 | |
186 | |
187 template<typename T1> arma_inline subview_elem1<eT,T1> elem(const Base<uword,T1>& a); | |
188 template<typename T1> arma_inline const subview_elem1<eT,T1> elem(const Base<uword,T1>& a) const; | |
189 | |
190 template<typename T1> arma_inline subview_elem1<eT,T1> operator()(const Base<uword,T1>& a); | |
191 template<typename T1> arma_inline const subview_elem1<eT,T1> operator()(const Base<uword,T1>& a) const; | |
192 | |
193 | |
194 template<typename T1, typename T2> arma_inline subview_elem2<eT,T1,T2> elem(const Base<uword,T1>& ri, const Base<uword,T2>& ci); | |
195 template<typename T1, typename T2> arma_inline const subview_elem2<eT,T1,T2> elem(const Base<uword,T1>& ri, const Base<uword,T2>& ci) const; | |
196 | |
197 template<typename T1, typename T2> arma_inline subview_elem2<eT,T1,T2> submat(const Base<uword,T1>& ri, const Base<uword,T2>& ci); | |
198 template<typename T1, typename T2> arma_inline const subview_elem2<eT,T1,T2> submat(const Base<uword,T1>& ri, const Base<uword,T2>& ci) const; | |
199 | |
200 template<typename T1, typename T2> arma_inline subview_elem2<eT,T1,T2> operator()(const Base<uword,T1>& ri, const Base<uword,T2>& ci); | |
201 template<typename T1, typename T2> arma_inline const subview_elem2<eT,T1,T2> operator()(const Base<uword,T1>& ri, const Base<uword,T2>& ci) const; | |
202 | |
203 | |
204 template<typename T1> arma_inline subview_elem2<eT,T1,T1> rows(const Base<uword,T1>& ri); | |
205 template<typename T1> arma_inline const subview_elem2<eT,T1,T1> rows(const Base<uword,T1>& ri) const; | |
206 | |
207 template<typename T2> arma_inline subview_elem2<eT,T2,T2> cols(const Base<uword,T2>& ci); | |
208 template<typename T2> arma_inline const subview_elem2<eT,T2,T2> cols(const Base<uword,T2>& ci) const; | |
209 | |
210 | |
211 arma_inline subview_each1< Mat<eT>, 0 > each_col(); | |
212 arma_inline subview_each1< Mat<eT>, 1 > each_row(); | |
213 | |
214 template<typename T1> inline subview_each2< Mat<eT>, 0, T1 > each_col(const Base<uword, T1>& indices); | |
215 template<typename T1> inline subview_each2< Mat<eT>, 1, T1 > each_row(const Base<uword, T1>& indices); | |
216 | |
217 arma_inline diagview<eT> diag(const sword in_id = 0); | |
218 arma_inline const diagview<eT> diag(const sword in_id = 0) const; | |
219 | |
220 | |
221 inline void swap_rows(const uword in_row1, const uword in_row2); | |
222 inline void swap_cols(const uword in_col1, const uword in_col2); | |
223 | |
224 inline void shed_row(const uword row_num); | |
225 inline void shed_col(const uword col_num); | |
226 | |
227 inline void shed_rows(const uword in_row1, const uword in_row2); | |
228 inline void shed_cols(const uword in_col1, const uword in_col2); | |
229 | |
230 inline void insert_rows(const uword row_num, const uword N, const bool set_to_zero = true); | |
231 inline void insert_cols(const uword col_num, const uword N, const bool set_to_zero = true); | |
232 | |
233 template<typename T1> inline void insert_rows(const uword row_num, const Base<eT,T1>& X); | |
234 template<typename T1> inline void insert_cols(const uword col_num, const Base<eT,T1>& X); | |
235 | |
236 | |
237 template<typename T1, typename gen_type> inline Mat(const Gen<T1, gen_type>& X); | |
238 template<typename T1, typename gen_type> inline const Mat& operator=(const Gen<T1, gen_type>& X); | |
239 template<typename T1, typename gen_type> inline const Mat& operator+=(const Gen<T1, gen_type>& X); | |
240 template<typename T1, typename gen_type> inline const Mat& operator-=(const Gen<T1, gen_type>& X); | |
241 template<typename T1, typename gen_type> inline const Mat& operator*=(const Gen<T1, gen_type>& X); | |
242 template<typename T1, typename gen_type> inline const Mat& operator%=(const Gen<T1, gen_type>& X); | |
243 template<typename T1, typename gen_type> inline const Mat& operator/=(const Gen<T1, gen_type>& X); | |
244 | |
245 template<typename T1, typename op_type> inline Mat(const Op<T1, op_type>& X); | |
246 template<typename T1, typename op_type> inline const Mat& operator=(const Op<T1, op_type>& X); | |
247 template<typename T1, typename op_type> inline const Mat& operator+=(const Op<T1, op_type>& X); | |
248 template<typename T1, typename op_type> inline const Mat& operator-=(const Op<T1, op_type>& X); | |
249 template<typename T1, typename op_type> inline const Mat& operator*=(const Op<T1, op_type>& X); | |
250 template<typename T1, typename op_type> inline const Mat& operator%=(const Op<T1, op_type>& X); | |
251 template<typename T1, typename op_type> inline const Mat& operator/=(const Op<T1, op_type>& X); | |
252 | |
253 template<typename T1, typename eop_type> inline Mat(const eOp<T1, eop_type>& X); | |
254 template<typename T1, typename eop_type> inline const Mat& operator=(const eOp<T1, eop_type>& X); | |
255 template<typename T1, typename eop_type> inline const Mat& operator+=(const eOp<T1, eop_type>& X); | |
256 template<typename T1, typename eop_type> inline const Mat& operator-=(const eOp<T1, eop_type>& X); | |
257 template<typename T1, typename eop_type> inline const Mat& operator*=(const eOp<T1, eop_type>& X); | |
258 template<typename T1, typename eop_type> inline const Mat& operator%=(const eOp<T1, eop_type>& X); | |
259 template<typename T1, typename eop_type> inline const Mat& operator/=(const eOp<T1, eop_type>& X); | |
260 | |
261 template<typename T1, typename op_type> inline Mat(const mtOp<eT, T1, op_type>& X); | |
262 template<typename T1, typename op_type> inline const Mat& operator=(const mtOp<eT, T1, op_type>& X); | |
263 template<typename T1, typename op_type> inline const Mat& operator+=(const mtOp<eT, T1, op_type>& X); | |
264 template<typename T1, typename op_type> inline const Mat& operator-=(const mtOp<eT, T1, op_type>& X); | |
265 template<typename T1, typename op_type> inline const Mat& operator*=(const mtOp<eT, T1, op_type>& X); | |
266 template<typename T1, typename op_type> inline const Mat& operator%=(const mtOp<eT, T1, op_type>& X); | |
267 template<typename T1, typename op_type> inline const Mat& operator/=(const mtOp<eT, T1, op_type>& X); | |
268 | |
269 template<typename T1, typename T2, typename glue_type> inline Mat(const Glue<T1, T2, glue_type>& X); | |
270 template<typename T1, typename T2, typename glue_type> inline const Mat& operator=(const Glue<T1, T2, glue_type>& X); | |
271 template<typename T1, typename T2, typename glue_type> inline const Mat& operator+=(const Glue<T1, T2, glue_type>& X); | |
272 template<typename T1, typename T2, typename glue_type> inline const Mat& operator-=(const Glue<T1, T2, glue_type>& X); | |
273 template<typename T1, typename T2, typename glue_type> inline const Mat& operator*=(const Glue<T1, T2, glue_type>& X); | |
274 template<typename T1, typename T2, typename glue_type> inline const Mat& operator%=(const Glue<T1, T2, glue_type>& X); | |
275 template<typename T1, typename T2, typename glue_type> inline const Mat& operator/=(const Glue<T1, T2, glue_type>& X); | |
276 | |
277 template<typename T1, typename T2> inline const Mat& operator+=(const Glue<T1, T2, glue_times>& X); | |
278 template<typename T1, typename T2> inline const Mat& operator-=(const Glue<T1, T2, glue_times>& X); | |
279 | |
280 template<typename T1, typename T2, typename eglue_type> inline Mat(const eGlue<T1, T2, eglue_type>& X); | |
281 template<typename T1, typename T2, typename eglue_type> inline const Mat& operator=(const eGlue<T1, T2, eglue_type>& X); | |
282 template<typename T1, typename T2, typename eglue_type> inline const Mat& operator+=(const eGlue<T1, T2, eglue_type>& X); | |
283 template<typename T1, typename T2, typename eglue_type> inline const Mat& operator-=(const eGlue<T1, T2, eglue_type>& X); | |
284 template<typename T1, typename T2, typename eglue_type> inline const Mat& operator*=(const eGlue<T1, T2, eglue_type>& X); | |
285 template<typename T1, typename T2, typename eglue_type> inline const Mat& operator%=(const eGlue<T1, T2, eglue_type>& X); | |
286 template<typename T1, typename T2, typename eglue_type> inline const Mat& operator/=(const eGlue<T1, T2, eglue_type>& X); | |
287 | |
288 template<typename T1, typename T2, typename glue_type> inline Mat(const mtGlue<eT, T1, T2, glue_type>& X); | |
289 template<typename T1, typename T2, typename glue_type> inline const Mat& operator=(const mtGlue<eT, T1, T2, glue_type>& X); | |
290 template<typename T1, typename T2, typename glue_type> inline const Mat& operator+=(const mtGlue<eT, T1, T2, glue_type>& X); | |
291 template<typename T1, typename T2, typename glue_type> inline const Mat& operator-=(const mtGlue<eT, T1, T2, glue_type>& X); | |
292 template<typename T1, typename T2, typename glue_type> inline const Mat& operator*=(const mtGlue<eT, T1, T2, glue_type>& X); | |
293 template<typename T1, typename T2, typename glue_type> inline const Mat& operator%=(const mtGlue<eT, T1, T2, glue_type>& X); | |
294 template<typename T1, typename T2, typename glue_type> inline const Mat& operator/=(const mtGlue<eT, T1, T2, glue_type>& X); | |
295 | |
296 | |
297 arma_inline arma_warn_unused const eT& at_alt (const uword ii) const; | |
298 | |
299 arma_inline arma_warn_unused eT& operator[] (const uword ii); | |
300 arma_inline arma_warn_unused const eT& operator[] (const uword ii) const; | |
301 arma_inline arma_warn_unused eT& at (const uword ii); | |
302 arma_inline arma_warn_unused const eT& at (const uword ii) const; | |
303 arma_inline arma_warn_unused eT& operator() (const uword ii); | |
304 arma_inline arma_warn_unused const eT& operator() (const uword ii) const; | |
305 | |
306 arma_inline arma_warn_unused eT& at (const uword in_row, const uword in_col); | |
307 arma_inline arma_warn_unused const eT& at (const uword in_row, const uword in_col) const; | |
308 arma_inline arma_warn_unused eT& operator() (const uword in_row, const uword in_col); | |
309 arma_inline arma_warn_unused const eT& operator() (const uword in_row, const uword in_col) const; | |
310 | |
311 arma_inline const Mat& operator++(); | |
312 arma_inline void operator++(int); | |
313 | |
314 arma_inline const Mat& operator--(); | |
315 arma_inline void operator--(int); | |
316 | |
317 arma_inline arma_warn_unused bool is_empty() const; | |
318 arma_inline arma_warn_unused bool is_vec() const; | |
319 arma_inline arma_warn_unused bool is_rowvec() const; | |
320 arma_inline arma_warn_unused bool is_colvec() const; | |
321 arma_inline arma_warn_unused bool is_square() const; | |
322 inline arma_warn_unused bool is_finite() const; | |
323 | |
324 arma_inline arma_warn_unused bool in_range(const uword ii) const; | |
325 arma_inline arma_warn_unused bool in_range(const span& x ) const; | |
326 | |
327 arma_inline arma_warn_unused bool in_range(const uword in_row, const uword in_col) const; | |
328 arma_inline arma_warn_unused bool in_range(const span& row_span, const uword in_col) const; | |
329 arma_inline arma_warn_unused bool in_range(const uword in_row, const span& col_span) const; | |
330 arma_inline arma_warn_unused bool in_range(const span& row_span, const span& col_span) const; | |
331 | |
332 arma_inline arma_warn_unused eT* colptr(const uword in_col); | |
333 arma_inline arma_warn_unused const eT* colptr(const uword in_col) const; | |
334 | |
335 arma_inline arma_warn_unused eT* memptr(); | |
336 arma_inline arma_warn_unused const eT* memptr() const; | |
337 | |
338 | |
339 inline void impl_print(const std::string& extra_text) const; | |
340 inline void impl_print(std::ostream& user_stream, const std::string& extra_text) const; | |
341 | |
342 inline void impl_raw_print(const std::string& extra_text) const; | |
343 inline void impl_raw_print(std::ostream& user_stream, const std::string& extra_text) const; | |
344 | |
345 | |
346 template<typename eT2, typename expr> | |
347 inline void copy_size(const Base<eT2,expr>& X); | |
348 | |
349 inline void set_size(const uword in_elem); | |
350 inline void set_size(const uword in_rows, const uword in_cols); | |
351 | |
352 inline void resize(const uword in_elem); | |
353 inline void resize(const uword in_rows, const uword in_cols); | |
354 inline void reshape(const uword in_rows, const uword in_cols, const uword dim = 0); | |
355 | |
356 | |
357 template<typename functor> | |
358 inline const Mat& transform(functor F); | |
359 | |
360 template<typename functor> | |
361 inline const Mat& imbue(functor F); | |
362 | |
363 | |
364 arma_hot inline const Mat& fill(const eT val); | |
365 | |
366 inline const Mat& zeros(); | |
367 inline const Mat& zeros(const uword in_elem); | |
368 inline const Mat& zeros(const uword in_rows, const uword in_cols); | |
369 | |
370 inline const Mat& ones(); | |
371 inline const Mat& ones(const uword in_elem); | |
372 inline const Mat& ones(const uword in_rows, const uword in_cols); | |
373 | |
374 inline const Mat& randu(); | |
375 inline const Mat& randu(const uword in_elem); | |
376 inline const Mat& randu(const uword in_rows, const uword in_cols); | |
377 | |
378 inline const Mat& randn(); | |
379 inline const Mat& randn(const uword in_elem); | |
380 inline const Mat& randn(const uword in_rows, const uword in_cols); | |
381 | |
382 inline const Mat& eye(); | |
383 inline const Mat& eye(const uword in_rows, const uword in_cols); | |
384 | |
385 inline void reset(); | |
386 | |
387 | |
388 template<typename T1> inline void set_real(const Base<pod_type,T1>& X); | |
389 template<typename T1> inline void set_imag(const Base<pod_type,T1>& X); | |
390 | |
391 | |
392 inline arma_warn_unused eT min() const; | |
393 inline arma_warn_unused eT max() const; | |
394 | |
395 inline eT min(uword& index_of_min_val) const; | |
396 inline eT max(uword& index_of_max_val) const; | |
397 | |
398 inline eT min(uword& row_of_min_val, uword& col_of_min_val) const; | |
399 inline eT max(uword& row_of_max_val, uword& col_of_max_val) const; | |
400 | |
401 | |
402 inline bool save(const std::string name, const file_type type = arma_binary, const bool print_status = true) const; | |
403 inline bool save( std::ostream& os, const file_type type = arma_binary, const bool print_status = true) const; | |
404 | |
405 inline bool load(const std::string name, const file_type type = auto_detect, const bool print_status = true); | |
406 inline bool load( std::istream& is, const file_type type = auto_detect, const bool print_status = true); | |
407 | |
408 inline bool quiet_save(const std::string name, const file_type type = arma_binary) const; | |
409 inline bool quiet_save( std::ostream& os, const file_type type = arma_binary) const; | |
410 | |
411 inline bool quiet_load(const std::string name, const file_type type = auto_detect); | |
412 inline bool quiet_load( std::istream& is, const file_type type = auto_detect); | |
413 | |
414 | |
415 // for container-like functionality | |
416 | |
417 typedef eT value_type; | |
418 typedef uword size_type; | |
419 | |
420 typedef eT* iterator; | |
421 typedef const eT* const_iterator; | |
422 | |
423 typedef eT* col_iterator; | |
424 typedef const eT* const_col_iterator; | |
425 | |
426 class row_iterator | |
427 { | |
428 public: | |
429 | |
430 inline row_iterator(Mat<eT>& in_M, const uword in_row); | |
431 | |
432 inline eT& operator* (); | |
433 | |
434 inline row_iterator& operator++(); | |
435 inline void operator++(int); | |
436 | |
437 inline row_iterator& operator--(); | |
438 inline void operator--(int); | |
439 | |
440 inline bool operator!=(const row_iterator& X) const; | |
441 inline bool operator==(const row_iterator& X) const; | |
442 | |
443 arma_aligned Mat<eT>& M; | |
444 arma_aligned uword row; | |
445 arma_aligned uword col; | |
446 }; | |
447 | |
448 | |
449 class const_row_iterator | |
450 { | |
451 public: | |
452 | |
453 const_row_iterator(const Mat<eT>& in_M, const uword in_row); | |
454 const_row_iterator(const row_iterator& X); | |
455 | |
456 inline eT operator*() const; | |
457 | |
458 inline const_row_iterator& operator++(); | |
459 inline void operator++(int); | |
460 | |
461 inline const_row_iterator& operator--(); | |
462 inline void operator--(int); | |
463 | |
464 inline bool operator!=(const const_row_iterator& X) const; | |
465 inline bool operator==(const const_row_iterator& X) const; | |
466 | |
467 arma_aligned const Mat<eT>& M; | |
468 arma_aligned uword row; | |
469 arma_aligned uword col; | |
470 }; | |
471 | |
472 inline iterator begin(); | |
473 inline const_iterator begin() const; | |
474 inline const_iterator cbegin() const; | |
475 | |
476 inline iterator end(); | |
477 inline const_iterator end() const; | |
478 inline const_iterator cend() const; | |
479 | |
480 inline col_iterator begin_col(const uword col_num); | |
481 inline const_col_iterator begin_col(const uword col_num) const; | |
482 | |
483 inline col_iterator end_col (const uword col_num); | |
484 inline const_col_iterator end_col (const uword col_num) const; | |
485 | |
486 inline row_iterator begin_row(const uword row_num); | |
487 inline const_row_iterator begin_row(const uword row_num) const; | |
488 | |
489 inline row_iterator end_row (const uword row_num); | |
490 inline const_row_iterator end_row (const uword row_num) const; | |
491 | |
492 inline void clear(); | |
493 inline bool empty() const; | |
494 inline uword size() const; | |
495 | |
496 inline void swap(Mat& B); | |
497 | |
498 inline void steal_mem(Mat& X); //!< don't use this unless you're writing code internal to Armadillo | |
499 | |
500 template<uword fixed_n_rows, uword fixed_n_cols> class fixed; | |
501 | |
502 | |
503 protected: | |
504 | |
505 inline void init_cold(); | |
506 inline void init_warm(uword in_rows, uword in_cols); | |
507 | |
508 inline void init(const std::string& text); | |
509 | |
510 #if defined(ARMA_USE_CXX11) | |
511 inline void init(const std::initializer_list<eT>& list); | |
512 #endif | |
513 | |
514 template<typename T1, typename T2> | |
515 inline void init(const Base<pod_type,T1>& A, const Base<pod_type,T2>& B); | |
516 | |
517 inline Mat(const char junk, const eT* aux_mem, const uword aux_n_rows, const uword aux_n_cols); | |
518 | |
519 inline Mat(const arma_vec_indicator&, const uhword in_vec_state); | |
520 inline Mat(const arma_vec_indicator&, const uword in_n_rows, const uword in_n_cols, const uhword in_vec_state); | |
521 | |
522 inline Mat(const arma_fixed_indicator&, const uword in_n_rows, const uword in_n_cols, const uhword in_vec_state, const eT* in_mem); | |
523 | |
524 | |
525 friend class Cube<eT>; | |
526 friend class glue_join; | |
527 friend class op_strans; | |
528 friend class op_htrans; | |
529 friend class op_resize; | |
530 | |
531 public: | |
532 | |
533 #ifdef ARMA_EXTRA_MAT_PROTO | |
534 #include ARMA_INCFILE_WRAP(ARMA_EXTRA_MAT_PROTO) | |
535 #endif | |
536 }; | |
537 | |
538 | |
539 | |
540 template<typename eT> | |
541 template<uword fixed_n_rows, uword fixed_n_cols> | |
542 class Mat<eT>::fixed : public Mat<eT> | |
543 { | |
544 private: | |
545 | |
546 static const uword fixed_n_elem = fixed_n_rows * fixed_n_cols; | |
547 static const bool use_extra = (fixed_n_elem > arma_config::mat_prealloc); | |
548 | |
549 arma_align_mem eT mem_local_extra[ (use_extra) ? fixed_n_elem : 1 ]; | |
550 | |
551 | |
552 public: | |
553 | |
554 typedef fixed<fixed_n_rows, fixed_n_cols> Mat_fixed_type; | |
555 | |
556 typedef eT elem_type; | |
557 typedef typename get_pod_type<eT>::result pod_type; | |
558 | |
559 static const bool is_col = (fixed_n_cols == 1) ? true : false; | |
560 static const bool is_row = (fixed_n_rows == 1) ? true : false; | |
561 | |
562 static const uword n_rows = fixed_n_rows; | |
563 static const uword n_cols = fixed_n_cols; | |
564 static const uword n_elem = fixed_n_elem; | |
565 | |
566 arma_inline fixed(); | |
567 arma_inline fixed(const fixed<fixed_n_rows, fixed_n_cols>& X); | |
568 | |
569 template<typename T1> inline fixed(const Base<eT,T1>& A); | |
570 template<typename T1, typename T2> inline fixed(const Base<pod_type,T1>& A, const Base<pod_type,T2>& B); | |
571 | |
572 inline fixed(const eT* aux_mem); | |
573 | |
574 inline fixed(const char* text); | |
575 inline fixed(const std::string& text); | |
576 | |
577 using Mat<eT>::operator=; | |
578 using Mat<eT>::operator(); | |
579 | |
580 #if defined(ARMA_USE_CXX11) | |
581 inline fixed(const std::initializer_list<eT>& list); | |
582 inline const Mat& operator=(const std::initializer_list<eT>& list); | |
583 #endif | |
584 | |
585 arma_inline const Op< Mat_fixed_type, op_htrans > t() const; | |
586 arma_inline const Op< Mat_fixed_type, op_htrans > ht() const; | |
587 arma_inline const Op< Mat_fixed_type, op_strans > st() const; | |
588 | |
589 arma_inline arma_warn_unused const eT& at_alt (const uword i) const; | |
590 | |
591 arma_inline arma_warn_unused eT& operator[] (const uword i); | |
592 arma_inline arma_warn_unused const eT& operator[] (const uword i) const; | |
593 arma_inline arma_warn_unused eT& at (const uword i); | |
594 arma_inline arma_warn_unused const eT& at (const uword i) const; | |
595 arma_inline arma_warn_unused eT& operator() (const uword i); | |
596 arma_inline arma_warn_unused const eT& operator() (const uword i) const; | |
597 | |
598 arma_inline arma_warn_unused eT& at (const uword in_row, const uword in_col); | |
599 arma_inline arma_warn_unused const eT& at (const uword in_row, const uword in_col) const; | |
600 arma_inline arma_warn_unused eT& operator() (const uword in_row, const uword in_col); | |
601 arma_inline arma_warn_unused const eT& operator() (const uword in_row, const uword in_col) const; | |
602 | |
603 arma_inline arma_warn_unused eT* colptr(const uword in_col); | |
604 arma_inline arma_warn_unused const eT* colptr(const uword in_col) const; | |
605 | |
606 arma_inline arma_warn_unused eT* memptr(); | |
607 arma_inline arma_warn_unused const eT* memptr() const; | |
608 | |
609 arma_inline arma_warn_unused bool is_vec() const; | |
610 | |
611 arma_hot inline const Mat<eT>& fill(const eT val); | |
612 arma_hot inline const Mat<eT>& zeros(); | |
613 arma_hot inline const Mat<eT>& ones(); | |
614 }; | |
615 | |
616 | |
617 | |
618 class Mat_aux | |
619 { | |
620 public: | |
621 | |
622 template<typename eT> arma_inline static void prefix_pp(Mat<eT>& x); | |
623 template<typename T> arma_inline static void prefix_pp(Mat< std::complex<T> >& x); | |
624 | |
625 template<typename eT> arma_inline static void postfix_pp(Mat<eT>& x); | |
626 template<typename T> arma_inline static void postfix_pp(Mat< std::complex<T> >& x); | |
627 | |
628 template<typename eT> arma_inline static void prefix_mm(Mat<eT>& x); | |
629 template<typename T> arma_inline static void prefix_mm(Mat< std::complex<T> >& x); | |
630 | |
631 template<typename eT> arma_inline static void postfix_mm(Mat<eT>& x); | |
632 template<typename T> arma_inline static void postfix_mm(Mat< std::complex<T> >& x); | |
633 | |
634 template<typename eT, typename T1> inline static void set_real(Mat<eT>& out, const Base<eT,T1>& X); | |
635 template<typename T, typename T1> inline static void set_real(Mat< std::complex<T> >& out, const Base< T,T1>& X); | |
636 | |
637 template<typename eT, typename T1> inline static void set_imag(Mat<eT>& out, const Base<eT,T1>& X); | |
638 template<typename T, typename T1> inline static void set_imag(Mat< std::complex<T> >& out, const Base< T,T1>& X); | |
639 }; | |
640 | |
641 | |
642 | |
643 //! @} |