summaryrefslogtreecommitdiff
path: root/src/Subsampling
diff options
context:
space:
mode:
authorglisse <glisse@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2017-03-26 12:38:26 +0000
committerglisse <glisse@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2017-03-26 12:38:26 +0000
commitd2e5de256424e824e9f54a6ae6c30cd06d8111d4 (patch)
treebf9f2210f06ef146c90f9953732fe998ab5a326c /src/Subsampling
parent1208d423e700764a3453767886e6a3b4c0a09125 (diff)
Remove overload of choose_n_farthest_points.
Use a named constant instead of -1 to denote a random value. git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/farthest_distance@2245 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 166dff85c74ab2c13bfd788f226d1d8a15d1d1b9
Diffstat (limited to 'src/Subsampling')
-rw-r--r--src/Subsampling/example/example_choose_n_farthest_points.cpp2
-rw-r--r--src/Subsampling/example/example_custom_kernel.cpp2
-rw-r--r--src/Subsampling/include/gudhi/choose_n_farthest_points.h45
3 files changed, 14 insertions, 35 deletions
diff --git a/src/Subsampling/example/example_choose_n_farthest_points.cpp b/src/Subsampling/example/example_choose_n_farthest_points.cpp
index 533aba74..adbd2b80 100644
--- a/src/Subsampling/example/example_choose_n_farthest_points.cpp
+++ b/src/Subsampling/example/example_choose_n_farthest_points.cpp
@@ -19,7 +19,7 @@ int main(void) {
K k;
std::vector<Point_d> results;
- Gudhi::subsampling::choose_n_farthest_points(k, points, 100, std::back_inserter(results));
+ Gudhi::subsampling::choose_n_farthest_points(k, points, 100, Gudhi::subsampling::random_first_landmark, std::back_inserter(results));
std::cout << "Before sparsification: " << points.size() << " points.\n";
std::cout << "After sparsification: " << results.size() << " points.\n";
diff --git a/src/Subsampling/example/example_custom_kernel.cpp b/src/Subsampling/example/example_custom_kernel.cpp
index 25b5bf6c..935ba885 100644
--- a/src/Subsampling/example/example_custom_kernel.cpp
+++ b/src/Subsampling/example/example_custom_kernel.cpp
@@ -54,7 +54,7 @@ int main(void) {
std::vector<Point_d> points = {0, 1, 2, 3};
std::vector<Point_d> results;
- Gudhi::subsampling::choose_n_farthest_points(k, points, 2, std::back_inserter(results));
+ Gudhi::subsampling::choose_n_farthest_points(k, points, 2, Gudhi::subsampling::random_first_landmark, std::back_inserter(results));
std::cout << "Before sparsification: " << points.size() << " points.\n";
std::cout << "After sparsification: " << results.size() << " points.\n";
std::cout << "Result table: {" << results[0] << "," << results[1] << "}\n";
diff --git a/src/Subsampling/include/gudhi/choose_n_farthest_points.h b/src/Subsampling/include/gudhi/choose_n_farthest_points.h
index 5061a511..02376c03 100644
--- a/src/Subsampling/include/gudhi/choose_n_farthest_points.h
+++ b/src/Subsampling/include/gudhi/choose_n_farthest_points.h
@@ -36,11 +36,21 @@ namespace Gudhi {
namespace subsampling {
+/**
+ * \ingroup subsampling
+ */
+enum : std::size_t {
+/**
+ * Argument for `choose_n_farthest_points` to indicate that the starting point should be picked randomly.
+ */
+ random_first_landmark = std::size_t(-1)
+};
+
/**
* \ingroup subsampling
* \brief Subsample by a greedy strategy of iteratively adding the farthest point from the
* current chosen point set to the subsampling.
- * The iteration starts with the landmark `starting point` or, if `starting point==-1`, with a random landmark.
+ * The iteration starts with the landmark `starting point` or, if `starting point==random_first_landmark`, with a random landmark.
* \tparam Kernel must provide a type Kernel::Squared_distance_d which is a model of the
* concept <a target="_blank"
* href="http://doc.cgal.org/latest/Kernel_d/classKernel__d_1_1Squared__distance__d.html">Kernel_d::Squared_distance_d</a>
@@ -80,7 +90,7 @@ void choose_n_farthest_points(Kernel const &k,
if (final_size < 1)
return;
- if (starting_point == std::size_t(-1)) {
+ if (starting_point == random_first_landmark) {
// Choose randomly the first landmark
std::random_device rd;
std::mt19937 gen(rd());
@@ -117,37 +127,6 @@ void choose_n_farthest_points(Kernel const &k,
}
}
-/**
- * \ingroup subsampling
- * \brief Subsample by a greedy strategy of iteratively adding the farthest point from the
- * current chosen point set to the subsampling.
- * The iteration starts with a random landmark.
- * \tparam Kernel must provide a type Kernel::Squared_distance_d which is a model of the
- * concept <a target="_blank"
- * href="http://doc.cgal.org/latest/Kernel_d/classKernel__d_1_1Squared__distance__d.html">Kernel_d::Squared_distance_d</a>
- * concept.
- * It must also contain a public member 'squared_distance_d_object' of this type.
- * \tparam Point_range Range whose value type is Kernel::Point_d. It must provide random-access
- * via `operator[]` and the points should be stored contiguously in memory.
- * \tparam PointOutputIterator Output iterator whose value type is Kernel::Point_d.
- * \details It chooses `final_size` points from a random access range `input_pts` and
- * outputs it in the output iterator `output_it`.
- * @param[in] k A kernel object.
- * @param[in] input_pts Const reference to the input points.
- * @param[in] final_size The size of the subsample to compute.
- * @param[out] output_it The output iterator.
- *
- */
-template < typename Kernel,
-typename Point_range,
-typename PointOutputIterator>
-void choose_n_farthest_points(Kernel const& k,
- Point_range const &input_pts,
- std::size_t final_size,
- PointOutputIterator output_it) {
- choose_n_farthest_points(k, input_pts, final_size, -1, output_it);
-}
-
} // namespace subsampling
} // namespace Gudhi