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  * Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society
00009  * Copyright (C) 2010 Berlin Institute of Technology
00010  */
00011 
00012 #ifndef _GAUSSIANKERNEL_H___
00013 #define _GAUSSIANKERNEL_H___
00014 
00015 #include "lib/common.h"
00016 #include "kernel/DotKernel.h"
00017 #include "features/DotFeatures.h"
00018 
00019 namespace shogun
00020 {
00021     class CDotFeatures;
00033 class CGaussianKernel: public CDotKernel
00034 {
00035     public:
00039         CGaussianKernel();
00040 
00046         CGaussianKernel(int32_t size, float64_t width);
00047 
00055         CGaussianKernel(CDotFeatures* l, CDotFeatures* r,
00056             float64_t width, int32_t size=10);
00057 
00058         virtual ~CGaussianKernel();
00059 
00066         virtual bool init(CFeatures* l, CFeatures* r);
00067 
00069         virtual void cleanup();
00070 
00075         virtual EKernelType get_kernel_type() { return K_GAUSSIAN; }
00076 
00081         inline virtual const char* get_name() const { return "GaussianKernel"; }
00082 
00087         inline virtual float64_t get_width(void) const {
00088             return width;
00089         }
00090 
00091     protected:
00100         virtual float64_t compute(int32_t idx_a, int32_t idx_b);
00101 
00110         virtual void load_serializable_post(void) throw (ShogunException);
00111 
00112     private:
00119         void precompute_squared();
00120 
00127         void precompute_squared_helper(float64_t* &buf, CDotFeatures* df);
00128 
00129         void init();
00130 
00131     protected:
00133         float64_t width;
00135         float64_t* sq_lhs;
00137         float64_t* sq_rhs;
00138 };
00139 }
00140 #endif /* _GAUSSIANKERNEL_H__ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation