Mat_bones.hpp
Go to the documentation of this file.
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 
16 
17 
18 
20 
21 template<typename eT>
22 class Mat : public Base< eT, Mat<eT> >
23  {
24  public:
25 
26  typedef eT elem_type;
28 
29  const uword n_rows;
30  const uword n_cols;
31  const uword n_elem;
32  const uhword vec_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;
41 
42  protected:
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);
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 
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;
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 
271  arma_inline arma_warn_unused bool is_vec() 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 
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 
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 
398  };
399 
400 
402  {
403  public:
404 
405  const_row_iterator(const Mat<eT>& in_M, const uword in_row);
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 
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();
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 
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;
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 
bool quiet_save(const std::string name, const file_type type=arma_binary) const
save the matrix to a file, without printing any error messages
Definition: Mat_meat.hpp:4938
iterator end()
Definition: Mat_meat.hpp:5231
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:...
Definition: Mat_bones.hpp:27
arma_inline arma_warn_unused bool is_vec() const
returns true if the object can be interpreted as a column or row vector
Definition: Mat_meat.hpp:3824
arma_inline arma_warn_unused eT * memptr()
returns a pointer to array of eTs used by the matrix
Definition: Mat_meat.hpp:4024
row_iterator(Mat< eT > &in_M, const uword in_row)
Definition: Mat_meat.hpp:4988
row_iterator & operator--()
Definition: Mat_meat.hpp:5039
void set_size(const uword in_elem)
change the matrix to have user specified dimensions (data is not preserved)
Definition: Mat_meat.hpp:4211
arma_warn_unused bool is_finite() const
returns true if all of the elements are finite
Definition: Mat_meat.hpp:3872
arma_aligned uword col
Definition: Mat_bones.hpp:397
const Mat & eye()
Definition: Mat_meat.hpp:4518
const uhword mem_state
Definition: Mat_bones.hpp:33
static const uword mat_prealloc
Definition: arma_config.hpp:24
iterator begin()
Definition: Mat_meat.hpp:5207
void steal_mem(Mat &X)
Definition: Mat_meat.hpp:630
void shed_rows(const uword in_row1, const uword in_row2)
remove specified rows
Definition: Mat_meat.hpp:2419
arma_inline subview< eT > submat(const uword in_row1, const uword in_col1, const uword in_row2, const uword in_col2)
creation of subview (submatrix)
Definition: Mat_meat.hpp:2092
arma_inline const Mat & operator--()
prefix –
Definition: Mat_meat.hpp:3788
void impl_raw_print_trans(const std::string &extra_text) const
DEPRECATED FUNCTION.
Definition: Mat_meat.hpp:4179
uword size() const
returns the number of elements in this matrix
Definition: Mat_meat.hpp:5390
arma_inline arma_warn_unused bool is_colvec() const
returns true if the object can be interpreted as a column vector
Definition: Mat_meat.hpp:3848
&#39;matrix transpose&#39; operation
Definition: span.hpp:35
void init_warm(uword in_rows, uword in_cols)
internal matrix construction; if the requested size is small enough, memory from the stack is used...
Definition: Mat_meat.hpp:126
const uword n_cols
number of columns in the matrix (read-only)
Definition: Mat_bones.hpp:30
support class for generator functions (eg. zeros, randu, randn, ...)
void init_cold()
Definition: Mat_meat.hpp:86
Mat()
Definition: Mat_meat.hpp:52
arma_inline subview_col< eT > col(const uword col_num)
creation of subview (column vector)
Definition: Mat_meat.hpp:1880
void set_real(const Base< pod_type, T1 > &X)
arma_aligned const Mat< eT > & M
Definition: Mat_bones.hpp:419
arma_inline subview_row< eT > row(const uword row_num)
creation of subview (row vector)
Definition: Mat_meat.hpp:1792
arma_inline const Mat & operator+=(const eT val)
In-place addition of a scalar to all elements of the matrix.
Definition: Mat_meat.hpp:467
const uword n_elem
number of elements in the matrix (read-only)
Definition: Mat_bones.hpp:31
arma_aligned Mat< eT > & M
Definition: Mat_bones.hpp:395
const uword n_rows
number of rows in the matrix (read-only)
Definition: Mat_bones.hpp:29
arma_inline subview< eT > rows(const uword in_row1, const uword in_row2)
creation of subview (submatrix comprised of specified row vectors)
Definition: Mat_meat.hpp:2008
bool empty() const
returns true if the matrix has no elements
Definition: Mat_meat.hpp:5379
void reshape(const uword in_rows, const uword in_cols, const uword dim=0)
change the matrix to have user specified dimensions (data is preserved)
Definition: Mat_meat.hpp:4289
void insert_cols(const uword col_num, const uword N, const bool set_to_zero=true)
Definition: Mat_meat.hpp:2531
arma_inline arma_warn_unused eT * colptr(const uword in_col)
returns a pointer to array of eTs for a specified column; no bounds check
Definition: Mat_meat.hpp:4000
void insert_rows(const uword row_num, const uword N, const bool set_to_zero=true)
Definition: Mat_meat.hpp:2488
u32 uword
Definition: typedef.hpp:85
row_iterator & operator++()
Definition: Mat_meat.hpp:5011
Class for column vectors (matrices with only one column)
Definition: Col_bones.hpp:20
~Mat()
Definition: Mat_meat.hpp:20
arma_warn_unused eT min() const
Definition: Mat_meat.hpp:4605
void init(const std::string &text)
internal function to create the matrix from a textual description
Definition: Mat_meat.hpp:318
eT elem_type
the type of elements stored in the matrix
Definition: Mat_bones.hpp:26
void resize(const uword in_elem)
change the matrix to have user specified dimensions (data is preserved)
Definition: Mat_meat.hpp:4250
void set_imag(const Base< pod_type, T1 > &X)
file_type
uword size_type
Definition: Mat_bones.hpp:370
const Mat & ones()
Definition: Mat_meat.hpp:4371
arma_inline arma_warn_unused bool is_rowvec() const
returns true if the object can be interpreted as a row vector
Definition: Mat_meat.hpp:3836
bool operator!=(const row_iterator &X) const
Definition: Mat_meat.hpp:5072
void impl_print(const std::string &extra_text) const
Definition: Mat_meat.hpp:4050
col_iterator begin_col(const uword col_num)
Definition: Mat_meat.hpp:5255
mat_injector< Mat > operator<<(const eT val)
Definition: Mat_meat.hpp:1771
arma_inline arma_warn_unused eT & at(const uword i)
linear element accessor (treats the matrix as a vector); no bounds check.
Definition: Mat_meat.hpp:3692
arma_inline arma_warn_unused bool is_square() const
returns true if the object has the same number of non-zero rows and columnns
Definition: Mat_meat.hpp:3860
subview_row< eT > operator()(const uword row_num, const span &col_span)
Definition: Mat_meat.hpp:1821
col_iterator end_col(const uword col_num)
Definition: Mat_meat.hpp:5283
Dense cube class.
Definition: Cube_bones.hpp:30
arma_inline const Mat & operator/=(const eT val)
In-place division of all elements of the matrix with a scalar.
Definition: Mat_meat.hpp:512
arma_inline arma_warn_unused eT & operator[](const uword i)
linear element accessor (treats the matrix as a vector); no bounds check.
Definition: Mat_meat.hpp:3668
const Mat & operator=(const char *text)
create the matrix from a textual description
Definition: Mat_meat.hpp:272
Armadillo binary format, with information about matrix type and size.
arma_inline arma_warn_unused bool in_range(const uword i) const
returns true if the given index is currently in range
Definition: Mat_meat.hpp:3884
arma_inline diagview< eT > diag(const sword in_id=0)
creation of diagview (diagonal)
Definition: Mat_meat.hpp:2284
eT value_type
Definition: Mat_bones.hpp:369
void reset()
Definition: Mat_meat.hpp:4553
void copy_size(const Mat< eT2 > &m)
change the matrix (without preserving data) to have the same dimensions as the given matrix ...
Definition: Mat_meat.hpp:4303
u16 uhword
Definition: typedef.hpp:88
#define arma_aligned
void swap_cols(const uword in_col1, const uword in_col2)
Definition: Mat_meat.hpp:2359
bool operator==(const row_iterator &X) const
Definition: Mat_meat.hpp:5082
&#39;hermitian transpose&#39; operation
void shed_col(const uword col_num)
remove specified column
Definition: Mat_meat.hpp:2404
const eT * const_iterator
Definition: Mat_bones.hpp:373
bool load(const std::string name, const file_type type=auto_detect, const bool print_status=true)
load a matrix from a file
Definition: Mat_meat.hpp:4801
row_iterator end_row(const uword row_num)
Definition: Mat_meat.hpp:5339
Analog of the Base class, intended for cubes.
#define arma_warn_unused
arma_inline const Mat & operator++()
prefix ++
Definition: Mat_meat.hpp:3765
bool quiet_load(const std::string name, const file_type type=auto_detect)
load a matrix from a file, without printing any error messages
Definition: Mat_meat.hpp:4964
arma_aligned uword col
Definition: Mat_bones.hpp:421
Col< eT > unsafe_col(const uword col_num)
Definition: Mat_meat.hpp:1972
row_iterator begin_row(const uword row_num)
Definition: Mat_meat.hpp:5311
arma_aligned uword row
Definition: Mat_bones.hpp:396
void shed_row(const uword row_num)
remove specified row
Definition: Mat_meat.hpp:2389
Dense matrix class.
arma_inline subview_elem1< eT, T1 > elem(const Base< uword, T1 > &a)
Definition: Mat_meat.hpp:2232
#define arma_inline
arma_inline const Mat & operator*=(const eT val)
In-place multiplication of all elements of the matrix with a scalar.
Definition: Mat_meat.hpp:497
void shed_cols(const uword in_col1, const uword in_col2)
remove specified columns
Definition: Mat_meat.hpp:2453
const Mat & zeros()
Definition: Mat_meat.hpp:4331
arma_aligned eT mem_local[arma_config::mat_prealloc]
Definition: Mat_bones.hpp:43
arma_inline subview< eT > cols(const uword in_col1, const uword in_col2)
creation of subview (submatrix comprised of specified column vectors)
Definition: Mat_meat.hpp:2050
const eT * const_col_iterator
Definition: Mat_bones.hpp:376
arma_aligned const eT *const mem
pointer to the memory used by the matrix (memory is read-only)
Definition: Mat_bones.hpp:40
const Mat & operator%=(const Mat &m)
in-place element-wise matrix multiplication
Definition: Mat_meat.hpp:809
arma_aligned uword row
Definition: Mat_bones.hpp:420
Class for storing data required to extract and set the diagonals of a matrix.
const uhword vec_state
0: matrix layout; 1: column vector layout; 2: row vector layout
Definition: Mat_bones.hpp:32
bool save(const std::string name, const file_type type=arma_binary, const bool print_status=true) const
save the matrix to a file
Definition: Mat_meat.hpp:4705
void clear()
resets this matrix to an empty matrix
Definition: Mat_meat.hpp:5368
void impl_raw_print(const std::string &extra_text) const
Definition: Mat_meat.hpp:4132
#define arma_hot
void impl_print_trans(const std::string &extra_text) const
DEPRECATED FUNCTION.
Definition: Mat_meat.hpp:4097
s32 sword
Definition: typedef.hpp:86
arma_hot const Mat & fill(const eT val)
fill the matrix with the specified value
Definition: Mat_meat.hpp:4317
eT * iterator
Definition: Mat_bones.hpp:372
arma_inline const Mat & operator-=(const eT val)
In-place subtraction of a scalar from all elements of the matrix.
Definition: Mat_meat.hpp:482
const Mat & randu()
Definition: Mat_meat.hpp:4411
void swap_rows(const uword in_row1, const uword in_row2)
Definition: Mat_meat.hpp:2331
Automatically detect the file type (file must be one of the following types)
arma_inline arma_warn_unused bool is_empty() const
returns true if the matrix has no elements
Definition: Mat_meat.hpp:3812
arma_warn_unused eT max() const
Definition: Mat_meat.hpp:4620
eT * col_iterator
Definition: Mat_bones.hpp:375
const Mat & randn()
Definition: Mat_meat.hpp:4470


armadillo_matrix
Author(s):
autogenerated on Fri Apr 16 2021 02:31:58