source: trunk/c++_tools/classifier/DataLookup1D.h @ 608

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

set properties

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date ID
File size: 2.0 KB
Line 
1// $Id$
2
3#ifndef _theplu_classifier_dataLookup1D_
4#define _theplu_classifier_dataLookup1D_
5
6#include <c++_tools/classifier/DataLookup2D.h>
7
8#include <cassert>
9#include <iostream>
10#include <vector>
11
12namespace theplu {
13namespace classifier { 
14
15  class DataLookup2D;
16
17  ///
18  /// Class for general vector view
19  ///
20
21  class DataLookup1D
22  {
23 
24  public:
25
26    ///
27    /// Constructor.
28    ///
29    /// @parameter row_vector if true (default) DataLookup1D is
30    /// looking into a row of DataLookup2D, otherwise looking into
31    /// a column. @parameter index which row/column to look into.
32    ///
33    DataLookup1D(const DataLookup2D&, const size_t index, 
34                 const bool row_vector);
35
36    ///
37    /// Copy constructor
38    ///
39    DataLookup1D(const DataLookup1D&);
40
41    ///
42    /// Construct DataLookup1D that owns its underlying matrix. Object
43    /// has size @ size and all its element is equal to @a value.
44    ///
45    DataLookup1D(const size_t size, const double value=0); 
46
47    ///
48    ///
49    ///
50    virtual ~DataLookup1D();
51
52    ///
53    ///
54    ///
55    inline size_t size(void) const
56      { return column_vector_ ? matrix_->rows() : matrix_->columns(); }
57
58    ///
59    ///
60    ///
61    inline double operator()(const size_t i) const 
62    { 
63      assert(i<size()); 
64      return column_vector_ ? (*matrix_)(i,index_) : (*matrix_)(index_,i); 
65    }
66
67    ///
68    ///
69    ///
70    inline double operator[](const size_t i) const 
71    { 
72      return this->operator()(i);
73    }
74
75
76    ///
77    /// scalar product
78    ///
79    double operator*(const DataLookup1D&) const;
80
81  private:
82    const DataLookup1D& operator=(const DataLookup1D&);
83
84    const bool column_vector_;
85    const size_t index_;
86    const DataLookup2D* matrix_;
87    const bool owner_;
88   
89  };
90
91  ///
92  /// @brief The output operator for DataLookup1D.
93  ///
94  /**
95   * Elements are separated by the character from the omanip fill.
96   * The following example will write the elements separated by tab.
97   *
98   @verbatim
99   char prev=s.fill('\t');
100   s << v;
101   s.fill(prev);
102   @endverbatim
103  */
104  std::ostream& operator<<(std::ostream& s, const DataLookup1D& v);
105 
106}} // of namespace classifier and namespace theplu
107
108#endif
Note: See TracBrowser for help on using the repository browser.