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 _LINEARSTRINGKERNEL_H___ 00012 #define _LINEARSTRINGKERNEL_H___ 00013 00014 #include "lib/common.h" 00015 #include "kernel/StringKernel.h" 00016 00017 namespace shogun 00018 { 00029 class CLinearStringKernel: public CStringKernel<char> 00030 { 00031 public: 00034 CLinearStringKernel(); 00035 00041 CLinearStringKernel(CStringFeatures<char>* l, CStringFeatures<char>* r); 00042 00043 virtual ~CLinearStringKernel(); 00044 00051 virtual bool init(CFeatures* l, CFeatures* r); 00052 00054 virtual void cleanup(); 00055 00060 virtual EKernelType get_kernel_type() 00061 { 00062 return K_LINEAR; 00063 } 00064 00069 virtual const char* get_name() const { return "Linear"; } 00070 00079 virtual bool init_optimization( 00080 int32_t num_suppvec, int32_t* sv_idx, float64_t* alphas); 00081 00086 virtual bool delete_optimization(); 00087 00093 virtual float64_t compute_optimized(int32_t idx); 00094 00096 virtual void clear_normal(); 00097 00103 virtual void add_to_normal(int32_t idx, float64_t weight); 00104 00105 protected: 00114 virtual float64_t compute(int32_t idx_a, int32_t idx_b); 00115 00116 protected: 00118 float64_t* normal; 00119 }; 00120 } 00121 #endif /* _LINEARSTRINGKERNEL_H___ */