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

Last change on this file since 880 was 880, checked in by Peter, 14 years ago

refs #244

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date ID
File size: 3.7 KB
Line 
1#ifndef _theplu_yat_classifier_dataLookup1D_
2#define _theplu_yat_classifier_dataLookup1D_
3
4#include "yat/utility/constIterator.h"
5#include "yat/utility/Iterator.h"
6
7// $Id$
8
9/*
10  Copyright (C) 2005 Peter Johansson
11  Copyright (C) 2006 Jari Häkkinen, Markus Ringnér, Peter Johansson
12  Copyright (C) 2007 Jari Häkkinen, Peter Johansson
13
14  This file is part of the yat library, http://trac.thep.lu.se/trac/yat
15
16  The yat library is free software; you can redistribute it and/or
17  modify it under the terms of the GNU General Public License as
18  published by the Free Software Foundation; either version 2 of the
19  License, or (at your option) any later version.
20
21  The yat library is distributed in the hope that it will be useful,
22  but WITHOUT ANY WARRANTY; without even the implied warranty of
23  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24  General Public License for more details.
25
26  You should have received a copy of the GNU General Public License
27  along with this program; if not, write to the Free Software
28  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
29  02111-1307, USA.
30*/
31
32#include <iostream>
33#include <vector>
34
35namespace theplu {
36namespace yat {
37namespace utility {
38  class vector;
39}
40namespace classifier { 
41
42  class DataLookup2D;
43
44  ///
45  /// @brief Class for general vector view.
46  ///
47
48  class DataLookup1D
49  {
50 
51  public:
52
53    typedef utility::constIterator<const classifier::DataLookup1D> 
54    const_iterator;
55
56    ///
57    /// Constructor.
58    ///
59    /// @param row_vector if true DataLookup1D is looking into a
60    /// row of DataLookup2D, otherwise looking into a
61    /// column. @param index which row/column to look into.
62    ///
63    DataLookup1D(const DataLookup2D&, const size_t index, 
64                 const bool row_vector);
65
66    ///
67    /// Copy constructor
68    ///
69    DataLookup1D(const DataLookup1D&);
70
71    ///
72    /// Construct DataLookup1D that owns its underlying matrix. Object
73    /// has size @ size and all its element is equal to @a value.
74    ///
75    DataLookup1D(const size_t size, const double value=0); 
76
77    /**
78       @brief Create general view from utility::vector
79   
80       Constructor creates a proper MatrixLookup that object can view
81       into. Object is owner of this underlying MatrixLookup. Object fulfills
82       \f$ x(i) = vec(index(i)) \f$
83    */
84    DataLookup1D(const utility::vector& vec, const std::vector<size_t>& index); 
85
86    /**
87       @brief Create general view from utility::vector
88   
89       Constructor creates a proper MatrixLookup that object can view
90       into. Object is owner of this underlying MatrixLookup. Object fulfills
91       \f$ x(i) = vec(i) \f$
92    */
93    DataLookup1D(const utility::vector& vec); 
94
95    ///
96    /// @brief Destructor deletes underlying DataLookup2D if object is owner
97    ///
98    virtual ~DataLookup1D();
99
100    /**
101     */
102    const_iterator begin() const;
103
104    /**
105     */
106    const_iterator end() const;
107
108    ///
109    /// @return number of elements
110    ///
111    size_t size(void) const;
112
113    ///
114    /// @brief access operator
115    ///
116    double operator()(const size_t i) const;
117
118    ///
119    /// @brief access operator
120    ///
121    double operator[](const size_t i) const;
122
123    ///
124    /// scalar product
125    ///
126    double operator*(const DataLookup1D&) const;
127
128  private:
129    const DataLookup1D& operator=(const DataLookup1D&);
130
131    const bool column_vector_;
132    const size_t index_;
133    const DataLookup2D* matrix_;
134    const bool owner_;
135   
136  };
137
138  ///
139  /// @brief The output operator for DataLookup1D.
140  ///
141  /**
142   * Elements are separated by the character from the omanip fill.
143   * The following example will write the elements separated by tab.
144   *
145   @verbatim
146   char prev=s.fill('\t');
147   s << v;
148   s.fill(prev);
149   @endverbatim
150  */
151  std::ostream& operator<<(std::ostream& s, const DataLookup1D& v);
152 
153}}} // of namespace classifier, yat, and theplu
154
155#endif
Note: See TracBrowser for help on using the repository browser.