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

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

refs #444. same as in [1525] but for DataLookupWeighted1D.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.1 KB
Line 
1#ifndef _theplu_yat_classifier_dataLookup_weighted_1D_
2#define _theplu_yat_classifier_dataLookup_weighted_1D_
3
4// $Id: DataLookupWeighted1D.h 1526 2008-09-24 12:42:52Z 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    /// 'Read Only' iterator
50    typedef MatrixLookupWeighted::const_row_iterator const_iterator;
51
52    ///
53    /// Constructor.
54    ///
55    /// \param m MatrixLookupWeighted to look into
56    /// @param row_vector if true (default) DataLookup1D is
57    /// looking into a row of MatrixLookupWeighted, otherwise looking into
58    /// a column. @param index which row/column to look into.
59    ///
60    DataLookupWeighted1D(const MatrixLookupWeighted& m, 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 \a 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    std::pair<double, double> operator()(const size_t i) const;
108
109  private:
110    const DataLookupWeighted1D& operator=(const DataLookupWeighted1D&);
111
112    const bool column_vector_;
113    const size_t index_;
114    const MatrixLookupWeighted* matrix_;
115    const bool owner_;
116   
117  };
118
119  ///
120  /// @return sum of weights
121  ///
122  double sum_weight(const DataLookupWeighted1D&);
123
124}}} // of namespace classifier, yat, and theplu
125
126#endif
Note: See TracBrowser for help on using the repository browser.