source: trunk/yat/classifier/DataLookupWeighted1D.h @ 1552

Last change on this file since 1552 was 1552, checked in by Peter, 13 years ago

using DataWeight? rather than std::pair<double, double>

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