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) 2011 RafaĆ Surowiecki 00008 * Copyright (C) 2011 Berlin Institute of Technology and Max-Planck-Society 00009 */ 00010 00011 #include <shogun/lib/config.h> 00012 00013 #ifndef RATIONAL_QUADRATIC_KERNEL_H_ 00014 #define RATIONAL_QUADRATIC_KERNEL_H_ 00015 00016 #include <shogun/lib/common.h> 00017 #include <shogun/kernel/Kernel.h> 00018 #include <shogun/distance/Distance.h> 00019 00020 namespace shogun 00021 { 00022 00023 class CDistance; 00024 00035 class CRationalQuadraticKernel: public CKernel 00036 { 00037 public: 00039 CRationalQuadraticKernel(); 00040 00046 CRationalQuadraticKernel(int32_t cache, float64_t coef, CDistance* dist); 00047 00054 CRationalQuadraticKernel(CFeatures *l, CFeatures *r, float64_t c, CDistance* dist); 00055 00061 virtual bool init(CFeatures* l, CFeatures* r); 00062 00066 inline virtual EKernelType get_kernel_type() { return K_RATIONAL_QUADRATIC; } 00067 00071 inline virtual EFeatureType get_feature_type() { return m_distance->get_feature_type(); } 00072 00076 inline virtual EFeatureClass get_feature_class() { return m_distance->get_feature_class(); } 00077 00081 inline virtual const char* get_name() const { return "RationalQuadraticKernel"; } 00082 00086 inline virtual const float64_t get_coef() const { return m_coef; } 00087 00091 inline void set_coef(float64_t coef) { m_coef=coef; } 00092 00093 virtual ~CRationalQuadraticKernel(); 00094 protected: 00102 virtual float64_t compute(int32_t idx_a, int32_t idx_b); 00103 00104 private: 00106 void init(); 00107 00108 protected: 00110 CDistance* m_distance; 00111 00113 float64_t m_coef; 00114 }; 00115 } 00116 00117 #endif /* RATIONAL_QUADRATIC_KERNEL_H_ */