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 
00077         virtual bool init(CFeatures* l, CFeatures* r);
00078 
00080         virtual void cleanup();
00081 
00086         virtual EKernelType get_kernel_type() { return K_GAUSSIAN; }
00087 
00092         inline virtual const char* get_name() const { return "GaussianKernel"; }
00093 
00098         inline virtual void set_width(float64_t w)
00099         {
00100             width=w;
00101         }
00102 
00107         inline virtual float64_t get_width() const
00108         {
00109             return width;
00110         }
00111 
00116         inline void set_compact_enabled(bool compact)
00117         {
00118             m_compact = compact;
00119         }
00120 
00125         inline bool get_compact_enabled()
00126         {
00127             return m_compact;
00128         }
00129 
00130     protected:
00139         virtual float64_t compute(int32_t idx_a, int32_t idx_b);
00140 
00149         virtual void load_serializable_post(void) throw (ShogunException);
00150 
00151     private:
00155         void precompute_squared();
00156 
00163         void precompute_squared_helper(float64_t* &buf, CDotFeatures* df);
00164 
00165         void init();
00166 
00167     protected:
00169         float64_t width;
00171         float64_t* sq_lhs;
00173         float64_t* sq_rhs;
00175         bool m_compact;
00176 };
00177 }
00178 #endif /* _GAUSSIANKERNEL_H__ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation