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 <shogun/lib/common.h> 00016 #include <shogun/features/Features.h> 00017 #include <shogun/features/StringFeatures.h> 00018 #include <shogun/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: 00029 CHammingWordDistance(); 00030 00035 CHammingWordDistance(bool use_sign); 00036 00043 CHammingWordDistance(CStringFeatures<uint16_t>* l, CStringFeatures<uint16_t>* r, bool use_sign); 00044 virtual ~CHammingWordDistance(); 00045 00052 virtual bool init(CFeatures* l, CFeatures* r); 00053 00055 virtual void cleanup(); 00056 00061 virtual EDistanceType get_distance_type() { return D_HAMMINGWORD; } 00062 00067 virtual const char* get_name() const { return "HammingWordDistance"; } 00068 00069 protected: 00073 float64_t compute(int32_t idx_a, int32_t idx_b); 00074 00075 private: 00076 void init(); 00077 00078 protected: 00080 bool use_sign; 00081 }; 00082 } // namespace shogun 00083 #endif /* _HAMMINGWORDDISTANCE_H___ */