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

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

updating copyright statements

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.2 KB
Line 
1#ifndef _theplu_yat_classifier_dataLookup_weighted_1D_
2#define _theplu_yat_classifier_dataLookup_weighted_1D_
3
4// $Id: DataLookupWeighted1D.h 1797 2009-02-12 18:07:10Z 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
10  This file is part of the yat library, http://dev.thep.lu.se/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 3 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 yat. If not, see <http://www.gnu.org/licenses/>.
24*/
25
26#include "MatrixLookupWeighted.h"
27#include "yat/utility/Container2DIterator.h"
28#include "yat/utility/StrideIterator.h"
29
30#include <iostream>
31#include <utility>
32#include <vector>
33
34namespace theplu {
35namespace yat {
36namespace 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  double sum_weight(const DataLookupWeighted1D&);
135
136}}} // of namespace classifier, yat, and theplu
137
138#endif
Note: See TracBrowser for help on using the repository browser.