subview_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 // Copyright (C) 2011 James Sanders
4 //
5 // This file is part of the Armadillo C++ library.
6 // It is provided without any warranty of fitness
7 // for any purpose. You can redistribute this file
8 // and/or modify it under the terms of the GNU
9 // Lesser General Public License (LGPL) as published
10 // by the Free Software Foundation, either version 3
11 // of the License or (at your option) any later version.
12 // (see http://www.opensource.org/licenses for more info)
13 
14 
17 
18 
21 template<typename eT>
22 class subview : public Base<eT, subview<eT> >
23  {
24  public: arma_aligned const Mat<eT>& m;
25  protected: arma_aligned Mat<eT>* m_ptr;
26 
27  public:
28 
29  typedef eT elem_type;
31 
32  const uword aux_row1;
33  const uword aux_col1;
34 
35  const uword n_rows;
36  const uword n_cols;
37  const uword n_elem;
38 
39 
40  protected:
41 
42  arma_inline subview(const Mat<eT>& in_m, const uword in_row1, const uword in_col1, const uword in_n_rows, const uword in_n_cols);
43  arma_inline subview( Mat<eT>& in_m, const uword in_row1, const uword in_col1, const uword in_n_rows, const uword in_n_cols);
44 
45 
46  public:
47 
48  inline ~subview();
49 
50  inline void operator+= (const eT val);
51  inline void operator-= (const eT val);
52  inline void operator*= (const eT val);
53  inline void operator/= (const eT val);
54 
55  // deliberately returning void
56  template<typename T1> inline void operator= (const Base<eT,T1>& x);
57  template<typename T1> inline void operator+= (const Base<eT,T1>& x);
58  template<typename T1> inline void operator-= (const Base<eT,T1>& x);
59  template<typename T1> inline void operator%= (const Base<eT,T1>& x);
60  template<typename T1> inline void operator/= (const Base<eT,T1>& x);
61 
62  inline void operator= (const subview& x);
63  inline void operator+= (const subview& x);
64  inline void operator-= (const subview& x);
65  inline void operator%= (const subview& x);
66  inline void operator/= (const subview& x);
67 
68  inline static void extract(Mat<eT>& out, const subview& in);
69 
70  inline static void plus_inplace(Mat<eT>& out, const subview& in);
71  inline static void minus_inplace(Mat<eT>& out, const subview& in);
72  inline static void schur_inplace(Mat<eT>& out, const subview& in);
73  inline static void div_inplace(Mat<eT>& out, const subview& in);
74 
75  inline void fill(const eT val);
76  inline void zeros();
77  inline void ones();
78  inline void eye();
79 
80  inline eT& operator[](const uword i);
81  inline eT operator[](const uword i) const;
82 
83  inline eT& operator()(const uword i);
84  inline eT operator()(const uword i) const;
85 
86  inline eT& operator()(const uword in_row, const uword in_col);
87  inline eT operator()(const uword in_row, const uword in_col) const;
88 
89  inline eT& at(const uword in_row, const uword in_col);
90  inline eT at(const uword in_row, const uword in_col) const;
91 
92  arma_inline eT* colptr(const uword in_col);
93  arma_inline const eT* colptr(const uword in_col) const;
94 
95  inline bool check_overlap(const subview& x) const;
96 
97  inline bool is_vec() const;
98 
99  inline subview_row<eT> row(const uword row_num);
100  inline const subview_row<eT> row(const uword row_num) const;
101 
102  inline subview_row<eT> operator()(const uword row_num, const span& col_span);
103  inline const subview_row<eT> operator()(const uword row_num, const span& col_span) const;
104 
105  inline subview_col<eT> col(const uword col_num);
106  inline const subview_col<eT> col(const uword col_num) const;
107 
108  inline subview_col<eT> operator()(const span& row_span, const uword col_num);
109  inline const subview_col<eT> operator()(const span& row_span, const uword col_num) const;
110 
111  inline Col<eT> unsafe_col(const uword col_num);
112  inline const Col<eT> unsafe_col(const uword col_num) const;
113 
114  inline subview<eT> rows(const uword in_row1, const uword in_row2);
115  inline const subview<eT> rows(const uword in_row1, const uword in_row2) const;
116 
117  inline subview<eT> cols(const uword in_col1, const uword in_col2);
118  inline const subview<eT> cols(const uword in_col1, const uword in_col2) const;
119 
120  inline subview<eT> submat(const uword in_row1, const uword in_col1, const uword in_row2, const uword in_col2);
121  inline const subview<eT> submat(const uword in_row1, const uword in_col1, const uword in_row2, const uword in_col2) const;
122 
123  inline subview<eT> submat (const span& row_span, const span& col_span);
124  inline const subview<eT> submat (const span& row_span, const span& col_span) const;
125 
126  inline subview<eT> operator()(const span& row_span, const span& col_span);
127  inline const subview<eT> operator()(const span& row_span, const span& col_span) const;
128 
129  inline diagview<eT> diag(const sword in_id = 0);
130  inline const diagview<eT> diag(const sword in_id = 0) const;
131 
132  inline void swap_rows(const uword in_row1, const uword in_row2);
133  inline void swap_cols(const uword in_col1, const uword in_col2);
134 
135 
136  // // primitive forward iterator
137  // class iter
138  // {
139  // public:
140  //
141  // inline iter(const subview<eT>& in_M);
142  //
143  // arma_inline eT operator* () const;
144  //
145  // inline void operator++();
146  // inline void operator++(int);
147  //
148  //
149  // private:
150  //
151  // arma_aligned const eT* mem;
152  //
153  // arma_aligned uword n_rows;
154  //
155  // arma_aligned uword row_start;
156  // arma_aligned uword row_end_p1;
157  //
158  // arma_aligned uword row;
159  // arma_aligned uword col;
160  // arma_aligned uword i;
161  // };
162 
163 
164  private:
165 
166  friend class Mat<eT>;
167  subview();
168  };
169 
170 
171 
172 template<typename eT>
173 class subview_col : public subview<eT>
174  {
175  public:
176 
177  typedef eT elem_type;
179 
180  inline void operator= (const subview<eT>& x);
181  inline void operator= (const subview_col& x);
182 
183  template<typename T1>
184  inline void operator= (const Base<eT,T1>& x);
185 
186  inline subview_col<eT> rows(const uword in_row1, const uword in_row2);
187  inline const subview_col<eT> rows(const uword in_row1, const uword in_row2) const;
188 
189  inline subview_col<eT> subvec(const uword in_row1, const uword in_row2);
190  inline const subview_col<eT> subvec(const uword in_row1, const uword in_row2) const;
191 
192 
193  protected:
194 
195  inline subview_col(const Mat<eT>& in_m, const uword in_col);
196  inline subview_col( Mat<eT>& in_m, const uword in_col);
197 
198  inline subview_col(const Mat<eT>& in_m, const uword in_col, const uword in_row1, const uword in_n_rows);
199  inline subview_col( Mat<eT>& in_m, const uword in_col, const uword in_row1, const uword in_n_rows);
200 
201 
202  private:
203 
204  friend class Mat<eT>;
205  friend class Col<eT>;
206  friend class subview<eT>;
207 
208  subview_col();
209  };
210 
211 
212 
213 template<typename eT>
214 class subview_row : public subview<eT>
215  {
216  public:
217 
218  typedef eT elem_type;
220 
221  inline void operator= (const subview<eT>& x);
222  inline void operator= (const subview_row& x);
223 
224  template<typename T1>
225  inline void operator= (const Base<eT,T1>& x);
226 
227  inline subview_row<eT> cols(const uword in_col1, const uword in_col2);
228  inline const subview_row<eT> cols(const uword in_col1, const uword in_col2) const;
229 
230  inline subview_row<eT> subvec(const uword in_col1, const uword in_col2);
231  inline const subview_row<eT> subvec(const uword in_col1, const uword in_col2) const;
232 
233 
234  protected:
235 
236  inline subview_row(const Mat<eT>& in_m, const uword in_row);
237  inline subview_row( Mat<eT>& in_m, const uword in_row);
238 
239  inline subview_row(const Mat<eT>& in_m, const uword in_row, const uword in_col1, const uword in_n_cols);
240  inline subview_row( Mat<eT>& in_m, const uword in_row, const uword in_col1, const uword in_n_cols);
241 
242 
243  private:
244 
245  friend class Mat<eT>;
246  friend class Row<eT>;
247  friend class subview<eT>;
248 
249  subview_row();
250  };
251 
252 
253 
static void extract(Mat< eT > &out, const subview &in)
X = Y.submat(...)
const uword aux_col1
void ones()
void operator/=(const eT val)
static void div_inplace(Mat< eT > &out, const subview &in)
X /= Y.submat(...)
get_pod_type< elem_type >::result pod_type
const uword n_cols
const uword n_rows
arma_aligned Mat< eT > * m_ptr
Definition: span.hpp:35
static void minus_inplace(Mat< eT > &out, const subview &in)
X -= Y.submat(...)
void operator-=(const eT val)
void operator%=(const Base< eT, T1 > &x)
void fill(const eT val)
void swap_rows(const uword in_row1, const uword in_row2)
u32 uword
Definition: typedef.hpp:85
void operator+=(const eT val)
Class for column vectors (matrices with only one column)
Definition: Col_bones.hpp:20
void swap_cols(const uword in_col1, const uword in_col2)
static void plus_inplace(Mat< eT > &out, const subview &in)
X += Y.submat(...)
const uword aux_row1
eT & operator()(const uword i)
diagview< eT > diag(const sword in_id=0)
creation of diagview (diagonal)
arma_aligned const Mat< eT > & m
arma_inline eT * colptr(const uword in_col)
get_pod_type< elem_type >::result pod_type
get_pod_type< elem_type >::result pod_type
subview_row< eT > row(const uword row_num)
creation of subview (row vector)
static void schur_inplace(Mat< eT > &out, const subview &in)
X %= Y.submat(...)
subview< eT > submat(const uword in_row1, const uword in_col1, const uword in_row2, const uword in_col2)
creation of subview (submatrix)
bool check_overlap(const subview &x) const
Class for row vectors (matrices with only one row)
#define arma_aligned
void eye()
eT & at(const uword in_row, const uword in_col)
Col< eT > unsafe_col(const uword col_num)
void zeros()
eT & operator[](const uword i)
Dense matrix class.
#define arma_inline
const uword n_elem
void operator=(const Base< eT, T1 > &x)
Class for storing data required to extract and set the diagonals of a matrix.
subview< eT > cols(const uword in_col1, const uword in_col2)
creation of subview (submatrix comprised of specified column vectors)
void operator*=(const eT val)
s32 sword
Definition: typedef.hpp:86
bool is_vec() const
subview< eT > rows(const uword in_row1, const uword in_row2)
creation of subview (submatrix comprised of specified row vectors)
subview_col< eT > col(const uword col_num)
creation of subview (column vector)


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