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 * Written (W) 1999-2008 Gunnar Raetsch 00009 * Copyright (C) 1999-2008 Fraunhofer Institute FIRST and Max-Planck-Society 00010 */ 00011 00012 #ifndef _HISTOGRAMWORDKERNEL_H___ 00013 #define _HISTOGRAMWORDKERNEL_H___ 00014 00015 #include "lib/common.h" 00016 #include "kernel/StringKernel.h" 00017 #include "classifier/PluginEstimate.h" 00018 #include "features/StringFeatures.h" 00019 00021 class CHistogramWordStringKernel: public CStringKernel<uint16_t> 00022 { 00023 public: 00029 CHistogramWordStringKernel(int32_t size, CPluginEstimate* pie); 00030 00037 CHistogramWordStringKernel( 00038 CStringFeatures<uint16_t>* l, CStringFeatures<uint16_t>* r, 00039 CPluginEstimate* pie); 00040 00041 virtual ~CHistogramWordStringKernel(); 00042 00049 virtual bool init(CFeatures* l, CFeatures* r); 00050 00052 virtual void cleanup(); 00053 00059 bool load_init(FILE* src); 00060 00066 bool save_init(FILE* dest); 00067 00072 virtual EKernelType get_kernel_type() { return K_HISTOGRAM; } 00073 00078 virtual const char* get_name() { return "Histogram" ; } 00079 00080 protected: 00089 float64_t compute(int32_t idx_a, int32_t idx_b); 00090 00097 inline int32_t compute_index(int32_t position, uint16_t symbol) 00098 { 00099 return position*num_symbols+symbol+1; 00100 } 00101 00102 protected: 00104 CPluginEstimate* estimate; 00105 00107 float64_t* mean; 00109 float64_t* variance; 00110 00112 float64_t* sqrtdiag_lhs; 00114 float64_t* sqrtdiag_rhs; 00115 00117 float64_t* ld_mean_lhs; 00119 float64_t* ld_mean_rhs; 00120 00122 float64_t* plo_lhs; 00124 float64_t* plo_rhs; 00125 00127 int32_t num_params; 00129 int32_t num_params2; 00131 int32_t num_symbols; 00133 float64_t sum_m2_s2; 00134 00136 bool initialized; 00137 }; 00138 00139 #endif /* _HISTOGRAMWORDKERNEL_H__ */