Skip to content

Commit

Permalink
Update nanoflann.
Browse files Browse the repository at this point in the history
  • Loading branch information
abellgithub committed Apr 27, 2020
1 parent 7845cda commit 2cc86f2
Showing 1 changed file with 0 additions and 111 deletions.
111 changes: 0 additions & 111 deletions vendor/nanoflann/nanoflann.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,105 +278,6 @@ class RadiusResultSet {

struct Metric {};

/** Manhattan distance functor (generic version, optimized for
* high-dimensionality data sets). Corresponding distance traits:
* nanoflann::metric_L1 \tparam T Type of the elements (e.g. double, float,
* uint8_t) \tparam _DistanceType Type of distance variables (must be signed)
* (e.g. float, double, int64_t)
*/
template <class T, class DataSource, typename _DistanceType = T>
struct L1_Adaptor {
typedef T ElementType;
typedef _DistanceType DistanceType;

const DataSource &data_source;

L1_Adaptor(const DataSource &_data_source) : data_source(_data_source) {}

inline DistanceType evalMetric(const T *a, const size_t b_idx, size_t size,
DistanceType worst_dist = -1) const {
DistanceType result = DistanceType();
const T *last = a + size;
const T *lastgroup = last - 3;
size_t d = 0;

/* Process 4 items with each loop for efficiency. */
while (a < lastgroup) {
const DistanceType diff0 =
std::abs(a[0] - data_source.kdtree_get_pt(b_idx, d++));
const DistanceType diff1 =
std::abs(a[1] - data_source.kdtree_get_pt(b_idx, d++));
const DistanceType diff2 =
std::abs(a[2] - data_source.kdtree_get_pt(b_idx, d++));
const DistanceType diff3 =
std::abs(a[3] - data_source.kdtree_get_pt(b_idx, d++));
result += diff0 + diff1 + diff2 + diff3;
a += 4;
if ((worst_dist > 0) && (result > worst_dist)) {
return result;
}
}
/* Process last 0-3 components. Not needed for standard vector lengths. */
while (a < last) {
result += std::abs(*a++ - data_source.kdtree_get_pt(b_idx, d++));
}
return result;
}

template <typename U, typename V>
inline DistanceType accum_dist(const U a, const V b, const size_t) const {
return std::abs(a - b);
}
};

/** Squared Euclidean distance functor (generic version, optimized for
* high-dimensionality data sets). Corresponding distance traits:
* nanoflann::metric_L2 \tparam T Type of the elements (e.g. double, float,
* uint8_t) \tparam _DistanceType Type of distance variables (must be signed)
* (e.g. float, double, int64_t)
*/
template <class T, class DataSource, typename _DistanceType = T>
struct L2_Adaptor {
typedef T ElementType;
typedef _DistanceType DistanceType;

const DataSource &data_source;

L2_Adaptor(const DataSource &_data_source) : data_source(_data_source) {}

inline DistanceType evalMetric(const T *a, const size_t b_idx, size_t size,
DistanceType worst_dist = -1) const {
DistanceType result = DistanceType();
const T *last = a + size;
const T *lastgroup = last - 3;
size_t d = 0;

/* Process 4 items with each loop for efficiency. */
while (a < lastgroup) {
const DistanceType diff0 = a[0] - data_source.kdtree_get_pt(b_idx, d++);
const DistanceType diff1 = a[1] - data_source.kdtree_get_pt(b_idx, d++);
const DistanceType diff2 = a[2] - data_source.kdtree_get_pt(b_idx, d++);
const DistanceType diff3 = a[3] - data_source.kdtree_get_pt(b_idx, d++);
result += diff0 * diff0 + diff1 * diff1 + diff2 * diff2 + diff3 * diff3;
a += 4;
if ((worst_dist > 0) && (result > worst_dist)) {
return result;
}
}
/* Process last 0-3 components. Not needed for standard vector lengths. */
while (a < last) {
const DistanceType diff0 = *a++ - data_source.kdtree_get_pt(b_idx, d++);
result += diff0 * diff0;
}
return result;
}

template <typename U, typename V>
inline DistanceType accum_dist(const U a, const V b, const size_t) const {
return (a - b) * (a - b);
}
};

/** Squared Euclidean (L2) distance functor (suitable for low-dimensionality
* datasets, like 2D or 3D point clouds) Corresponding distance traits:
* nanoflann::metric_L2_Simple \tparam T Type of the elements (e.g. double,
Expand Down Expand Up @@ -409,18 +310,6 @@ struct L2_Simple_Adaptor {
}
};

/** Metaprogramming helper traits class for the L1 (Manhattan) metric */
struct metric_L1 : public Metric {
template <class T, class DataSource> struct traits {
typedef L1_Adaptor<T, DataSource> distance_t;
};
};
/** Metaprogramming helper traits class for the L2 (Euclidean) metric */
struct metric_L2 : public Metric {
template <class T, class DataSource> struct traits {
typedef L2_Adaptor<T, DataSource> distance_t;
};
};
/** Metaprogramming helper traits class for the L2_simple (Euclidean) metric */
struct metric_L2_Simple : public Metric {
template <class T, class DataSource> struct traits {
Expand Down

0 comments on commit 2cc86f2

Please sign in to comment.