comparison armadillo-2.4.4/include/armadillo_bits/subview_bones.hpp @ 0:8b6102e2a9b0

Armadillo Library
author maxzanoni76 <max.zanoni@eecs.qmul.ac.uk>
date Wed, 11 Apr 2012 09:27:06 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:8b6102e2a9b0
1 // Copyright (C) 2008-2011 NICTA (www.nicta.com.au)
2 // Copyright (C) 2008-2011 Conrad Sanderson
3 // 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
15 //! \addtogroup subview
16 //! @{
17
18
19 //! Class for storing data required to construct or apply operations to a submatrix
20 //! (i.e. where the submatrix starts and ends as well as a reference/pointer to the original matrix),
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;
30 typedef typename get_pod_type<elem_type>::result pod_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;
178 typedef typename get_pod_type<elem_type>::result pod_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;
219 typedef typename get_pod_type<elem_type>::result pod_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
254 //! @}