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