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

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

Fixes #65

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