1 | // Copyright (C) 2008-2015 Conrad Sanderson |
---|
2 | // Copyright (C) 2008-2015 NICTA (www.nicta.com.au) |
---|
3 | // |
---|
4 | // This Source Code Form is subject to the terms of the Mozilla Public |
---|
5 | // License, v. 2.0. If a copy of the MPL was not distributed with this |
---|
6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. |
---|
7 | |
---|
8 | |
---|
9 | //! \addtogroup Col |
---|
10 | //! @{ |
---|
11 | |
---|
12 | //! Class for column vectors (matrices with only one column) |
---|
13 | |
---|
14 | template<typename eT> |
---|
15 | class Col : public Mat<eT> |
---|
16 | { |
---|
17 | public: |
---|
18 | |
---|
19 | typedef eT elem_type; |
---|
20 | typedef typename get_pod_type<eT>::result pod_type; |
---|
21 | |
---|
22 | static const bool is_col = true; |
---|
23 | static const bool is_row = false; |
---|
24 | |
---|
25 | inline Col(); |
---|
26 | inline Col(const Col<eT>& X); |
---|
27 | inline explicit Col(const uword n_elem); |
---|
28 | inline Col(const uword in_rows, const uword in_cols); |
---|
29 | |
---|
30 | template<typename fill_type> inline Col(const uword n_elem, const fill::fill_class<fill_type>& f); |
---|
31 | template<typename fill_type> inline Col(const uword in_rows, const uword in_cols, const fill::fill_class<fill_type>& f); |
---|
32 | |
---|
33 | inline Col(const char* text); |
---|
34 | inline const Col& operator=(const char* text); |
---|
35 | |
---|
36 | inline Col(const std::string& text); |
---|
37 | inline const Col& operator=(const std::string& text); |
---|
38 | |
---|
39 | inline Col(const std::vector<eT>& x); |
---|
40 | inline const Col& operator=(const std::vector<eT>& x); |
---|
41 | |
---|
42 | #if defined(ARMA_USE_CXX11) |
---|
43 | inline Col(const std::initializer_list<eT>& list); |
---|
44 | inline const Col& operator=(const std::initializer_list<eT>& list); |
---|
45 | |
---|
46 | inline Col(Col&& m); |
---|
47 | inline const Col& operator=(Col&& m); |
---|
48 | #endif |
---|
49 | |
---|
50 | inline explicit Col(const SpCol<eT>& X); |
---|
51 | |
---|
52 | inline const Col& operator=(const eT val); |
---|
53 | inline const Col& operator=(const Col& m); |
---|
54 | |
---|
55 | template<typename T1> inline Col(const Base<eT,T1>& X); |
---|
56 | template<typename T1> inline const Col& operator=(const Base<eT,T1>& X); |
---|
57 | |
---|
58 | inline Col( eT* aux_mem, const uword aux_length, const bool copy_aux_mem = true, const bool strict = true); |
---|
59 | inline Col(const eT* aux_mem, const uword aux_length); |
---|
60 | |
---|
61 | template<typename T1, typename T2> |
---|
62 | inline explicit Col(const Base<pod_type,T1>& A, const Base<pod_type,T2>& B); |
---|
63 | |
---|
64 | template<typename T1> inline Col(const BaseCube<eT,T1>& X); |
---|
65 | template<typename T1> inline const Col& operator=(const BaseCube<eT,T1>& X); |
---|
66 | |
---|
67 | inline Col(const subview_cube<eT>& X); |
---|
68 | inline const Col& operator=(const subview_cube<eT>& X); |
---|
69 | |
---|
70 | inline mat_injector<Col> operator<<(const eT val); |
---|
71 | |
---|
72 | arma_inline const Op<Col<eT>,op_htrans> t() const; |
---|
73 | arma_inline const Op<Col<eT>,op_htrans> ht() const; |
---|
74 | arma_inline const Op<Col<eT>,op_strans> st() const; |
---|
75 | |
---|
76 | arma_inline subview_col<eT> row(const uword row_num); |
---|
77 | arma_inline const subview_col<eT> row(const uword row_num) const; |
---|
78 | |
---|
79 | using Mat<eT>::rows; |
---|
80 | using Mat<eT>::operator(); |
---|
81 | |
---|
82 | arma_inline subview_col<eT> rows(const uword in_row1, const uword in_row2); |
---|
83 | arma_inline const subview_col<eT> rows(const uword in_row1, const uword in_row2) const; |
---|
84 | |
---|
85 | arma_inline subview_col<eT> subvec(const uword in_row1, const uword in_row2); |
---|
86 | arma_inline const subview_col<eT> subvec(const uword in_row1, const uword in_row2) const; |
---|
87 | |
---|
88 | arma_inline subview_col<eT> rows(const span& row_span); |
---|
89 | arma_inline const subview_col<eT> rows(const span& row_span) const; |
---|
90 | |
---|
91 | arma_inline subview_col<eT> subvec(const span& row_span); |
---|
92 | arma_inline const subview_col<eT> subvec(const span& row_span) const; |
---|
93 | |
---|
94 | arma_inline subview_col<eT> operator()(const span& row_span); |
---|
95 | arma_inline const subview_col<eT> operator()(const span& row_span) const; |
---|
96 | |
---|
97 | arma_inline subview_col<eT> head(const uword N); |
---|
98 | arma_inline const subview_col<eT> head(const uword N) const; |
---|
99 | |
---|
100 | arma_inline subview_col<eT> tail(const uword N); |
---|
101 | arma_inline const subview_col<eT> tail(const uword N) const; |
---|
102 | |
---|
103 | arma_inline subview_col<eT> head_rows(const uword N); |
---|
104 | arma_inline const subview_col<eT> head_rows(const uword N) const; |
---|
105 | |
---|
106 | arma_inline subview_col<eT> tail_rows(const uword N); |
---|
107 | arma_inline const subview_col<eT> tail_rows(const uword N) const; |
---|
108 | |
---|
109 | |
---|
110 | inline void shed_row (const uword row_num); |
---|
111 | inline void shed_rows(const uword in_row1, const uword in_row2); |
---|
112 | |
---|
113 | inline void insert_rows(const uword row_num, const uword N, const bool set_to_zero = true); |
---|
114 | template<typename T1> inline void insert_rows(const uword row_num, const Base<eT,T1>& X); |
---|
115 | |
---|
116 | |
---|
117 | arma_inline arma_warn_unused eT& at(const uword i); |
---|
118 | arma_inline arma_warn_unused const eT& at(const uword i) const; |
---|
119 | |
---|
120 | arma_inline arma_warn_unused eT& at(const uword in_row, const uword in_col); |
---|
121 | arma_inline arma_warn_unused const eT& at(const uword in_row, const uword in_col) const; |
---|
122 | |
---|
123 | |
---|
124 | typedef eT* row_iterator; |
---|
125 | typedef const eT* const_row_iterator; |
---|
126 | |
---|
127 | inline row_iterator begin_row(const uword row_num); |
---|
128 | inline const_row_iterator begin_row(const uword row_num) const; |
---|
129 | |
---|
130 | inline row_iterator end_row (const uword row_num); |
---|
131 | inline const_row_iterator end_row (const uword row_num) const; |
---|
132 | |
---|
133 | |
---|
134 | template<uword fixed_n_elem> class fixed; |
---|
135 | |
---|
136 | |
---|
137 | protected: |
---|
138 | |
---|
139 | inline Col(const arma_fixed_indicator&, const uword in_n_elem, const eT* in_mem); |
---|
140 | |
---|
141 | |
---|
142 | public: |
---|
143 | |
---|
144 | #ifdef ARMA_EXTRA_COL_PROTO |
---|
145 | #include ARMA_INCFILE_WRAP(ARMA_EXTRA_COL_PROTO) |
---|
146 | #endif |
---|
147 | }; |
---|
148 | |
---|
149 | |
---|
150 | |
---|
151 | template<typename eT> |
---|
152 | template<uword fixed_n_elem> |
---|
153 | class Col<eT>::fixed : public Col<eT> |
---|
154 | { |
---|
155 | private: |
---|
156 | |
---|
157 | static const bool use_extra = (fixed_n_elem > arma_config::mat_prealloc); |
---|
158 | |
---|
159 | arma_align_mem eT mem_local_extra[ (use_extra) ? fixed_n_elem : 1 ]; |
---|
160 | |
---|
161 | arma_inline void change_to_row(); |
---|
162 | |
---|
163 | |
---|
164 | public: |
---|
165 | |
---|
166 | typedef fixed<fixed_n_elem> Col_fixed_type; |
---|
167 | |
---|
168 | typedef eT elem_type; |
---|
169 | typedef typename get_pod_type<eT>::result pod_type; |
---|
170 | |
---|
171 | static const bool is_col = true; |
---|
172 | static const bool is_row = false; |
---|
173 | |
---|
174 | static const uword n_rows = fixed_n_elem; |
---|
175 | static const uword n_cols = 1; |
---|
176 | static const uword n_elem = fixed_n_elem; |
---|
177 | |
---|
178 | arma_inline fixed(); |
---|
179 | arma_inline fixed(const fixed<fixed_n_elem>& X); |
---|
180 | inline fixed(const subview_cube<eT>& X); |
---|
181 | |
---|
182 | template<typename fill_type> inline fixed(const fill::fill_class<fill_type>& f); |
---|
183 | template<typename T1> inline fixed(const Base<eT,T1>& A); |
---|
184 | template<typename T1, typename T2> inline fixed(const Base<pod_type,T1>& A, const Base<pod_type,T2>& B); |
---|
185 | |
---|
186 | inline fixed(const eT* aux_mem); |
---|
187 | |
---|
188 | inline fixed(const char* text); |
---|
189 | inline fixed(const std::string& text); |
---|
190 | |
---|
191 | template<typename T1> inline const Col& operator=(const Base<eT,T1>& A); |
---|
192 | |
---|
193 | inline const Col& operator=(const eT val); |
---|
194 | inline const Col& operator=(const char* text); |
---|
195 | inline const Col& operator=(const std::string& text); |
---|
196 | inline const Col& operator=(const subview_cube<eT>& X); |
---|
197 | |
---|
198 | using Col<eT>::operator(); |
---|
199 | |
---|
200 | #if defined(ARMA_USE_CXX11) |
---|
201 | inline fixed(const std::initializer_list<eT>& list); |
---|
202 | inline const Col& operator=(const std::initializer_list<eT>& list); |
---|
203 | #endif |
---|
204 | |
---|
205 | arma_inline const Col& operator=(const fixed<fixed_n_elem>& X); |
---|
206 | |
---|
207 | #if defined(ARMA_GOOD_COMPILER) |
---|
208 | template<typename T1, typename eop_type> inline const Col& operator=(const eOp<T1, eop_type>& X); |
---|
209 | template<typename T1, typename T2, typename eglue_type> inline const Col& operator=(const eGlue<T1, T2, eglue_type>& X); |
---|
210 | #endif |
---|
211 | |
---|
212 | arma_inline const Op< Col_fixed_type, op_htrans > t() const; |
---|
213 | arma_inline const Op< Col_fixed_type, op_htrans > ht() const; |
---|
214 | arma_inline const Op< Col_fixed_type, op_strans > st() const; |
---|
215 | |
---|
216 | arma_inline arma_warn_unused const eT& at_alt (const uword i) const; |
---|
217 | |
---|
218 | arma_inline arma_warn_unused eT& operator[] (const uword i); |
---|
219 | arma_inline arma_warn_unused const eT& operator[] (const uword i) const; |
---|
220 | arma_inline arma_warn_unused eT& at (const uword i); |
---|
221 | arma_inline arma_warn_unused const eT& at (const uword i) const; |
---|
222 | arma_inline arma_warn_unused eT& operator() (const uword i); |
---|
223 | arma_inline arma_warn_unused const eT& operator() (const uword i) const; |
---|
224 | |
---|
225 | arma_inline arma_warn_unused eT& at (const uword in_row, const uword in_col); |
---|
226 | arma_inline arma_warn_unused const eT& at (const uword in_row, const uword in_col) const; |
---|
227 | arma_inline arma_warn_unused eT& operator() (const uword in_row, const uword in_col); |
---|
228 | arma_inline arma_warn_unused const eT& operator() (const uword in_row, const uword in_col) const; |
---|
229 | |
---|
230 | arma_inline arma_warn_unused eT* memptr(); |
---|
231 | arma_inline arma_warn_unused const eT* memptr() const; |
---|
232 | |
---|
233 | arma_hot inline const Col<eT>& fill(const eT val); |
---|
234 | arma_hot inline const Col<eT>& zeros(); |
---|
235 | arma_hot inline const Col<eT>& ones(); |
---|
236 | }; |
---|
237 | |
---|
238 | |
---|
239 | |
---|
240 | //! @} |
---|