00001
00002
00003
00004
00005
00006 #ifndef __RD_BITOPS_H__
00007 #define __RD_BITOPS_H__
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "BitVects.h"
00020 #include <string>
00021
00022
00023
00024
00025 template <typename T>
00026 double SimilarityWrapper(const T &bv1,const T &bv2,
00027 const double (*metric)(const T &,const T &),
00028 bool returnDistance=false){
00029 double res=0.0;
00030 if(bv1.GetNumBits()>bv2.GetNumBits()){
00031 T *bv1tmp = FoldFingerprint(bv1,bv1.GetNumBits()/bv2.GetNumBits());
00032 res = metric(*bv1tmp,bv2);
00033 delete bv1tmp;
00034 } else if(bv2.GetNumBits()>bv1.GetNumBits()){
00035 T *bv2tmp = FoldFingerprint(bv2,bv2.GetNumBits()/bv1.GetNumBits());
00036 res = metric(bv1,*bv2tmp);
00037 delete bv2tmp;
00038 } else {
00039 res = metric(bv1,bv2);
00040 }
00041 if(returnDistance) res = 1.0-res;
00042 return res;
00043 }
00044
00045
00046 bool AllProbeBitsMatch(const char *probe,const char *ref);
00047 bool AllProbeBitsMatch(const std::string &probe,const std::string &ref);
00048
00049
00050 template <typename T1>
00051 bool AllProbeBitsMatch(const T1 &probe,const std::string &pkl);
00052
00053
00054
00055
00056
00057
00058 template <typename T1, typename T2>
00059 int
00060 NumOnBitsInCommon(const T1& bv1,const T2& bv2);
00061
00062 int
00063 NumOnBitsInCommon(const ExplicitBitVect & bv1,const ExplicitBitVect & bv2);
00064
00065
00066
00067
00068
00069 template <typename T1, typename T2>
00070 const double
00071 TanimotoSimilarity(const T1& bv1,const T2& bv2);
00072
00073
00074
00075
00076
00077 template <typename T1, typename T2>
00078 const double
00079 CosineSimilarity(const T1& bv1,
00080 const T2& bv2);
00081
00082
00083
00084
00085
00086 template <typename T1, typename T2>
00087 const double
00088 KulczynskiSimilarity(const T1& bv1,
00089 const T2& bv2);
00090
00091
00092
00093
00094
00095 template <typename T1, typename T2>
00096 const double
00097 DiceSimilarity(const T1& bv1,
00098 const T2& bv2);
00099
00100
00101
00102
00103
00104 template <typename T1, typename T2>
00105 const double
00106 SokalSimilarity(const T1& bv1,
00107 const T2& bv2);
00108
00109
00110
00111
00112
00113 template <typename T1, typename T2>
00114 const double
00115 McConnaugheySimilarity(const T1& bv1,
00116 const T2& bv2);
00117
00118
00119
00120
00121
00122 template <typename T1, typename T2>
00123 const double
00124 AsymmetricSimilarity(const T1& bv1,
00125 const T2& bv2);
00126
00127
00128
00129
00130
00131 template <typename T1, typename T2>
00132 const double
00133 BraunBlanquetSimilarity(const T1& bv1,
00134 const T2& bv2);
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144 template <typename T1, typename T2>
00145 const double
00146 RusselSimilarity(const T1& bv1,
00147 const T2& bv2);
00148
00149
00150
00151
00152
00153
00154 template <typename T1, typename T2>
00155 const double
00156 OnBitSimilarity(const T1& bv1,const T2& bv2);
00157
00158
00159
00160
00161
00162 template <typename T1, typename T2>
00163 const int
00164 NumBitsInCommon(const T1& bv1,const T2& bv2);
00165
00166
00167
00168
00169
00170 template <typename T1, typename T2>
00171 const double
00172 AllBitSimilarity(const T1& bv1,const T2& bv2);
00173
00174
00175 template <typename T1, typename T2>
00176 IntVect
00177 OnBitsInCommon(const T1& bv1,const T2& bv2);
00178
00179
00180 template <typename T1, typename T2>
00181 IntVect
00182 OffBitsInCommon(const T1& bv1,const T2& bv2);
00183
00184
00185
00186
00187
00188
00189
00190 template <typename T1, typename T2>
00191 DoubleVect
00192 OnBitProjSimilarity(const T1& bv1,const T2& bv2);
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203 template <typename T1, typename T2>
00204 DoubleVect
00205 OffBitProjSimilarity(const T1& bv1,const T2& bv2);
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218 template <typename T1>
00219 T1 *
00220 FoldFingerprint(const T1& bv1,unsigned int factor=2);
00221
00222
00223
00224
00225
00226
00227
00228
00229 template <typename T1>
00230 std::string
00231 BitVectToText(const T1& bv1);
00232
00233
00234
00235 #endif