diff options
author | ROUVREAU Vincent <vincent.rouvreau@inria.fr> | 2020-05-25 08:21:47 +0200 |
---|---|---|
committer | ROUVREAU Vincent <vincent.rouvreau@inria.fr> | 2020-05-25 08:21:47 +0200 |
commit | a7decae3cdf47441cbd72c31e794176dbd3739c4 (patch) | |
tree | b446f56f76714bc88cd6f18b7dc405d8d693a39b /src | |
parent | 78fb7ccd413ca655bdbe4adc9b4b256f20e11fe5 (diff) |
C++ version and documentation
Diffstat (limited to 'src')
-rw-r--r-- | src/python/doc/alpha_complex_user.rst | 21 | ||||
-rw-r--r-- | src/python/include/Alpha_complex_interface.h | 29 |
2 files changed, 30 insertions, 20 deletions
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 <https://gudhi.inria.fr/doc/latest/group__cech__complex.html>`_ and much smaller if + you do not bound the radii. `Čech complex <https://gudhi.inria.fr/doc/latest/group__cech__complex.html>`_ 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<NT>::set_relative_precision_of_to_double <https://doc.cgal.org/latest/Number_types/classCGAL_1_1Lazy__exact__nt.html>`_ + 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 <installation.html#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<CGAL::Dynamic_dimension_tag>; + using Inexact_kernel = CGAL::Epick_d<CGAL::Dynamic_dimension_tag>; 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 <typename CgalPointType> - CgalPointType pt_cython_to_cgal(std::vector<double> const& vec) { + static CgalPointType pt_cython_to_cgal(std::vector<double> const& vec) { return CgalPointType(vec.size(), vec.begin(), vec.end()); } public: Alpha_complex_interface(const std::vector<std::vector<double>>& points, bool fast_version) - : fast_version_(fast_version) { - auto pt = pt_cython_to_cgal<Point_inexact_kernel>(points[0]); + : fast_version_(fast_version) { if (fast_version_) { - auto mkpt = [](std::vector<double> const& vec) { - return Point_inexact_kernel(vec.size(), vec.begin(), vec.end()); - }; - ac_inexact_ptr_ = std::make_unique<Alpha_complex<Inexact_kernel>>(boost::adaptors::transform(points, mkpt)); - //ac_inexact_ptr_ = std::make_unique<Alpha_complex<Inexact_kernel>>(boost::adaptors::transform(points, pt_cython_to_cgal<Point_inexact_kernel>)); + ac_inexact_ptr_ = std::make_unique<Alpha_complex<Inexact_kernel>>( + boost::adaptors::transform(points, pt_cython_to_cgal<Point_inexact_kernel>)); } else { - auto mkpt = [](std::vector<double> const& vec) { - return Point_exact_kernel(vec.size(), vec.begin(), vec.end()); - }; - ac_exact_ptr_ = std::make_unique<Alpha_complex<Exact_kernel>>(boost::adaptors::transform(points, mkpt)); - //ac_exact_ptr_ = std::make_unique<Alpha_complex<Exact_kernel>>(boost::adaptors::transform(points, pt_cython_to_cgal<Point_exact_kernel>)); + ac_exact_ptr_ = std::make_unique<Alpha_complex<Exact_kernel>>( + boost::adaptors::transform(points, pt_cython_to_cgal<Point_exact_kernel>)); } } 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<Alpha_complex<Inexact_kernel>>(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 |