SHOGUN  3.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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  * Written (W) 2012 Heiko Strathmann
10  * Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society
11  * Copyright (C) 2010 Berlin Institute of Technology
12  */
13 
14 #ifndef _GAUSSIANKERNEL_H___
15 #define _GAUSSIANKERNEL_H___
16 
17 #include <shogun/lib/config.h>
18 
19 #include <shogun/lib/common.h>
20 #include <shogun/kernel/Kernel.h>
23 
24 namespace shogun
25 {
26  class CDotFeatures;
49 {
50  public:
53 
59  CGaussianKernel(int32_t size, float64_t width);
60 
69  float64_t width, int32_t size=10);
70 
71  virtual ~CGaussianKernel();
72 
78 
80  virtual CSGObject* shallow_copy() const;
81 
88  virtual bool init(CFeatures* l, CFeatures* r);
89 
91  virtual void cleanup();
92 
97  virtual EKernelType get_kernel_type() { return K_GAUSSIAN; }
98 
103  virtual const char* get_name() const { return "GaussianKernel"; }
104 
109  virtual void set_width(float64_t w) { width=w; }
110 
115  virtual float64_t get_width() const { return width; }
116 
121  inline void set_compact_enabled(bool compact) { m_compact=compact; }
122 
127  inline bool get_compact_enabled() { return m_compact; }
128 
137  const TParameter* param, index_t index=-1);
138 
139  protected:
148  virtual float64_t compute(int32_t idx_a, int32_t idx_b);
149 
156  virtual void load_serializable_post() throw (ShogunException);
157 
158  private:
162  void precompute_squared();
163 
170  void precompute_squared_helper(float64_t* &buf, CDotFeatures* df);
171 
172  void init();
173 
174  protected:
176  float64_t width;
182  bool m_compact;
183 };
184 }
185 #endif /* _GAUSSIANKERNEL_H__ */

SHOGUN Machine Learning Toolbox - Documentation