From a7decae3cdf47441cbd72c31e794176dbd3739c4 Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Mon, 25 May 2020 08:21:47 +0200 Subject: C++ version and documentation --- src/python/doc/alpha_complex_user.rst | 21 ++++++++++++++++++-- src/python/include/Alpha_complex_interface.h | 29 +++++++++++----------------- 2 files changed, 30 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/python/doc/alpha_complex_user.rst b/src/python/doc/alpha_complex_user.rst index d49f45b4..c1ed0eaa 100644 --- a/src/python/doc/alpha_complex_user.rst +++ b/src/python/doc/alpha_complex_user.rst @@ -16,8 +16,25 @@ Definition Remarks ^^^^^^^ -When an :math:`\alpha`-complex is constructed with an infinite value of :math:`\alpha^2`, -the complex is a Delaunay complex (with special filtration values). +* When an :math:`\alpha`-complex is constructed with an infinite value of :math:`\alpha^2`, the complex is a Delaunay + complex (with special filtration values). The Delaunay complex without filtration values is also available by + passing :code:`default_filtration_value = True` to :func:`~gudhi.AlphaComplex.create_simplex_tree`. +* For people only interested in the topology of the Alpha complex (for instance persistence), Alpha complex is + equivalent to the `Čech complex `_ and much smaller if + you do not bound the radii. `Čech complex `_ can still + make sense in higher dimension precisely because you can bound the radii. +* Using the default :code:`complexity = 'safe'` makes the construction safe. + If you pass :code:`complexity = 'exact'` to :func:`~gudhi.AlphaComplex.__init__`, the filtration values are the exact + ones converted to the filtration value type of the simplicial complex. This can be very slow. + If you pass :code:`complexity = 'safe'` (the default) or :code:`complexity = 'fast'`, the filtration values are only + guaranteed to have a small multiplicative error compared to the exact value, see + `CGAL::Lazy_exact_nt::set_relative_precision_of_to_double `_ + for details. A drawback, when computing persistence, is that an empty exact interval [10^12,10^12] may become a + non-empty approximate interval [10^12,10^12+10^6]. + Using :code:`complexity = 'fast'` makes the computations slightly faster, and the combinatorics are still exact, but + the computation of filtration values can exceptionally be arbitrarily bad. In all cases, we still guarantee that the + output is a valid filtration (faces have a filtration value no larger than their cofaces). +* For performances reasons, it is advised to use Alpha_complex with `CGAL `_ :math:`\geq` 5.0.0. Example from points ------------------- diff --git a/src/python/include/Alpha_complex_interface.h b/src/python/include/Alpha_complex_interface.h index 46f2ba03..dce9c8e9 100644 --- a/src/python/include/Alpha_complex_interface.h +++ b/src/python/include/Alpha_complex_interface.h @@ -31,8 +31,8 @@ namespace alpha_complex { class Alpha_complex_interface { private: - using Exact_kernel = CGAL::Epeck_d< CGAL::Dynamic_dimension_tag >; - using Inexact_kernel = CGAL::Epick_d< CGAL::Dynamic_dimension_tag >; + using Exact_kernel = CGAL::Epeck_d; + using Inexact_kernel = CGAL::Epick_d; using Point_exact_kernel = typename Exact_kernel::Point_d; using Point_inexact_kernel = typename Inexact_kernel::Point_d; @@ -45,31 +45,24 @@ class Alpha_complex_interface { } template - CgalPointType pt_cython_to_cgal(std::vector const& vec) { + static CgalPointType pt_cython_to_cgal(std::vector const& vec) { return CgalPointType(vec.size(), vec.begin(), vec.end()); } public: Alpha_complex_interface(const std::vector>& points, bool fast_version) - : fast_version_(fast_version) { - auto pt = pt_cython_to_cgal(points[0]); + : fast_version_(fast_version) { if (fast_version_) { - auto mkpt = [](std::vector const& vec) { - return Point_inexact_kernel(vec.size(), vec.begin(), vec.end()); - }; - ac_inexact_ptr_ = std::make_unique>(boost::adaptors::transform(points, mkpt)); - //ac_inexact_ptr_ = std::make_unique>(boost::adaptors::transform(points, pt_cython_to_cgal)); + ac_inexact_ptr_ = std::make_unique>( + boost::adaptors::transform(points, pt_cython_to_cgal)); } else { - auto mkpt = [](std::vector const& vec) { - return Point_exact_kernel(vec.size(), vec.begin(), vec.end()); - }; - ac_exact_ptr_ = std::make_unique>(boost::adaptors::transform(points, mkpt)); - //ac_exact_ptr_ = std::make_unique>(boost::adaptors::transform(points, pt_cython_to_cgal)); + ac_exact_ptr_ = std::make_unique>( + boost::adaptors::transform(points, pt_cython_to_cgal)); } } Alpha_complex_interface(const std::string& off_file_name, bool fast_version, bool from_file = true) - : fast_version_(fast_version) { + : fast_version_(fast_version) { if (fast_version_) ac_inexact_ptr_ = std::make_unique>(off_file_name); else @@ -86,8 +79,8 @@ class Alpha_complex_interface { } } - void create_simplex_tree(Simplex_tree_interface<>* simplex_tree, double max_alpha_square, - bool exact_version, bool default_filtration_value) { + void create_simplex_tree(Simplex_tree_interface<>* simplex_tree, double max_alpha_square, bool exact_version, + bool default_filtration_value) { if (fast_version_) ac_inexact_ptr_->create_complex(*simplex_tree, max_alpha_square, exact_version, default_filtration_value); else -- cgit v1.2.3