From 3cd1e01f0b0d4fdb46f49ec640c389374ca2fe70 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Thu, 22 Feb 2018 23:16:55 +0000 Subject: Fix Cech with radius distance Add a meta generation script for off_file_generator git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/cechcomplex_vincent@3256 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: fb13baa124ddc97c0dc61835ab0c72595d666155 --- src/common/include/gudhi/distance_functions.h | 33 +++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'src/common') diff --git a/src/common/include/gudhi/distance_functions.h b/src/common/include/gudhi/distance_functions.h index 3a5d1fd5..3ce51ad1 100644 --- a/src/common/include/gudhi/distance_functions.h +++ b/src/common/include/gudhi/distance_functions.h @@ -25,6 +25,8 @@ #include +#include + #include #include // for std::sqrt @@ -68,6 +70,37 @@ class Euclidean_distance { } }; +/** @brief Compute the squared radius between Points given by a range of coordinates. The points are assumed to + * have the same dimension. */ +class Radius_distance { + public: + // boost::range_value is not SFINAE-friendly so we cannot use it in the return type + template< typename Point > + typename std::iterator_traits::type>::value_type + operator()(const Point& p1, const Point& p2) const { + return Euclidean_distance()(p1, p2) / 2.; + } + // boost::range_value is not SFINAE-friendly so we cannot use it in the return type + template< typename Point_cloud, + typename Point_iterator = typename boost::range_const_iterator::type, + typename Point= typename std::iterator_traits::value_type, + typename Coordinate_iterator = typename boost::range_const_iterator::type, + typename Coordinate = typename std::iterator_traits::value_type> + Coordinate + operator()(const Point_cloud& point_cloud) const { + using Min_sphere = Miniball::Miniball>; + + //Min_sphere ms(point_cloud.begin()->end() - point_cloud.begin()->begin(), point_cloud.begin(),point_cloud.end()); + Min_sphere ms(point_cloud.end() - point_cloud.begin(), point_cloud.begin(),point_cloud.end()); +#ifdef DEBUG_TRACES + std::cout << "Radius on " << point_cloud.end() - point_cloud.begin() << " points = " + << std::sqrt(ms.squared_radius()) << std::endl; +#endif // DEBUG_TRACES + + return std::sqrt(ms.squared_radius()); + } +}; + } // namespace Gudhi #endif // DISTANCE_FUNCTIONS_H_ -- cgit v1.2.3 From b3a64294af818c977804c4b67a317782d872e2b5 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Mon, 5 Mar 2018 13:38:57 +0000 Subject: Fix doc and tests git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/cechcomplex_vincent@3262 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: c76eb981f5960938221aa2498cb87b0707391733 --- .../benchmark/cech_complex_benchmark.cpp | 10 +- src/Cech_complex/doc/Intro_cech_complex.h | 52 ++++--- .../doc/cech_complex_representation.ipe | 160 +++++++++++---------- .../doc/cech_complex_representation.png | Bin 15677 -> 54399 bytes src/Cech_complex/doc/cech_one_skeleton.ipe | 154 +++++++++----------- src/Cech_complex/doc/cech_one_skeleton.png | Bin 12070 -> 29354 bytes .../example/cech_complex_example_from_points.cpp | 22 +-- .../cech_complex_example_from_points_for_doc.txt | 45 ++++-- src/Cech_complex/include/gudhi/Cech_complex.h | 4 +- .../include/gudhi/Cech_complex_blocker.h | 11 +- src/Cech_complex/test/test_cech_complex.cpp | 12 +- src/Doxyfile | 3 +- src/common/include/gudhi/distance_functions.h | 8 +- 13 files changed, 255 insertions(+), 226 deletions(-) (limited to 'src/common') diff --git a/src/Cech_complex/benchmark/cech_complex_benchmark.cpp b/src/Cech_complex/benchmark/cech_complex_benchmark.cpp index 71c88982..83ef9dca 100644 --- a/src/Cech_complex/benchmark/cech_complex_benchmark.cpp +++ b/src/Cech_complex/benchmark/cech_complex_benchmark.cpp @@ -93,12 +93,12 @@ int main(int argc, char * argv[]) { Radius_distance()); std::cout << radius_clock << std::endl; - Gudhi::Clock squared_radius_clock("Gudhi::Radius_distance()"); + Gudhi::Clock common_radius_clock("Gudhi::Radius_distance()"); // Compute the proximity graph of the points Proximity_graph sq_radius_prox_graph = Gudhi::compute_proximity_graph(off_reader.get_point_cloud(), threshold, Gudhi::Radius_distance()); - std::cout << squared_radius_clock << std::endl; + std::cout << common_radius_clock << std::endl; boost::filesystem::path full_path(boost::filesystem::current_path()); @@ -116,6 +116,7 @@ int main(int argc, char * argv[]) { if ( itr->path().extension() == ".off" ) // see below { Points_off_reader off_reader(itr->path().string()); + Point p0 = off_reader.get_point_cloud()[0]; for (Filtration_value radius = 0.1; radius < 0.4; radius += 0.1) { std::cout << itr->path().stem() << ";"; @@ -123,7 +124,7 @@ int main(int argc, char * argv[]) { Gudhi::Clock rips_clock("Rips computation"); Rips_complex rips_complex_from_points(off_reader.get_point_cloud(), radius, Gudhi::Radius_distance()); Simplex_tree rips_stree; - rips_complex_from_points.create_complex(rips_stree, 2); + rips_complex_from_points.create_complex(rips_stree, p0.size() - 1); // ------------------------------------------ // Display information about the Rips complex // ------------------------------------------ @@ -133,7 +134,7 @@ int main(int argc, char * argv[]) { Gudhi::Clock cech_clock("Cech computation"); Cech_complex cech_complex_from_points(off_reader.get_point_cloud(), radius); Simplex_tree cech_stree; - cech_complex_from_points.create_complex(cech_stree, 2); + cech_complex_from_points.create_complex(cech_stree, p0.size() - 1); // ------------------------------------------ // Display information about the Cech complex // ------------------------------------------ @@ -141,6 +142,7 @@ int main(int argc, char * argv[]) { std::cout << cech_sec << ";"; std::cout << cech_sec / rips_sec << ";"; + assert(rips_stree.num_simplices() >= cech_stree.num_simplices()); std::cout << rips_stree.num_simplices() << ";"; std::cout << cech_stree.num_simplices() << ";" << std::endl; } diff --git a/src/Cech_complex/doc/Intro_cech_complex.h b/src/Cech_complex/doc/Intro_cech_complex.h index f2052763..8b6c7851 100644 --- a/src/Cech_complex/doc/Intro_cech_complex.h +++ b/src/Cech_complex/doc/Intro_cech_complex.h @@ -29,7 +29,7 @@ namespace cech_complex { /** \defgroup cech_complex Cech complex * - * \author Clément Maria, Pawel Dlotko, Vincent Rouvreau + * \author Vincent Rouvreau * * @{ * @@ -40,40 +40,54 @@ namespace cech_complex { * proximity graph that allows to construct a * simplicial complex * from it. - * The input can be a point cloud with a given distance function. + * The input shall be a point cloud in an Euclidean space. * - * The filtration value of each edge is computed from a user-given distance function. + * The filtration value of each edge of the `Gudhi::Proximity_graph` is computed from `Gudhi::Radius_distance` function. * - * All edges that have a filtration value strictly greater than a given threshold value are not inserted into - * the complex. + * All edges that have a filtration value strictly greater than a user given maximal radius value, \f$max\_radius\f$, + * are not inserted into the complex. * - * When creating a simplicial complex from this proximity graph, Cech inserts the proximity graph into the data - * structure, and then expands the simplicial complex when required. - * * Vertex name correspond to the index of the point in the given range (aka. the point cloud). * - * \image html "cech_complex_representation.png" "Cech complex proximity graph representation" - * - * On this example, as edges (4,5), (4,6) and (5,6) are in the complex, simplex (4,5,6) is added with the filtration - * value set with \f$max(filtration(4,5), filtration(4,6), filtration(5,6))\f$. - * And so on for simplex (0,1,2,3). + * \image html "cech_one_skeleton.png" "Cech complex proximity graph representation" * + * When creating a simplicial complex from this proximity graph, Cech inserts the proximity graph into the simplicial + * complex data structure, and then expands the simplicial complex when required. + * + * On this example, as edges \f$(x,y)\f$, \f$(y,z)\f$ and \f$(z,y)\f$ are in the complex, the minimal ball radius + * containing the points \f$(x,y,z)\f$ is computed. + * + * \f$(x,y,z)\f$ is inserted to the simplicial complex with the filtration value set with + * \f$mini\_ball\_radius(x,y,z))\f$ iff \f$mini\_ball\_radius(x,y,z)) \leq max\_radius\f$. + * + * And so on for higher dimensions. + * + * \image html "cech_complex_representation.png" "Cech complex expansion" + * + * The minimal ball radius computation is insured by + * + * the miniball software (V3.0) - Smallest Enclosing Balls of Points - and distributed with GUDHI. + * + * Please refer to + * + * the miniball software design description for more information about this computation. + * * If the Cech_complex interfaces are not detailed enough for your need, please refer to - * - * cech_persistence_step_by_step.cpp example, where the graph construction over the Simplex_tree is more detailed. + * + * cech_complex_step_by_step.cpp example, where the graph construction over the Simplex_tree is more detailed. * - * \section cechpointsdistance Point cloud and distance function + * \section cechpointsdistance Point cloud * - * \subsection cechpointscloudexample Example from a point cloud and a distance function + * \subsection cechpointscloudexample Example from a point cloud * - * This example builds the proximity graph from the given points, threshold value, and distance function. + * This example builds the proximity graph from the given points, and maximal radius values. * Then it creates a `Simplex_tree` with it. * * Then, it is asked to display information about the simplicial complex. * * \include Cech_complex/cech_complex_example_from_points.cpp * - * When launching (Cech maximal distance between 2 points is 7.1, is expanded until dimension 2): + * When launching (Cech maximal distance between 2 points is 1., is expanded until dimension 2): * * \code $> ./Cech_complex_example_from_points * \endcode diff --git a/src/Cech_complex/doc/cech_complex_representation.ipe b/src/Cech_complex/doc/cech_complex_representation.ipe index 7f6028f4..c64d7596 100644 --- a/src/Cech_complex/doc/cech_complex_representation.ipe +++ b/src/Cech_complex/doc/cech_complex_representation.ipe @@ -1,7 +1,7 @@ - + @@ -232,95 +232,99 @@ h - -109.771 601.912 m -159.595 601.797 l -140.058 541.915 l + +48 640 m +80 672 l +48 672 l h - -79.8776 552.169 m -109.756 601.699 l -139.812 542.209 l +Cech complex +0 +1 +2 +3 +4 +5 +6 + + + + + + + + + + + + + +32 0 0 32 304 672 e + + +304 672 m +336 672 l + +Maximal radius +7 +8 +9 + +112 576 m +144 608 l + + +144 672 m +144 608 l +200 640 l h - -69.8453 682.419 m -159.925 712.208 l -90.12 732.039 l + +48 576 m +112 576 l +80 544 l h -Rips complex -0 -1 -2 -3 -4 -5 -6 - -60 710 m -40 660 l - - -40 660 m -130 690 l - - -130 690 m -60 710 l - - -40 660 m -80 580 l - - -80 580 m -130 580 l -130 580 l - - -130 580 m -110 520 l - - -110 520 m -50 530 l -50 530 l -50 530 l + + +80 672 m +144 672 l +112 728 l +h - -50 530 m -80 580 l + + + + +48 576 m +48 640 l +32 608 l +h - -130 580 m -130 690 l + + + + + + + +32 0 0 32 80 576 e - - - - - - -150.038 609.9 m -179.929 549.727 l + +22.6274 0 0 22.6274 64 656 e - - - -158.7 593.269 m -81.4925 544.805 l + +37.1429 0 0 37.1429 112 690.857 e - -256.324 639.958 m -370.055 639.958 l + +37.1429 0 0 37.1429 162.857 640 e - -56.8567 0 0 56.8567 313.217 639.756 e + +10 + +32 0 0 32 48 608 e - - -Rips threshold + + diff --git a/src/Cech_complex/doc/cech_complex_representation.png b/src/Cech_complex/doc/cech_complex_representation.png index e901d92e..4d103a56 100644 Binary files a/src/Cech_complex/doc/cech_complex_representation.png and b/src/Cech_complex/doc/cech_complex_representation.png differ diff --git a/src/Cech_complex/doc/cech_one_skeleton.ipe b/src/Cech_complex/doc/cech_one_skeleton.ipe index 3a35970c..345e6d7b 100644 --- a/src/Cech_complex/doc/cech_one_skeleton.ipe +++ b/src/Cech_complex/doc/cech_one_skeleton.ipe @@ -1,7 +1,7 @@ - + @@ -232,95 +232,83 @@ h - -109.771 601.912 m -159.595 601.797 l -140.058 541.915 l +Proximity graph +0 +1 + +304 672 m +336 672 l + +2 +3 +4 +5 +6 + + + + + + + + + + + +32 0 0 32 304 672 e + +Maximal radius +7 +8 +9 + +112 576 m +144 608 l + + +144 672 m +144 608 l +200 640 l h - -79.8776 552.169 m -109.756 601.699 l -139.812 542.209 l + +48 640 m +80 672 l +48 672 l h - -69.8453 682.419 m -159.925 712.208 l -90.12 732.039 l + +48 576 m +112 576 l +80 544 l h -One skeleton graph -0 -1 -2 -3 -4 -5 -6 - -60 710 m -40 660 l - - -40 660 m -130 690 l - - -130 690 m -60 710 l - - -40 660 m -80 580 l - - -80 580 m -130 580 l -130 580 l - - -130 580 m -110 520 l - - -110 520 m -50 530 l -50 530 l -50 530 l - - -50 530 m -80 580 l - - -130 580 m -130 690 l - - - - - - - -150.038 609.9 m -179.929 549.727 l - - - - -158.7 593.269 m -81.4925 544.805 l - - -256.324 639.958 m -370.055 639.958 l + + +80 672 m +144 672 l +112 728 l +h - -56.8567 0 0 56.8567 313.217 639.756 e + + +48 576 m +48 640 l +32 608 l +h - - -Rips threshold + + + + + + + + + + +10 + + diff --git a/src/Cech_complex/doc/cech_one_skeleton.png b/src/Cech_complex/doc/cech_one_skeleton.png index ffa9c329..807e0936 100644 Binary files a/src/Cech_complex/doc/cech_one_skeleton.png and b/src/Cech_complex/doc/cech_one_skeleton.png differ diff --git a/src/Cech_complex/example/cech_complex_example_from_points.cpp b/src/Cech_complex/example/cech_complex_example_from_points.cpp index 97327e69..3b889d56 100644 --- a/src/Cech_complex/example/cech_complex_example_from_points.cpp +++ b/src/Cech_complex/example/cech_complex_example_from_points.cpp @@ -15,22 +15,26 @@ int main() { using Cech_complex = Gudhi::cech_complex::Cech_complex; Point_cloud points; - points.push_back({0., 0.}); - points.push_back({0., 2.}); - points.push_back({std::sqrt(3.), 1.}); - points.push_back({1., 0.}); - points.push_back({1., 2.}); - points.push_back({1. - std::sqrt(3.), 1.}); + points.push_back({1., 0.}); // 0 + points.push_back({0., 1.}); // 1 + points.push_back({2., 1.}); // 2 + points.push_back({3., 2.}); // 3 + points.push_back({0., 3.}); // 4 + points.push_back({3. + std::sqrt(3.), 3.}); // 5 + points.push_back({1., 4.}); // 6 + points.push_back({3., 4.}); // 7 + points.push_back({2., 4. + std::sqrt(3.)}); // 8 + points.push_back({0., 4.}); // 9 + points.push_back({-0.5, 2.}); // 10 // ---------------------------------------------------------------------------- // Init of a Cech complex from points // ---------------------------------------------------------------------------- - // 5. is a magic number to force one blocker, and one non-blocker - Filtration_value max_radius = 12.; + Filtration_value max_radius = 1.; Cech_complex cech_complex_from_points(points, max_radius); Simplex_tree stree; - cech_complex_from_points.create_complex(stree, -1); + cech_complex_from_points.create_complex(stree, 2); // ---------------------------------------------------------------------------- // Display information about the one skeleton Cech complex // ---------------------------------------------------------------------------- diff --git a/src/Cech_complex/example/cech_complex_example_from_points_for_doc.txt b/src/Cech_complex/example/cech_complex_example_from_points_for_doc.txt index 684e120b..be0afc76 100644 --- a/src/Cech_complex/example/cech_complex_example_from_points_for_doc.txt +++ b/src/Cech_complex/example/cech_complex_example_from_points_for_doc.txt @@ -1,16 +1,31 @@ -Cech complex is of dimension 2 - 14 simplices - 7 vertices. Iterator on Cech complex simplices in the filtration order, with [filtration value]: - ( 0 ) -> [0] - ( 1 ) -> [0] - ( 2 ) -> [0] - ( 3 ) -> [0] - ( 4 ) -> [0] - ( 5 ) -> [0] - ( 6 ) -> [0] - ( 3 2 ) -> [5] - ( 5 4 ) -> [5.38516] - ( 2 0 ) -> [5.83095] - ( 1 0 ) -> [6.08276] - ( 3 1 ) -> [6.32456] - ( 2 1 ) -> [6.7082] - ( 3 2 1 ) -> [7.07107] + ( 0 ) -> [0] + ( 1 ) -> [0] + ( 2 ) -> [0] + ( 3 ) -> [0] + ( 4 ) -> [0] + ( 5 ) -> [0] + ( 6 ) -> [0] + ( 7 ) -> [0] + ( 8 ) -> [0] + ( 9 ) -> [0] + ( 10 ) -> [0] + ( 9 4 ) -> [0.5] + ( 9 6 ) -> [0.5] + ( 10 1 ) -> [0.559017] + ( 10 4 ) -> [0.559017] + ( 1 0 ) -> [0.707107] + ( 2 0 ) -> [0.707107] + ( 3 2 ) -> [0.707107] + ( 6 4 ) -> [0.707107] + ( 9 6 4 ) -> [0.707107] + ( 2 1 ) -> [1] + ( 2 1 0 ) -> [1] + ( 4 1 ) -> [1] + ( 5 3 ) -> [1] + ( 7 3 ) -> [1] + ( 7 5 ) -> [1] + ( 7 6 ) -> [1] + ( 8 6 ) -> [1] + ( 8 7 ) -> [1] + ( 10 4 1 ) -> [1] diff --git a/src/Cech_complex/include/gudhi/Cech_complex.h b/src/Cech_complex/include/gudhi/Cech_complex.h index a50ed9fa..612c73c3 100644 --- a/src/Cech_complex/include/gudhi/Cech_complex.h +++ b/src/Cech_complex/include/gudhi/Cech_complex.h @@ -23,7 +23,7 @@ #ifndef CECH_COMPLEX_H_ #define CECH_COMPLEX_H_ -#include // for Gudhi::Squared_radius +#include // for Gudhi::Radius_distance #include // for Gudhi::Proximity_graph #include // for GUDHI_CHECK #include // for Gudhi::cech_complex::Cech_blocker @@ -43,7 +43,7 @@ namespace cech_complex { * * \details * The data structure is a proximity graph, containing edges when the edge length is less or equal - * to a given max_radius. Edge length is computed from `Gudhi::Squared_radius` distance function. + * to a given max_radius. Edge length is computed from `Gudhi::Radius_distance` distance function. * * \tparam SimplicialComplexForProximityGraph furnishes `Vertex_handle` and `Filtration_value` type definition required * by `Gudhi::Proximity_graph`. diff --git a/src/Cech_complex/include/gudhi/Cech_complex_blocker.h b/src/Cech_complex/include/gudhi/Cech_complex_blocker.h index d718b56e..5ba17c51 100644 --- a/src/Cech_complex/include/gudhi/Cech_complex_blocker.h +++ b/src/Cech_complex/include/gudhi/Cech_complex_blocker.h @@ -24,7 +24,7 @@ #define CECH_COMPLEX_BLOCKER_H_ #include // Cech_blocker is using a pointer on Gudhi::cech_complex::Cech_complex -#include // for Gudhi::Squared_radius +#include // for Gudhi::Radius_distance #include #include @@ -75,12 +75,13 @@ class Cech_blocker { std::cout << "#(" << vertex << ")#"; #endif // DEBUG_TRACES } - Filtration_value squared_radius = Gudhi::Radius_distance()(points); + Filtration_value radius = Gudhi::Radius_distance()(points); #ifdef DEBUG_TRACES - std::cout << "squared_radius = " << squared_radius << " - " << (squared_radius > cc_ptr_->max_radius()) << std::endl; + if (radius > cc_ptr_->max_radius()) + std::cout << "radius > max_radius => expansion is blocked\n"; #endif // DEBUG_TRACES - simplicial_complex_.assign_filtration(sh, squared_radius); - return (squared_radius > cc_ptr_->max_radius()); + simplicial_complex_.assign_filtration(sh, radius); + return (radius > cc_ptr_->max_radius()); } /** \internal \brief Cech complex blocker constructor. */ diff --git a/src/Cech_complex/test/test_cech_complex.cpp b/src/Cech_complex/test/test_cech_complex.cpp index 626f1d82..eae8778c 100644 --- a/src/Cech_complex/test/test_cech_complex.cpp +++ b/src/Cech_complex/test/test_cech_complex.cpp @@ -86,7 +86,7 @@ BOOST_AUTO_TEST_CASE(Cech_complex_from_file) { BOOST_CHECK(st.num_vertices() == NUMBER_OF_VERTICES); std::cout << "st.num_simplices()=" << st.num_simplices() << std::endl; - BOOST_CHECK(st.num_simplices() == 18); + BOOST_CHECK(st.num_simplices() == 28); // Check filtration values of vertices is 0.0 for (auto f_simplex : st.skeleton_simplex_range(0)) { @@ -119,7 +119,7 @@ BOOST_AUTO_TEST_CASE(Cech_complex_from_file) { BOOST_CHECK(st2.num_vertices() == NUMBER_OF_VERTICES); std::cout << "st2.num_simplices()=" << st2.num_simplices() << std::endl; - BOOST_CHECK(st2.num_simplices() == 23); + BOOST_CHECK(st2.num_simplices() == 63); Point_cloud points012; for (std::size_t vertex = 0; vertex <= 2; vertex++) { @@ -156,7 +156,7 @@ BOOST_AUTO_TEST_CASE(Cech_complex_from_file) { BOOST_CHECK(st3.num_vertices() == NUMBER_OF_VERTICES); std::cout << "st3.num_simplices()=" << st3.num_simplices() << std::endl; - BOOST_CHECK(st3.num_simplices() == 24); + BOOST_CHECK(st3.num_simplices() == 98); Point_cloud points0123; for (std::size_t vertex = 0; vertex <= 3; vertex++) { @@ -236,13 +236,13 @@ BOOST_AUTO_TEST_CASE(Cech_complex_from_points) { GUDHI_TEST_FLOAT_EQUALITY_CHECK(st.filtration(f_simplex), 0.0); break; case 1: - GUDHI_TEST_FLOAT_EQUALITY_CHECK(st.filtration(f_simplex), 0.5); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(st.filtration(f_simplex), 0.707107, .00001); break; case 2: - GUDHI_TEST_FLOAT_EQUALITY_CHECK(st.filtration(f_simplex), 0.666667, .00001); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(st.filtration(f_simplex), 0.816497, .00001); break; case 3: - GUDHI_TEST_FLOAT_EQUALITY_CHECK(st.filtration(f_simplex), 0.75); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(st.filtration(f_simplex), 0.866025, .00001); break; default: BOOST_CHECK(false); // Shall not happen diff --git a/src/Doxyfile b/src/Doxyfile index f1981e2e..52de65b0 100644 --- a/src/Doxyfile +++ b/src/Doxyfile @@ -843,7 +843,8 @@ EXAMPLE_RECURSIVE = NO IMAGE_PATH = doc/Skeleton_blocker/ \ doc/Alpha_complex/ \ doc/common/ \ - doc/Contraction/ \ + doc/Cech_complex/ \ + doc/Contraction/ \ doc/Simplex_tree/ \ doc/Persistent_cohomology/ \ doc/Witness_complex/ \ diff --git a/src/common/include/gudhi/distance_functions.h b/src/common/include/gudhi/distance_functions.h index 3ce51ad1..7749b98e 100644 --- a/src/common/include/gudhi/distance_functions.h +++ b/src/common/include/gudhi/distance_functions.h @@ -90,11 +90,11 @@ class Radius_distance { operator()(const Point_cloud& point_cloud) const { using Min_sphere = Miniball::Miniball>; - //Min_sphere ms(point_cloud.begin()->end() - point_cloud.begin()->begin(), point_cloud.begin(),point_cloud.end()); - Min_sphere ms(point_cloud.end() - point_cloud.begin(), point_cloud.begin(),point_cloud.end()); + Min_sphere ms(point_cloud.begin()->end() - point_cloud.begin()->begin(), point_cloud.begin(),point_cloud.end()); #ifdef DEBUG_TRACES - std::cout << "Radius on " << point_cloud.end() - point_cloud.begin() << " points = " - << std::sqrt(ms.squared_radius()) << std::endl; + std::cout << "Radius_distance = " << std::sqrt(ms.squared_radius()) << " | nb points = " + << point_cloud.end() - point_cloud.begin() << " | dimension = " + << point_cloud.begin()->end() - point_cloud.begin()->begin() << std::endl; #endif // DEBUG_TRACES return std::sqrt(ms.squared_radius()); -- cgit v1.2.3 From 2a9f6eb628979a9634c647be93e575e3177c15da Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Mon, 5 Mar 2018 15:43:13 +0000 Subject: Fix documentation git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/cechcomplex_vincent@3264 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: af6241dfe42d988b542224b9dae7364f3f22b6fd --- src/Cech_complex/doc/Intro_cech_complex.h | 4 +- .../doc/cech_complex_representation.ipe | 4 +- .../doc/cech_complex_representation.png | Bin 54399 -> 39938 bytes src/Cech_complex/doc/cech_one_skeleton.ipe | 4 +- src/Cech_complex/doc/cech_one_skeleton.png | Bin 29354 -> 24662 bytes src/Cech_complex/test/test_cech_complex.cpp | 124 ++++++++++----------- src/common/doc/main_page.h | 18 ++- 7 files changed, 85 insertions(+), 69 deletions(-) (limited to 'src/common') diff --git a/src/Cech_complex/doc/Intro_cech_complex.h b/src/Cech_complex/doc/Intro_cech_complex.h index 8b6c7851..ec0d35e2 100644 --- a/src/Cech_complex/doc/Intro_cech_complex.h +++ b/src/Cech_complex/doc/Intro_cech_complex.h @@ -67,11 +67,13 @@ namespace cech_complex { * The minimal ball radius computation is insured by * * the miniball software (V3.0) - Smallest Enclosing Balls of Points - and distributed with GUDHI. - * * Please refer to * * the miniball software design description for more information about this computation. * + * This radius computation is the reason why the Cech_complex is taking much more time to be computed than the + * \ref rips_complex but it offers more topological guarantees. + * * If the Cech_complex interfaces are not detailed enough for your need, please refer to * * cech_complex_step_by_step.cpp example, where the graph construction over the Simplex_tree is more detailed. diff --git a/src/Cech_complex/doc/cech_complex_representation.ipe b/src/Cech_complex/doc/cech_complex_representation.ipe index c64d7596..377745a3 100644 --- a/src/Cech_complex/doc/cech_complex_representation.ipe +++ b/src/Cech_complex/doc/cech_complex_representation.ipe @@ -1,7 +1,7 @@ - + @@ -267,7 +267,7 @@ h Maximal radius 7 -8 +8 9 112 576 m diff --git a/src/Cech_complex/doc/cech_complex_representation.png b/src/Cech_complex/doc/cech_complex_representation.png index 4d103a56..d0eb85a5 100644 Binary files a/src/Cech_complex/doc/cech_complex_representation.png and b/src/Cech_complex/doc/cech_complex_representation.png differ diff --git a/src/Cech_complex/doc/cech_one_skeleton.ipe b/src/Cech_complex/doc/cech_one_skeleton.ipe index 345e6d7b..ed66e132 100644 --- a/src/Cech_complex/doc/cech_one_skeleton.ipe +++ b/src/Cech_complex/doc/cech_one_skeleton.ipe @@ -1,7 +1,7 @@ - + @@ -259,7 +259,7 @@ h Maximal radius 7 -8 +8 9 112 576 m diff --git a/src/Cech_complex/doc/cech_one_skeleton.png b/src/Cech_complex/doc/cech_one_skeleton.png index 807e0936..cc636616 100644 Binary files a/src/Cech_complex/doc/cech_one_skeleton.png and b/src/Cech_complex/doc/cech_one_skeleton.png differ diff --git a/src/Cech_complex/test/test_cech_complex.cpp b/src/Cech_complex/test/test_cech_complex.cpp index eae8778c..8cbfe431 100644 --- a/src/Cech_complex/test/test_cech_complex.cpp +++ b/src/Cech_complex/test/test_cech_complex.cpp @@ -42,7 +42,7 @@ // Type definitions using Simplex_tree = Gudhi::Simplex_tree<>; using Filtration_value = Simplex_tree::Filtration_value; -using Point = std::vector; +using Point = std::vector; using Point_cloud = std::vector; using Points_off_reader = Gudhi::Points_off_reader; using Cech_complex = Gudhi::cech_complex::Cech_complex; @@ -51,42 +51,52 @@ using Point_iterator = Point_cloud::const_iterator; using Coordinate_iterator = Point::const_iterator; using Min_sphere = Miniball::Miniball>; -BOOST_AUTO_TEST_CASE(Cech_complex_from_file) { +BOOST_AUTO_TEST_CASE(Cech_complex_for_documentation) { // ---------------------------------------------------------------------------- // - // Init of a Cech complex from a OFF file + // Init of a Cech complex from a point cloud // // ---------------------------------------------------------------------------- - std::string off_file_name("alphacomplexdoc.off"); - double max_radius = 12.0; - std::cout << "========== OFF FILE NAME = " << off_file_name << " - Cech max_radius=" << + Point_cloud points; + points.push_back({1., 0.}); // 0 + points.push_back({0., 1.}); // 1 + points.push_back({2., 1.}); // 2 + points.push_back({3., 2.}); // 3 + points.push_back({0., 3.}); // 4 + points.push_back({3. + std::sqrt(3.), 3.}); // 5 + points.push_back({1., 4.}); // 6 + points.push_back({3., 4.}); // 7 + points.push_back({2., 4. + std::sqrt(3.)}); // 8 + points.push_back({0., 4.}); // 9 + points.push_back({-0.5, 2.}); // 10 + + Filtration_value max_radius = 1.0; + std::cout << "========== NUMBER OF POINTS = " << points.size() << " - Cech max_radius = " << max_radius << "==========" << std::endl; - Points_off_reader off_reader(off_file_name); - Point_cloud point_cloud = off_reader.get_point_cloud(); - Cech_complex cech_complex_from_file(point_cloud, max_radius); + Cech_complex cech_complex_for_doc(points, max_radius); - GUDHI_TEST_FLOAT_EQUALITY_CHECK(cech_complex_from_file.max_radius(), max_radius); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(cech_complex_for_doc.max_radius(), max_radius); std::size_t i = 0; - for (; i < point_cloud.size(); i++) { - BOOST_CHECK(point_cloud[i] == *(cech_complex_from_file.point_iterator(i))); + for (; i < points.size(); i++) { + BOOST_CHECK(points[i] == *(cech_complex_for_doc.point_iterator(i))); } #ifdef GUDHI_DEBUG - BOOST_CHECK_THROW (cech_complex_from_file.point_iterator(i+1), std::out_of_range); + BOOST_CHECK_THROW (cech_complex_for_doc.point_iterator(i+1), std::out_of_range); #endif // GUDHI_DEBUG const int DIMENSION_1 = 1; Simplex_tree st; - cech_complex_from_file.create_complex(st, DIMENSION_1); + cech_complex_for_doc.create_complex(st, DIMENSION_1); std::cout << "st.dimension()=" << st.dimension() << std::endl; BOOST_CHECK(st.dimension() == DIMENSION_1); - const int NUMBER_OF_VERTICES = 7; + const int NUMBER_OF_VERTICES = 11; std::cout << "st.num_vertices()=" << st.num_vertices() << std::endl; BOOST_CHECK(st.num_vertices() == NUMBER_OF_VERTICES); std::cout << "st.num_simplices()=" << st.num_simplices() << std::endl; - BOOST_CHECK(st.num_simplices() == 28); + BOOST_CHECK(st.num_simplices() == 27); // Check filtration values of vertices is 0.0 for (auto f_simplex : st.skeleton_simplex_range(0)) { @@ -100,7 +110,7 @@ BOOST_AUTO_TEST_CASE(Cech_complex_from_file) { std::cout << "vertex = ("; for (auto vertex : st.simplex_vertex_range(f_simplex)) { std::cout << vertex << ","; - vp.push_back(off_reader.get_point_cloud().at(vertex)); + vp.push_back(points.at(vertex)); } std::cout << ") - distance =" << Gudhi::Radius_distance()(vp.at(0), vp.at(1)) << " - filtration =" << st.filtration(f_simplex) << std::endl; @@ -110,8 +120,13 @@ BOOST_AUTO_TEST_CASE(Cech_complex_from_file) { } const int DIMENSION_2 = 2; + +#ifdef GUDHI_DEBUG + BOOST_CHECK_THROW (cech_complex_for_doc.create_complex(st, DIMENSION_2), std::invalid_argument); +#endif + Simplex_tree st2; - cech_complex_from_file.create_complex(st2, DIMENSION_2); + cech_complex_for_doc.create_complex(st2, DIMENSION_2); std::cout << "st2.dimension()=" << st2.dimension() << std::endl; BOOST_CHECK(st2.dimension() == DIMENSION_2); @@ -119,14 +134,14 @@ BOOST_AUTO_TEST_CASE(Cech_complex_from_file) { BOOST_CHECK(st2.num_vertices() == NUMBER_OF_VERTICES); std::cout << "st2.num_simplices()=" << st2.num_simplices() << std::endl; - BOOST_CHECK(st2.num_simplices() == 63); + BOOST_CHECK(st2.num_simplices() == 30); Point_cloud points012; for (std::size_t vertex = 0; vertex <= 2; vertex++) { - points012.push_back(Point(cech_complex_from_file.point_iterator(vertex)->begin(), - cech_complex_from_file.point_iterator(vertex)->end())); + points012.push_back(Point(cech_complex_for_doc.point_iterator(vertex)->begin(), + cech_complex_for_doc.point_iterator(vertex)->end())); } - std::size_t dimension = point_cloud[0].end() - point_cloud[0].begin(); + std::size_t dimension = points[0].end() - points[0].begin(); Min_sphere ms012(dimension, points012.begin(),points012.end()); Simplex_tree::Filtration_value f012 = st2.filtration(st2.find({0, 1, 2})); @@ -134,53 +149,36 @@ BOOST_AUTO_TEST_CASE(Cech_complex_from_file) { GUDHI_TEST_FLOAT_EQUALITY_CHECK(f012, std::sqrt(ms012.squared_radius())); - Point_cloud points456; - for (std::size_t vertex = 4; vertex <= 6; vertex++) { - points456.push_back(Point(cech_complex_from_file.point_iterator(vertex)->begin(), - cech_complex_from_file.point_iterator(vertex)->end())); - } - Min_sphere ms456(dimension, points456.begin(),points456.end()); - - Simplex_tree::Filtration_value f456 = st2.filtration(st2.find({4, 5, 6})); - std::cout << "f456= " << f456 << " | ms456_radius= " << std::sqrt(ms456.squared_radius()) << std::endl; + Point_cloud points1410; + points1410.push_back(Point(cech_complex_for_doc.point_iterator(1)->begin(), + cech_complex_for_doc.point_iterator(1)->end())); + points1410.push_back(Point(cech_complex_for_doc.point_iterator(4)->begin(), + cech_complex_for_doc.point_iterator(4)->end())); + points1410.push_back(Point(cech_complex_for_doc.point_iterator(10)->begin(), + cech_complex_for_doc.point_iterator(10)->end())); + Min_sphere ms1410(dimension, points1410.begin(),points1410.end()); - GUDHI_TEST_FLOAT_EQUALITY_CHECK(f456, std::sqrt(ms456.squared_radius())); + Simplex_tree::Filtration_value f1410 = st2.filtration(st2.find({1, 4, 10})); + std::cout << "f1410= " << f1410 << " | ms1410_radius= " << std::sqrt(ms1410.squared_radius()) << std::endl; - const int DIMENSION_3 = 3; - Simplex_tree st3; - cech_complex_from_file.create_complex(st3, DIMENSION_3); - std::cout << "st3.dimension()=" << st3.dimension() << std::endl; - BOOST_CHECK(st3.dimension() == DIMENSION_3); - - std::cout << "st3.num_vertices()=" << st3.num_vertices() << std::endl; - BOOST_CHECK(st3.num_vertices() == NUMBER_OF_VERTICES); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(f1410, std::sqrt(ms1410.squared_radius())); - std::cout << "st3.num_simplices()=" << st3.num_simplices() << std::endl; - BOOST_CHECK(st3.num_simplices() == 98); - - Point_cloud points0123; - for (std::size_t vertex = 0; vertex <= 3; vertex++) { - points0123.push_back(Point(cech_complex_from_file.point_iterator(vertex)->begin(), - cech_complex_from_file.point_iterator(vertex)->end())); - } - Min_sphere ms0123(dimension, points0123.begin(),points0123.end()); + Point_cloud points469; + points469.push_back(Point(cech_complex_for_doc.point_iterator(4)->begin(), + cech_complex_for_doc.point_iterator(4)->end())); + points469.push_back(Point(cech_complex_for_doc.point_iterator(6)->begin(), + cech_complex_for_doc.point_iterator(6)->end())); + points469.push_back(Point(cech_complex_for_doc.point_iterator(9)->begin(), + cech_complex_for_doc.point_iterator(9)->end())); + Min_sphere ms469(dimension, points469.begin(),points469.end()); - Simplex_tree::Filtration_value f0123 = st3.filtration(st3.find({0, 1, 2, 3})); - std::cout << "f0123= " << f0123 << " | ms0123_radius= " << std::sqrt(ms0123.squared_radius()) << std::endl; + Simplex_tree::Filtration_value f469 = st2.filtration(st2.find({4, 6, 9})); + std::cout << "f469= " << f469 << " | ms469_radius= " << std::sqrt(ms469.squared_radius()) << std::endl; - GUDHI_TEST_FLOAT_EQUALITY_CHECK(f0123, std::sqrt(ms0123.squared_radius())); - - - - Point_cloud points01; - for (std::size_t vertex = 0; vertex <= 1; vertex++) { - points01.push_back(Point(cech_complex_from_file.point_iterator(vertex)->begin(), - cech_complex_from_file.point_iterator(vertex)->end())); - } - Min_sphere ms01(dimension, points01.begin(),points01.end()); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(f469, std::sqrt(ms469.squared_radius())); - Simplex_tree::Filtration_value f01 = st2.filtration(st2.find({0, 1})); - std::cout << "f01= " << f01 << " | ms01_radius= " << std::sqrt(ms01.squared_radius()) << std::endl; + BOOST_CHECK((st2.find({6, 7, 8}) == st2.null_simplex())); + BOOST_CHECK((st2.find({3, 5, 7}) == st2.null_simplex())); } diff --git a/src/common/doc/main_page.h b/src/common/doc/main_page.h index b3e9ea03..3851dde7 100644 --- a/src/common/doc/main_page.h +++ b/src/common/doc/main_page.h @@ -41,6 +41,22 @@ User manual: \ref alpha_complex - Reference manual: Gudhi::alpha_complex::Alpha_complex + + \subsection CechComplexDataStructure Cech complex + \image html "cech_complex_representation.png" "Cech complex representation" + + + + +
+ Author: Vincent Rouvreau
+ Introduced in: GUDHI 2.2.0
+ Copyright: GPL v3
+
+ The Cech complex is a proximity graph that allows to construct a simplicial complex from it. + It guarantees the simplices inserted are inside a ball of a given radius.
+ User manual: \ref cech_complex - Reference manual: Gudhi::cech_complex::Cech_complex +
\subsection CubicalComplexDataStructure Cubical complex \image html "Cubical_complex_representation.png" "Cubical complex representation" @@ -57,6 +73,7 @@ User manual: \ref cubical_complex - Reference manual: Gudhi::cubical_complex::Bitmap_cubical_complex + \subsection RipsComplexDataStructure Rips complex \image html "rips_complex_representation.png" "Rips complex representation" @@ -74,7 +91,6 @@ User manual: \ref rips_complex - Reference manual: Gudhi::rips_complex::Rips_complex -
\subsection SimplexTreeDataStructure Simplex tree \image html "Simplex_tree_representation.png" "Simplex tree representation" -- cgit v1.2.3 From 0d0ca116e7fef77cc950b7e85380495661311d91 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Thu, 22 Mar 2018 08:36:00 +0000 Subject: Move Miniball in gudhi git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/cechcomplex_vincent@3302 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 736e5c33a9593e4dfb5b19ddc745ab9852d71b40 --- src/CMakeLists.txt | 1 - .../benchmark/cech_complex_benchmark.cpp | 5 +- src/Cech_complex/example/CMakeLists.txt | 2 + .../example/cech_complex_step_by_step.cpp | 4 +- .../include/Miniball/Miniball.COPYRIGHT | 4 - src/Cech_complex/include/Miniball/Miniball.README | 23 - src/Cech_complex/include/Miniball/Miniball.hpp | 520 -------------------- src/Cech_complex/include/gudhi/Miniball.COPYRIGHT | 4 + src/Cech_complex/include/gudhi/Miniball.README | 23 + src/Cech_complex/include/gudhi/Miniball.hpp | 523 +++++++++++++++++++++ src/Cech_complex/test/test_cech_complex.cpp | 5 +- src/common/include/gudhi/distance_functions.h | 2 +- 12 files changed, 559 insertions(+), 557 deletions(-) delete mode 100644 src/Cech_complex/include/Miniball/Miniball.COPYRIGHT delete mode 100644 src/Cech_complex/include/Miniball/Miniball.README delete mode 100644 src/Cech_complex/include/Miniball/Miniball.hpp create mode 100644 src/Cech_complex/include/gudhi/Miniball.COPYRIGHT create mode 100644 src/Cech_complex/include/gudhi/Miniball.README create mode 100644 src/Cech_complex/include/gudhi/Miniball.hpp (limited to 'src/common') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ff7acafc..7cccb19f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -105,5 +105,4 @@ install(FILES # install the include file on "make install" install(DIRECTORY include/gudhi DESTINATION include) -install(DIRECTORY include/Miniball DESTINATION include) #--------------------------------------------------------------------------------------- diff --git a/src/Cech_complex/benchmark/cech_complex_benchmark.cpp b/src/Cech_complex/benchmark/cech_complex_benchmark.cpp index 83ef9dca..6ba52419 100644 --- a/src/Cech_complex/benchmark/cech_complex_benchmark.cpp +++ b/src/Cech_complex/benchmark/cech_complex_benchmark.cpp @@ -27,8 +27,7 @@ #include #include #include - -#include +#include #include "boost/filesystem.hpp" // includes all needed Boost.Filesystem declarations @@ -57,7 +56,7 @@ class Radius_distance { using Point_cloud = std::vector; using Point_iterator = typename Point_cloud::const_iterator; using Coordinate_iterator = typename Point::const_iterator; - using Min_sphere = typename Miniball::Miniball>; + using Min_sphere = typename Gudhi::Miniball::Miniball>; Point_cloud point_cloud; point_cloud.push_back(p1); diff --git a/src/Cech_complex/example/CMakeLists.txt b/src/Cech_complex/example/CMakeLists.txt index ac32ff95..ab391215 100644 --- a/src/Cech_complex/example/CMakeLists.txt +++ b/src/Cech_complex/example/CMakeLists.txt @@ -6,6 +6,8 @@ target_link_libraries(Cech_complex_example_step_by_step ${Boost_PROGRAM_OPTIONS_ if (TBB_FOUND) target_link_libraries(Cech_complex_example_step_by_step ${TBB_LIBRARIES}) endif() +add_test(NAME Cech_complex_utility_from_rips_on_tore_3D COMMAND $ + "${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off" "-r" "0.25" "-d" "3") add_executable ( Cech_complex_example_from_points cech_complex_example_from_points.cpp) if (TBB_FOUND) diff --git a/src/Cech_complex/example/cech_complex_step_by_step.cpp b/src/Cech_complex/example/cech_complex_step_by_step.cpp index 8705a3e5..0e7c4bbd 100644 --- a/src/Cech_complex/example/cech_complex_step_by_step.cpp +++ b/src/Cech_complex/example/cech_complex_step_by_step.cpp @@ -25,7 +25,7 @@ #include #include -#include +#include #include @@ -55,7 +55,7 @@ class Cech_blocker { using Point_cloud = std::vector; using Point_iterator = Point_cloud::const_iterator; using Coordinate_iterator = Point::const_iterator; - using Min_sphere = Miniball::Miniball >; + using Min_sphere = Gudhi::Miniball::Miniball >; public: bool operator()(Simplex_handle sh) { std::vector points; diff --git a/src/Cech_complex/include/Miniball/Miniball.COPYRIGHT b/src/Cech_complex/include/Miniball/Miniball.COPYRIGHT deleted file mode 100644 index dbe4c553..00000000 --- a/src/Cech_complex/include/Miniball/Miniball.COPYRIGHT +++ /dev/null @@ -1,4 +0,0 @@ -The miniball software is available under the GNU General Public License (GPLv3 - https://www.gnu.org/copyleft/gpl.html). -If your intended use is not compliant with this license, please buy a commercial license (EUR 500 - https://people.inf.ethz.ch/gaertner/subdir/software/miniball/license.html). -You need a license if the software that you develop using Miniball V3.0 is not open source. - diff --git a/src/Cech_complex/include/Miniball/Miniball.README b/src/Cech_complex/include/Miniball/Miniball.README deleted file mode 100644 index 86a96f08..00000000 --- a/src/Cech_complex/include/Miniball/Miniball.README +++ /dev/null @@ -1,23 +0,0 @@ -https://people.inf.ethz.ch/gaertner/subdir/software/miniball.html - -Smallest Enclosing Balls of Points - Fast and Robust in C++. -(high-quality software for smallest enclosing balls of balls is available in the computational geometry algorithms library CGAL) - - -This is the miniball software (V3.0) for computing smallest enclosing balls of points in arbitrary dimensions. It consists of a C++ header file Miniball.hpp (around 500 lines of code) and two example programs miniball_example.cpp and miniball_example_containers.cpp that demonstrate the usage. The first example stores the coordinates of the input points in a two-dimensional array, the second example uses a list of vectors to show how generic containers can be used. - -Credits: Aditya Gupta and Alexandros Konstantinakis-Karmis have significantly contributed to this version of the software. - -Changes - https://people.inf.ethz.ch/gaertner/subdir/software/miniball/changes.txt - from previous versions. - -The theory - https://people.inf.ethz.ch/gaertner/subdir/texts/own_work/esa99_final.pdf - behind the miniball software (Proc. 7th Annual European Symposium on Algorithms (ESA), Lecture Notes in Computer Science 1643, Springer-Verlag, pp.325-338, 1999). - -Main Features: - - Very fast in low dimensions. 1 million points in 5-space are processed within 0.05 seconds on any recent machine. - - High numerical stability. Almost all input degeneracies (cospherical points, multiple points, points very close together) are routinely handled. - - Easily integrates into your code. You can freely choose the coordinate type of your points and the container to store the points. If you still need to adapt the code, the header is small and readable and contains documentation for all major methods. - - diff --git a/src/Cech_complex/include/Miniball/Miniball.hpp b/src/Cech_complex/include/Miniball/Miniball.hpp deleted file mode 100644 index a42d62a7..00000000 --- a/src/Cech_complex/include/Miniball/Miniball.hpp +++ /dev/null @@ -1,520 +0,0 @@ -// Copright (C) 1999-2013, Bernd Gaertner -// $Rev: 3581 $ -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -// -// Contact: -// -------- -// Bernd Gaertner -// Institute of Theoretical Computer Science -// ETH Zuerich -// CAB G31.1 -// CH-8092 Zuerich, Switzerland -// http://www.inf.ethz.ch/personal/gaertner - -#ifndef MINIBALL_HPP_ -#define MINIBALL_HPP_ - -#include -#include -#include -#include -#include - -namespace Miniball { - - // Global Functions - // ================ - template - inline NT mb_sqr (NT r) {return r*r;} - - // Functors - // ======== - - // functor to map a point iterator to the corresponding coordinate iterator; - // generic version for points whose coordinate containers have begin() - template < typename Pit_, typename Cit_ > - struct CoordAccessor { - typedef Pit_ Pit; - typedef Cit_ Cit; - inline Cit operator() (Pit it) const { return (*it).begin(); } - }; - - // partial specialization for points whose coordinate containers are arrays - template < typename Pit_, typename Cit_ > - struct CoordAccessor { - typedef Pit_ Pit; - typedef Cit_* Cit; - inline Cit operator() (Pit it) const { return *it; } - }; - - // Class Declaration - // ================= - - template - class Miniball { - private: - // types - // The iterator type to go through the input points - typedef typename CoordAccessor::Pit Pit; - // The iterator type to go through the coordinates of a single point. - typedef typename CoordAccessor::Cit Cit; - // The coordinate type - typedef typename std::iterator_traits::value_type NT; - // The iterator to go through the support points - typedef typename std::list::iterator Sit; - - // data members... - const int d; // dimension - Pit points_begin; - Pit points_end; - CoordAccessor coord_accessor; - double time; - const NT nt0; // NT(0) - - //...for the algorithms - std::list L; - Sit support_end; - int fsize; // number of forced points - int ssize; // number of support points - - // ...for the ball updates - NT* current_c; - NT current_sqr_r; - NT** c; - NT* sqr_r; - - // helper arrays - NT* q0; - NT* z; - NT* f; - NT** v; - NT** a; - - public: - // The iterator type to go through the support points - typedef typename std::list::const_iterator SupportPointIterator; - - // PRE: [begin, end) is a nonempty range - // POST: computes the smallest enclosing ball of the points in the range - // [begin, end); the functor a maps a point iterator to an iterator - // through the d coordinates of the point - Miniball (int d_, Pit begin, Pit end, CoordAccessor ca = CoordAccessor()); - - // POST: returns a pointer to the first element of an array that holds - // the d coordinates of the center of the computed ball - const NT* center () const; - - // POST: returns the squared radius of the computed ball - NT squared_radius () const; - - // POST: returns the number of support points of the computed ball; - // the support points form a minimal set with the same smallest - // enclosing ball as the input set; in particular, the support - // points are on the boundary of the computed ball, and their - // number is at most d+1 - int nr_support_points () const; - - // POST: returns an iterator to the first support point - SupportPointIterator support_points_begin () const; - - // POST: returns a past-the-end iterator for the range of support points - SupportPointIterator support_points_end () const; - - // POST: returns the maximum excess of any input point w.r.t. the computed - // ball, divided by the squared radius of the computed ball. The - // excess of a point is the difference between its squared distance - // from the center and the squared radius; Ideally, the return value - // is 0. subopt is set to the absolute value of the most negative - // coefficient in the affine combination of the support points that - // yields the center. Ideally, this is a convex combination, and there - // is no negative coefficient in which case subopt is set to 0. - NT relative_error (NT& subopt) const; - - // POST: return true if the relative error is at most tol, and the - // suboptimality is 0; the default tolerance is 10 times the - // coordinate type's machine epsilon - bool is_valid (NT tol = NT(10) * std::numeric_limits::epsilon()) const; - - // POST: returns the time in seconds taken by the constructor call for - // computing the smallest enclosing ball - double get_time() const; - - // POST: deletes dynamically allocated arrays - ~Miniball(); - - private: - void mtf_mb (Sit n); - void mtf_move_to_front (Sit j); - void pivot_mb (Pit n); - void pivot_move_to_front (Pit j); - NT excess (Pit pit) const; - void pop (); - bool push (Pit pit); - NT suboptimality () const; - void create_arrays(); - void delete_arrays(); - }; - - // Class Definition - // ================ - template - Miniball::Miniball (int d_, Pit begin, Pit end, - CoordAccessor ca) - : d (d_), - points_begin (begin), - points_end (end), - coord_accessor (ca), - time (clock()), - nt0 (NT(0)), - L(), - support_end (L.begin()), - fsize(0), - ssize(0), - current_c (NULL), - current_sqr_r (NT(-1)), - c (NULL), - sqr_r (NULL), - q0 (NULL), - z (NULL), - f (NULL), - v (NULL), - a (NULL) - { - assert (points_begin != points_end); - create_arrays(); - - // set initial center - for (int j=0; j - Miniball::~Miniball() - { - delete_arrays(); - } - - template - void Miniball::create_arrays() - { - c = new NT*[d+1]; - v = new NT*[d+1]; - a = new NT*[d+1]; - for (int i=0; i - void Miniball::delete_arrays() - { - delete[] f; - delete[] z; - delete[] q0; - delete[] sqr_r; - for (int i=0; i - const typename Miniball::NT* - Miniball::center () const - { - return current_c; - } - - template - typename Miniball::NT - Miniball::squared_radius () const - { - return current_sqr_r; - } - - template - int Miniball::nr_support_points () const - { - assert (ssize < d+2); - return ssize; - } - - template - typename Miniball::SupportPointIterator - Miniball::support_points_begin () const - { - return L.begin(); - } - - template - typename Miniball::SupportPointIterator - Miniball::support_points_end () const - { - return support_end; - } - - template - typename Miniball::NT - Miniball::relative_error (NT& subopt) const - { - NT e, max_e = nt0; - // compute maximum absolute excess of support points - for (SupportPointIterator it = support_points_begin(); - it != support_points_end(); ++it) { - e = excess (*it); - if (e < nt0) e = -e; - if (e > max_e) { - max_e = e; - } - } - // compute maximum excess of any point - for (Pit i = points_begin; i != points_end; ++i) - if ((e = excess (i)) > max_e) - max_e = e; - - subopt = suboptimality(); - assert (current_sqr_r > nt0 || max_e == nt0); - return (current_sqr_r == nt0 ? nt0 : max_e / current_sqr_r); - } - - template - bool Miniball::is_valid (NT tol) const - { - NT suboptimality; - return ( (relative_error (suboptimality) <= tol) && (suboptimality == 0) ); - } - - template - double Miniball::get_time() const - { - return time; - } - - template - void Miniball::mtf_mb (Sit n) - { - // Algorithm 1: mtf_mb (L_{n-1}, B), where L_{n-1} = [L.begin, n) - // B: the set of forced points, defining the current ball - // S: the superset of support points computed by the algorithm - // -------------------------------------------------------------- - // from B. Gaertner, Fast and Robust Smallest Enclosing Balls, ESA 1999, - // http://www.inf.ethz.ch/personal/gaertner/texts/own_work/esa99_final.pdf - - // PRE: B = S - assert (fsize == ssize); - - support_end = L.begin(); - if ((fsize) == d+1) return; - - // incremental construction - for (Sit i = L.begin(); i != n;) - { - // INV: (support_end - L.begin() == |S|-|B|) - assert (std::distance (L.begin(), support_end) == ssize - fsize); - - Sit j = i++; - if (excess(*j) > nt0) - if (push(*j)) { // B := B + p_i - mtf_mb (j); // mtf_mb (L_{i-1}, B + p_i) - pop(); // B := B - p_i - mtf_move_to_front(j); - } - } - // POST: the range [L.begin(), support_end) stores the set S\B - } - - template - void Miniball::mtf_move_to_front (Sit j) - { - if (support_end == j) - support_end++; - L.splice (L.begin(), L, j); - } - - template - void Miniball::pivot_mb (Pit n) - { - // Algorithm 2: pivot_mb (L_{n-1}), where L_{n-1} = [L.begin, n) - // -------------------------------------------------------------- - // from B. Gaertner, Fast and Robust Smallest Enclosing Balls, ESA 1999, - // http://www.inf.ethz.ch/personal/gaertner/texts/own_work/esa99_final.pdf - NT old_sqr_r; - const NT* c; - Pit pivot, k; - NT e, max_e, sqr_r; - Cit p; - do { - old_sqr_r = current_sqr_r; - sqr_r = current_sqr_r; - - pivot = points_begin; - max_e = nt0; - for (k = points_begin; k != n; ++k) { - p = coord_accessor(k); - e = -sqr_r; - c = current_c; - for (int j=0; j(*p++-*c++); - if (e > max_e) { - max_e = e; - pivot = k; - } - } - - if (max_e > nt0) { - // check if the pivot is already contained in the support set - if (std::find(L.begin(), support_end, pivot) == support_end) { - assert (fsize == 0); - if (push (pivot)) { - mtf_mb(support_end); - pop(); - pivot_move_to_front(pivot); - } - } - } - } while (old_sqr_r < current_sqr_r); - } - - template - void Miniball::pivot_move_to_front (Pit j) - { - L.push_front(j); - if (std::distance(L.begin(), support_end) == d+2) - support_end--; - } - - template - inline typename Miniball::NT - Miniball::excess (Pit pit) const - { - Cit p = coord_accessor(pit); - NT e = -current_sqr_r; - NT* c = current_c; - for (int k=0; k(*p++-*c++); - } - return e; - } - - template - void Miniball::pop () - { - --fsize; - } - - template - bool Miniball::push (Pit pit) - { - int i, j; - NT eps = mb_sqr(std::numeric_limits::epsilon()); - - Cit cit = coord_accessor(pit); - Cit p = cit; - - if (fsize==0) { - for (i=0; i(v[fsize][j]); - z[fsize]*=2; - - // reject push if z_fsize too small - if (z[fsize](*p++-c[fsize-1][i]); - f[fsize]=e/z[fsize]; - - for (i=0; i - typename Miniball::NT - Miniball::suboptimality () const - { - NT* l = new NT[d+1]; - NT min_l = nt0; - l[0] = NT(1); - for (int i=ssize-1; i>0; --i) { - l[i] = f[i]; - for (int k=ssize-1; k>i; --k) - l[i]-=a[k][i]*l[k]; - if (l[i] < min_l) min_l = l[i]; - l[0] -= l[i]; - } - if (l[0] < min_l) min_l = l[0]; - delete[] l; - if (min_l < nt0) - return -min_l; - return nt0; - } - -} // end Namespace Miniball - -#endif // MINIBALL_HPP_ diff --git a/src/Cech_complex/include/gudhi/Miniball.COPYRIGHT b/src/Cech_complex/include/gudhi/Miniball.COPYRIGHT new file mode 100644 index 00000000..dbe4c553 --- /dev/null +++ b/src/Cech_complex/include/gudhi/Miniball.COPYRIGHT @@ -0,0 +1,4 @@ +The miniball software is available under the GNU General Public License (GPLv3 - https://www.gnu.org/copyleft/gpl.html). +If your intended use is not compliant with this license, please buy a commercial license (EUR 500 - https://people.inf.ethz.ch/gaertner/subdir/software/miniball/license.html). +You need a license if the software that you develop using Miniball V3.0 is not open source. + diff --git a/src/Cech_complex/include/gudhi/Miniball.README b/src/Cech_complex/include/gudhi/Miniball.README new file mode 100644 index 00000000..86a96f08 --- /dev/null +++ b/src/Cech_complex/include/gudhi/Miniball.README @@ -0,0 +1,23 @@ +https://people.inf.ethz.ch/gaertner/subdir/software/miniball.html + +Smallest Enclosing Balls of Points - Fast and Robust in C++. +(high-quality software for smallest enclosing balls of balls is available in the computational geometry algorithms library CGAL) + + +This is the miniball software (V3.0) for computing smallest enclosing balls of points in arbitrary dimensions. It consists of a C++ header file Miniball.hpp (around 500 lines of code) and two example programs miniball_example.cpp and miniball_example_containers.cpp that demonstrate the usage. The first example stores the coordinates of the input points in a two-dimensional array, the second example uses a list of vectors to show how generic containers can be used. + +Credits: Aditya Gupta and Alexandros Konstantinakis-Karmis have significantly contributed to this version of the software. + +Changes - https://people.inf.ethz.ch/gaertner/subdir/software/miniball/changes.txt - from previous versions. + +The theory - https://people.inf.ethz.ch/gaertner/subdir/texts/own_work/esa99_final.pdf - behind the miniball software (Proc. 7th Annual European Symposium on Algorithms (ESA), Lecture Notes in Computer Science 1643, Springer-Verlag, pp.325-338, 1999). + +Main Features: + + Very fast in low dimensions. 1 million points in 5-space are processed within 0.05 seconds on any recent machine. + + High numerical stability. Almost all input degeneracies (cospherical points, multiple points, points very close together) are routinely handled. + + Easily integrates into your code. You can freely choose the coordinate type of your points and the container to store the points. If you still need to adapt the code, the header is small and readable and contains documentation for all major methods. + + diff --git a/src/Cech_complex/include/gudhi/Miniball.hpp b/src/Cech_complex/include/gudhi/Miniball.hpp new file mode 100644 index 00000000..ce6cbb5b --- /dev/null +++ b/src/Cech_complex/include/gudhi/Miniball.hpp @@ -0,0 +1,523 @@ +// Copright (C) 1999-2013, Bernd Gaertner +// $Rev: 3581 $ +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// Contact: +// -------- +// Bernd Gaertner +// Institute of Theoretical Computer Science +// ETH Zuerich +// CAB G31.1 +// CH-8092 Zuerich, Switzerland +// http://www.inf.ethz.ch/personal/gaertner + +#ifndef MINIBALL_HPP_ +#define MINIBALL_HPP_ + +#include +#include +#include +#include +#include + +namespace Gudhi { + +namespace Miniball { + + // Global Functions + // ================ + template + inline NT mb_sqr (NT r) {return r*r;} + + // Functors + // ======== + + // functor to map a point iterator to the corresponding coordinate iterator; + // generic version for points whose coordinate containers have begin() + template < typename Pit_, typename Cit_ > + struct CoordAccessor { + typedef Pit_ Pit; + typedef Cit_ Cit; + inline Cit operator() (Pit it) const { return (*it).begin(); } + }; + + // partial specialization for points whose coordinate containers are arrays + template < typename Pit_, typename Cit_ > + struct CoordAccessor { + typedef Pit_ Pit; + typedef Cit_* Cit; + inline Cit operator() (Pit it) const { return *it; } + }; + + // Class Declaration + // ================= + + template + class Miniball { + private: + // types + // The iterator type to go through the input points + typedef typename CoordAccessor::Pit Pit; + // The iterator type to go through the coordinates of a single point. + typedef typename CoordAccessor::Cit Cit; + // The coordinate type + typedef typename std::iterator_traits::value_type NT; + // The iterator to go through the support points + typedef typename std::list::iterator Sit; + + // data members... + const int d; // dimension + Pit points_begin; + Pit points_end; + CoordAccessor coord_accessor; + double time; + const NT nt0; // NT(0) + + //...for the algorithms + std::list L; + Sit support_end; + int fsize; // number of forced points + int ssize; // number of support points + + // ...for the ball updates + NT* current_c; + NT current_sqr_r; + NT** c; + NT* sqr_r; + + // helper arrays + NT* q0; + NT* z; + NT* f; + NT** v; + NT** a; + + public: + // The iterator type to go through the support points + typedef typename std::list::const_iterator SupportPointIterator; + + // PRE: [begin, end) is a nonempty range + // POST: computes the smallest enclosing ball of the points in the range + // [begin, end); the functor a maps a point iterator to an iterator + // through the d coordinates of the point + Miniball (int d_, Pit begin, Pit end, CoordAccessor ca = CoordAccessor()); + + // POST: returns a pointer to the first element of an array that holds + // the d coordinates of the center of the computed ball + const NT* center () const; + + // POST: returns the squared radius of the computed ball + NT squared_radius () const; + + // POST: returns the number of support points of the computed ball; + // the support points form a minimal set with the same smallest + // enclosing ball as the input set; in particular, the support + // points are on the boundary of the computed ball, and their + // number is at most d+1 + int nr_support_points () const; + + // POST: returns an iterator to the first support point + SupportPointIterator support_points_begin () const; + + // POST: returns a past-the-end iterator for the range of support points + SupportPointIterator support_points_end () const; + + // POST: returns the maximum excess of any input point w.r.t. the computed + // ball, divided by the squared radius of the computed ball. The + // excess of a point is the difference between its squared distance + // from the center and the squared radius; Ideally, the return value + // is 0. subopt is set to the absolute value of the most negative + // coefficient in the affine combination of the support points that + // yields the center. Ideally, this is a convex combination, and there + // is no negative coefficient in which case subopt is set to 0. + NT relative_error (NT& subopt) const; + + // POST: return true if the relative error is at most tol, and the + // suboptimality is 0; the default tolerance is 10 times the + // coordinate type's machine epsilon + bool is_valid (NT tol = NT(10) * std::numeric_limits::epsilon()) const; + + // POST: returns the time in seconds taken by the constructor call for + // computing the smallest enclosing ball + double get_time() const; + + // POST: deletes dynamically allocated arrays + ~Miniball(); + + private: + void mtf_mb (Sit n); + void mtf_move_to_front (Sit j); + void pivot_mb (Pit n); + void pivot_move_to_front (Pit j); + NT excess (Pit pit) const; + void pop (); + bool push (Pit pit); + NT suboptimality () const; + void create_arrays(); + void delete_arrays(); + }; + + // Class Definition + // ================ + template + Miniball::Miniball (int d_, Pit begin, Pit end, + CoordAccessor ca) + : d (d_), + points_begin (begin), + points_end (end), + coord_accessor (ca), + time (clock()), + nt0 (NT(0)), + L(), + support_end (L.begin()), + fsize(0), + ssize(0), + current_c (NULL), + current_sqr_r (NT(-1)), + c (NULL), + sqr_r (NULL), + q0 (NULL), + z (NULL), + f (NULL), + v (NULL), + a (NULL) + { + assert (points_begin != points_end); + create_arrays(); + + // set initial center + for (int j=0; j + Miniball::~Miniball() + { + delete_arrays(); + } + + template + void Miniball::create_arrays() + { + c = new NT*[d+1]; + v = new NT*[d+1]; + a = new NT*[d+1]; + for (int i=0; i + void Miniball::delete_arrays() + { + delete[] f; + delete[] z; + delete[] q0; + delete[] sqr_r; + for (int i=0; i + const typename Miniball::NT* + Miniball::center () const + { + return current_c; + } + + template + typename Miniball::NT + Miniball::squared_radius () const + { + return current_sqr_r; + } + + template + int Miniball::nr_support_points () const + { + assert (ssize < d+2); + return ssize; + } + + template + typename Miniball::SupportPointIterator + Miniball::support_points_begin () const + { + return L.begin(); + } + + template + typename Miniball::SupportPointIterator + Miniball::support_points_end () const + { + return support_end; + } + + template + typename Miniball::NT + Miniball::relative_error (NT& subopt) const + { + NT e, max_e = nt0; + // compute maximum absolute excess of support points + for (SupportPointIterator it = support_points_begin(); + it != support_points_end(); ++it) { + e = excess (*it); + if (e < nt0) e = -e; + if (e > max_e) { + max_e = e; + } + } + // compute maximum excess of any point + for (Pit i = points_begin; i != points_end; ++i) + if ((e = excess (i)) > max_e) + max_e = e; + + subopt = suboptimality(); + assert (current_sqr_r > nt0 || max_e == nt0); + return (current_sqr_r == nt0 ? nt0 : max_e / current_sqr_r); + } + + template + bool Miniball::is_valid (NT tol) const + { + NT suboptimality; + return ( (relative_error (suboptimality) <= tol) && (suboptimality == 0) ); + } + + template + double Miniball::get_time() const + { + return time; + } + + template + void Miniball::mtf_mb (Sit n) + { + // Algorithm 1: mtf_mb (L_{n-1}, B), where L_{n-1} = [L.begin, n) + // B: the set of forced points, defining the current ball + // S: the superset of support points computed by the algorithm + // -------------------------------------------------------------- + // from B. Gaertner, Fast and Robust Smallest Enclosing Balls, ESA 1999, + // http://www.inf.ethz.ch/personal/gaertner/texts/own_work/esa99_final.pdf + + // PRE: B = S + assert (fsize == ssize); + + support_end = L.begin(); + if ((fsize) == d+1) return; + + // incremental construction + for (Sit i = L.begin(); i != n;) + { + // INV: (support_end - L.begin() == |S|-|B|) + assert (std::distance (L.begin(), support_end) == ssize - fsize); + + Sit j = i++; + if (excess(*j) > nt0) + if (push(*j)) { // B := B + p_i + mtf_mb (j); // mtf_mb (L_{i-1}, B + p_i) + pop(); // B := B - p_i + mtf_move_to_front(j); + } + } + // POST: the range [L.begin(), support_end) stores the set S\B + } + + template + void Miniball::mtf_move_to_front (Sit j) + { + if (support_end == j) + support_end++; + L.splice (L.begin(), L, j); + } + + template + void Miniball::pivot_mb (Pit n) + { + // Algorithm 2: pivot_mb (L_{n-1}), where L_{n-1} = [L.begin, n) + // -------------------------------------------------------------- + // from B. Gaertner, Fast and Robust Smallest Enclosing Balls, ESA 1999, + // http://www.inf.ethz.ch/personal/gaertner/texts/own_work/esa99_final.pdf + NT old_sqr_r; + const NT* c; + Pit pivot, k; + NT e, max_e, sqr_r; + Cit p; + do { + old_sqr_r = current_sqr_r; + sqr_r = current_sqr_r; + + pivot = points_begin; + max_e = nt0; + for (k = points_begin; k != n; ++k) { + p = coord_accessor(k); + e = -sqr_r; + c = current_c; + for (int j=0; j(*p++-*c++); + if (e > max_e) { + max_e = e; + pivot = k; + } + } + + if (max_e > nt0) { + // check if the pivot is already contained in the support set + if (std::find(L.begin(), support_end, pivot) == support_end) { + assert (fsize == 0); + if (push (pivot)) { + mtf_mb(support_end); + pop(); + pivot_move_to_front(pivot); + } + } + } + } while (old_sqr_r < current_sqr_r); + } + + template + void Miniball::pivot_move_to_front (Pit j) + { + L.push_front(j); + if (std::distance(L.begin(), support_end) == d+2) + support_end--; + } + + template + inline typename Miniball::NT + Miniball::excess (Pit pit) const + { + Cit p = coord_accessor(pit); + NT e = -current_sqr_r; + NT* c = current_c; + for (int k=0; k(*p++-*c++); + } + return e; + } + + template + void Miniball::pop () + { + --fsize; + } + + template + bool Miniball::push (Pit pit) + { + int i, j; + NT eps = mb_sqr(std::numeric_limits::epsilon()); + + Cit cit = coord_accessor(pit); + Cit p = cit; + + if (fsize==0) { + for (i=0; i(v[fsize][j]); + z[fsize]*=2; + + // reject push if z_fsize too small + if (z[fsize](*p++-c[fsize-1][i]); + f[fsize]=e/z[fsize]; + + for (i=0; i + typename Miniball::NT + Miniball::suboptimality () const + { + NT* l = new NT[d+1]; + NT min_l = nt0; + l[0] = NT(1); + for (int i=ssize-1; i>0; --i) { + l[i] = f[i]; + for (int k=ssize-1; k>i; --k) + l[i]-=a[k][i]*l[k]; + if (l[i] < min_l) min_l = l[i]; + l[0] -= l[i]; + } + if (l[0] < min_l) min_l = l[0]; + delete[] l; + if (min_l < nt0) + return -min_l; + return nt0; + } +} // namespace Miniball + +} // namespace Gudhi + +#endif // MINIBALL_HPP_ diff --git a/src/Cech_complex/test/test_cech_complex.cpp b/src/Cech_complex/test/test_cech_complex.cpp index 8cbfe431..4aa85057 100644 --- a/src/Cech_complex/test/test_cech_complex.cpp +++ b/src/Cech_complex/test/test_cech_complex.cpp @@ -36,8 +36,7 @@ #include #include #include - -#include +#include // Type definitions using Simplex_tree = Gudhi::Simplex_tree<>; @@ -49,7 +48,7 @@ using Cech_complex = Gudhi::cech_complex::Cech_complex>; +using Min_sphere = Gudhi::Miniball::Miniball>; BOOST_AUTO_TEST_CASE(Cech_complex_for_documentation) { // ---------------------------------------------------------------------------- diff --git a/src/common/include/gudhi/distance_functions.h b/src/common/include/gudhi/distance_functions.h index 7749b98e..93956a69 100644 --- a/src/common/include/gudhi/distance_functions.h +++ b/src/common/include/gudhi/distance_functions.h @@ -25,7 +25,7 @@ #include -#include +#include #include -- cgit v1.2.3 From 1f3716292673a56413d3501b4b98b54416d193ed Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Thu, 22 Mar 2018 10:10:08 +0000 Subject: code review : Rename Radius_distance Minimal_enclosing_ball_radius git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/cechcomplex_vincent@3304 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 204aa7a7098773b2d290e35a12a1c92449743d7d --- .../benchmark/cech_complex_benchmark.cpp | 32 ++++++++++++---------- .../example/cech_complex_step_by_step.cpp | 4 +-- src/Cech_complex/include/gudhi/Cech_complex.h | 11 ++++---- .../include/gudhi/Cech_complex_blocker.h | 4 +-- src/Cech_complex/test/test_cech_complex.cpp | 4 +-- src/common/include/gudhi/distance_functions.h | 8 +++--- 6 files changed, 34 insertions(+), 29 deletions(-) (limited to 'src/common') diff --git a/src/Cech_complex/benchmark/cech_complex_benchmark.cpp b/src/Cech_complex/benchmark/cech_complex_benchmark.cpp index 6ba52419..2fa255ed 100644 --- a/src/Cech_complex/benchmark/cech_complex_benchmark.cpp +++ b/src/Cech_complex/benchmark/cech_complex_benchmark.cpp @@ -46,7 +46,7 @@ using Rips_complex = Gudhi::rips_complex::Rips_complex; using Cech_complex = Gudhi::cech_complex::Cech_complex; -class Radius_distance { +class Minimal_enclosing_ball_radius { public: // boost::range_value is not SFINAE-friendly so we cannot use it in the return type template< typename Point > @@ -80,24 +80,26 @@ int main(int argc, char * argv[]) { Gudhi::Clock euclidean_clock("Gudhi::Euclidean_distance"); // Compute the proximity graph of the points Proximity_graph euclidean_prox_graph = Gudhi::compute_proximity_graph(off_reader.get_point_cloud(), - threshold, - Gudhi::Euclidean_distance()); + threshold, + Gudhi::Euclidean_distance()); std::cout << euclidean_clock << std::endl; - Gudhi::Clock radius_clock("Radius_distance"); + Gudhi::Clock miniball_clock("Minimal_enclosing_ball_radius"); // Compute the proximity graph of the points - Proximity_graph radius_prox_graph = Gudhi::compute_proximity_graph(off_reader.get_point_cloud(), - threshold, - Radius_distance()); - std::cout << radius_clock << std::endl; + Proximity_graph miniball_prox_graph = + Gudhi::compute_proximity_graph(off_reader.get_point_cloud(), + threshold, + Minimal_enclosing_ball_radius()); + std::cout << miniball_clock << std::endl; - Gudhi::Clock common_radius_clock("Gudhi::Radius_distance()"); + Gudhi::Clock common_miniball_clock("Gudhi::Minimal_enclosing_ball_radius()"); // Compute the proximity graph of the points - Proximity_graph sq_radius_prox_graph = Gudhi::compute_proximity_graph(off_reader.get_point_cloud(), - threshold, - Gudhi::Radius_distance()); - std::cout << common_radius_clock << std::endl; + Proximity_graph common_miniball_prox_graph = + Gudhi::compute_proximity_graph(off_reader.get_point_cloud(), + threshold, + Gudhi::Minimal_enclosing_ball_radius()); + std::cout << common_miniball_clock << std::endl; boost::filesystem::path full_path(boost::filesystem::current_path()); @@ -121,7 +123,9 @@ int main(int argc, char * argv[]) { std::cout << itr->path().stem() << ";"; std::cout << radius << ";"; Gudhi::Clock rips_clock("Rips computation"); - Rips_complex rips_complex_from_points(off_reader.get_point_cloud(), radius, Gudhi::Radius_distance()); + Rips_complex rips_complex_from_points(off_reader.get_point_cloud(), + radius, + Gudhi::Minimal_enclosing_ball_radius()); Simplex_tree rips_stree; rips_complex_from_points.create_complex(rips_stree, p0.size() - 1); // ------------------------------------------ diff --git a/src/Cech_complex/example/cech_complex_step_by_step.cpp b/src/Cech_complex/example/cech_complex_step_by_step.cpp index 0e7c4bbd..760b53dc 100644 --- a/src/Cech_complex/example/cech_complex_step_by_step.cpp +++ b/src/Cech_complex/example/cech_complex_step_by_step.cpp @@ -65,7 +65,7 @@ class Cech_blocker { std::cout << "#(" << vertex << ")#"; #endif // DEBUG_TRACES } - Filtration_value radius = Gudhi::Radius_distance()(points); + Filtration_value radius = Gudhi::Minimal_enclosing_ball_radius()(points); #ifdef DEBUG_TRACES std::cout << "radius = " << radius << " - " << (radius > max_radius_) << std::endl; #endif // DEBUG_TRACES @@ -105,7 +105,7 @@ int main(int argc, char * argv[]) { // Compute the proximity graph of the points Proximity_graph prox_graph = Gudhi::compute_proximity_graph(off_reader.get_point_cloud(), max_radius, - Gudhi::Radius_distance()); + Gudhi::Minimal_enclosing_ball_radius()); // Construct the Rips complex in a Simplex Tree Simplex_tree st; diff --git a/src/Cech_complex/include/gudhi/Cech_complex.h b/src/Cech_complex/include/gudhi/Cech_complex.h index 612c73c3..8b1a9221 100644 --- a/src/Cech_complex/include/gudhi/Cech_complex.h +++ b/src/Cech_complex/include/gudhi/Cech_complex.h @@ -23,7 +23,7 @@ #ifndef CECH_COMPLEX_H_ #define CECH_COMPLEX_H_ -#include // for Gudhi::Radius_distance +#include // for Gudhi::Minimal_enclosing_ball_radius #include // for Gudhi::Proximity_graph #include // for GUDHI_CHECK #include // for Gudhi::cech_complex::Cech_blocker @@ -43,7 +43,7 @@ namespace cech_complex { * * \details * The data structure is a proximity graph, containing edges when the edge length is less or equal - * to a given max_radius. Edge length is computed from `Gudhi::Radius_distance` distance function. + * to a given max_radius. Edge length is computed from `Gudhi::Minimal_enclosing_ball_radius` distance function. * * \tparam SimplicialComplexForProximityGraph furnishes `Vertex_handle` and `Filtration_value` type definition required * by `Gudhi::Proximity_graph`. @@ -71,9 +71,10 @@ class Cech_complex { Cech_complex(const ForwardPointRange& points, Filtration_value max_radius) : max_radius_(max_radius), point_cloud_(points) { - cech_skeleton_graph_ = Gudhi::compute_proximity_graph(point_cloud_, - max_radius_, - Gudhi::Radius_distance()); + cech_skeleton_graph_ = + Gudhi::compute_proximity_graph(point_cloud_, + max_radius_, + Gudhi::Minimal_enclosing_ball_radius()); } /** \brief Initializes the simplicial complex from the proximity graph and expands it until a given maximal diff --git a/src/Cech_complex/include/gudhi/Cech_complex_blocker.h b/src/Cech_complex/include/gudhi/Cech_complex_blocker.h index 5ba17c51..c082815d 100644 --- a/src/Cech_complex/include/gudhi/Cech_complex_blocker.h +++ b/src/Cech_complex/include/gudhi/Cech_complex_blocker.h @@ -24,7 +24,7 @@ #define CECH_COMPLEX_BLOCKER_H_ #include // Cech_blocker is using a pointer on Gudhi::cech_complex::Cech_complex -#include // for Gudhi::Radius_distance +#include // for Gudhi::Minimal_enclosing_ball_radius #include #include @@ -75,7 +75,7 @@ class Cech_blocker { std::cout << "#(" << vertex << ")#"; #endif // DEBUG_TRACES } - Filtration_value radius = Gudhi::Radius_distance()(points); + Filtration_value radius = Gudhi::Minimal_enclosing_ball_radius()(points); #ifdef DEBUG_TRACES if (radius > cc_ptr_->max_radius()) std::cout << "radius > max_radius => expansion is blocked\n"; diff --git a/src/Cech_complex/test/test_cech_complex.cpp b/src/Cech_complex/test/test_cech_complex.cpp index 4aa85057..8658729b 100644 --- a/src/Cech_complex/test/test_cech_complex.cpp +++ b/src/Cech_complex/test/test_cech_complex.cpp @@ -111,10 +111,10 @@ BOOST_AUTO_TEST_CASE(Cech_complex_for_documentation) { std::cout << vertex << ","; vp.push_back(points.at(vertex)); } - std::cout << ") - distance =" << Gudhi::Radius_distance()(vp.at(0), vp.at(1)) << + std::cout << ") - distance =" << Gudhi::Minimal_enclosing_ball_radius()(vp.at(0), vp.at(1)) << " - filtration =" << st.filtration(f_simplex) << std::endl; BOOST_CHECK(vp.size() == 2); - GUDHI_TEST_FLOAT_EQUALITY_CHECK(st.filtration(f_simplex), Gudhi::Radius_distance()(vp.at(0), vp.at(1))); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(st.filtration(f_simplex), Gudhi::Minimal_enclosing_ball_radius()(vp.at(0), vp.at(1))); } } diff --git a/src/common/include/gudhi/distance_functions.h b/src/common/include/gudhi/distance_functions.h index 93956a69..429a5fa7 100644 --- a/src/common/include/gudhi/distance_functions.h +++ b/src/common/include/gudhi/distance_functions.h @@ -70,9 +70,9 @@ class Euclidean_distance { } }; -/** @brief Compute the squared radius between Points given by a range of coordinates. The points are assumed to - * have the same dimension. */ -class Radius_distance { +/** @brief Compute the radius of the minimal enclosing ball between Points given by a range of coordinates. + * The points are assumed to have the same dimension. */ +class Minimal_enclosing_ball_radius { public: // boost::range_value is not SFINAE-friendly so we cannot use it in the return type template< typename Point > @@ -92,7 +92,7 @@ class Radius_distance { Min_sphere ms(point_cloud.begin()->end() - point_cloud.begin()->begin(), point_cloud.begin(),point_cloud.end()); #ifdef DEBUG_TRACES - std::cout << "Radius_distance = " << std::sqrt(ms.squared_radius()) << " | nb points = " + std::cout << "Minimal_enclosing_ball_radius = " << std::sqrt(ms.squared_radius()) << " | nb points = " << point_cloud.end() - point_cloud.begin() << " | dimension = " << point_cloud.begin()->end() - point_cloud.begin()->begin() << std::endl; #endif // DEBUG_TRACES -- cgit v1.2.3 From b69cc713465675a9bab998cb0688eb91390978a6 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Thu, 22 Mar 2018 15:12:17 +0000 Subject: code review : use std::begin, std::end and boost::size git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/cechcomplex_vincent@3305 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: e59699bc13ae66476001ef5f648759fef68ee76a --- src/Cech_complex/include/gudhi/Cech_complex.h | 12 ++++++------ src/common/include/gudhi/distance_functions.h | 9 ++++----- 2 files changed, 10 insertions(+), 11 deletions(-) (limited to 'src/common') diff --git a/src/Cech_complex/include/gudhi/Cech_complex.h b/src/Cech_complex/include/gudhi/Cech_complex.h index 8b1a9221..bfad8b77 100644 --- a/src/Cech_complex/include/gudhi/Cech_complex.h +++ b/src/Cech_complex/include/gudhi/Cech_complex.h @@ -48,8 +48,8 @@ namespace cech_complex { * \tparam SimplicialComplexForProximityGraph furnishes `Vertex_handle` and `Filtration_value` type definition required * by `Gudhi::Proximity_graph`. * - * \tparam ForwardPointRange furnishes `.size()`, `.begin()` and `.end()` methods, and a `const_iterator` type - * definition. + * \tparam ForwardPointRange must be a range for which `std::begin()` and `std::end()` methods return input + * iterators on a point. `std::begin()` and `std::end()` methods are also required for a point. */ template class Cech_complex { @@ -64,8 +64,8 @@ class Cech_complex { * @param[in] points Range of points. * @param[in] max_radius Maximal radius value. * - * \tparam ForwardPointRange must be a range for which `.size()`, `.begin()` and `.end()` methods return input - * iterators on a point. `.begin()` and `.end()` methods are required for a point. + * \tparam ForwardPointRange must be a range for which `std::begin()` and `std::end()` methods return input + * iterators on a point. `std::begin()` and `std::end()` methods are also required for a point. * */ Cech_complex(const ForwardPointRange& points, Filtration_value max_radius) @@ -107,9 +107,9 @@ class Cech_complex { * @exception std::out_of_range In debug mode, if point position in the range is out. */ typename ForwardPointRange::const_iterator point_iterator(std::size_t vertex) const { - GUDHI_CHECK((point_cloud_.begin() + vertex) < point_cloud_.end(), + GUDHI_CHECK((std::begin(point_cloud_) + vertex) < std::end(point_cloud_), std::out_of_range("Cech_complex::point - simplicial complex is not empty")); - return (point_cloud_.begin() + vertex); + return (std::begin(point_cloud_) + vertex); } private: diff --git a/src/common/include/gudhi/distance_functions.h b/src/common/include/gudhi/distance_functions.h index 429a5fa7..20b04000 100644 --- a/src/common/include/gudhi/distance_functions.h +++ b/src/common/include/gudhi/distance_functions.h @@ -28,6 +28,7 @@ #include #include +#include #include // for std::sqrt #include // for std::decay @@ -74,13 +75,11 @@ class Euclidean_distance { * The points are assumed to have the same dimension. */ class Minimal_enclosing_ball_radius { public: - // boost::range_value is not SFINAE-friendly so we cannot use it in the return type template< typename Point > typename std::iterator_traits::type>::value_type operator()(const Point& p1, const Point& p2) const { return Euclidean_distance()(p1, p2) / 2.; } - // boost::range_value is not SFINAE-friendly so we cannot use it in the return type template< typename Point_cloud, typename Point_iterator = typename boost::range_const_iterator::type, typename Point= typename std::iterator_traits::value_type, @@ -90,11 +89,11 @@ class Minimal_enclosing_ball_radius { operator()(const Point_cloud& point_cloud) const { using Min_sphere = Miniball::Miniball>; - Min_sphere ms(point_cloud.begin()->end() - point_cloud.begin()->begin(), point_cloud.begin(),point_cloud.end()); + Min_sphere ms(boost::size(*point_cloud.begin()), point_cloud.begin(),point_cloud.end()); #ifdef DEBUG_TRACES std::cout << "Minimal_enclosing_ball_radius = " << std::sqrt(ms.squared_radius()) << " | nb points = " - << point_cloud.end() - point_cloud.begin() << " | dimension = " - << point_cloud.begin()->end() - point_cloud.begin()->begin() << std::endl; + << boost::size(point_cloud) << " | dimension = " + << boost::size(*point_cloud.begin()) << std::endl; #endif // DEBUG_TRACES return std::sqrt(ms.squared_radius()); -- cgit v1.2.3 From 1648030e27e828f92c6ae109c96190f986cdec8b Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Mon, 9 Apr 2018 08:53:50 +0000 Subject: Doc review: Fix main page cech complex explaination git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/cechcomplex_vincent@3354 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 0871ae5a851c40e880625a08f470277f93476864 --- src/common/doc/main_page.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/common') diff --git a/src/common/doc/main_page.h b/src/common/doc/main_page.h index 3851dde7..30d4e71b 100644 --- a/src/common/doc/main_page.h +++ b/src/common/doc/main_page.h @@ -42,8 +42,8 @@ - \subsection CechComplexDataStructure Cech complex - \image html "cech_complex_representation.png" "Cech complex representation" + \subsection CechComplexDataStructure Čech complex + \image html "cech_complex_representation.png" "Čech complex representation" -- cgit v1.2.3 From be6997e1cb3b7e6feeb3ece37437f02e6c60a18b Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Tue, 10 Apr 2018 16:06:27 +0000 Subject: Doc review : Gudhi::Proximity_graph and Gudhi::Radius_distance must be links in the doc git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/cechcomplex_vincent@3370 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: fc57faf137316ae07e06491482e0756fbacaf479 --- src/common/include/gudhi/distance_functions.h | 22 ++++++++++++++++++++-- .../include/gudhi/graph_simplicial_complex.h | 6 ++++++ 2 files changed, 26 insertions(+), 2 deletions(-) (limited to 'src/common') diff --git a/src/common/include/gudhi/distance_functions.h b/src/common/include/gudhi/distance_functions.h index 20b04000..9ab35fb1 100644 --- a/src/common/include/gudhi/distance_functions.h +++ b/src/common/include/gudhi/distance_functions.h @@ -75,11 +75,29 @@ class Euclidean_distance { * The points are assumed to have the same dimension. */ class Minimal_enclosing_ball_radius { public: + /** \brief Minimal_enclosing_ball_radius from two points. + * + * @param[in] point_1 First point. + * @param[in] point_2 second point. + * @return The minimal enclosing ball radius for the two points (aka. Euclidean distance / 2.). + * + * \tparam Point must be a range of Cartesian coordinates. + * + */ template< typename Point > typename std::iterator_traits::type>::value_type - operator()(const Point& p1, const Point& p2) const { - return Euclidean_distance()(p1, p2) / 2.; + operator()(const Point& point_1, const Point& point_2) const { + return Euclidean_distance()(point_1, point_2) / 2.; } + /** \brief Minimal_enclosing_ball_radius from a point cloud. + * + * @param[in] point_cloud The points. + * @return The minimal enclosing ball radius for the points. + * + * \tparam Point_cloud must be a range of points with Cartesian coordinates. + * Point_cloud is a range over a range of Coordinate. + * + */ template< typename Point_cloud, typename Point_iterator = typename boost::range_const_iterator::type, typename Point= typename std::iterator_traits::value_type, diff --git a/src/common/include/gudhi/graph_simplicial_complex.h b/src/common/include/gudhi/graph_simplicial_complex.h index d84421b2..a6126182 100644 --- a/src/common/include/gudhi/graph_simplicial_complex.h +++ b/src/common/include/gudhi/graph_simplicial_complex.h @@ -42,6 +42,12 @@ struct vertex_filtration_t { typedef boost::vertex_property_tag kind; }; +/** \brief Proximity_graph contains the vertices and edges with their filtration values in order to store the result + * of `Gudhi::compute_proximity_graph` function. + * + * \tparam SimplicialComplexForProximityGraph furnishes `Filtration_value` type definition. + * + */ template using Proximity_graph = typename boost::adjacency_list < boost::vecS, boost::vecS, boost::undirectedS , boost::property < vertex_filtration_t, typename SimplicialComplexForProximityGraph::Filtration_value > -- cgit v1.2.3 From 00a3424bd68ced3e2d159acf8b2e73f515a3d88b Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Tue, 15 May 2018 19:55:31 +0000 Subject: CMake minimal version is now 3.1 Compilation flags are now externalized in cmake/modules Add NO_POLICY_SCOPE for GUDHI_third_parties to fix warnings Try to fix CGAL 4.12 that is no more setting CGAL_LIBRARIES git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/cmake_v3_vincent@3445 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 0ac7613f016e28cc634606f76e85ecaf5bacb2d4 --- CMakeLists.txt | 29 ++++------------ src/Alpha_complex/example/CMakeLists.txt | 1 - src/Alpha_complex/test/CMakeLists.txt | 1 - src/Alpha_complex/utilities/CMakeLists.txt | 1 - src/Bitmap_cubical_complex/example/CMakeLists.txt | 1 - src/Bitmap_cubical_complex/test/CMakeLists.txt | 1 - .../utilities/CMakeLists.txt | 1 - src/Bottleneck_distance/benchmark/CMakeLists.txt | 1 - src/Bottleneck_distance/example/CMakeLists.txt | 1 - src/Bottleneck_distance/test/CMakeLists.txt | 1 - src/Bottleneck_distance/utilities/CMakeLists.txt | 1 - src/CMakeLists.txt | 39 ++++++---------------- src/Contraction/example/CMakeLists.txt | 1 - src/GudhUI/CMakeLists.txt | 3 +- src/Nerve_GIC/example/CMakeLists.txt | 7 ++-- src/Nerve_GIC/test/CMakeLists.txt | 1 - src/Nerve_GIC/utilities/CMakeLists.txt | 1 - .../example/CMakeLists.txt | 1 - .../test/CMakeLists.txt | 1 - .../utilities/persistence_heat_maps/CMakeLists.txt | 1 - .../utilities/persistence_intervals/CMakeLists.txt | 1 - .../persistence_landscapes/CMakeLists.txt | 1 - .../persistence_landscapes_on_grid/CMakeLists.txt | 1 - .../utilities/persistence_vectors/CMakeLists.txt | 1 - src/Persistent_cohomology/benchmark/CMakeLists.txt | 2 -- src/Persistent_cohomology/example/CMakeLists.txt | 1 - src/Persistent_cohomology/test/CMakeLists.txt | 1 - src/Rips_complex/example/CMakeLists.txt | 1 - src/Rips_complex/test/CMakeLists.txt | 1 - src/Rips_complex/utilities/CMakeLists.txt | 1 - src/Simplex_tree/example/CMakeLists.txt | 1 - src/Simplex_tree/test/CMakeLists.txt | 1 - src/Skeleton_blocker/example/CMakeLists.txt | 1 - src/Skeleton_blocker/test/CMakeLists.txt | 1 - src/Spatial_searching/example/CMakeLists.txt | 1 - src/Spatial_searching/test/CMakeLists.txt | 1 - src/Subsampling/example/CMakeLists.txt | 1 - src/Subsampling/test/CMakeLists.txt | 1 - src/Tangential_complex/benchmark/CMakeLists.txt | 1 - src/Tangential_complex/example/CMakeLists.txt | 1 - src/Tangential_complex/test/CMakeLists.txt | 1 - src/Witness_complex/example/CMakeLists.txt | 1 - src/Witness_complex/test/CMakeLists.txt | 1 - src/Witness_complex/utilities/CMakeLists.txt | 1 - src/cmake/modules/GUDHI_compilation_flags.cmake | 36 ++++++++++++++++++++ src/common/example/CMakeLists.txt | 1 - src/common/test/CMakeLists.txt | 1 - src/common/utilities/CMakeLists.txt | 1 - src/cython/CMakeLists.txt | 6 ++-- 49 files changed, 60 insertions(+), 104 deletions(-) create mode 100644 src/cmake/modules/GUDHI_compilation_flags.cmake (limited to 'src/common') diff --git a/CMakeLists.txt b/CMakeLists.txt index 10373f75..08291b54 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,35 +1,18 @@ -cmake_minimum_required(VERSION 2.6) +cmake_minimum_required(VERSION 3.1) + project(GUDHIdev) include(CMakeGUDHIVersion.txt) list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/src/cmake/modules/") -enable_testing() - -# This variable is used by Cython CMakeLists.txt to know its path +# This variable is used by Cython CMakeLists.txt and by GUDHI_third_party_libraries to know its path set(GUDHI_CYTHON_PATH "src/cython") -# For third parties libraries management - To be done last as CGAL updates CMAKE_MODULE_PATH -include(GUDHI_third_party_libraries) - -if(MSVC) - # Turn off some VC++ warnings - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4267 /wd4668 /wd4311 /wd4800 /wd4820 /wd4503 /wd4244 /wd4345 /wd4996 /wd4396 /wd4018") -else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -pedantic") -endif() -if(CMAKE_BUILD_TYPE MATCHES Debug) - message("++ Debug compilation flags are: ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG}") -else() - message("++ Release compilation flags are: ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE}") -endif() +# For third parties libraries management - To be done last as CGAL updates CMAKE_MODULE_PATH +include(GUDHI_third_party_libraries NO_POLICY_SCOPE) -if (DEBUG_TRACES) - # For programs to be more verbose - message(STATUS "DEBUG_TRACES are activated") - add_definitions(-DDEBUG_TRACES) -endif() +include(GUDHI_compilation_flags) # Add your new module in the list, order is not important include(GUDHI_modules) diff --git a/src/Alpha_complex/example/CMakeLists.txt b/src/Alpha_complex/example/CMakeLists.txt index 5bf553e9..2fc62452 100644 --- a/src/Alpha_complex/example/CMakeLists.txt +++ b/src/Alpha_complex/example/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 2.6) project(Alpha_complex_examples) # need CGAL 4.7 diff --git a/src/Alpha_complex/test/CMakeLists.txt b/src/Alpha_complex/test/CMakeLists.txt index 9e0b3b3c..9255d3db 100644 --- a/src/Alpha_complex/test/CMakeLists.txt +++ b/src/Alpha_complex/test/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 2.6) project(Alpha_complex_tests) if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.7.0) diff --git a/src/Alpha_complex/utilities/CMakeLists.txt b/src/Alpha_complex/utilities/CMakeLists.txt index a2dfac20..7ace6064 100644 --- a/src/Alpha_complex/utilities/CMakeLists.txt +++ b/src/Alpha_complex/utilities/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 2.6) project(Alpha_complex_utilities) if(CGAL_FOUND) diff --git a/src/Bitmap_cubical_complex/example/CMakeLists.txt b/src/Bitmap_cubical_complex/example/CMakeLists.txt index 99304aa4..dc659f2d 100644 --- a/src/Bitmap_cubical_complex/example/CMakeLists.txt +++ b/src/Bitmap_cubical_complex/example/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 2.6) project(Bitmap_cubical_complex_examples) add_executable ( Random_bitmap_cubical_complex Random_bitmap_cubical_complex.cpp ) diff --git a/src/Bitmap_cubical_complex/test/CMakeLists.txt b/src/Bitmap_cubical_complex/test/CMakeLists.txt index 02b026f2..8b43632a 100644 --- a/src/Bitmap_cubical_complex/test/CMakeLists.txt +++ b/src/Bitmap_cubical_complex/test/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 2.6) project(Bitmap_cubical_complex_tests) include(GUDHI_test_coverage) diff --git a/src/Bitmap_cubical_complex/utilities/CMakeLists.txt b/src/Bitmap_cubical_complex/utilities/CMakeLists.txt index 676a730a..416db67f 100644 --- a/src/Bitmap_cubical_complex/utilities/CMakeLists.txt +++ b/src/Bitmap_cubical_complex/utilities/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 2.6) project(Bitmap_cubical_complex_utilities) add_executable ( cubical_complex_persistence cubical_complex_persistence.cpp ) diff --git a/src/Bottleneck_distance/benchmark/CMakeLists.txt b/src/Bottleneck_distance/benchmark/CMakeLists.txt index 20a4e47b..3105a1d5 100644 --- a/src/Bottleneck_distance/benchmark/CMakeLists.txt +++ b/src/Bottleneck_distance/benchmark/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 2.6) project(Bottleneck_distance_benchmark) if (NOT CGAL_VERSION VERSION_LESS 4.8.1) diff --git a/src/Bottleneck_distance/example/CMakeLists.txt b/src/Bottleneck_distance/example/CMakeLists.txt index 6095d6eb..c6f10127 100644 --- a/src/Bottleneck_distance/example/CMakeLists.txt +++ b/src/Bottleneck_distance/example/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 2.6) project(Bottleneck_distance_examples) if (NOT CGAL_VERSION VERSION_LESS 4.8.1) diff --git a/src/Bottleneck_distance/test/CMakeLists.txt b/src/Bottleneck_distance/test/CMakeLists.txt index 2676b82c..bb739280 100644 --- a/src/Bottleneck_distance/test/CMakeLists.txt +++ b/src/Bottleneck_distance/test/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 2.6) project(Bottleneck_distance_tests) if (NOT CGAL_VERSION VERSION_LESS 4.8.1) diff --git a/src/Bottleneck_distance/utilities/CMakeLists.txt b/src/Bottleneck_distance/utilities/CMakeLists.txt index d19e3b1c..2f35885c 100644 --- a/src/Bottleneck_distance/utilities/CMakeLists.txt +++ b/src/Bottleneck_distance/utilities/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 2.6) project(Bottleneck_distance_utilities) if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 94587044..5d543018 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,12 +1,19 @@ -cmake_minimum_required(VERSION 2.6) -project(GUDHI) +cmake_minimum_required(VERSION 3.1) -include("CMakeGUDHIVersion.txt") +project(GUDHI) -enable_testing() +include(CMakeGUDHIVersion.txt) list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules/") +# This variable is used by Cython CMakeLists.txt and by GUDHI_third_party_libraries to know its path +set(GUDHI_CYTHON_PATH "cython") + +# For third parties libraries management - To be done last as CGAL updates CMAKE_MODULE_PATH +include(GUDHI_third_party_libraries NO_POLICY_SCOPE) + +include(GUDHI_compilation_flags) + # Add your new module in the list, order is not important include(GUDHI_modules) @@ -33,30 +40,6 @@ message("++ GUDHI_MODULES list is:\"${GUDHI_MODULES}\"") set(GUDHI_USER_VERSION_DIR ${CMAKE_SOURCE_DIR}) include(GUDHI_doxygen_target) -# This variable is used by Cython CMakeLists.txt to know its path -set(GUDHI_CYTHON_PATH "cython") -# For third parties libraries management - To be done last as CGAL updates CMAKE_MODULE_PATH -include(GUDHI_third_party_libraries) - -if(MSVC) - # Turn off some VC++ warnings - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4267 /wd4668 /wd4311 /wd4800 /wd4820 /wd4503 /wd4244 /wd4345 /wd4996 /wd4396 /wd4018") -else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -pedantic") -endif() - -if(CMAKE_BUILD_TYPE MATCHES Debug) - message("++ Debug compilation flags are: ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG}") -else() - message("++ Release compilation flags are: ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE}") -endif() - -if (DEBUG_TRACES) - message(STATUS "DEBUG_TRACES are activated") - # For programs to be more verbose - add_definitions(-DDEBUG_TRACES) -endif() - #--------------------------------------------------------------------------------------- # Gudhi compilation part include_directories(include) diff --git a/src/Contraction/example/CMakeLists.txt b/src/Contraction/example/CMakeLists.txt index a92d1685..582b7ab8 100644 --- a/src/Contraction/example/CMakeLists.txt +++ b/src/Contraction/example/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 2.6) project(Contraction_examples) add_executable(RipsContraction Rips_contraction.cpp) diff --git a/src/GudhUI/CMakeLists.txt b/src/GudhUI/CMakeLists.txt index 2503a03e..b357b8f7 100644 --- a/src/GudhUI/CMakeLists.txt +++ b/src/GudhUI/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 2.8) project(GudhUI) # Need to find OpenGL first as find_package(Qt5) tries to #include"GL/gl.h" on some platforms @@ -38,4 +37,4 @@ if (OPENGL_FOUND) install(TARGETS GudhUI DESTINATION bin) endif() -endif(OPENGL_FOUND) \ No newline at end of file +endif(OPENGL_FOUND) diff --git a/src/Nerve_GIC/example/CMakeLists.txt b/src/Nerve_GIC/example/CMakeLists.txt index 542c6af4..fdecf86e 100644 --- a/src/Nerve_GIC/example/CMakeLists.txt +++ b/src/Nerve_GIC/example/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 2.6) project(Nerve_GIC_examples) if (NOT CGAL_VERSION VERSION_LESS 4.8.1) @@ -17,11 +16,11 @@ if (NOT CGAL_VERSION VERSION_LESS 4.8.1) file(COPY "${CMAKE_SOURCE_DIR}/data/points/COIL_database/lucky_cat_PCA1" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) add_test(NAME Nerve_GIC_example_CoordGIC COMMAND $ - "tore3D_1307.off" "0") + "${CMAKE_CURRENT_BINARY_DIR}/tore3D_1307.off" "0") add_test(NAME Nerve_GIC_example_FuncGIC COMMAND $ - "lucky_cat.off" - "lucky_cat_PCA1") + "${CMAKE_CURRENT_BINARY_DIR}/lucky_cat.off" + "${CMAKE_CURRENT_BINARY_DIR}/lucky_cat_PCA1") install(TARGETS CoordGIC DESTINATION bin) install(TARGETS FuncGIC DESTINATION bin) diff --git a/src/Nerve_GIC/test/CMakeLists.txt b/src/Nerve_GIC/test/CMakeLists.txt index c35cdff7..99263ea0 100644 --- a/src/Nerve_GIC/test/CMakeLists.txt +++ b/src/Nerve_GIC/test/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 2.6) project(Graph_induced_complex_tests) if (NOT CGAL_VERSION VERSION_LESS 4.8.1) diff --git a/src/Nerve_GIC/utilities/CMakeLists.txt b/src/Nerve_GIC/utilities/CMakeLists.txt index 7a838a8c..215f9dfd 100644 --- a/src/Nerve_GIC/utilities/CMakeLists.txt +++ b/src/Nerve_GIC/utilities/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 2.6) project(Nerve_GIC_examples) if (NOT CGAL_VERSION VERSION_LESS 4.8.1) diff --git a/src/Persistence_representations/example/CMakeLists.txt b/src/Persistence_representations/example/CMakeLists.txt index 54d719ac..33558df3 100644 --- a/src/Persistence_representations/example/CMakeLists.txt +++ b/src/Persistence_representations/example/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 2.6) project(Persistence_representations_example) add_executable ( Persistence_representations_example_landscape_on_grid persistence_landscape_on_grid.cpp ) diff --git a/src/Persistence_representations/test/CMakeLists.txt b/src/Persistence_representations/test/CMakeLists.txt index 335a71ef..5e2b6910 100644 --- a/src/Persistence_representations/test/CMakeLists.txt +++ b/src/Persistence_representations/test/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 2.6) project(Persistence_representations_test) include(GUDHI_test_coverage) diff --git a/src/Persistence_representations/utilities/persistence_heat_maps/CMakeLists.txt b/src/Persistence_representations/utilities/persistence_heat_maps/CMakeLists.txt index 386e9fa5..89ef232f 100644 --- a/src/Persistence_representations/utilities/persistence_heat_maps/CMakeLists.txt +++ b/src/Persistence_representations/utilities/persistence_heat_maps/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 2.6) project(Persistence_representations_heat_maps_utilities) add_persistence_representation_creation_utility(create_pssk "10" "-1" "-1" "4" "-1") diff --git a/src/Persistence_representations/utilities/persistence_intervals/CMakeLists.txt b/src/Persistence_representations/utilities/persistence_intervals/CMakeLists.txt index 875ff45e..649b72cb 100644 --- a/src/Persistence_representations/utilities/persistence_intervals/CMakeLists.txt +++ b/src/Persistence_representations/utilities/persistence_intervals/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 2.6) project(Persistence_representations_intervals_utilities) diff --git a/src/Persistence_representations/utilities/persistence_landscapes/CMakeLists.txt b/src/Persistence_representations/utilities/persistence_landscapes/CMakeLists.txt index d7087ed8..6b24d032 100644 --- a/src/Persistence_representations/utilities/persistence_landscapes/CMakeLists.txt +++ b/src/Persistence_representations/utilities/persistence_landscapes/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 2.6) project(Persistence_representations_landscapes_utilities) add_persistence_representation_creation_utility(create_landscapes "-1") diff --git a/src/Persistence_representations/utilities/persistence_landscapes_on_grid/CMakeLists.txt b/src/Persistence_representations/utilities/persistence_landscapes_on_grid/CMakeLists.txt index c5ea4bbf..36f3196b 100644 --- a/src/Persistence_representations/utilities/persistence_landscapes_on_grid/CMakeLists.txt +++ b/src/Persistence_representations/utilities/persistence_landscapes_on_grid/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 2.6) project(Persistence_representations_lanscapes_on_grid_utilities) # Need to set grid min and max for further average, distance and scalar_product diff --git a/src/Persistence_representations/utilities/persistence_vectors/CMakeLists.txt b/src/Persistence_representations/utilities/persistence_vectors/CMakeLists.txt index a401c955..bc982094 100644 --- a/src/Persistence_representations/utilities/persistence_vectors/CMakeLists.txt +++ b/src/Persistence_representations/utilities/persistence_vectors/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 2.6) project(Persistence_vectors_utilities) add_persistence_representation_creation_utility(create_persistence_vectors "-1") diff --git a/src/Persistent_cohomology/benchmark/CMakeLists.txt b/src/Persistent_cohomology/benchmark/CMakeLists.txt index 8b135ba1..2bb3b0c7 100644 --- a/src/Persistent_cohomology/benchmark/CMakeLists.txt +++ b/src/Persistent_cohomology/benchmark/CMakeLists.txt @@ -1,6 +1,4 @@ -cmake_minimum_required(VERSION 2.6) project(Persistent_cohomology_benchmark) - if(GMP_FOUND) if(GMPXX_FOUND) diff --git a/src/Persistent_cohomology/example/CMakeLists.txt b/src/Persistent_cohomology/example/CMakeLists.txt index 18e2913b..0f731519 100644 --- a/src/Persistent_cohomology/example/CMakeLists.txt +++ b/src/Persistent_cohomology/example/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 2.6) project(Persistent_cohomology_examples) add_executable(plain_homology plain_homology.cpp) diff --git a/src/Persistent_cohomology/test/CMakeLists.txt b/src/Persistent_cohomology/test/CMakeLists.txt index 45f53eb9..f8baf861 100644 --- a/src/Persistent_cohomology/test/CMakeLists.txt +++ b/src/Persistent_cohomology/test/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 2.6) project(Persistent_cohomology_tests) include(GUDHI_test_coverage) diff --git a/src/Rips_complex/example/CMakeLists.txt b/src/Rips_complex/example/CMakeLists.txt index af86636b..e7772bdb 100644 --- a/src/Rips_complex/example/CMakeLists.txt +++ b/src/Rips_complex/example/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 2.6) project(Rips_complex_examples) # Point cloud diff --git a/src/Rips_complex/test/CMakeLists.txt b/src/Rips_complex/test/CMakeLists.txt index 3da9c90d..745d953c 100644 --- a/src/Rips_complex/test/CMakeLists.txt +++ b/src/Rips_complex/test/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 2.6) project(Rips_complex_tests) include(GUDHI_test_coverage) diff --git a/src/Rips_complex/utilities/CMakeLists.txt b/src/Rips_complex/utilities/CMakeLists.txt index deb73ff0..4b565628 100644 --- a/src/Rips_complex/utilities/CMakeLists.txt +++ b/src/Rips_complex/utilities/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 2.6) project(Rips_complex_utilities) add_executable(rips_distance_matrix_persistence rips_distance_matrix_persistence.cpp) diff --git a/src/Simplex_tree/example/CMakeLists.txt b/src/Simplex_tree/example/CMakeLists.txt index b33b2d05..857e8518 100644 --- a/src/Simplex_tree/example/CMakeLists.txt +++ b/src/Simplex_tree/example/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 2.6) project(Simplex_tree_examples) add_executable ( Simplex_tree_example_from_cliques_of_graph simplex_tree_from_cliques_of_graph.cpp ) diff --git a/src/Simplex_tree/test/CMakeLists.txt b/src/Simplex_tree/test/CMakeLists.txt index 8684ad2a..c63d8532 100644 --- a/src/Simplex_tree/test/CMakeLists.txt +++ b/src/Simplex_tree/test/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 2.6) project(Simplex_tree_tests) include(GUDHI_test_coverage) diff --git a/src/Skeleton_blocker/example/CMakeLists.txt b/src/Skeleton_blocker/example/CMakeLists.txt index de70f089..0e5d2f11 100644 --- a/src/Skeleton_blocker/example/CMakeLists.txt +++ b/src/Skeleton_blocker/example/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 2.6) project(Skeleton_blocker_examples) add_executable(Skeleton_blocker_example_from_simplices Skeleton_blocker_from_simplices.cpp) diff --git a/src/Skeleton_blocker/test/CMakeLists.txt b/src/Skeleton_blocker/test/CMakeLists.txt index 4a363294..19c65871 100644 --- a/src/Skeleton_blocker/test/CMakeLists.txt +++ b/src/Skeleton_blocker/test/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 2.6) project(Skeleton_blocker_tests) include(GUDHI_test_coverage) diff --git a/src/Spatial_searching/example/CMakeLists.txt b/src/Spatial_searching/example/CMakeLists.txt index 4cf3d863..0f799987 100644 --- a/src/Spatial_searching/example/CMakeLists.txt +++ b/src/Spatial_searching/example/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 2.6) project(Spatial_searching_examples) if(NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1) diff --git a/src/Spatial_searching/test/CMakeLists.txt b/src/Spatial_searching/test/CMakeLists.txt index b9da7b4e..b60ab1e3 100644 --- a/src/Spatial_searching/test/CMakeLists.txt +++ b/src/Spatial_searching/test/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 2.6) project(Spatial_searching_tests) if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1) diff --git a/src/Subsampling/example/CMakeLists.txt b/src/Subsampling/example/CMakeLists.txt index 34400b1e..f26d107f 100644 --- a/src/Subsampling/example/CMakeLists.txt +++ b/src/Subsampling/example/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 2.6) project(Subsampling_examples) if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1) diff --git a/src/Subsampling/test/CMakeLists.txt b/src/Subsampling/test/CMakeLists.txt index dbf97db3..924f0925 100644 --- a/src/Subsampling/test/CMakeLists.txt +++ b/src/Subsampling/test/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 2.6) project(Subsampling_tests) if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1) diff --git a/src/Tangential_complex/benchmark/CMakeLists.txt b/src/Tangential_complex/benchmark/CMakeLists.txt index 8729e394..f136ab27 100644 --- a/src/Tangential_complex/benchmark/CMakeLists.txt +++ b/src/Tangential_complex/benchmark/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 2.6) project(Tangential_complex_benchmark) if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1) diff --git a/src/Tangential_complex/example/CMakeLists.txt b/src/Tangential_complex/example/CMakeLists.txt index 16d1339d..af0dac51 100644 --- a/src/Tangential_complex/example/CMakeLists.txt +++ b/src/Tangential_complex/example/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 2.6) project(Tangential_complex_examples) if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1) diff --git a/src/Tangential_complex/test/CMakeLists.txt b/src/Tangential_complex/test/CMakeLists.txt index 1948c8f6..902f19af 100644 --- a/src/Tangential_complex/test/CMakeLists.txt +++ b/src/Tangential_complex/test/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 2.6) project(Tangential_complex_tests) if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1) diff --git a/src/Witness_complex/example/CMakeLists.txt b/src/Witness_complex/example/CMakeLists.txt index a8231392..3d838c0d 100644 --- a/src/Witness_complex/example/CMakeLists.txt +++ b/src/Witness_complex/example/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 2.6) project(Witness_complex_examples) add_executable ( Witness_complex_example_nearest_landmark_table example_nearest_landmark_table.cpp ) diff --git a/src/Witness_complex/test/CMakeLists.txt b/src/Witness_complex/test/CMakeLists.txt index 0b523eaf..58ac60c5 100644 --- a/src/Witness_complex/test/CMakeLists.txt +++ b/src/Witness_complex/test/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 2.6) project(Witness_complex_tests) include(GUDHI_test_coverage) diff --git a/src/Witness_complex/utilities/CMakeLists.txt b/src/Witness_complex/utilities/CMakeLists.txt index 125a41ff..ce5e29f2 100644 --- a/src/Witness_complex/utilities/CMakeLists.txt +++ b/src/Witness_complex/utilities/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 2.6) project(Witness_complex_utilities) # CGAL and Eigen3 are required for Euclidean version of Witness diff --git a/src/cmake/modules/GUDHI_compilation_flags.cmake b/src/cmake/modules/GUDHI_compilation_flags.cmake new file mode 100644 index 00000000..614d3812 --- /dev/null +++ b/src/cmake/modules/GUDHI_compilation_flags.cmake @@ -0,0 +1,36 @@ +# This files manage compilation flags required by GUDHI + +include(TestCXXAcceptsFlag) + +# add a compiler flag only if it is accepted +macro(add_cxx_compiler_flag _flag) + string(REPLACE "-" "_" _flag_var ${_flag}) + check_cxx_accepts_flag("${_flag}" CXX_COMPILER_${_flag_var}_OK) + if(CXX_COMPILER_${_flag_var}_OK) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${_flag}") + endif() +endmacro() + +set (CMAKE_CXX_STANDARD 11) + +enable_testing() + +if(MSVC) + # Turn off some VC++ warnings + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4267 /wd4668 /wd4311 /wd4800 /wd4820 /wd4503 /wd4244 /wd4345 /wd4996 /wd4396 /wd4018") +endif() + +add_cxx_compiler_flag("-Wall") +add_cxx_compiler_flag("-pedantic") + +if(CMAKE_BUILD_TYPE MATCHES Debug) + message("++ Debug compilation flags are: ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG}") +else() + message("++ Release compilation flags are: ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE}") +endif() + +if (DEBUG_TRACES) + # For programs to be more verbose + message(STATUS "DEBUG_TRACES are activated") + add_definitions(-DDEBUG_TRACES) +endif() diff --git a/src/common/example/CMakeLists.txt b/src/common/example/CMakeLists.txt index 1273c699..04015cdc 100644 --- a/src/common/example/CMakeLists.txt +++ b/src/common/example/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 2.6) project(Common_examples) add_executable ( vector_double_off_reader example_vector_double_points_off_reader.cpp ) diff --git a/src/common/test/CMakeLists.txt b/src/common/test/CMakeLists.txt index de3e765a..0b49fa1e 100644 --- a/src/common/test/CMakeLists.txt +++ b/src/common/test/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 2.6) project(Common_tests) include(GUDHI_test_coverage) diff --git a/src/common/utilities/CMakeLists.txt b/src/common/utilities/CMakeLists.txt index b3e4b436..7f1d1cd7 100644 --- a/src/common/utilities/CMakeLists.txt +++ b/src/common/utilities/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 2.6) project(off_file_from_shape_generator) if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.6.0) diff --git a/src/cython/CMakeLists.txt b/src/cython/CMakeLists.txt index b19cc550..2c21d158 100644 --- a/src/cython/CMakeLists.txt +++ b/src/cython/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 2.8) project(Cython) include(CheckCXXSourceCompiles) @@ -100,12 +99,13 @@ if(CYTHON_FOUND) add_gudhi_cython_lib(${Boost_THREAD_LIBRARY}) set(GUDHI_CYTHON_LIBRARY_DIRS "${GUDHI_CYTHON_LIBRARY_DIRS}'${Boost_LIBRARY_DIRS}', ") endif() - + message("*** ${CGAL_HEADER_ONLY}") # Add CGAL compilation args if(CGAL_HEADER_ONLY) set(GUDHI_CYTHON_EXTRA_COMPILE_ARGS "${GUDHI_CYTHON_EXTRA_COMPILE_ARGS}'-DCGAL_HEADER_ONLY', ") else(CGAL_HEADER_ONLY) - add_gudhi_cython_lib(${CGAL_LIBRARIES}) + message("*** ${CGAL_LIBRARY}") + add_gudhi_cython_lib(${CGAL_LIBRARY}) set(GUDHI_CYTHON_LIBRARY_DIRS "${GUDHI_CYTHON_LIBRARY_DIRS}'${CGAL_LIBRARIES_DIR}', ") # If CGAL is not header only, CGAL library may link with boost system, add_gudhi_cython_lib(${Boost_SYSTEM_LIBRARY}) -- cgit v1.2.3 From e996b0fd0a0aecfa3b77e0ff3780f31b1b8bab4a Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Tue, 22 May 2018 20:59:45 +0000 Subject: Add CMake 3.1 in installation requirements. git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@3450 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: bae61cf108841dae3ff1be5953eb9f87f1713e41 --- src/common/doc/installation.h | 5 +++-- src/cython/doc/installation.rst | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'src/common') diff --git a/src/common/doc/installation.h b/src/common/doc/installation.h index 25675cc5..12407c18 100644 --- a/src/common/doc/installation.h +++ b/src/common/doc/installation.h @@ -5,8 +5,9 @@ * Examples of GUDHI headers inclusion can be found in \ref demos. * * \section compiling Compiling - * The library uses c++11 and requires Boost with version 1.48.0 or - * more recent. It is a multi-platform library and compiles on Linux, Mac OSX and Visual Studio 2015. + * The library uses c++11 and requires Boost ≥ 1.48.0 + * and CMake ≥ 3.1. + * It is a multi-platform library and compiles on Linux, Mac OSX and Visual Studio 2015. * * \subsection demos Demos and examples * To build the demos and examples, run the following commands in a terminal: diff --git a/src/cython/doc/installation.rst b/src/cython/doc/installation.rst index c182f176..52c5eb49 100644 --- a/src/cython/doc/installation.rst +++ b/src/cython/doc/installation.rst @@ -3,10 +3,10 @@ Installation Compiling ********* - -The library uses c++11 and requires `Boost `_ with -version 1.48.0 or more recent. It is a multi-platform library and compiles on -Linux, Mac OSX and Visual Studio 2015. +The library uses c++11 and requires `Boost `_ ≥ 1.48.0 +and `CMake `_ ≥ 3.1. +It is a multi-platform library and compiles on Linux, Mac OSX and Visual +Studio 2015. It also requires cmake to generate makefiles, and cython to compile the library. -- cgit v1.2.3 From ef31bf2f968299589e9668e3b00ab90228ad08bf Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Tue, 5 Jun 2018 16:05:54 +0000 Subject: Add author name on main page git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@3536 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 7fc4d6de9bc65d51f4f0fb263b01a88adcab77d3 --- src/common/doc/main_page.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/common') diff --git a/src/common/doc/main_page.h b/src/common/doc/main_page.h index 30d4e71b..db1e80ce 100644 --- a/src/common/doc/main_page.h +++ b/src/common/doc/main_page.h @@ -79,7 +79,7 @@
@@ -52,8 +52,8 @@ Copyright: GPL v3
- The Cech complex is a proximity graph that allows to construct a simplicial complex from it. - It guarantees the simplices inserted are inside a ball of a given radius.
+ The Čech complex is a simplicial complex constructed from a proximity graph.
+ The set of all simplices is filtered by the radius of their minimal enclosing ball.
User manual: \ref cech_complex - Reference manual: Gudhi::cech_complex::Cech_complex
-- cgit v1.2.3 From dde12ef73a36913c06d33ff3f5c2df43dd209930 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Tue, 5 Jun 2018 19:44:59 +0000 Subject: Add new layout for documentation website for Doxygen (C++) and sphinx (Python) git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@3539 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 2dc9edea317426fad7a7d99d849145845eb75bb9 --- src/common/doc/header.html | 109 +++++++++++++++++----------------- src/cython/doc/_templates/layout.html | 109 +++++++++++++++++----------------- 2 files changed, 110 insertions(+), 108 deletions(-) (limited to 'src/common') diff --git a/src/common/doc/header.html b/src/common/doc/header.html index 2f54e68d..4661dbbe 100644 --- a/src/common/doc/header.html +++ b/src/common/doc/header.html @@ -24,60 +24,61 @@ $extrastylesheet diff --git a/src/cython/doc/_templates/layout.html b/src/cython/doc/_templates/layout.html index c9356116..613d7d06 100644 --- a/src/cython/doc/_templates/layout.html +++ b/src/cython/doc/_templates/layout.html @@ -166,60 +166,61 @@ -- cgit v1.2.3 From e7fa347f0d0e0160e90ee2f869c8039625aaed5f Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Wed, 13 Jun 2018 07:32:36 +0000 Subject: Fix cppcheck issues git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@3601 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 44cc04b1609d3b3d40382fd02d4fe15e5ba0159f --- src/Cech_complex/include/gudhi/Cech_complex.h | 1 + .../include/gudhi/read_persistence_from_file.h | 6 ++-- .../include/gudhi/Sparse_rips_complex.h | 4 +-- .../rips_correlation_matrix_persistence.cpp | 1 + src/Witness_complex/example/generators.h | 6 ++-- src/common/doc/header.html | 34 ++++++++++----------- src/common/include/gudhi/Off_reader.h | 2 +- src/common/include/gudhi/distance_functions.h | 4 +-- src/common/include/gudhi/random_point_generators.h | 3 +- .../include/gudhi/writing_persistence_to_file.h | 8 ++--- src/cython/doc/_templates/layout.html | 35 +++++++++++----------- 11 files changed, 54 insertions(+), 50 deletions(-) (limited to 'src/common') diff --git a/src/Cech_complex/include/gudhi/Cech_complex.h b/src/Cech_complex/include/gudhi/Cech_complex.h index f4fb4288..f9b8a269 100644 --- a/src/Cech_complex/include/gudhi/Cech_complex.h +++ b/src/Cech_complex/include/gudhi/Cech_complex.h @@ -30,6 +30,7 @@ #include #include // for exception management +#include namespace Gudhi { diff --git a/src/Persistence_representations/include/gudhi/read_persistence_from_file.h b/src/Persistence_representations/include/gudhi/read_persistence_from_file.h index e0fc7107..4a2b9d68 100644 --- a/src/Persistence_representations/include/gudhi/read_persistence_from_file.h +++ b/src/Persistence_representations/include/gudhi/read_persistence_from_file.h @@ -57,7 +57,7 @@ std::vector > read_persistence_intervals_in_one_dimens std::string line; std::vector > barcode_initial = - read_persistence_intervals_in_dimension(filename, (int)dimension); + read_persistence_intervals_in_dimension(filename, static_cast(dimension)); std::vector > final_barcode; final_barcode.reserve(barcode_initial.size()); @@ -92,8 +92,8 @@ std::vector > read_persistence_intervals_in_one_dimens if ((barcode_initial[i].second == std::numeric_limits::infinity()) && (what_to_substitute_for_infinite_bar != -1)) { - if (barcode_initial[i].first < what_to_substitute_for_infinite_bar) // if only birth < death. - { + if (barcode_initial[i].first < what_to_substitute_for_infinite_bar) { + // if only birth < death. final_barcode.push_back( std::pair(barcode_initial[i].first, what_to_substitute_for_infinite_bar)); } diff --git a/src/Rips_complex/include/gudhi/Sparse_rips_complex.h b/src/Rips_complex/include/gudhi/Sparse_rips_complex.h index 19a44b28..4dcc08ed 100644 --- a/src/Rips_complex/include/gudhi/Sparse_rips_complex.h +++ b/src/Rips_complex/include/gudhi/Sparse_rips_complex.h @@ -54,7 +54,7 @@ namespace rips_complex { template class Sparse_rips_complex { private: - // TODO: use a different graph where we know we can safely insert in parallel. + // TODO(MG): use a different graph where we know we can safely insert in parallel. typedef typename boost::adjacency_list, boost::property> @@ -140,7 +140,7 @@ class Sparse_rips_complex { put(vertex_filtration_t(), graph_, v, 0); } - // TODO: + // TODO(MG): // - make it parallel // - only test near-enough neighbors for (int i = 0; i < n; ++i) diff --git a/src/Rips_complex/utilities/rips_correlation_matrix_persistence.cpp b/src/Rips_complex/utilities/rips_correlation_matrix_persistence.cpp index d4671b45..c78677d2 100644 --- a/src/Rips_complex/utilities/rips_correlation_matrix_persistence.cpp +++ b/src/Rips_complex/utilities/rips_correlation_matrix_persistence.cpp @@ -31,6 +31,7 @@ #include #include #include // infinity +#include // for sort // Types definition using Simplex_tree = Gudhi::Simplex_tree; diff --git a/src/Witness_complex/example/generators.h b/src/Witness_complex/example/generators.h index 81566824..4b755daa 100644 --- a/src/Witness_complex/example/generators.h +++ b/src/Witness_complex/example/generators.h @@ -20,8 +20,8 @@ * along with this program. If not, see . */ -#ifndef EXAMPLE_WITNESS_COMPLEX_GENERATORS_H_ -#define EXAMPLE_WITNESS_COMPLEX_GENERATORS_H_ +#ifndef GENERATORS_H_ +#define GENERATORS_H_ #include #include @@ -163,4 +163,4 @@ void generate_points_torus(Point_Vector& W, int nbP, int dim) { } } -#endif // EXAMPLE_WITNESS_COMPLEX_GENERATORS_H_ +#endif // GENERATORS_H_ diff --git a/src/common/doc/header.html b/src/common/doc/header.html index 4661dbbe..56833d39 100644 --- a/src/common/doc/header.html +++ b/src/common/doc/header.html @@ -27,7 +27,7 @@ $extrastylesheet
- Author: Clément Maria, Pawel Dlotko, Vincent Rouvreau
+ Author: Clément Maria, Pawel Dlotko, Vincent Rouvreau, Marc Glisse
Introduced in: GUDHI 2.0.0
Copyright: GPL v3