-- cgit v1.2.3 From 6f9560fe6d6cca6c5a0de35fcf7938912e103930 Mon Sep 17 00:00:00 2001 From: glisse Date: Fri, 24 Feb 2017 14:37:59 +0000 Subject: Drop unused include gudhi/Clock.h. git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/farthest_distance@2108 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: a210a519993cb4f0118fb250e76afea10d20bad3 --- src/Subsampling/include/gudhi/choose_n_farthest_points.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Subsampling/include/gudhi/choose_n_farthest_points.h b/src/Subsampling/include/gudhi/choose_n_farthest_points.h index a77d0cd7..5061a511 100644 --- a/src/Subsampling/include/gudhi/choose_n_farthest_points.h +++ b/src/Subsampling/include/gudhi/choose_n_farthest_points.h @@ -26,7 +26,6 @@ #include #include -#include #include #include -- cgit v1.2.3 From d2e5de256424e824e9f54a6ae6c30cd06d8111d4 Mon Sep 17 00:00:00 2001 From: glisse Date: Sun, 26 Mar 2017 12:38:26 +0000 Subject: 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 --- .../example/example_choose_n_farthest_points.cpp | 2 +- src/Subsampling/example/example_custom_kernel.cpp | 2 +- .../include/gudhi/choose_n_farthest_points.h | 45 ++++++---------------- src/cython/include/Subsampling_interface.h | 2 +- 4 files changed, 15 insertions(+), 36 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 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 points = {0, 1, 2, 3}; std::vector 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 Kernel_d::Squared_distance_d @@ -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 Kernel_d::Squared_distance_d - * 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 diff --git a/src/cython/include/Subsampling_interface.h b/src/cython/include/Subsampling_interface.h index 1c6032c0..a4a872e4 100644 --- a/src/cython/include/Subsampling_interface.h +++ b/src/cython/include/Subsampling_interface.h @@ -46,7 +46,7 @@ std::vector> subsampling_n_farthest_points(const std::vector unsigned nb_points) { std::vector> landmarks; Subsampling_dynamic_kernel k; - choose_n_farthest_points(k, points, nb_points, std::back_inserter(landmarks)); + choose_n_farthest_points(k, points, nb_points, random_first_landmark, std::back_inserter(landmarks)); return landmarks; } -- cgit v1.2.3 From 732eb3a08d9a16e8e8ffd66ed76b99968d5cb06f Mon Sep 17 00:00:00 2001 From: glisse Date: Mon, 27 Mar 2017 15:49:37 +0000 Subject: Rename random_first_landmark to random_starting_point. git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/farthest_distance@2250 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 953403f208094ca4145d837f736bfc939efa9223 --- src/Subsampling/example/example_choose_n_farthest_points.cpp | 2 +- src/Subsampling/example/example_custom_kernel.cpp | 2 +- src/Subsampling/include/gudhi/choose_n_farthest_points.h | 6 +++--- src/cython/include/Subsampling_interface.h | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Subsampling/example/example_choose_n_farthest_points.cpp b/src/Subsampling/example/example_choose_n_farthest_points.cpp index adbd2b80..fc9ea7a6 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 results; - Gudhi::subsampling::choose_n_farthest_points(k, points, 100, Gudhi::subsampling::random_first_landmark, std::back_inserter(results)); + Gudhi::subsampling::choose_n_farthest_points(k, points, 100, Gudhi::subsampling::random_starting_point, 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 935ba885..2719ee90 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 points = {0, 1, 2, 3}; std::vector results; - Gudhi::subsampling::choose_n_farthest_points(k, points, 2, Gudhi::subsampling::random_first_landmark, std::back_inserter(results)); + Gudhi::subsampling::choose_n_farthest_points(k, points, 2, Gudhi::subsampling::random_starting_point, 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 02376c03..1d2338cb 100644 --- a/src/Subsampling/include/gudhi/choose_n_farthest_points.h +++ b/src/Subsampling/include/gudhi/choose_n_farthest_points.h @@ -43,14 +43,14 @@ 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) + random_starting_point = 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==random_first_landmark`, with a random landmark. + * The iteration starts with the landmark `starting point` or, if `starting point==random_starting_point`, with a random landmark. * \tparam Kernel must provide a type Kernel::Squared_distance_d which is a model of the * concept Kernel_d::Squared_distance_d @@ -90,7 +90,7 @@ void choose_n_farthest_points(Kernel const &k, if (final_size < 1) return; - if (starting_point == random_first_landmark) { + if (starting_point == random_starting_point) { // Choose randomly the first landmark std::random_device rd; std::mt19937 gen(rd()); diff --git a/src/cython/include/Subsampling_interface.h b/src/cython/include/Subsampling_interface.h index a4a872e4..b0f4a50a 100644 --- a/src/cython/include/Subsampling_interface.h +++ b/src/cython/include/Subsampling_interface.h @@ -46,7 +46,7 @@ std::vector> subsampling_n_farthest_points(const std::vector unsigned nb_points) { std::vector> landmarks; Subsampling_dynamic_kernel k; - choose_n_farthest_points(k, points, nb_points, random_first_landmark, std::back_inserter(landmarks)); + choose_n_farthest_points(k, points, nb_points, random_starting_point, std::back_inserter(landmarks)); return landmarks; } -- cgit v1.2.3 From 99d4649ada3b6314269bb22d2a8d95b4011a15ec Mon Sep 17 00:00:00 2001 From: glisse Date: Fri, 7 Apr 2017 08:02:39 +0000 Subject: Clarify doc about Squared_distance_d in Subsampling. git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/farthest_distance@2315 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 5559e1c426569fba1dd4cd350a8697ab7e3260f1 --- src/Subsampling/include/gudhi/choose_n_farthest_points.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Subsampling/include/gudhi/choose_n_farthest_points.h b/src/Subsampling/include/gudhi/choose_n_farthest_points.h index 1d2338cb..50d3cf80 100644 --- a/src/Subsampling/include/gudhi/choose_n_farthest_points.h +++ b/src/Subsampling/include/gudhi/choose_n_farthest_points.h @@ -53,9 +53,8 @@ enum : std::size_t { * The iteration starts with the landmark `starting point` or, if `starting point==random_starting_point`, with a random landmark. * \tparam Kernel must provide a type Kernel::Squared_distance_d which is a model of the * concept Kernel_d::Squared_distance_d - * concept. - * It must also contain a public member 'squared_distance_d_object' of this type. + * href="http://doc.cgal.org/latest/Kernel_d/classKernel__d_1_1Squared__distance__d.html">Kernel_d::Squared_distance_d (despite the name, taken from CGAL, this can be any kind of metric or proximity measure). + * It must also contain a public member `squared_distance_d_object()` that returns an 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. -- cgit v1.2.3 From c536d49278965cd578281ecbec72cea2c8b90cc3 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Mon, 10 Apr 2017 16:23:30 +0000 Subject: Fix and rename test farthest git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/farthest_distance@2328 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: f1761bf66bcf6d45f72a051fa9a62c4699e3999d --- src/Subsampling/test/test_choose_n_farthest_points.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Subsampling/test/test_choose_n_farthest_points.cpp b/src/Subsampling/test/test_choose_n_farthest_points.cpp index 6bc5f7b0..ee9d4c77 100644 --- a/src/Subsampling/test/test_choose_n_farthest_points.cpp +++ b/src/Subsampling/test/test_choose_n_farthest_points.cpp @@ -25,7 +25,7 @@ // #endif #define BOOST_TEST_DYN_LINK -#define BOOST_TEST_MODULE "witness_complex_points" +#define BOOST_TEST_MODULE Subsampling - test choose_n_farthest_points #include #include @@ -56,7 +56,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(test_choose_farthest_point, Kernel, list_of_tested landmarks.clear(); Kernel k; - Gudhi::subsampling::choose_n_farthest_points(k, points, 100, std::back_inserter(landmarks)); + Gudhi::subsampling::choose_n_farthest_points(k, points, 100, Gudhi::subsampling::random_starting_point, std::back_inserter(landmarks)); BOOST_CHECK(landmarks.size() == 100); for (auto landmark : landmarks) -- cgit v1.2.3