LinearStringKernel.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef _LINEARSTRINGKERNEL_H___
00012 #define _LINEARSTRINGKERNEL_H___
00013
00014 #include "lib/common.h"
00015 #include "kernel/StringKernel.h"
00016
00018 class CLinearStringKernel: public CStringKernel<CHAR>
00019 {
00020 public:
00027 CLinearStringKernel(INT size,
00028 bool do_rescale=true, DREAL scale=1.);
00029
00037 CLinearStringKernel(
00038 CStringFeatures<CHAR>* l, CStringFeatures<CHAR>* r,
00039 bool do_rescale=true, DREAL scale=1.);
00040
00041 virtual ~CLinearStringKernel();
00042
00049 virtual bool init(CFeatures* l, CFeatures* r);
00050
00052 virtual void cleanup();
00053
00059 virtual bool load_init(FILE* src);
00060
00066 virtual bool save_init(FILE* dest);
00067
00072 virtual EKernelType get_kernel_type()
00073 {
00074 return K_LINEAR;
00075 }
00076
00081 virtual const CHAR* get_name()
00082 {
00083 return "Linear";
00084 }
00085
00094 virtual bool init_optimization(INT num_suppvec, INT* sv_idx,
00095 DREAL* alphas);
00096
00101 virtual bool delete_optimization();
00102
00108 virtual DREAL compute_optimized(INT idx);
00109
00111 virtual void clear_normal();
00112
00118 virtual void add_to_normal(INT idx, DREAL weight);
00119
00120 protected:
00129 virtual DREAL compute(INT idx_a, INT idx_b);
00130
00132 virtual void init_rescale();
00133
00134 protected:
00136 double scale;
00138 bool do_rescale;
00140 bool initialized;
00142 double* normal;
00143 };
00144
00145 #endif