SHOGUN  v1.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GaussianKernel.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 3 of the License, or
5  * (at your option) any later version.
6  *
7  * Written (W) 1999-2010 Soeren Sonnenburg
8  * Written (W) 2011 Abhinav Maurya
9  * Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society
10  * Copyright (C) 2010 Berlin Institute of Technology
11  */
12 
13 #ifndef _GAUSSIANKERNEL_H___
14 #define _GAUSSIANKERNEL_H___
15 
16 #include <shogun/lib/common.h>
17 #include <shogun/kernel/Kernel.h>
20 
21 namespace shogun
22 {
23  class CDotFeatures;
45 {
46  public:
51 
57  CGaussianKernel(int32_t size, float64_t width);
58 
67  float64_t width, int32_t size=10);
68 
69  virtual ~CGaussianKernel();
70 
77  virtual bool init(CFeatures* l, CFeatures* r);
78 
80  virtual void cleanup();
81 
86  virtual EKernelType get_kernel_type() { return K_GAUSSIAN; }
87 
92  inline virtual const char* get_name() const { return "GaussianKernel"; }
93 
98  inline virtual void set_width(float64_t w)
99  {
100  width=w;
101  }
102 
107  inline virtual float64_t get_width() const
108  {
109  return width;
110  }
111 
116  inline void set_compact_enabled(bool compact)
117  {
118  m_compact = compact;
119  }
120 
125  inline bool get_compact_enabled()
126  {
127  return m_compact;
128  }
129 
130  protected:
139  virtual float64_t compute(int32_t idx_a, int32_t idx_b);
140 
149  virtual void load_serializable_post() throw (ShogunException);
150 
151  private:
155  void precompute_squared();
156 
163  void precompute_squared_helper(float64_t* &buf, CDotFeatures* df);
164 
165  void init();
166 
167  protected:
169  float64_t width;
175  bool m_compact;
176 };
177 }
178 #endif /* _GAUSSIANKERNEL_H__ */

SHOGUN Machine Learning Toolbox - Documentation