SHOGUN  v2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
GaussianKernel.h
Go to the documentation of this file.
00001 /*
00002  * This program is free software; you can redistribute it and/or modify
00003  * it under the terms of the GNU General Public License as published by
00004  * the Free Software Foundation; either version 3 of the License, or
00005  * (at your option) any later version.
00006  *
00007  * Written (W) 1999-2010 Soeren Sonnenburg
00008  * Written (W) 2011 Abhinav Maurya
00009  * Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society
00010  * Copyright (C) 2010 Berlin Institute of Technology
00011  */
00012 
00013 #ifndef _GAUSSIANKERNEL_H___
00014 #define _GAUSSIANKERNEL_H___
00015 
00016 #include <shogun/lib/common.h>
00017 #include <shogun/kernel/Kernel.h>
00018 #include <shogun/kernel/DotKernel.h>
00019 #include <shogun/features/DotFeatures.h>
00020 
00021 namespace shogun
00022 {
00023     class CDotFeatures;
00044 class CGaussianKernel: public CDotKernel
00045 {
00046     public:
00050         CGaussianKernel();
00051 
00057         CGaussianKernel(int32_t size, float64_t width);
00058 
00066         CGaussianKernel(CDotFeatures* l, CDotFeatures* r,
00067             float64_t width, int32_t size=10);
00068 
00069         virtual ~CGaussianKernel();
00070 
00072         virtual CSGObject *shallow_copy() const;
00073 
00080         virtual bool init(CFeatures* l, CFeatures* r);
00081 
00083         virtual void cleanup();
00084 
00089         virtual EKernelType get_kernel_type() { return K_GAUSSIAN; }
00090 
00095         inline virtual const char* get_name() const { return "GaussianKernel"; }
00096 
00101         inline virtual void set_width(float64_t w)
00102         {
00103             width=w;
00104         }
00105 
00110         inline virtual float64_t get_width() const
00111         {
00112             return width;
00113         }
00114 
00119         inline void set_compact_enabled(bool compact)
00120         {
00121             m_compact = compact;
00122         }
00123 
00128         inline bool get_compact_enabled()
00129         {
00130             return m_compact;
00131         }
00132         
00141         virtual SGMatrix<float64_t> get_parameter_gradient(TParameter* param,
00142                 CSGObject* obj, index_t index = -1);
00143 
00144 
00145     protected:
00154         virtual float64_t compute(int32_t idx_a, int32_t idx_b);
00155 
00164         virtual void load_serializable_post() throw (ShogunException);
00165 
00166     private:
00170         void precompute_squared();
00171 
00178         void precompute_squared_helper(float64_t* &buf, CDotFeatures* df);
00179 
00180         void init();
00181 
00182     protected:
00184         float64_t width;
00186         float64_t* sq_lhs;
00188         float64_t* sq_rhs;
00190         bool m_compact;
00191 };
00192 }
00193 #endif /* _GAUSSIANKERNEL_H__ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation