source: trunk/lib/classifier/Kernel.h @ 513

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

added kernels using weights

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 1.7 KB
Line 
1// $Id: Kernel.h 513 2006-02-18 16:02:43Z peter $
2
3#ifndef _theplu_classifier_kernel_
4#define _theplu_classifier_kernel_
5
6#include <c++_tools/gslapi/matrix.h>
7
8#include <cctype>
9
10namespace theplu {
11namespace classifier {
12
13  class KernelFunction;
14
15  ///
16  ///   @brief Base Class for Kernels.
17  ///
18  ///   Class taking care of the \f$NxN\f$ kernel matrix, where
19  ///   \f$N\f$ is number of samples. Each element in the Kernel
20  ///   matrix is the scalar product of the corresponding pair of
21  ///   samples. Type of Kernel is defined by a KernelFunction.
22  ///   
23  ///   @note If the KernelFunction is destroyed, the Kernel is no
24  ///   longer defined.
25  ///
26  class Kernel
27  {
28   
29  public:
30
31    ///
32    ///   Constructor taking the data matrix and KernelFunction as
33    ///   input.Each column in the data matrix corresponds to one
34    ///   sample.
35    ///
36    ///   @note Can not handle NaNs.
37    ///
38    Kernel(const gslapi::matrix& data, const KernelFunction& kf) 
39      : data_(data), kf_(&kf) {};
40   
41    ///
42    /// Constructor using weights
43    ///
44    Kernel(const gslapi::matrix& data, const KernelFunction& kf, 
45           const gslapi::matrix& weights) 
46      : data_(data), kf_(&kf) {};
47   
48    ///
49    ///   Destructor
50    ///
51    virtual ~Kernel(void) {};
52
53    ///
54    /// @return element at position (\a row, \a column) of the Kernel
55    /// matrix
56    ///
57    virtual double operator()(const size_t row,const size_t column) const=0;
58
59    ///
60    /// @brief number of samples
61    ///
62    inline size_t size(void) const { return data_.columns(); } 
63
64  protected:
65    const gslapi::matrix& data_;
66    const KernelFunction* kf_;
67
68  private:
69    ///
70    /// Copy constructor (not implemented)
71    ///
72    Kernel(const Kernel&);
73
74
75  }; // class Kernel
76
77}} // of namespace classifier and namespace theplu
78
79#endif
Note: See TracBrowser for help on using the repository browser.