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) 2007-2009 Christian Gehl 00008 * Written (W) 1999-2009 Soeren Sonnenburg 00009 * Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society 00010 */ 00011 00012 #ifndef _HAMMINGWORDDISTANCE_H___ 00013 #define _HAMMINGWORDDISTANCE_H___ 00014 00015 #include "lib/common.h" 00016 #include "features/Features.h" 00017 #include "features/StringFeatures.h" 00018 #include "distance/StringDistance.h" 00019 00020 namespace shogun 00021 { 00022 template <class T> class CStringFeatures; 00023 00025 class CHammingWordDistance: public CStringDistance<uint16_t> 00026 { 00027 public: 00032 CHammingWordDistance(bool use_sign); 00033 00040 CHammingWordDistance(CStringFeatures<uint16_t>* l, CStringFeatures<uint16_t>* r, bool use_sign); 00041 virtual ~CHammingWordDistance(); 00042 00049 virtual bool init(CFeatures* l, CFeatures* r); 00050 00052 virtual void cleanup(); 00053 00058 virtual EDistanceType get_distance_type() { return D_HAMMINGWORD; } 00059 00064 virtual const char* get_name() const { return "HammingWord"; } 00065 00071 void get_dictionary(int32_t& dsize, float64_t*& dweights) 00072 { 00073 dsize=dictionary_size; 00074 dweights = dictionary_weights; 00075 } 00076 00077 protected: 00081 float64_t compute(int32_t idx_a, int32_t idx_b); 00082 00083 protected: 00085 int32_t dictionary_size; 00087 float64_t* dictionary_weights; 00089 bool use_sign; 00090 }; 00091 } // namespace shogun 00092 #endif /* _HAMMINGWORDDISTANCE_H___ */