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 _LINEARWORDKERNEL_H___ 00012 #define _LINEARWORDKERNEL_H___ 00013 00014 #include "lib/common.h" 00015 #include "kernel/SimpleKernel.h" 00016 #include "features/WordFeatures.h" 00017 00023 class CLinearWordKernel: public CSimpleKernel<uint16_t> 00024 { 00025 public: 00028 CLinearWordKernel(); 00029 00035 CLinearWordKernel(CWordFeatures* l, CWordFeatures* r); 00036 00037 virtual ~CLinearWordKernel(); 00038 00045 virtual bool init(CFeatures* l, CFeatures* r); 00046 00048 virtual void cleanup(); 00049 00055 virtual bool load_init(FILE* src); 00056 00062 virtual bool save_init(FILE* dest); 00063 00068 virtual EKernelType get_kernel_type() { return K_LINEAR; } 00069 00074 virtual const char* get_name() { return "Linear"; } 00075 00083 virtual bool init_optimization( 00084 int32_t num_suppvec, int32_t* sv_idx, float64_t* alphas); 00085 00090 virtual bool delete_optimization(); 00091 00097 virtual float64_t compute_optimized(int32_t idx); 00098 00100 virtual void clear_normal(); 00101 00107 virtual void add_to_normal(int32_t idx, float64_t weight); 00108 00109 protected: 00118 virtual float64_t compute(int32_t idx_a, int32_t idx_b); 00119 00120 protected: 00122 float64_t* normal; 00123 }; 00124 00125 #endif /* _LINEARWORDKERNEL_H__ */