double operator()(unsigned int i, unsigned int j) { double res = 0.0; switch (d_method) { case TANIMOTO: res = 1. - TanimotoSimilarity(*d_obj[i], *d_obj[j]); break; case DICE: res = 1. - DiceSimilarity(*d_obj[i], *d_obj[j]); break; default: throw_value_error("unsupported similarity value"); } return res; }
double operator()(unsigned int i,unsigned int j) { const ExplicitBitVect *bvi,*bvj; try{ bvi=python::extract<const ExplicitBitVect *>(dp_obj[i]); bvj=python::extract<const ExplicitBitVect *>(dp_obj[j]); } catch (...) { throw_value_error("unable to extract ExplicitBitVect from sequence value"); } double res=0.0; switch(d_method){ case TANIMOTO: res = 1.-TanimotoSimilarity(*bvi,*bvj); break; case DICE: res = 1.-DiceSimilarity(*bvi,*bvj); break; default: throw_value_error("unsupported similarity value"); } return res; }
double operator()(unsigned int i, unsigned int j) { double res = 0.0; std::pair<unsigned int, unsigned int> idxPair(i, j); if (dp_cache && dp_cache->count(idxPair) > 0) { res = (*dp_cache)[idxPair]; } else { switch (d_method) { case TANIMOTO: res = 1. - TanimotoSimilarity(*d_obj[i], *d_obj[j]); break; case DICE: res = 1. - DiceSimilarity(*d_obj[i], *d_obj[j]); break; default: throw_value_error("unsupported similarity value"); } if (dp_cache) { (*dp_cache)[idxPair] = res; } } return res; }