source: trunk/lib/svm/GaussianKernelFunction.h @ 353

Last change on this file since 353 was 353, checked in by Peter, 17 years ago

removed function returning the whole matrix. It is not needed anymore and should not be there for simplistic reasons.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 1.4 KB
Line 
1// $Id: GaussianKernelFunction.h 353 2005-06-08 23:28:35Z peter $
2
3#ifndef _theplu_svm_gaussian_kernel_function_
4#define _theplu_svm_gaussian_kernel_function_
5
6#include <c++_tools/gslapi/vector.h>
7#include <c++_tools/svm/KernelFunction.h>
8
9#include <cmath>
10
11namespace theplu {
12class gslapi::vector;
13
14namespace svm {
15
16  ///
17  /// Class for Gaussian kernel calculations.
18  ///
19 
20  class GaussianKernelFunction : public KernelFunction
21  {
22   
23  public:
24    ///
25    ///Constructor taking the sigma_ , i.e. the width of the Gaussian,as
26    ///input. Default is sigma_ = 1.
27    ///
28    GaussianKernelFunction(double = 1);
29   
30    ///
31    ///Destructor
32    ///
33       virtual ~GaussianKernelFunction(void) {};
34   
35    ///
36    /// returning the scalar product of two vectors in feature space using the
37    /// Gaussian kernel. @return \f$ exp((x - y)^{2}/\sigma^2) \f$ \n
38    ///
39    inline double operator()(const gslapi::vector& a1,
40                             const gslapi::vector& a2) const
41    { gslapi::vector a(a1); return exp(-((a-=a2)*a)/(sigma_*sigma_)); }
42
43    ///
44    ///returning the scalar product of two vectors in feature space using the
45    ///Gaussian kernel with weights.
46    ///
47    double operator()(const gslapi::vector& a1,
48                      const gslapi::vector& a2,
49                      const gslapi::vector& w1,
50                      const gslapi::vector& w2) const;
51         
52  private:
53    double sigma_;
54
55  }; // class GaussianKernelFunction
56
57}} // of namespace svm and namespace theplu
58
59#endif
Note: See TracBrowser for help on using the repository browser.