10 #ifndef __RD_BITOPS_H__ 11 #define __RD_BITOPS_H__ 31 double (*metric)(
const T&,
const T&),
32 bool returnDistance =
false) {
34 if (bv1.getNumBits() > bv2.getNumBits()) {
36 res = metric(*bv1tmp, bv2);
38 }
else if (bv2.getNumBits() > bv1.getNumBits()) {
40 res = metric(bv1, *bv2tmp);
43 res = metric(bv1, bv2);
45 if (returnDistance) res = 1.0 - res;
51 double (*metric)(
const T&,
const T&,
double,
double),
52 bool returnDistance =
false) {
54 if (bv1.getNumBits() > bv2.getNumBits()) {
56 res = metric(*bv1tmp, bv2, a, b);
58 }
else if (bv2.getNumBits() > bv1.getNumBits()) {
60 res = metric(bv1, *bv2tmp, a, b);
63 res = metric(bv1, bv2, a, b);
65 if (returnDistance) res = 1.0 - res;
74 template <
typename T1>
77 template <
typename T1>
84 template <
typename T1,
typename T2>
93 template <
typename T1,
typename T2>
100 template <
typename T1,
typename T2>
107 template <
typename T1,
typename T2>
114 template <
typename T1,
typename T2>
127 template <
typename T1,
typename T2>
134 template <
typename T1,
typename T2>
142 template <
typename T1,
typename T2>
149 template <
typename T1,
typename T2>
156 template <
typename T1,
typename T2>
167 template <
typename T1,
typename T2>
175 template <
typename T1,
typename T2>
182 template <
typename T1,
typename T2>
189 template <
typename T1,
typename T2>
199 template <
typename T1,
typename T2>
204 template <
typename T1,
typename T2>
209 template <
typename T1,
typename T2>
218 template <
typename T1,
typename T2>
230 template <
typename T1,
typename T2>
243 template <
typename T1>
253 template <
typename T1>
264 template <
typename T1>
274 template <
typename T1>
284 template <
typename T1>
295 template <
typename T1>
303 unsigned int nBytes);
304 double CalcBitmapDice(
const unsigned char* bv1,
const unsigned char* bv2,
305 unsigned int nBytes);
307 unsigned int nBytes,
double ca,
double cb);
309 const unsigned char* ref,
unsigned int nBytes);
Pulls in all the BitVect classes.
double DiceSimilarity(const T1 &bv1, const T2 &bv2)
returns the Dice similarity between two bit vects
T1 * FoldFingerprint(const T1 &bv1, unsigned int factor=2)
folds a bit vector factor times and returns the result
std::string BitVectToFPSText(const T1 &bv1)
returns a hex representation of a bit vector compatible with Andrew Dalke's
double SokalSimilarity(const T1 &bv1, const T2 &bv2)
returns the Sokal similarity between two bit vects
DoubleVect OffBitProjSimilarity(const T1 &bv1, const T2 &bv2)
returns the on-bit projected similarities between two bit vects
double TanimotoSimilarity(const T1 &bv1, const T2 &bv2)
returns the Tanimoto similarity between two bit vects
double OnBitSimilarity(const T1 &bv1, const T2 &bv2)
returns the on bit similarity between two bit vects
DoubleVect OnBitProjSimilarity(const T1 &bv1, const T2 &bv2)
returns the on-bit projected similarities between two bit vects
double CalcBitmapTversky(const unsigned char *bv1, const unsigned char *bv2, unsigned int nBytes, double ca, double cb)
int NumOnBitsInCommon(const T1 &bv1, const T2 &bv2)
returns the number of on bits in common between two bit vectors
bool CalcBitmapAllProbeBitsMatch(const unsigned char *probe, const unsigned char *ref, unsigned int nBytes)
int NumBitsInCommon(const T1 &bv1, const T2 &bv2)
returns the number of common bits (on and off) between two bit vects
double RogotGoldbergSimilarity(const T1 &bv1, const T2 &bv2)
returns the Rogot-Goldberg similarity between two bit vects
void UpdateBitVectFromBinaryText(T1 &bv1, const std::string &fps)
updates a bit vector from a binary string representation of a bit vector (an
double AsymmetricSimilarity(const T1 &bv1, const T2 &bv2)
returns the Asymmetric similarity between two bit vects
std::string BitVectToBinaryText(const T1 &bv1)
returns a binary string representation of a bit vector (an array of bytes)
double CosineSimilarity(const T1 &bv1, const T2 &bv2)
returns the Cosine similarity between two bit vects
std::vector< double > DoubleVect
double CalcBitmapDice(const unsigned char *bv1, const unsigned char *bv2, unsigned int nBytes)
double SimilarityWrapper(const T &bv1, const T &bv2, double(*metric)(const T &, const T &), bool returnDistance=false)
IntVect OnBitsInCommon(const T1 &bv1, const T2 &bv2)
returns an IntVect with indices of all on bits in common between two bit
std::string BitVectToText(const T1 &bv1)
returns a text representation of a bit vector (a string of 0s and 1s)
double TverskySimilarity(const T1 &bv1, const T2 &bv2, double a, double b)
returns the Tversky similarity between two bit vects
double McConnaugheySimilarity(const T1 &bv1, const T2 &bv2)
returns the McConnaughey similarity between two bit vects
double AllBitSimilarity(const T1 &bv1, const T2 &bv2)
bool AllProbeBitsMatch(const char *probe, const char *ref)
std::vector< int > IntVect
a class for bit vectors that are densely occupied
double CalcBitmapTanimoto(const unsigned char *bv1, const unsigned char *bv2, unsigned int nBytes)
IntVect OffBitsInCommon(const T1 &bv1, const T2 &bv2)
returns an IntVect with indices of all off bits in common between two bit
double RusselSimilarity(const T1 &bv1, const T2 &bv2)
returns the Russel similarity between two bit vects
double KulczynskiSimilarity(const T1 &bv1, const T2 &bv2)
returns the Kulczynski similarity between two bit vects
void UpdateBitVectFromFPSText(T1 &bv1, const std::string &fps)
updates a bit vector from Andrew Dalke's FPS format
double BraunBlanquetSimilarity(const T1 &bv1, const T2 &bv2)
returns the Braun-Blanquet similarity between two bit vects
unsigned int CalcBitmapPopcount(const unsigned char *bv1, unsigned int nBytes)