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

Last change on this file since 890 was 890, checked in by Markus Ringnér, 15 years ago

Refs #245 #246 #247

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.9 KB
Line 
1#ifndef _theplu_yat_classifier_dataLookup_weighted_1D_
2#define _theplu_yat_classifier_dataLookup_weighted_1D_
3
4// $Id: DataLookupWeighted1D.h 890 2007-09-25 09:35:25Z markus $
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
33namespace theplu {
34namespace yat {
35namespace 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    typedef utility::IteratorWeighted<const double, const classifier::DataLookupWeighted1D> 
50    const_iterator;
51
52    ///
53    /// Constructor.
54    ///
55    /// @param row_vector if true (default) DataLookup1D is
56    /// looking into a row of DataLookup2D, otherwise looking into
57    /// a column. @param index which row/column to look into.
58    ///
59    DataLookupWeighted1D(const MatrixLookupWeighted&, const size_t index, 
60                         const bool row_vector);
61
62    ///
63    /// Copy constructor
64    ///
65    DataLookupWeighted1D(const DataLookupWeighted1D&);
66
67    ///
68    /// Construct DataLookup1D that owns its underlying matrix. Object
69    /// has size @ size and all its element is equal to @a value.
70    ///
71    DataLookupWeighted1D(const size_t size, double value=0, double weight=1); 
72
73    ///
74    /// @brief Destructor
75    ///
76    virtual ~DataLookupWeighted1D();
77
78    /**
79     */
80    const_iterator begin() const;
81
82    /**
83       \return data(i)
84    */
85    double data(const size_t i) const;
86   
87    /**
88     */
89    const_iterator end() const;
90
91    ///
92    /// @return number of elements
93    ///
94    size_t size(void) const;
95
96    ///
97    /// @return weight(i)
98    ///
99    double weight(const size_t i) const;
100
101    ///
102    /// @return data(i) * weight(i)
103    ///
104    double operator()(const size_t i) const;
105
106    ///
107    /// @return data(i) * weight(i)
108    ///
109    double operator[](const size_t i) const;
110
111  private:
112    const DataLookupWeighted1D& operator=(const DataLookupWeighted1D&);
113
114    const bool column_vector_;
115    const size_t index_;
116    const MatrixLookupWeighted* matrix_;
117    const bool owner_;
118   
119  };
120
121  ///
122  /// @return sum of weights
123  ///
124  double sum_weight(const DataLookupWeighted1D&);
125
126}}} // of namespace classifier, yat, and theplu
127
128#endif
Note: See TracBrowser for help on using the repository browser.