Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef __RD_METRICFUNCS_H__
00011 #define __RD_METRICFUNCS_H__
00012 #include <cmath>
00013 #include <DataStructs/BitOps.h>
00014
00015 namespace RDDataManip {
00016
00017 template <typename T1, typename T2>
00018 double EuclideanDistanceMetric(const T1 &v1, const T2 &v2, unsigned int dim) {
00019 double dist = 0.0;
00020 for (unsigned int i = 0; i < dim; i++) {
00021 double diff = static_cast<double>(v1[i]) - static_cast<double>(v2[i]);
00022 dist += (diff*diff);
00023 }
00024 return sqrt(dist);
00025 };
00026
00027
00028
00029
00030
00031 template <typename T1, typename T2>
00032 double TanimotoDistanceMetric(const T1 &bv1, const T2 &bv2, unsigned int dim) {
00033
00034
00035 return (1.0 - SimilarityWrapper(bv1, bv2,(double (*)(const T1&,const T2&))TanimotoSimilarity));
00036 };
00037
00038
00039 template <typename T1, typename T2>
00040 double TanimotoSimilarityMetric(const T1 &bv1, const T2 &bv2, unsigned int dim) {
00041 return SimilarityWrapper(bv1,bv2,(double (*)(const T1&,const T2&))TanimotoSimilarity);
00042 };
00043 }
00044
00045 #endif
00046
00047