HammingWordDistance.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) 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 
00021 class CHammingWordDistance: public CStringDistance<uint16_t>
00022 {
00023     public:
00028         CHammingWordDistance(bool use_sign);
00029 
00036         CHammingWordDistance(CStringFeatures<uint16_t>* l, CStringFeatures<uint16_t>* r, bool use_sign);
00037         virtual ~CHammingWordDistance();
00038 
00045         virtual bool init(CFeatures* l, CFeatures* r);
00046 
00048         virtual void cleanup();
00049 
00055         bool load_init(FILE* src);
00056 
00062         bool save_init(FILE* dest);
00063 
00068         virtual EDistanceType get_distance_type() { return D_HAMMINGWORD; }
00069 
00074         virtual const char* get_name() const { return "HammingWord"; }
00075 
00081         void get_dictionary(int32_t& dsize, float64_t*& dweights)
00082         {
00083             dsize=dictionary_size;
00084             dweights = dictionary_weights;
00085         }
00086 
00087     protected:
00091         float64_t compute(int32_t idx_a, int32_t idx_b);
00092 
00093     protected:
00095         int32_t dictionary_size;
00097         float64_t* dictionary_weights;
00099         bool use_sign;
00100 };
00101 #endif /* _HAMMINGWORDDISTANCE_H___ */

SHOGUN Machine Learning Toolbox - Documentation