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

Last change on this file since 865 was 865, checked in by Peter, 14 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
File size: 3.4 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, Markus Ringnér, Peter Johansson
9  Copyright (C) 2007 Jari Häkkinen, Peter Johansson
10
11  This file is part of the yat library, http://trac.thep.lu.se/trac/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 2 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 this program; if not, write to the Free Software
25  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
26  02111-1307, USA.
27*/
28
29#include <iostream>
30#include <vector>
31
32namespace theplu {
33namespace yat {
34namespace utility {
35  class vector;
36}
37namespace classifier { 
38
39  class DataLookup2D;
40
41  ///
42  /// @brief Class for general vector view.
43  ///
44
45  class DataLookup1D
46  {
47 
48  public:
49
50    ///
51    /// Constructor.
52    ///
53    /// @param row_vector if true DataLookup1D is looking into a
54    /// row of DataLookup2D, otherwise looking into a
55    /// column. @param index which row/column to look into.
56    ///
57    DataLookup1D(const DataLookup2D&, const size_t index, 
58                 const bool row_vector);
59
60    ///
61    /// Copy constructor
62    ///
63    DataLookup1D(const DataLookup1D&);
64
65    ///
66    /// Construct DataLookup1D that owns its underlying matrix. Object
67    /// has size @ size and all its element is equal to @a value.
68    ///
69    DataLookup1D(const size_t size, const double value=0); 
70
71    /**
72       @brief Create general view from utility::vector
73   
74       Constructor creates a proper MatrixLookup that object can view
75       into. Object is owner of this underlying MatrixLookup. Object fulfills
76       \f$ x(i) = vec(index(i)) \f$
77    */
78    DataLookup1D(const utility::vector& vec, const std::vector<size_t>& index); 
79
80    /**
81       @brief Create general view from utility::vector
82   
83       Constructor creates a proper MatrixLookup that object can view
84       into. Object is owner of this underlying MatrixLookup. Object fulfills
85       \f$ x(i) = vec(i) \f$
86    */
87    DataLookup1D(const utility::vector& vec); 
88
89    ///
90    /// @brief Destructor deletes underlying DataLookup2D if object is owner
91    ///
92    virtual ~DataLookup1D();
93
94    ///
95    /// @return number of elements
96    ///
97    size_t size(void) const;
98
99    ///
100    /// @brief access operator
101    ///
102    double operator()(const size_t i) const;
103
104    ///
105    /// @brief access operator
106    ///
107    double operator[](const size_t i) const;
108
109    ///
110    /// scalar product
111    ///
112    double operator*(const DataLookup1D&) const;
113
114  private:
115    const DataLookup1D& operator=(const DataLookup1D&);
116
117    const bool column_vector_;
118    const size_t index_;
119    const DataLookup2D* matrix_;
120    const bool owner_;
121   
122  };
123
124  ///
125  /// @brief The output operator for DataLookup1D.
126  ///
127  /**
128   * Elements are separated by the character from the omanip fill.
129   * The following example will write the elements separated by tab.
130   *
131   @verbatim
132   char prev=s.fill('\t');
133   s << v;
134   s.fill(prev);
135   @endverbatim
136  */
137  std::ostream& operator<<(std::ostream& s, const DataLookup1D& v);
138 
139}}} // of namespace classifier, yat, and theplu
140
141#endif
Note: See TracBrowser for help on using the repository browser.