source: trunk/lib/classifier/KernelView.h @ 451

Last change on this file since 451 was 451, checked in by Peter, 16 years ago

directory svm -> classifier

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 1.6 KB
Line 
1// $Id: KernelView.h 451 2005-12-15 21:09:12Z peter $
2
3#ifndef _theplu_classifier_kernel_view_
4#define _theplu_classifier_kernel_view_
5
6#include <c++_tools/classifier/Kernel.h>
7#include <vector>
8
9namespace theplu {
10namespace classifier {
11
12  class KernelFunction;
13
14  ///
15  ///   @brief View into sub Kernel
16  ///   When training
17  ///
18  class KernelView : public Kernel
19  {
20   
21  public:
22   
23    ///
24    /// Contructor taking the Kernel to view into and a vector of the
25    /// indeces we view into. The constructed Kernel matrix will have
26    /// dimensions \f$NxN\f$ where \f$N\f$ is the size of \a index. If
27    /// Kernel is a KernelView, as now it implemented to view into the
28    /// view rather directly into the original Kernel, and may
29    /// therefore be slow. Use instead the original Kernel and view
30    /// directly into that.
31    ///
32    KernelView(const Kernel& kernel, const std::vector<size_t>& index);
33   
34    ///
35    /// Copy constructor
36    ///
37    KernelView(const KernelView&);
38
39    ///
40    ///   Destructor
41    ///
42    virtual ~KernelView(void);
43
44    ///
45    /// @return element at position (\a row, \a column) in the Kernel
46    /// matrix
47    ///
48    inline double operator()(const size_t row,const size_t column) const
49    { return (*kernel_)(index_[row],index_[column]); }
50
51    ///
52    /// @brief number of samples
53    ///
54    inline size_t size(void) const { return index_.size(); } 
55   
56
57  private:
58    ///
59    /// Default constructor. Not implemented.
60    ///
61    KernelView(void);
62
63    const Kernel* kernel_;
64    const std::vector<size_t>& index_;
65
66
67    inline bool is_view(void) const { return true; }
68
69  }; // class KernelView
70
71}} // of namespace classifier and namespace theplu
72
73#endif
Note: See TracBrowser for help on using the repository browser.