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-2008 Gunnar Raetsch 00008 * Written (W) 2013 Soeren Sonnenburg 00009 * Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society 00010 * Copyright (C) 2013 Soeren Sonnenburg 00011 */ 00012 00013 #ifndef _SIMPLELOCALITYIMPROVEDSTRINGKERNEL_H___ 00014 #define _SIMPLELOCALITYIMPROVEDSTRINGKERNEL_H___ 00015 00016 #include <shogun/lib/common.h> 00017 #include <shogun/kernel/string/StringKernel.h> 00018 00019 namespace shogun 00020 { 00032 class CSimpleLocalityImprovedStringKernel: public CStringKernel<char> 00033 { 00034 public: 00036 CSimpleLocalityImprovedStringKernel(); 00037 00045 CSimpleLocalityImprovedStringKernel(int32_t size, int32_t length, 00046 int32_t inner_degree, int32_t outer_degree); 00047 00056 CSimpleLocalityImprovedStringKernel( 00057 CStringFeatures<char>* l, CStringFeatures<char>* r, 00058 int32_t length, int32_t inner_degree, int32_t outer_degree); 00059 00060 virtual ~CSimpleLocalityImprovedStringKernel(); 00061 00068 virtual bool init(CFeatures *l, CFeatures *r); 00069 00071 virtual void cleanup(); 00072 00077 virtual EKernelType get_kernel_type() 00078 { 00079 return K_SIMPLELOCALITYIMPROVED; 00080 } 00081 00086 virtual const char* get_name() const 00087 { 00088 return "SimpleLocalityImprovedStringKernel"; 00089 } 00090 00091 private: 00103 float64_t dot_pyr (const char* const x1, const char* const x2, 00104 const int32_t NOF_NTS, const int32_t NTWIDTH, 00105 const int32_t DEGREE1, const int32_t DEGREE2, float64_t *pyra); 00106 00107 protected: 00116 float64_t compute(int32_t idx_a, int32_t idx_b); 00117 00118 private: 00119 void init(); 00120 00121 protected: 00123 int32_t length; 00125 int32_t inner_degree; 00127 int32_t outer_degree; 00128 00130 SGVector<float64_t> pyramid_weights; 00131 }; 00132 } 00133 #endif /* _SIMPLELOCALITYIMPROVEDSTRINGKERNEL_H___ */