source: trunk/yat/classifier/DataLookup1D.h @ 1883

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

refs #512. added relates and relatesalso tags on some free functions in namespace classifier.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date ID
File size: 3.9 KB
Line 
1#ifndef _theplu_yat_classifier_dataLookup1D_
2#define _theplu_yat_classifier_dataLookup1D_
3
4// $Id$
5
6/*
7  Copyright (C) 2005 Peter Johansson
8  Copyright (C) 2006 Jari Häkkinen, Peter Johansson, Markus Ringnér
9  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
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 "MatrixLookup.h"
28
29#include <iostream>
30#include <vector>
31
32namespace theplu {
33namespace yat {
34namespace utility {
35  class VectorBase;
36}
37namespace classifier { 
38
39  ///
40  /// @brief Class for general vector view.
41  ///
42  class DataLookup1D
43  {
44  public:
45    /**
46       value_type is double
47
48       \since New in yat 0.5
49     */
50    typedef MatrixLookup::value_type value_type;
51
52    /**
53       const_reference type is const double&
54
55       \since New in yat 0.5
56     */
57    typedef MatrixLookup::const_reference const_reference;
58
59    /// 'Read Only' iterator
60    typedef MatrixLookup::const_row_iterator const_iterator;
61
62    ///
63    /// Constructor.
64    ///
65    /// \param m MatrixLookup to look into
66    /// @param row_vector if true DataLookup1D is looking into a
67    /// row of MatrixLookup, otherwise looking into a
68    /// column. @param index which row/column to look into.
69    ///
70    DataLookup1D(const MatrixLookup& m, const size_t index, 
71                 const bool row_vector);
72
73    ///
74    /// Copy constructor
75    ///
76    DataLookup1D(const DataLookup1D&);
77
78    ///
79    /// Construct DataLookup1D that owns its underlying matrix. Object
80    /// has size @ size and all its element is equal to @a value.
81    ///
82    DataLookup1D(const size_t size, const double value=0); 
83
84    /**
85       @brief Create general view from utility::VectorBase
86   
87       Constructor creates a proper MatrixLookup that object can view
88       into. Object is owner of this underlying MatrixLookup. Object fulfills
89       \f$ x(i) = vec(index(i)) \f$
90    */
91    DataLookup1D(const utility::VectorBase& vec, 
92                 const std::vector<size_t>& index); 
93
94    /**
95       @brief Create general view from utility::VectorBase
96   
97       Constructor creates a proper MatrixLookup that object can view
98       into. Object is owner of this underlying MatrixLookup. Object fulfills
99       \f$ x(i) = vec(i) \f$
100    */
101    DataLookup1D(const utility::VectorBase& vec); 
102
103    ///
104    /// @brief Destructor deletes underlying MatrixLookup if object is owner
105    ///
106    virtual ~DataLookup1D();
107
108    /**
109       \return 'Read Only' iterator to first element.
110     */
111    const_iterator begin() const;
112
113    /**
114       \return 'Read Only' iterator to end of DataLookup1D.
115     */
116    const_iterator end() const;
117
118    ///
119    /// @return number of elements
120    ///
121    size_t size(void) const;
122
123    ///
124    /// @brief access operator
125    ///
126    double operator()(const size_t i) const;
127
128    ///
129    /// scalar product
130    ///
131    double operator*(const DataLookup1D&) const;
132
133  private:
134    // assignment no allowed
135    const DataLookup1D& operator=(const DataLookup1D&);
136
137    const bool column_vector_;
138    const size_t index_;
139    const MatrixLookup* matrix_;
140    const bool owner_;
141   
142  };
143
144  ///
145  /// @brief The output operator for DataLookup1D.
146  ///
147  /**
148   * Elements are separated by the character from the omanip fill.
149   * The following example will write the elements separated by tab.
150   *
151   @verbatim
152   char prev=s.fill('\t');
153   s << v;
154   s.fill(prev);
155   @endverbatim
156
157   \relates DataLookup1D
158  */
159  std::ostream& operator<<(std::ostream& s, const DataLookup1D& v);
160 
161}}} // of namespace classifier, yat, and theplu
162
163#endif
Note: See TracBrowser for help on using the repository browser.