SHOGUN
v3.2.0
|
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-2009 Soeren Sonnenburg 00008 * Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society 00009 */ 00010 00011 #ifndef _CHI2KERNEL_H___ 00012 #define _CHI2KERNEL_H___ 00013 00014 #include <shogun/lib/common.h> 00015 #include <shogun/kernel/DotKernel.h> 00016 #include <shogun/features/Features.h> 00017 #include <shogun/features/DenseFeatures.h> 00018 00019 namespace shogun 00020 { 00032 class CChi2Kernel: public CDotKernel 00033 { 00034 void init(); 00035 00036 public: 00038 CChi2Kernel(); 00039 00045 CChi2Kernel(int32_t size, float64_t width); 00046 00054 CChi2Kernel( CDenseFeatures<float64_t>* l, CDenseFeatures<float64_t>* r, 00055 float64_t width, int32_t size=10); 00056 00057 virtual ~CChi2Kernel(); 00058 00065 virtual bool init(CFeatures* l, CFeatures* r); 00066 00068 virtual float64_t get_width(); 00069 00074 static CChi2Kernel* obtain_from_generic(CKernel* kernel); 00075 00080 virtual EKernelType get_kernel_type() { return K_CHI2; } 00081 00086 virtual EFeatureClass get_feature_class() { return C_DENSE; } 00087 00092 virtual EFeatureType get_feature_type() { return F_DREAL; } 00093 00098 virtual const char* get_name() const { return "Chi2Kernel"; } 00099 00100 protected: 00109 virtual float64_t compute(int32_t idx_a, int32_t idx_b); 00110 00111 protected: 00113 float64_t width; 00114 }; 00115 } 00116 #endif /* _CHI2KERNEL_H__ */