double operator()(unsigned int i, unsigned int j) { double res; std::pair<unsigned int, unsigned int> idxPair(i, j); if (dp_cache && dp_cache->count(idxPair) > 0) { res = (*dp_cache)[idxPair]; } else { res = python::extract<double>(dp_obj(i, j)); if (dp_cache) (*dp_cache)[idxPair] = res; } return res; }
double operator()(unsigned int i,unsigned int j) { double res; std::pair<unsigned int ,unsigned int> idxPair(i,j); if(this->d_cache.count(idxPair)>0){ res = this->d_cache[idxPair]; } else { res=python::extract<double>(dp_obj(i,j)); this->d_cache[idxPair]=res; } 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; }