LinearStringKernel.h

Go to the documentation of this file.
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 Soeren Sonnenburg
00008  * Copyright (C) 1999-2008 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 
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 /* _LINEARSTRINGKERNEL_H___ */

SHOGUN Machine Learning Toolbox - Documentation