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