SHOGUN  v2.0.0
 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  * 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 
72  virtual CSGObject *shallow_copy() const;
73 
80  virtual bool init(CFeatures* l, CFeatures* r);
81 
83  virtual void cleanup();
84 
89  virtual EKernelType get_kernel_type() { return K_GAUSSIAN; }
90 
95  inline virtual const char* get_name() const { return "GaussianKernel"; }
96 
101  inline virtual void set_width(float64_t w)
102  {
103  width=w;
104  }
105 
110  inline virtual float64_t get_width() const
111  {
112  return width;
113  }
114 
119  inline void set_compact_enabled(bool compact)
120  {
121  m_compact = compact;
122  }
123 
128  inline bool get_compact_enabled()
129  {
130  return m_compact;
131  }
132 
142  CSGObject* obj, index_t index = -1);
143 
144 
145  protected:
154  virtual float64_t compute(int32_t idx_a, int32_t idx_b);
155 
164  virtual void load_serializable_post() throw (ShogunException);
165 
166  private:
170  void precompute_squared();
171 
178  void precompute_squared_helper(float64_t* &buf, CDotFeatures* df);
179 
180  void init();
181 
182  protected:
184  float64_t width;
190  bool m_compact;
191 };
192 }
193 #endif /* _GAUSSIANKERNEL_H__ */

SHOGUN Machine Learning Toolbox - Documentation