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

Last change on this file since 676 was 675, checked in by Jari Häkkinen, 15 years ago

References #83. Changing project name to yat. Compilation will fail in this revision.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date ID
File size: 2.9 KB
Line 
1#ifndef _theplu_classifier_dataLookup1D_
2#define _theplu_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 "yat/classifier/DataLookup2D.h"
28
29#include <cassert>
30#include <iostream>
31#include <vector>
32
33namespace theplu {
34namespace classifier { 
35
36  ///
37  /// Class for general vector view
38  ///
39
40  class DataLookup1D
41  {
42 
43  public:
44
45    ///
46    /// Constructor.
47    ///
48    /// @param row_vector if true DataLookup1D is looking into a
49    /// row of DataLookup2D, otherwise looking into a
50    /// column. @param index which row/column to look into.
51    ///
52    DataLookup1D(const DataLookup2D&, const size_t index, 
53                 const bool row_vector);
54
55    ///
56    /// Copy constructor
57    ///
58    DataLookup1D(const DataLookup1D&);
59
60    ///
61    /// Construct DataLookup1D that owns its underlying matrix. Object
62    /// has size @ size and all its element is equal to @a value.
63    ///
64    DataLookup1D(const size_t size, const double value=0); 
65
66    ///
67    ///
68    ///
69    virtual ~DataLookup1D();
70
71    ///
72    /// @return number of elements
73    ///
74    inline size_t size(void) const
75      { return column_vector_ ? matrix_->rows() : matrix_->columns(); }
76
77    ///
78    /// @brief access operator
79    ///
80    inline double operator()(const size_t i) const 
81    { 
82      assert(i<size()); 
83      return column_vector_ ? (*matrix_)(i,index_) : (*matrix_)(index_,i); 
84    }
85
86    ///
87    /// @brief access operator
88    ///
89    inline double operator[](const size_t i) const 
90    { 
91      return this->operator()(i);
92    }
93
94
95    ///
96    /// scalar product
97    ///
98    double operator*(const DataLookup1D&) const;
99
100  private:
101    const DataLookup1D& operator=(const DataLookup1D&);
102
103    const bool column_vector_;
104    const size_t index_;
105    const DataLookup2D* matrix_;
106    const bool owner_;
107   
108  };
109
110  ///
111  /// @brief The output operator for DataLookup1D.
112  ///
113  /**
114   * Elements are separated by the character from the omanip fill.
115   * The following example will write the elements separated by tab.
116   *
117   @verbatim
118   char prev=s.fill('\t');
119   s << v;
120   s.fill(prev);
121   @endverbatim
122  */
123  std::ostream& operator<<(std::ostream& s, const DataLookup1D& v);
124 
125}} // of namespace classifier and namespace theplu
126
127#endif
Note: See TracBrowser for help on using the repository browser.