1 | #ifndef _theplu_yat_classifier_dataLookup_weighted_1D_ |
---|
2 | #define _theplu_yat_classifier_dataLookup_weighted_1D_ |
---|
3 | |
---|
4 | // $Id: DataLookupWeighted1D.h 3293 2014-07-25 03:42:58Z peter $ |
---|
5 | |
---|
6 | /* |
---|
7 | Copyright (C) 2006 Jari Häkkinen, Peter Johansson |
---|
8 | Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson, Markus Ringnér |
---|
9 | Copyright (C) 2009, 2014 Peter Johansson |
---|
10 | |
---|
11 | This file is part of the yat library, http://dev.thep.lu.se/yat |
---|
12 | |
---|
13 | The yat library is free software; you can redistribute it and/or |
---|
14 | modify it under the terms of the GNU General Public License as |
---|
15 | published by the Free Software Foundation; either version 3 of the |
---|
16 | License, or (at your option) any later version. |
---|
17 | |
---|
18 | The yat library is distributed in the hope that it will be useful, |
---|
19 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
20 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
21 | General Public License for more details. |
---|
22 | |
---|
23 | You should have received a copy of the GNU General Public License |
---|
24 | along with yat. If not, see <http://www.gnu.org/licenses/>. |
---|
25 | */ |
---|
26 | |
---|
27 | #include "MatrixLookupWeighted.h" |
---|
28 | #include "yat/utility/Container2DIterator.h" |
---|
29 | #include "yat/utility/StrideIterator.h" |
---|
30 | |
---|
31 | #include <utility> |
---|
32 | #include <vector> |
---|
33 | |
---|
34 | namespace theplu { |
---|
35 | namespace yat { |
---|
36 | namespace classifier { |
---|
37 | |
---|
38 | /// |
---|
39 | /// @brief Class for general weighted vector view. |
---|
40 | /// |
---|
41 | /// @see MatrixLookupWeighted |
---|
42 | /// |
---|
43 | class DataLookupWeighted1D |
---|
44 | { |
---|
45 | |
---|
46 | public: |
---|
47 | /** |
---|
48 | value_type is DataWeight |
---|
49 | |
---|
50 | \since New in yat 0.5 |
---|
51 | */ |
---|
52 | typedef utility::DataWeight value_type; |
---|
53 | |
---|
54 | /** |
---|
55 | const_reference type is const DataWeight |
---|
56 | |
---|
57 | \since New in yat 0.5 |
---|
58 | */ |
---|
59 | typedef const utility::DataWeight const_reference; |
---|
60 | |
---|
61 | /// 'Read Only' iterator |
---|
62 | typedef MatrixLookupWeighted::const_row_iterator const_iterator; |
---|
63 | |
---|
64 | /// |
---|
65 | /// Constructor. |
---|
66 | /// |
---|
67 | /// \param m MatrixLookupWeighted to look into |
---|
68 | /// @param row_vector if true (default) DataLookup1D is |
---|
69 | /// looking into a row of MatrixLookupWeighted, otherwise looking into |
---|
70 | /// a column. @param index which row/column to look into. |
---|
71 | /// |
---|
72 | DataLookupWeighted1D(const MatrixLookupWeighted& m, const size_t index, |
---|
73 | const bool row_vector); |
---|
74 | |
---|
75 | /// |
---|
76 | /// Copy constructor |
---|
77 | /// |
---|
78 | DataLookupWeighted1D(const DataLookupWeighted1D&); |
---|
79 | |
---|
80 | /// |
---|
81 | /// Construct DataLookup1D that owns its underlying matrix. Object |
---|
82 | /// has size \a size and all its element is equal to \a value. |
---|
83 | /// |
---|
84 | DataLookupWeighted1D(const size_t size, double value=0, double weight=1); |
---|
85 | |
---|
86 | /// |
---|
87 | /// @brief Destructor |
---|
88 | /// |
---|
89 | virtual ~DataLookupWeighted1D(); |
---|
90 | |
---|
91 | /** |
---|
92 | \return 'Read Only' iterator to beginning of DataLookupWeighted1D. |
---|
93 | */ |
---|
94 | const_iterator begin() const; |
---|
95 | |
---|
96 | /** |
---|
97 | \return data(i) |
---|
98 | */ |
---|
99 | double data(const size_t i) const; |
---|
100 | |
---|
101 | /** |
---|
102 | \return 'Read Only' iterator to end of DataLookupWeighted1D. |
---|
103 | */ |
---|
104 | const_iterator end() const; |
---|
105 | |
---|
106 | /// |
---|
107 | /// @return number of elements |
---|
108 | /// |
---|
109 | size_t size(void) const; |
---|
110 | |
---|
111 | /// |
---|
112 | /// @return weight(i) |
---|
113 | /// |
---|
114 | double weight(const size_t i) const; |
---|
115 | |
---|
116 | /** |
---|
117 | \brief access operator |
---|
118 | */ |
---|
119 | const_reference operator()(const size_t i) const; |
---|
120 | |
---|
121 | private: |
---|
122 | const DataLookupWeighted1D& operator=(const DataLookupWeighted1D&); |
---|
123 | |
---|
124 | const bool column_vector_; |
---|
125 | const size_t index_; |
---|
126 | const MatrixLookupWeighted* matrix_; |
---|
127 | const bool owner_; |
---|
128 | |
---|
129 | }; |
---|
130 | |
---|
131 | /// |
---|
132 | /// @return sum of weights |
---|
133 | /// |
---|
134 | /// \relatesalso DataLookupWeighted1D |
---|
135 | /// |
---|
136 | double sum_weight(const DataLookupWeighted1D&); |
---|
137 | |
---|
138 | }}} // of namespace classifier, yat, and theplu |
---|
139 | |
---|
140 | #endif |
---|