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) 2011 Heiko Strathmann 00008 * DS-Kernel implementation Written (W) 2008 Sébastien Boisvert under GPLv3 00009 * Copyright (C) 2011 Berlin Institute of Technology and Max-Planck-Society 00010 */ 00011 00012 #ifndef DISTANTSEGMENTSKERNEL_H_ 00013 #define DISTANTSEGMENTSKERNEL_H_ 00014 00015 #include <shogun/kernel/string/StringKernel.h> 00016 00017 namespace shogun 00018 { 00019 00034 class CDistantSegmentsKernel: public CStringKernel<char> 00035 { 00036 public: 00038 CDistantSegmentsKernel(); 00039 00046 CDistantSegmentsKernel(int32_t size, int32_t delta, int32_t theta); 00047 00056 CDistantSegmentsKernel(CStringFeatures<char>* l, CStringFeatures<char>* r, 00057 int32_t size, int32_t delta, int32_t theta); 00058 00065 virtual bool init(CFeatures* l, CFeatures* r); 00066 00070 virtual EKernelType get_kernel_type() 00071 { 00072 return K_DISTANTSEGMENTS; 00073 } 00074 00078 virtual const char* get_name() const 00079 { 00080 return "DistantSegmentsKernel"; 00081 } 00082 00083 protected: 00093 virtual float64_t compute(int32_t idx_a, int32_t idx_b); 00094 00095 private: 00097 void init(); 00098 00103 int32_t bin(int32_t j, int32_t i); 00104 00118 int32_t compute(char* s, int32_t sLength, char* b, int32_t bLength, 00119 int32_t delta_m, int32_t theta_m); 00120 00121 protected: 00123 int32_t m_delta; 00124 00126 int32_t m_theta; 00127 00128 00129 }; 00130 00131 } 00132 00133 #endif /* DISTANTSEGMENTSKERNEL_H_ */