1 | #ifndef _theplu_yat_classifier_dataLookup_weighted_1D_ |
---|
2 | #define _theplu_yat_classifier_dataLookup_weighted_1D_ |
---|
3 | |
---|
4 | // $Id: DataLookupWeighted1D.h 1567 2008-10-11 15:03:51Z peter $ |
---|
5 | |
---|
6 | /* |
---|
7 | Copyright (C) 2006 Jari Häkkinen, Peter Johansson |
---|
8 | Copyright (C) 2007 Jari Häkkinen, Peter Johansson, Markus Ringnér |
---|
9 | Copyright (C) 2008 Peter Johansson, Markus Ringnér |
---|
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 <iostream> |
---|
32 | #include <utility> |
---|
33 | #include <vector> |
---|
34 | |
---|
35 | namespace theplu { |
---|
36 | namespace yat { |
---|
37 | namespace classifier { |
---|
38 | |
---|
39 | /// |
---|
40 | /// @brief Class for general weighted vector view. |
---|
41 | /// |
---|
42 | /// @see MatrixLookupWeighted |
---|
43 | /// |
---|
44 | class DataLookupWeighted1D |
---|
45 | { |
---|
46 | |
---|
47 | public: |
---|
48 | /** |
---|
49 | value_type is DataWeight |
---|
50 | |
---|
51 | \since New in yat 0.5 |
---|
52 | */ |
---|
53 | typedef utility::DataWeight value_type; |
---|
54 | |
---|
55 | /** |
---|
56 | const_reference type is const DataWeight |
---|
57 | |
---|
58 | \since New in yat 0.5 |
---|
59 | */ |
---|
60 | typedef const utility::DataWeight const_reference; |
---|
61 | |
---|
62 | /// 'Read Only' iterator |
---|
63 | typedef MatrixLookupWeighted::const_row_iterator const_iterator; |
---|
64 | |
---|
65 | /// |
---|
66 | /// Constructor. |
---|
67 | /// |
---|
68 | /// \param m MatrixLookupWeighted to look into |
---|
69 | /// @param row_vector if true (default) DataLookup1D is |
---|
70 | /// looking into a row of MatrixLookupWeighted, otherwise looking into |
---|
71 | /// a column. @param index which row/column to look into. |
---|
72 | /// |
---|
73 | DataLookupWeighted1D(const MatrixLookupWeighted& m, const size_t index, |
---|
74 | const bool row_vector); |
---|
75 | |
---|
76 | /// |
---|
77 | /// Copy constructor |
---|
78 | /// |
---|
79 | DataLookupWeighted1D(const DataLookupWeighted1D&); |
---|
80 | |
---|
81 | /// |
---|
82 | /// Construct DataLookup1D that owns its underlying matrix. Object |
---|
83 | /// has size \a size and all its element is equal to \a value. |
---|
84 | /// |
---|
85 | DataLookupWeighted1D(const size_t size, double value=0, double weight=1); |
---|
86 | |
---|
87 | /// |
---|
88 | /// @brief Destructor |
---|
89 | /// |
---|
90 | virtual ~DataLookupWeighted1D(); |
---|
91 | |
---|
92 | /** |
---|
93 | \return 'Read Only' iterator to beginning of DataLookupWeighted1D. |
---|
94 | */ |
---|
95 | const_iterator begin() const; |
---|
96 | |
---|
97 | /** |
---|
98 | \return data(i) |
---|
99 | */ |
---|
100 | double data(const size_t i) const; |
---|
101 | |
---|
102 | /** |
---|
103 | \return 'Read Only' iterator to end of DataLookupWeighted1D. |
---|
104 | */ |
---|
105 | const_iterator end() const; |
---|
106 | |
---|
107 | /// |
---|
108 | /// @return number of elements |
---|
109 | /// |
---|
110 | size_t size(void) const; |
---|
111 | |
---|
112 | /// |
---|
113 | /// @return weight(i) |
---|
114 | /// |
---|
115 | double weight(const size_t i) const; |
---|
116 | |
---|
117 | /** |
---|
118 | \brief access operator |
---|
119 | */ |
---|
120 | const_reference operator()(const size_t i) const; |
---|
121 | |
---|
122 | private: |
---|
123 | const DataLookupWeighted1D& operator=(const DataLookupWeighted1D&); |
---|
124 | |
---|
125 | const bool column_vector_; |
---|
126 | const size_t index_; |
---|
127 | const MatrixLookupWeighted* matrix_; |
---|
128 | const bool owner_; |
---|
129 | |
---|
130 | }; |
---|
131 | |
---|
132 | /// |
---|
133 | /// @return sum of weights |
---|
134 | /// |
---|
135 | double sum_weight(const DataLookupWeighted1D&); |
---|
136 | |
---|
137 | }}} // of namespace classifier, yat, and theplu |
---|
138 | |
---|
139 | #endif |
---|