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

Last change on this file since 865 was 865, checked in by Peter, 15 years ago

changing URL to http://trac.thep.lu.se/trac/yat

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.7 KB
Line 
1#ifndef _theplu_yat_classifier_dataLookup_weighted_1D_
2#define _theplu_yat_classifier_dataLookup_weighted_1D_
3
4// $Id: DataLookupWeighted1D.h 865 2007-09-10 19:41:04Z 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 <iostream>
29#include <vector>
30
31namespace theplu {
32namespace yat {
33namespace classifier { 
34
35  class MatrixLookupWeighted;
36
37  ///
38  /// @brief Class for general weighted vector view.
39  ///
40  /// @see MatrixLookupWeighted
41  ///
42  class DataLookupWeighted1D
43  {
44 
45  public:
46
47    ///
48    /// Constructor.
49    ///
50    /// @param row_vector if true (default) DataLookup1D is
51    /// looking into a row of DataLookup2D, otherwise looking into
52    /// a column. @param index which row/column to look into.
53    ///
54    DataLookupWeighted1D(const MatrixLookupWeighted&, const size_t index, 
55                         const bool row_vector);
56
57    ///
58    /// Copy constructor
59    ///
60    DataLookupWeighted1D(const DataLookupWeighted1D&);
61
62    ///
63    /// Construct DataLookup1D that owns its underlying matrix. Object
64    /// has size @ size and all its element is equal to @a value.
65    ///
66    DataLookupWeighted1D(const size_t size, double value=0, double weight=1); 
67
68    ///
69    /// @brief Destructor
70    ///
71    virtual ~DataLookupWeighted1D();
72
73    /**
74       \return data(i)
75    */
76    double data(const size_t i) const;
77
78    ///
79    /// @return number of elements
80    ///
81    size_t size(void) const;
82
83    ///
84    /// @return weight(i)
85    ///
86    double weight(const size_t i) const;
87
88    ///
89    /// @return data(i) * weight(i)
90    ///
91    double operator()(const size_t i) const;
92
93    ///
94    /// @return data(i) * weight(i)
95    ///
96    double operator[](const size_t i) const;
97
98  private:
99    const DataLookupWeighted1D& operator=(const DataLookupWeighted1D&);
100
101    const bool column_vector_;
102    const size_t index_;
103    const MatrixLookupWeighted* matrix_;
104    const bool owner_;
105   
106  };
107
108  ///
109  /// @return sum of weights
110  ///
111  double sum_weight(const DataLookupWeighted1D&);
112
113}}} // of namespace classifier, yat, and theplu
114
115#endif
Note: See TracBrowser for help on using the repository browser.