1 | // Copyright (C) 2008-2013 NICTA (www.nicta.com.au) |
---|
2 | // Copyright (C) 2008-2013 Conrad Sanderson |
---|
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 diagview |
---|
10 | //! @{ |
---|
11 | |
---|
12 | |
---|
13 | //! Class for storing data required to extract and set the diagonals of a matrix |
---|
14 | template<typename eT> |
---|
15 | class diagview : public Base<eT, diagview<eT> > |
---|
16 | { |
---|
17 | public: |
---|
18 | |
---|
19 | typedef eT elem_type; |
---|
20 | typedef typename get_pod_type<eT>::result pod_type; |
---|
21 | |
---|
22 | arma_aligned const Mat<eT>& m; |
---|
23 | |
---|
24 | static const bool is_row = false; |
---|
25 | static const bool is_col = true; |
---|
26 | |
---|
27 | const uword row_offset; |
---|
28 | const uword col_offset; |
---|
29 | |
---|
30 | const uword n_rows; // equal to n_elem |
---|
31 | const uword n_elem; |
---|
32 | |
---|
33 | static const uword n_cols = 1; |
---|
34 | |
---|
35 | |
---|
36 | protected: |
---|
37 | |
---|
38 | arma_inline diagview(const Mat<eT>& in_m, const uword in_row_offset, const uword in_col_offset, const uword len); |
---|
39 | |
---|
40 | |
---|
41 | public: |
---|
42 | |
---|
43 | inline ~diagview(); |
---|
44 | |
---|
45 | inline void operator=(const diagview& x); |
---|
46 | |
---|
47 | inline void operator+=(const eT val); |
---|
48 | inline void operator-=(const eT val); |
---|
49 | inline void operator*=(const eT val); |
---|
50 | inline void operator/=(const eT val); |
---|
51 | |
---|
52 | template<typename T1> inline void operator= (const Base<eT,T1>& x); |
---|
53 | template<typename T1> inline void operator+=(const Base<eT,T1>& x); |
---|
54 | template<typename T1> inline void operator-=(const Base<eT,T1>& x); |
---|
55 | template<typename T1> inline void operator%=(const Base<eT,T1>& x); |
---|
56 | template<typename T1> inline void operator/=(const Base<eT,T1>& x); |
---|
57 | |
---|
58 | |
---|
59 | arma_inline eT at_alt (const uword ii) const; |
---|
60 | |
---|
61 | arma_inline eT& operator[](const uword ii); |
---|
62 | arma_inline eT operator[](const uword ii) const; |
---|
63 | |
---|
64 | arma_inline eT& at(const uword ii); |
---|
65 | arma_inline eT at(const uword ii) const; |
---|
66 | |
---|
67 | arma_inline eT& operator()(const uword ii); |
---|
68 | arma_inline eT operator()(const uword ii) const; |
---|
69 | |
---|
70 | arma_inline eT& at(const uword in_n_row, const uword); |
---|
71 | arma_inline eT at(const uword in_n_row, const uword) const; |
---|
72 | |
---|
73 | arma_inline eT& operator()(const uword in_n_row, const uword in_n_col); |
---|
74 | arma_inline eT operator()(const uword in_n_row, const uword in_n_col) const; |
---|
75 | |
---|
76 | |
---|
77 | arma_inline const Op<diagview<eT>,op_htrans> t() const; |
---|
78 | arma_inline const Op<diagview<eT>,op_htrans> ht() const; |
---|
79 | arma_inline const Op<diagview<eT>,op_strans> st() const; |
---|
80 | |
---|
81 | inline void fill(const eT val); |
---|
82 | inline void zeros(); |
---|
83 | inline void ones(); |
---|
84 | inline void randu(); |
---|
85 | inline void randn(); |
---|
86 | |
---|
87 | inline static void extract(Mat<eT>& out, const diagview& in); |
---|
88 | |
---|
89 | inline static void plus_inplace(Mat<eT>& out, const diagview& in); |
---|
90 | inline static void minus_inplace(Mat<eT>& out, const diagview& in); |
---|
91 | inline static void schur_inplace(Mat<eT>& out, const diagview& in); |
---|
92 | inline static void div_inplace(Mat<eT>& out, const diagview& in); |
---|
93 | |
---|
94 | |
---|
95 | private: |
---|
96 | |
---|
97 | friend class Mat<eT>; |
---|
98 | friend class subview<eT>; |
---|
99 | |
---|
100 | diagview(); |
---|
101 | //diagview(const diagview&); // making this private causes an error under gcc 4.1/4.2, but not 4.3 |
---|
102 | }; |
---|
103 | |
---|
104 | |
---|
105 | //! @} |
---|