summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Spatial_searching/doc/Intro_spatial_searching.h2
-rw-r--r--src/Spatial_searching/example/example_spatial_searching.cpp22
-rw-r--r--src/Spatial_searching/include/gudhi/Kd_tree_search.h34
-rw-r--r--src/Spatial_searching/test/test_Kd_tree_search.cpp24
-rw-r--r--src/Subsampling/include/gudhi/sparsify_point_set.h2
-rw-r--r--src/Tangential_complex/include/gudhi/Tangential_complex.h16
-rw-r--r--src/Witness_complex/include/gudhi/Euclidean_strong_witness_complex.h2
-rw-r--r--src/Witness_complex/include/gudhi/Euclidean_witness_complex.h2
-rw-r--r--src/Witness_complex/test/test_euclidean_simple_witness_complex.cpp2
9 files changed, 52 insertions, 54 deletions
diff --git a/src/Spatial_searching/doc/Intro_spatial_searching.h b/src/Spatial_searching/doc/Intro_spatial_searching.h
index 22652ac4..1ee5e92e 100644
--- a/src/Spatial_searching/doc/Intro_spatial_searching.h
+++ b/src/Spatial_searching/doc/Intro_spatial_searching.h
@@ -46,7 +46,7 @@ namespace spatial_searching {
*
* \section spatial_searching_examples Example
*
- * This example generates 500 random points, then performs near search, and queries for nearest and farthest points using different methods.
+ * This example generates 500 random points, then performs all-near-neighbors searches, and queries for nearest and furthest neighbors using different methods.
*
* \include Spatial_searching/example_spatial_searching.cpp
*
diff --git a/src/Spatial_searching/example/example_spatial_searching.cpp b/src/Spatial_searching/example/example_spatial_searching.cpp
index 201b589e..034ad24a 100644
--- a/src/Spatial_searching/example/example_spatial_searching.cpp
+++ b/src/Spatial_searching/example/example_spatial_searching.cpp
@@ -24,34 +24,34 @@ int main(void) {
// 10-nearest neighbor query
std::cout << "10 nearest neighbors from points[20]:\n";
- auto knn_range = points_ds.query_k_nearest_neighbors(points[20], 10, true);
+ auto knn_range = points_ds.k_nearest_neighbors(points[20], 10, true);
for (auto const& nghb : knn_range)
std::cout << nghb.first << " (sq. dist. = " << nghb.second << ")\n";
// Incremental nearest neighbor query
std::cout << "Incremental nearest neighbors:\n";
- auto inn_range = points_ds.query_incremental_nearest_neighbors(points[45]);
+ auto inn_range = points_ds.incremental_nearest_neighbors(points[45]);
// Get the neighbors in distance order until we hit the first point
for (auto ins_iterator = inn_range.begin(); ins_iterator->first != 0; ++ins_iterator)
std::cout << ins_iterator->first << " (sq. dist. = " << ins_iterator->second << ")\n";
- // 10-farthest neighbor query
- std::cout << "10 farthest neighbors from points[20]:\n";
- auto kfn_range = points_ds.query_k_farthest_neighbors(points[20], 10, true);
+ // 10-furthest neighbor query
+ std::cout << "10 furthest neighbors from points[20]:\n";
+ auto kfn_range = points_ds.k_furthest_neighbors(points[20], 10, true);
for (auto const& nghb : kfn_range)
std::cout << nghb.first << " (sq. dist. = " << nghb.second << ")\n";
- // Incremental farthest neighbor query
- std::cout << "Incremental farthest neighbors:\n";
- auto ifn_range = points_ds.query_incremental_farthest_neighbors(points[45]);
+ // Incremental furthest neighbor query
+ std::cout << "Incremental furthest neighbors:\n";
+ auto ifn_range = points_ds.incremental_furthest_neighbors(points[45]);
// Get the neighbors in distance reverse order until we hit the first point
for (auto ifs_iterator = ifn_range.begin(); ifs_iterator->first != 0; ++ifs_iterator)
std::cout << ifs_iterator->first << " (sq. dist. = " << ifs_iterator->second << ")\n";
- // Near search
- std::cout << "Near search:\n";
+ // All-near-neighbors search
+ std::cout << "All-near-neighbors search:\n";
std::vector<std::size_t> rs_result;
- points_ds.near_search(points[45], 0.5, std::back_inserter(rs_result));
+ points_ds.all_near_neighbors(points[45], 0.5, std::back_inserter(rs_result));
K k;
for (auto const& p_idx : rs_result)
std::cout << p_idx << " (sq. dist. = " << k.squared_distance_d_object()(points[p_idx], points[45]) << ")\n";
diff --git a/src/Spatial_searching/include/gudhi/Kd_tree_search.h b/src/Spatial_searching/include/gudhi/Kd_tree_search.h
index af04736b..ef428002 100644
--- a/src/Spatial_searching/include/gudhi/Kd_tree_search.h
+++ b/src/Spatial_searching/include/gudhi/Kd_tree_search.h
@@ -42,19 +42,19 @@ namespace spatial_searching {
/**
* \class Kd_tree_search Kd_tree_search.h gudhi/Kd_tree_search.h
- * \brief Spatial tree data structure to perform (approximate) nearest and farthest neighbor search.
+ * \brief Spatial tree data structure to perform (approximate) nearest and furthest neighbor search.
*
* \ingroup spatial_searching
*
* \details
* The class Kd_tree_search is a tree-based data structure, based on
* <a target="_blank" href="http://doc.cgal.org/latest/Spatial_searching/index.html">CGAL dD spatial searching data structures</a>.
- * It provides a simplified API to perform (approximate) nearest and farthest neighbor searches. Contrary to CGAL default behavior, the tree
+ * It provides a simplified API to perform (approximate) nearest and furthest neighbor searches. Contrary to CGAL default behavior, the tree
* does not store the points themselves, but stores indices.
*
- * There are two types of queries: the <i>k-nearest or k-farthest neighbor query</i>, where <i>k</i> is fixed and the <i>k</i> nearest
- * or farthest points are computed right away,
- * and the <i>incremental nearest or farthest neighbor query</i>, where no number of neighbors is provided during the call, as the
+ * There are two types of queries: the <i>k-nearest or k-furthest neighbor query</i>, where <i>k</i> is fixed and the <i>k</i> nearest
+ * or furthest points are computed right away,
+ * and the <i>incremental nearest or furthest neighbor query</i>, where no number of neighbors is provided during the call, as the
* neighbors will be computed incrementally when the iterator on the range is incremented.
*
* \tparam Search_traits must be a model of the <a target="_blank"
@@ -96,7 +96,7 @@ class Kd_tree_search {
typedef CGAL::Orthogonal_k_neighbor_search<STraits> K_neighbor_search;
typedef typename K_neighbor_search::Tree Tree;
typedef typename K_neighbor_search::Distance Distance;
- /// \brief The range returned by a k-nearest or k-farthest neighbor search.
+ /// \brief The range returned by a k-nearest or k-furthest neighbor search.
/// Its value type is `std::pair<std::size_t, FT>` where `first` is the index
/// of a point P and `second` is the squared distance between P and the query point.
typedef K_neighbor_search KNS_range;
@@ -104,7 +104,7 @@ class Kd_tree_search {
typedef CGAL::Orthogonal_incremental_neighbor_search<
STraits, Distance, CGAL::Sliding_midpoint<STraits>, Tree>
Incremental_neighbor_search;
- /// \brief The range returned by an incremental nearest or farthest neighbor search.
+ /// \brief The range returned by an incremental nearest or furthest neighbor search.
/// Its value type is `std::pair<std::size_t, FT>` where `first` is the index
/// of a point P and `second` is the squared distance between P and the query point.
typedef Incremental_neighbor_search INS_range;
@@ -171,7 +171,7 @@ class Kd_tree_search {
/// @param[in] sorted Indicates if the computed sequence of k-nearest neighbors needs to be sorted.
/// @param[in] eps Approximation factor.
/// @return A range (whose `value_type` is `std::size_t`) containing the k-nearest neighbors.
- KNS_range query_k_nearest_neighbors(
+ KNS_range k_nearest_neighbors(
Point const& p,
unsigned int k,
bool sorted = true,
@@ -197,7 +197,7 @@ class Kd_tree_search {
/// neighbors sorted by their distance to p.
/// All the neighbors are not computed by this function, but they will be
/// computed incrementally when the iterator on the range is incremented.
- INS_range query_incremental_nearest_neighbors(Point const& p, FT eps = FT(0)) const {
+ INS_range incremental_nearest_neighbors(Point const& p, FT eps = FT(0)) const {
// Initialize the search structure, and search all N points
// Note that we need to pass the Distance explicitly since it needs to
// know the property map
@@ -211,13 +211,13 @@ class Kd_tree_search {
return search;
}
- /// \brief Search for the k-farthest points from a query point.
+ /// \brief Search for the k-furthest points from a query point.
/// @param[in] p The query point.
- /// @param[in] k Number of farthest points to search.
- /// @param[in] sorted Indicates if the computed sequence of k-farthest neighbors needs to be sorted.
+ /// @param[in] k Number of furthest points to search.
+ /// @param[in] sorted Indicates if the computed sequence of k-furthest neighbors needs to be sorted.
/// @param[in] eps Approximation factor.
- /// @return A range (whose `value_type` is `std::size_t`) containing the k-farthest neighbors.
- KNS_range query_k_farthest_neighbors(
+ /// @return A range (whose `value_type` is `std::size_t`) containing the k-furthest neighbors.
+ KNS_range k_furthest_neighbors(
Point const& p,
unsigned int k,
bool sorted = true,
@@ -236,14 +236,14 @@ class Kd_tree_search {
return search;
}
- /// \brief Search incrementally for the farthest neighbors from a query point.
+ /// \brief Search incrementally for the furthest neighbors from a query point.
/// @param[in] p The query point.
/// @param[in] eps Approximation factor.
/// @return A range (whose `value_type` is `std::size_t`)
/// containing the neighbors sorted by their distance to p.
/// All the neighbors are not computed by this function, but they will be
/// computed incrementally when the iterator on the range is incremented.
- INS_range query_incremental_farthest_neighbors(Point const& p, FT eps = FT(0)) const {
+ INS_range incremental_furthest_neighbors(Point const& p, FT eps = FT(0)) const {
// Initialize the search structure, and search all N points
// Note that we need to pass the Distance explicitly since it needs to
// know the property map
@@ -264,7 +264,7 @@ class Kd_tree_search {
/// Note: `it` is used this way: `*it++ = each_point`.
/// @param[in] eps Approximation factor.
template <typename OutputIterator>
- void near_search(Point const& p,
+ void all_near_neighbors(Point const& p,
FT radius,
OutputIterator it,
FT eps = FT(0)) const {
diff --git a/src/Spatial_searching/test/test_Kd_tree_search.cpp b/src/Spatial_searching/test/test_Kd_tree_search.cpp
index 663a103a..8a8334c3 100644
--- a/src/Spatial_searching/test/test_Kd_tree_search.cpp
+++ b/src/Spatial_searching/test/test_Kd_tree_search.cpp
@@ -48,12 +48,12 @@ BOOST_AUTO_TEST_CASE(test_Kd_tree_search) {
Points_ds points_ds(points);
- // Test query_k_nearest_neighbors
+ // Test k_nearest_neighbors
std::size_t closest_pt_index =
- points_ds.query_k_nearest_neighbors(points[10], 1, false).begin()->first;
+ points_ds.k_nearest_neighbors(points[10], 1, false).begin()->first;
BOOST_CHECK(closest_pt_index == 10);
- auto kns_range = points_ds.query_k_nearest_neighbors(points[20], 10, true);
+ auto kns_range = points_ds.k_nearest_neighbors(points[20], 10, true);
std::vector<std::size_t> knn_result;
FT last_dist = -1.;
@@ -63,12 +63,12 @@ BOOST_AUTO_TEST_CASE(test_Kd_tree_search) {
last_dist = nghb.second;
}
- // Test query_incremental_nearest_neighbors
+ // Test incremental_nearest_neighbors
closest_pt_index =
- points_ds.query_incremental_nearest_neighbors(points[10]).begin()->first;
+ points_ds.incremental_nearest_neighbors(points[10]).begin()->first;
BOOST_CHECK(closest_pt_index == 10);
- auto inn_range = points_ds.query_incremental_nearest_neighbors(points[20]);
+ auto inn_range = points_ds.incremental_nearest_neighbors(points[20]);
std::vector<std::size_t> inn_result;
last_dist = -1.;
@@ -83,8 +83,8 @@ BOOST_AUTO_TEST_CASE(test_Kd_tree_search) {
// Same result for KNN and INN?
BOOST_CHECK(knn_result == inn_result);
- // Test query_k_farthest_neighbors
- auto kfn_range = points_ds.query_k_farthest_neighbors(points[20], 10, true);
+ // Test k_furthest_neighbors
+ auto kfn_range = points_ds.k_furthest_neighbors(points[20], 10, true);
std::vector<std::size_t> kfn_result;
last_dist = kfn_range.begin()->second;
@@ -94,8 +94,8 @@ BOOST_AUTO_TEST_CASE(test_Kd_tree_search) {
last_dist = nghb.second;
}
- // Test query_k_farthest_neighbors
- auto ifn_range = points_ds.query_incremental_farthest_neighbors(points[20]);
+ // Test k_furthest_neighbors
+ auto ifn_range = points_ds.incremental_furthest_neighbors(points[20]);
std::vector<std::size_t> ifn_result;
last_dist = ifn_range.begin()->second;
@@ -110,10 +110,10 @@ BOOST_AUTO_TEST_CASE(test_Kd_tree_search) {
// Same result for KFN and IFN?
BOOST_CHECK(kfn_result == ifn_result);
- // Test near search
+ // Test all_near_neighbors
Point rs_q(rd.get_double(-1., 1), rd.get_double(-1., 1), rd.get_double(-1., 1), rd.get_double(-1., 1));
std::vector<std::size_t> rs_result;
- points_ds.near_search(rs_q, 0.5, std::back_inserter(rs_result));
+ points_ds.all_near_neighbors(rs_q, 0.5, std::back_inserter(rs_result));
K k;
for (auto const& p_idx : rs_result)
BOOST_CHECK(k.squared_distance_d_object()(points[p_idx], rs_q) <= 0.5);
diff --git a/src/Subsampling/include/gudhi/sparsify_point_set.h b/src/Subsampling/include/gudhi/sparsify_point_set.h
index 507f8c79..7d3b97fb 100644
--- a/src/Subsampling/include/gudhi/sparsify_point_set.h
+++ b/src/Subsampling/include/gudhi/sparsify_point_set.h
@@ -83,7 +83,7 @@ sparsify_point_set(
*output_it++ = *it_pt;
- auto ins_range = points_ds.query_incremental_nearest_neighbors(*it_pt);
+ auto ins_range = points_ds.incremental_nearest_neighbors(*it_pt);
// If another point Q is closer that min_squared_dist, mark Q to be dropped
for (auto const& neighbor : ins_range) {
diff --git a/src/Tangential_complex/include/gudhi/Tangential_complex.h b/src/Tangential_complex/include/gudhi/Tangential_complex.h
index 9fa7c825..a5cefd6a 100644
--- a/src/Tangential_complex/include/gudhi/Tangential_complex.h
+++ b/src/Tangential_complex/include/gudhi/Tangential_complex.h
@@ -1093,8 +1093,8 @@ class Tangential_complex {
std::size_t num_inserted_points = 1;
#endif
// const int NUM_NEIGHBORS = 150;
- // KNS_range ins_range = m_points_ds.query_k_nearest_neighbors(center_pt, NUM_NEIGHBORS);
- INS_range ins_range = m_points_ds.query_incremental_nearest_neighbors(center_pt);
+ // KNS_range ins_range = m_points_ds.k_nearest_neighbors(center_pt, NUM_NEIGHBORS);
+ INS_range ins_range = m_points_ds.incremental_nearest_neighbors(center_pt);
// While building the local triangulation, we keep the radius
// of the sphere "star sphere" centered at "center_vertex"
@@ -1203,7 +1203,7 @@ class Tangential_complex {
Point center_point = compute_perturbed_point(i);
// Among updated point, what is the closer from our center point?
std::size_t closest_pt_index =
- updated_pts_ds.query_k_nearest_neighbors(center_point, 1, false).begin()->first;
+ updated_pts_ds.k_nearest_neighbors(center_point, 1, false).begin()->first;
typename K::Construct_weighted_point_d k_constr_wp =
m_k.construct_weighted_point_d_object();
@@ -1315,11 +1315,10 @@ class Tangential_complex {
m_k.compute_coordinate_d_object();
#ifdef GUDHI_TC_USE_ANOTHER_POINT_SET_FOR_TANGENT_SPACE_ESTIM
- KNS_range kns_range = m_points_ds_for_tse.query_k_nearest_neighbors(
- p, num_pts_for_pca, false);
+ KNS_range kns_range = m_points_ds_for_tse.k_nearest_neighbors(p, num_pts_for_pca, false);
const Points &points_for_pca = m_points_for_tse;
#else
- KNS_range kns_range = m_points_ds.query_k_nearest_neighbors(p, num_pts_for_pca, false);
+ KNS_range kns_range = m_points_ds.k_nearest_neighbors(p, num_pts_for_pca, false);
const Points &points_for_pca = m_points;
#endif
@@ -1413,11 +1412,10 @@ class Tangential_complex {
const Point &p = m_points[*it_index];
#ifdef GUDHI_TC_USE_ANOTHER_POINT_SET_FOR_TANGENT_SPACE_ESTIM
- KNS_range kns_range = m_points_ds_for_tse.query_k_nearest_neighbors(
- p, num_pts_for_pca, false);
+ KNS_range kns_range = m_points_ds_for_tse.k_nearest_neighbors(p, num_pts_for_pca, false);
const Points &points_for_pca = m_points_for_tse;
#else
- KNS_range kns_range = m_points_ds.query_k_nearest_neighbors(p, num_pts_for_pca, false);
+ KNS_range kns_range = m_points_ds.k_nearest_neighbors(p, num_pts_for_pca, false);
const Points &points_for_pca = m_points;
#endif
diff --git a/src/Witness_complex/include/gudhi/Euclidean_strong_witness_complex.h b/src/Witness_complex/include/gudhi/Euclidean_strong_witness_complex.h
index fb669ef8..4f3cef4f 100644
--- a/src/Witness_complex/include/gudhi/Euclidean_strong_witness_complex.h
+++ b/src/Witness_complex/include/gudhi/Euclidean_strong_witness_complex.h
@@ -84,7 +84,7 @@ class Euclidean_strong_witness_complex
: landmarks_(std::begin(landmarks), std::end(landmarks)), landmark_tree_(landmarks_) {
nearest_landmark_table_.reserve(boost::size(witnesses));
for (auto w : witnesses)
- nearest_landmark_table_.push_back(landmark_tree_.query_incremental_nearest_neighbors(w));
+ nearest_landmark_table_.push_back(landmark_tree_.incremental_nearest_neighbors(w));
}
/** \brief Returns the point corresponding to the given vertex.
diff --git a/src/Witness_complex/include/gudhi/Euclidean_witness_complex.h b/src/Witness_complex/include/gudhi/Euclidean_witness_complex.h
index 6afe9a5d..ff8bb139 100644
--- a/src/Witness_complex/include/gudhi/Euclidean_witness_complex.h
+++ b/src/Witness_complex/include/gudhi/Euclidean_witness_complex.h
@@ -86,7 +86,7 @@ class Euclidean_witness_complex
: landmarks_(std::begin(landmarks), std::end(landmarks)), landmark_tree_(landmarks) {
nearest_landmark_table_.reserve(boost::size(witnesses));
for (auto w : witnesses)
- nearest_landmark_table_.push_back(landmark_tree_.query_incremental_nearest_neighbors(w));
+ nearest_landmark_table_.push_back(landmark_tree_.incremental_nearest_neighbors(w));
}
/** \brief Returns the point corresponding to the given vertex.
diff --git a/src/Witness_complex/test/test_euclidean_simple_witness_complex.cpp b/src/Witness_complex/test/test_euclidean_simple_witness_complex.cpp
index 62fd1157..4f718203 100644
--- a/src/Witness_complex/test/test_euclidean_simple_witness_complex.cpp
+++ b/src/Witness_complex/test/test_euclidean_simple_witness_complex.cpp
@@ -75,7 +75,7 @@ BOOST_AUTO_TEST_CASE(simple_witness_complex) {
Kd_tree landmark_tree(landmarks);
Nearest_landmark_table nearest_landmark_table;
for (auto w: witnesses)
- nearest_landmark_table.push_back(landmark_tree.query_incremental_nearest_neighbors(w));
+ nearest_landmark_table.push_back(landmark_tree.incremental_nearest_neighbors(w));
// Weak witness complex: Euclidean version
EuclideanWitnessComplex eucl_witness_complex(landmarks,