source: trunk/lib/svm/KernelView.h @ 333

Last change on this file since 333 was 333, checked in by Jari Häkkinen, 18 years ago

Fixed needed base class contructor.

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