9 #ifndef IMPMISC_METRIC_CLOSE_PAIRS_FINDER_H
10 #define IMPMISC_METRIC_CLOSE_PAIRS_FINDER_H
12 #include <IMP/misc/misc_config.h>
20 IMPMISC_BEGIN_NAMESPACE
41 template <
class LowerBound,
class UpperBound>
51 unsigned int index_size = std::min<unsigned int>(
52 1U, std::sqrt(static_cast<double>(inputs.size())));
53 std::random_shuffle(inputs.begin(), inputs.end());
56 inputs.begin() + index_size);
57 for (
unsigned int i = 0; i < index_size; ++i) {
61 for (
unsigned int i = 0; i < inputs.size(); ++i) {
62 double min_dist = std::numeric_limits<double>::max();
64 for (
unsigned int j = 0; j < indexes.size(); ++j) {
68 "The bounds are not ordered.");
71 if (cur_dist < min_dist) {
72 min_index = indexes[j];
76 ret[min_index].access_indexes().push_back(inputs[i]);
77 ret[min_index].set_width(std::min(min_dist, ret[min_index].get_width()));
79 for (
typename Index::const_iterator it = ret.begin(); it != ret.end();
88 for (
unsigned int i = 0; i < p.size(); ++i) {
89 for (
unsigned int j = 0; j < i; ++j) {
92 "The bounds are not ordered.");
104 for (
unsigned int i = 0; i < pa.size(); ++i) {
105 for (
unsigned int j = 0; j < pb.size(); ++j) {
108 "The bounds are not ordered.");
119 bool is_same)
const {
121 for (
typename Index::const_iterator ita = ia.begin(); ita != ia.end();
123 for (
typename Index::const_iterator itb = ib.begin(); itb != ib.end();
126 if (ita->first < itb->first)
continue;
127 if (ita->first == itb->first) {
128 ret += get_close_pairs_internal(m, ita->second.get_indexes());
135 "The bounds are not ordered.");
137 ita->second.get_width() - itb->second.get_width()) {
138 ret += get_close_pairs_internal(m, ita->second.get_indexes(),
139 itb->second.get_indexes());
148 std::string name =
"MetricClosePairsFinder%1%")
151 using ClosePairsFinder::get_close_pairs;
175 return get_close_pairs_internal(m, index, index,
true);
184 return get_close_pairs_internal(m, indexa, indexb,
false);
196 template <
class LowerBound,
class UpperBound>
202 IMPMISC_END_NAMESPACE
virtual IntPairs get_close_pairs(const algebra::BoundingBox3Ds &, const algebra::BoundingBox3Ds &) const
Various general useful functions for IMP.
Ints get_index(const kernel::ParticlesTemp &particles, const Subset &subset, const Subsets &excluded)
A base class for algorithms to find spatial proximities.
A nullptr-initialized pointer to an IMP Object.
ParticlesTemp get_particles(kernel::Model *m, const ParticleIndexes &ps)
virtual IntPairs get_close_pairs(const algebra::BoundingBox3Ds &) const
#define IMP_USAGE_CHECK(expr, message)
A runtime test for incorrect usage of a class or method.
virtual kernel::ModelObjectsTemp do_get_inputs(kernel::Model *m, const kernel::ParticleIndexes &pis) const
A class to store an fixed array of same-typed values.
double get_distance(const Plane3D &pln, const Vector3D &p)
Return the distance between a plane and a point in 3D.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
#define IMP_OBJECT_LOG
Set the log level to the object's log level.
core::ClosePairsFinder * create_metric_close_pairs_finder(LowerBound lb, UpperBound ub)
A base class for algorithms to detect proximities.
#define IMP_FAILURE(message)
A runtime failure for IMP.
#define IMP_LOG_VERBOSE(expr)
Declare an efficient stl-compatible map.
Class for storing model, its restraints, constraints, and particles.