SHOGUN
v3.2.0
|
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) 2012 Chiyuan Zhang 00008 * Copyright (C) 2012 Chiyuan Zhang 00009 */ 00010 00011 #ifndef ECOCUTIL_H__ 00012 #define ECOCUTIL_H__ 00013 00014 #include <shogun/mathematics/Math.h> 00015 00016 namespace shogun 00017 { 00018 00020 class CECOCUtil 00021 { 00022 public: 00028 template<typename T1, typename T2> 00029 static int32_t hamming_distance(T1 *c1, T2 *c2, int32_t len) 00030 { 00031 int32_t dist = 0; 00032 for (int32_t i=0; i < len; ++i) 00033 dist += static_cast<int32_t>(CMath::abs((c1[i]-c2[i]))); 00034 return dist/2; 00035 } 00036 }; 00037 00038 } /* shogun */ 00039 00040 #endif /* end of include guard: ECOCUTIL_H__ */ 00041