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