diff options
author | ROUVREAU Vincent <vincent.rouvreau@inria.fr> | 2019-06-12 07:43:43 +0200 |
---|---|---|
committer | ROUVREAU Vincent <vincent.rouvreau@inria.fr> | 2019-06-12 07:43:43 +0200 |
commit | c65eba306f7fe2777f8851edb9fcb2d2592c27d2 (patch) | |
tree | 859605631b2560b22fdc51c450bf83912c2fca39 /src/cython | |
parent | 7e8685458f684f347b2aa6a77a288c249c722f25 (diff) | |
parent | f58f0bb2cb99076d0cd3a11ad39f3277213e3f5e (diff) |
Merge branch 'master' into persistence_intervals_numpy_arrays_vincent
Diffstat (limited to 'src/cython')
23 files changed, 267 insertions, 254 deletions
diff --git a/src/cython/CMakeLists.txt b/src/cython/CMakeLists.txt index 480332d7..d4ace20e 100644 --- a/src/cython/CMakeLists.txt +++ b/src/cython/CMakeLists.txt @@ -138,6 +138,7 @@ if(PYTHONINTERP_FOUND) else() add_gudhi_cython_lib("${Boost_THREAD_LIBRARY_RELEASE}") endif() + message("** Add Boost ${Boost_LIBRARY_DIRS}") set(GUDHI_CYTHON_LIBRARY_DIRS "${GUDHI_CYTHON_LIBRARY_DIRS}'${Boost_LIBRARY_DIRS}', ") endif() # Add CGAL compilation args @@ -148,6 +149,7 @@ if(PYTHONINTERP_FOUND) add_gudhi_debug_info("CGAL version ${CGAL_VERSION}") add_gudhi_cython_lib("${CGAL_LIBRARY}") set(GUDHI_CYTHON_LIBRARY_DIRS "${GUDHI_CYTHON_LIBRARY_DIRS}'${CGAL_LIBRARIES_DIR}', ") + message("** Add CGAL ${CGAL_LIBRARIES_DIR}") # If CGAL is not header only, CGAL library may link with boost system, if(CMAKE_BUILD_TYPE MATCHES Debug) add_gudhi_cython_lib("${Boost_SYSTEM_LIBRARY_DEBUG}") @@ -155,6 +157,7 @@ if(PYTHONINTERP_FOUND) add_gudhi_cython_lib("${Boost_SYSTEM_LIBRARY_RELEASE}") endif() set(GUDHI_CYTHON_LIBRARY_DIRS "${GUDHI_CYTHON_LIBRARY_DIRS}'${Boost_LIBRARY_DIRS}', ") + message("** Add Boost ${Boost_LIBRARY_DIRS}") endif(CGAL_HEADER_ONLY) # GMP and GMPXX are not required, but if present, CGAL will link with them. if(GMP_FOUND) @@ -162,11 +165,13 @@ if(PYTHONINTERP_FOUND) set(GUDHI_CYTHON_EXTRA_COMPILE_ARGS "${GUDHI_CYTHON_EXTRA_COMPILE_ARGS}'-DCGAL_USE_GMP', ") add_gudhi_cython_lib("${GMP_LIBRARIES}") set(GUDHI_CYTHON_LIBRARY_DIRS "${GUDHI_CYTHON_LIBRARY_DIRS}'${GMP_LIBRARIES_DIR}', ") + message("** Add gmp ${GMP_LIBRARIES_DIR}") if(GMPXX_FOUND) add_gudhi_debug_info("GMPXX_LIBRARIES = ${GMPXX_LIBRARIES}") set(GUDHI_CYTHON_EXTRA_COMPILE_ARGS "${GUDHI_CYTHON_EXTRA_COMPILE_ARGS}'-DCGAL_USE_GMPXX', ") add_gudhi_cython_lib("${GMPXX_LIBRARIES}") set(GUDHI_CYTHON_LIBRARY_DIRS "${GUDHI_CYTHON_LIBRARY_DIRS}'${GMPXX_LIBRARIES_DIR}', ") + message("** Add gmpxx ${GMPXX_LIBRARIES_DIR}") endif(GMPXX_FOUND) endif(GMP_FOUND) endif(CGAL_FOUND) @@ -195,6 +200,7 @@ if(PYTHONINTERP_FOUND) add_gudhi_cython_lib("${TBB_MALLOC_RELEASE_LIBRARY}") endif() set(GUDHI_CYTHON_LIBRARY_DIRS "${GUDHI_CYTHON_LIBRARY_DIRS}'${TBB_LIBRARY_DIRS}', ") + message("** Add tbb ${TBB_LIBRARY_DIRS}") set(GUDHI_CYTHON_INCLUDE_DIRS "${GUDHI_CYTHON_INCLUDE_DIRS}'${TBB_INCLUDE_DIRS}', ") endif() diff --git a/src/cython/cython/simplex_tree.pyx b/src/cython/cython/simplex_tree.pyx index ee04589e..43bc11c9 100644 --- a/src/cython/cython/simplex_tree.pyx +++ b/src/cython/cython/simplex_tree.pyx @@ -407,7 +407,8 @@ cdef class SimplexTree: """This function ensures that each simplex has a higher filtration value than its faces by increasing the filtration values. - :returns: The filtration modification information. + :returns: True if any filtration value was modified, + False if the filtration was already non-decreasing. :rtype: bool @@ -515,10 +516,9 @@ cdef class SimplexTree: return np_array(intervals_result) def persistence_pairs(self): - """This function returns the persistence pairs of the simplicial - complex. + """This function returns a list of persistence birth and death simplices pairs. - :returns: The persistence intervals. + :returns: A list of persistence simplices intervals. :rtype: list of pair of list of int :note: persistence_pairs function requires diff --git a/src/cython/cython/strong_witness_complex.pyx b/src/cython/cython/strong_witness_complex.pyx index 74c5cb05..4b7bff34 100644 --- a/src/cython/cython/strong_witness_complex.pyx +++ b/src/cython/cython/strong_witness_complex.pyx @@ -47,8 +47,10 @@ cdef class StrongWitnessComplex: def __init__(self, nearest_landmark_table=None): """StrongWitnessComplex constructor. - :param nearest_landmark_table: A list of nearest landmark. - :type nearest_landmark_table: list of list of pair of unsigned and double + :param nearest_landmark_table: A list of lists of nearest landmarks and their distances. + `nearest_landmark_table[w][k]==(l,d)` means that l is the k-th nearest landmark to + witness w, and d is the (squared) distance between l and w. + :type nearest_landmark_table: list of list of pair of int and float """ # The real cython constructor @@ -65,10 +67,10 @@ cdef class StrongWitnessComplex: """ return self.thisptr != NULL - def create_simplex_tree(self, max_alpha_square, limit_dimension = -1): + def create_simplex_tree(self, max_alpha_square = float('inf'), limit_dimension = -1): """ - :param max_alpha_square: The maximum alpha square threshold the - simplices shall not exceed. Default is set to infinity. + :param max_alpha_square: The maximum relaxation parameter. + Default is set to infinity. :type max_alpha_square: float :returns: A simplex tree created from the Delaunay Triangulation. :rtype: SimplexTree diff --git a/src/cython/cython/witness_complex.pyx b/src/cython/cython/witness_complex.pyx index 8591465a..b1cce83f 100644 --- a/src/cython/cython/witness_complex.pyx +++ b/src/cython/cython/witness_complex.pyx @@ -47,8 +47,10 @@ cdef class WitnessComplex: def __init__(self, nearest_landmark_table=None): """WitnessComplex constructor. - :param nearest_landmark_table: A list of nearest landmark. - :type nearest_landmark_table: list of list of pair of unsigned and double + :param nearest_landmark_table: A list of lists of nearest landmarks and their distances. + `nearest_landmark_table[w][k]==(l,d)` means that l is the k-th nearest landmark to + witness w, and d is the (squared) distance between l and w. + :type nearest_landmark_table: list of list of pair of int and float """ # The real cython constructor @@ -65,10 +67,10 @@ cdef class WitnessComplex: """ return self.thisptr != NULL - def create_simplex_tree(self, max_alpha_square, limit_dimension = -1): + def create_simplex_tree(self, max_alpha_square = float('inf'), limit_dimension = -1): """ - :param max_alpha_square: The maximum alpha square threshold the - simplices shall not exceed. Default is set to infinity. + :param max_alpha_square: The maximum relaxation parameter. + Default is set to infinity. :type max_alpha_square: float :returns: A simplex tree created from the Delaunay Triangulation. :rtype: SimplexTree diff --git a/src/cython/doc/alpha_complex_sum.inc b/src/cython/doc/alpha_complex_sum.inc index 1680a712..806988bb 100644 --- a/src/cython/doc/alpha_complex_sum.inc +++ b/src/cython/doc/alpha_complex_sum.inc @@ -1,22 +1,20 @@ -================================================================= =================================== =================================== -:Author: Vincent Rouvreau :Introduced in: GUDHI 2.0.0 :Copyright: GPL v3 -:Requires: CGAL :math:`\geq` 4.7.0 Eigen3 -================================================================= =================================== =================================== +.. table:: + :widths: 30 50 20 -+----------------------------------------------------------------+------------------------------------------------------------------------+ -| .. figure:: | Alpha_complex is a simplicial complex constructed from the finite | -| ../../doc/Alpha_complex/alpha_complex_representation.png | cells of a Delaunay Triangulation. | -| :alt: Alpha complex representation | | -| :figclass: align-center | The filtration value of each simplex is computed as the square of the | -| | circumradius of the simplex if the circumsphere is empty (the simplex | -| Alpha complex representation | is then said to be Gabriel), and as the minimum of the filtration | -| | values of the codimension 1 cofaces that make it not Gabriel | -| | otherwise. All simplices that have a filtration value strictly | -| | greater than a given alpha squared value are not inserted into the | -| | complex. | -| | | -| | This package requires having CGAL version 4.7 or higher (4.8.1 is | -| | advised for better performance). | -+----------------------------------------------------------------+------------------------------------------------------------------------+ -| :doc:`alpha_complex_user` | :doc:`alpha_complex_ref` | -+----------------------------------------------------------------+------------------------------------------------------------------------+ + +----------------------------------------------------------------+------------------------------------------------------------------------+-----------------------------------------------+ + | .. figure:: | Alpha complex is a simplicial complex constructed from the finite | :Author: Vincent Rouvreau | + | ../../doc/Alpha_complex/alpha_complex_representation.png | cells of a Delaunay Triangulation. | | + | :alt: Alpha complex representation | | :Introduced in: GUDHI 2.0.0 | + | :figclass: align-center | The filtration value of each simplex is computed as the square of the | | + | | circumradius of the simplex if the circumsphere is empty (the simplex | :Copyright: GPL v3 | + | | is then said to be Gabriel), and as the minimum of the filtration | | + | | values of the codimension 1 cofaces that make it not Gabriel | :Requires: Eigen3 and CGAL :math:`\geq` 4.7.0 | + | | otherwise. All simplices that have a filtration value strictly | | + | | greater than a given alpha squared value are not inserted into the | | + | | complex. | | + | | | | + | | This package requires having CGAL version 4.7 or higher (4.8.1 is | | + | | advised for better performance). | | + +----------------------------------------------------------------+------------------------------------------------------------------------+-----------------------------------------------+ + | * :doc:`alpha_complex_user` | * :doc:`alpha_complex_ref` | + +----------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------+ diff --git a/src/cython/doc/bottleneck_distance_sum.inc b/src/cython/doc/bottleneck_distance_sum.inc index 030fad9e..41b9c5a3 100644 --- a/src/cython/doc/bottleneck_distance_sum.inc +++ b/src/cython/doc/bottleneck_distance_sum.inc @@ -1,15 +1,14 @@ -================================================================= =================================== =================================== -:Author: François Godi :Introduced in: GUDHI 2.0.0 :Copyright: GPL v3 -:Requires: CGAL :math:`\geq` 4.8.0 -================================================================= =================================== =================================== +.. table:: + :widths: 30 50 20 -+-----------------------------------------------------------------+----------------------------------------------------------------------+ -| .. figure:: | Bottleneck distance measures the similarity between two persistence | -| ../../doc/Bottleneck_distance/perturb_pd.png | diagrams. It's the shortest distance b for which there exists a | -| :figclass: align-center | perfect matching between the points of the two diagrams (+ all the | -| | diagonal points) such that any couple of matched points are at | -| Bottleneck distance is the length of | distance at most b. | -| the longest edge | | -+-----------------------------------------------------------------+----------------------------------------------------------------------+ -| :doc:`bottleneck_distance_user` | | -+-----------------------------------------------------------------+----------------------------------------------------------------------+ + +-----------------------------------------------------------------+----------------------------------------------------------------------+-----------------------------------------------+ + | .. figure:: | Bottleneck distance measures the similarity between two persistence | :Author: François Godi | + | ../../doc/Bottleneck_distance/perturb_pd.png | diagrams. It's the shortest distance b for which there exists a | | + | :figclass: align-center | perfect matching between the points of the two diagrams (+ all the | :Introduced in: GUDHI 2.0.0 | + | | diagonal points) such that any couple of matched points are at | | + | Bottleneck distance is the length of | distance at most b. | :Copyright: GPL v3 | + | the longest edge | | | + | | | :Requires: CGAL :math:`\geq` 4.8.0 | + +-----------------------------------------------------------------+----------------------------------------------------------------------+-----------------------------------------------+ + | * :doc:`bottleneck_distance_user` | | + +-----------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------+ diff --git a/src/cython/doc/conf.py b/src/cython/doc/conf.py index 4a54d4fd..ce08f679 100755 --- a/src/cython/doc/conf.py +++ b/src/cython/doc/conf.py @@ -125,7 +125,7 @@ html_theme_options = { "sidebarbgcolor": "#A1ADCD", "sidebartextcolor": "black", "sidebarlinkcolor": "#334D5C", - "body_max_width": "1200px", + "body_max_width": "100%", } # Add any paths that contain custom themes here, relative to this directory. diff --git a/src/cython/doc/cubical_complex_sum.inc b/src/cython/doc/cubical_complex_sum.inc index 280ad0e0..6dcf8e48 100644 --- a/src/cython/doc/cubical_complex_sum.inc +++ b/src/cython/doc/cubical_complex_sum.inc @@ -1,15 +1,14 @@ -================================================================= =================================== =================================== -:Author: Pawel Dlotko :Introduced in: GUDHI 2.0.0 :Copyright: GPL v3 -================================================================= =================================== =================================== +.. table:: + :widths: 30 50 20 -+--------------------------------------------------------------------------+----------------------------------------------------------------------+ -| .. figure:: | The cubical complex is an example of a structured complex useful in | -| ../../doc/Bitmap_cubical_complex/Cubical_complex_representation.png | computational mathematics (specially rigorous numerics) and image | -| :alt: Cubical complex representation | analysis. | -| :figclass: align-center | | -| | | -| Cubical complex representation | | -+--------------------------------------------------------------------------+----------------------------------------------------------------------+ -| :doc:`cubical_complex_user` | * :doc:`cubical_complex_ref` | -| | * :doc:`periodic_cubical_complex_ref` | -+--------------------------------------------------------------------------+----------------------------------------------------------------------+ + +--------------------------------------------------------------------------+----------------------------------------------------------------------+-----------------------------+ + | .. figure:: | The cubical complex is an example of a structured complex useful in | :Author: Pawel Dlotko | + | ../../doc/Bitmap_cubical_complex/Cubical_complex_representation.png | computational mathematics (specially rigorous numerics) and image | | + | :alt: Cubical complex representation | analysis. | :Introduced in: GUDHI 2.0.0 | + | :figclass: align-center | | | + | | | :Copyright: GPL v3 | + | | | | + +--------------------------------------------------------------------------+----------------------------------------------------------------------+-----------------------------+ + | * :doc:`cubical_complex_user` | * :doc:`cubical_complex_ref` | + | | * :doc:`periodic_cubical_complex_ref` | + +--------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+ diff --git a/src/cython/doc/fileformats.rst b/src/cython/doc/fileformats.rst index e205cc8b..345dfdba 100644 --- a/src/cython/doc/fileformats.rst +++ b/src/cython/doc/fileformats.rst @@ -5,6 +5,35 @@ File formats ############ +OFF file format +*************** + +OFF files must be conform to format described here: +http://www.geomview.org/docs/html/OFF.html + +OFF files are mainly used as point cloud inputs. Here is an example of 7 points +in a 3-dimensional space. As edges and faces are not used for point set, there +is no need to specify them (just set their numbers to 0): + +.. literalinclude:: ../../data/points/alphacomplexdoc.off + +.. centered:: ../../points/alphacomplexdoc.off + +For dimensions bigger than 3, the dimension can be set like here:: + + # Dimension is no more 3 + nOFF + # dimension 4 - 7 vertices - 0 face - 0 edge + 4 7 0 0 + # Point set: + 1.0 1.0 0.0 0.0 + 7.0 0.0 0.0 0.0 + 4.0 6.0 0.0 0.0 + 9.0 6.0 0.0 0.0 + 0.0 14.0 0.0 0.0 + 2.0 19.0 0.0 0.0 + 9.0 17.0 0.0 0.0 + Persistence Diagram ******************* diff --git a/src/cython/doc/index.rst b/src/cython/doc/index.rst index 15cbe267..e379bc23 100644 --- a/src/cython/doc/index.rst +++ b/src/cython/doc/index.rst @@ -6,80 +6,73 @@ GUDHI Python module documentation :alt: Gudhi banner :figclass: align-center -Introduction -************ - -The Python interface for the Gudhi library (Geometry Understanding in Higher -Dimensions) is a generic open source -`Python module <http://gudhi.gforge.inria.fr/python/latest/>`_, for -Computational Topology and Topological Data Analysis -(`TDA <https://en.wikipedia.org/wiki/Topological_data_analysis>`_). -The GUDHI library intends to help the development of new algorithmic solutions -in TDA and their transfer to applications. It provides robust, efficient, -flexible and easy to use implementations of state-of-the-art algorithms and -data structures. - -The current release of the GUDHI library includes: +Complexes +********* -* Data structures to represent, construct and manipulate simplicial complexes. -* Simplification of simplicial complexes by edge contraction. -* Algorithms to compute persistent homology and bottleneck distance. +Cubical complexes +================= -We refer to :cite:`gudhilibrary_ICMS14` for a detailed description of the -design of the library. +.. include:: cubical_complex_sum.inc -Data structures -*************** +Simplicial complexes +==================== Alpha complex -============= +------------- .. include:: alpha_complex_sum.inc -Cover complexes -=============== +Rips complex +------------- + +.. include:: rips_complex_sum.inc -.. include:: nerve_gic_complex_sum.rst +Witness complex +--------------- -Cubical complex +.. include:: witness_complex_sum.inc + +Cover complexes =============== -.. include:: cubical_complex_sum.inc +.. include:: nerve_gic_complex_sum.inc -Rips complex -============ +Data structures and basic operations +************************************ -.. include:: rips_complex_sum.inc +Data structures +=============== Simplex tree -============ +------------ .. include:: simplex_tree_sum.inc +Topological descriptors computation +*********************************** + +Persistence cohomology +====================== + +.. include:: persistent_cohomology_sum.inc + +Manifold reconstruction +*********************** + Tangential complex ================== .. include:: tangential_complex_sum.inc -Witness complex -=============== - -.. include:: witness_complex_sum.inc - -Toolbox -******* +Topological descriptors tools +***************************** Bottleneck distance =================== .. include:: bottleneck_distance_sum.inc -Persistence cohomology -====================== - -.. include:: persistent_cohomology_sum.inc - Persistence graphical tools =========================== diff --git a/src/cython/doc/nerve_gic_complex_sum.inc b/src/cython/doc/nerve_gic_complex_sum.inc new file mode 100644 index 00000000..0e606fe1 --- /dev/null +++ b/src/cython/doc/nerve_gic_complex_sum.inc @@ -0,0 +1,16 @@ +.. table:: + :widths: 30 50 20 + + +----------------------------------------------------------------+------------------------------------------------------------------------+------------------------------------+ + | .. figure:: | Nerves and Graph Induced Complexes are cover complexes, i.e. | :Author: Mathieu Carrière | + | ../../doc/Nerve_GIC/gicvisu.jpg | simplicial complexes that provably contain topological information | | + | :alt: Graph Induced Complex of a point cloud. | about the input data. They can be computed with a cover of the data, | :Introduced in: GUDHI 2.3.0 | + | :figclass: align-center | that comes i.e. from the preimage of a family of intervals covering | | + | | the image of a scalar-valued function defined on the data. | :Copyright: GPL v3 | + | | | | + | | | :Requires: CGAL :math:`\geq` 4.8.1 | + | | | | + | | | | + +----------------------------------------------------------------+------------------------------------------------------------------------+------------------------------------+ + | * :doc:`nerve_gic_complex_user` | * :doc:`nerve_gic_complex_ref` | + +----------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------+ diff --git a/src/cython/doc/nerve_gic_complex_sum.rst b/src/cython/doc/nerve_gic_complex_sum.rst deleted file mode 100644 index 523c119f..00000000 --- a/src/cython/doc/nerve_gic_complex_sum.rst +++ /dev/null @@ -1,15 +0,0 @@ -================================================================= =================================== =================================== -:Author: Mathieu Carrière :Introduced in: GUDHI 2.3.0 :Copyright: GPL v3 -:Requires: CGAL :math:`\geq` 4.8.1 -================================================================= =================================== =================================== - -+----------------------------------------------------------------+------------------------------------------------------------------------+ -| .. figure:: | Nerves and Graph Induced Complexes are cover complexes, i.e. | -| ../../doc/Nerve_GIC/gicvisu.jpg | simplicial complexes that provably contain topological information | -| :alt: Graph Induced Complex of a point cloud. | about the input data. They can be computed with a cover of the data, | -| :figclass: align-center | that comes i.e. from the preimage of a family of intervals covering | -| | the image of a scalar-valued function defined on the data. | -| Graph Induced Complex of a point cloud. | | -+----------------------------------------------------------------+------------------------------------------------------------------------+ -| :doc:`nerve_gic_complex_user` | :doc:`nerve_gic_complex_ref` | -+----------------------------------------------------------------+------------------------------------------------------------------------+ diff --git a/src/cython/doc/nerve_gic_complex_user.rst b/src/cython/doc/nerve_gic_complex_user.rst index 44f30e1a..9101f45d 100644 --- a/src/cython/doc/nerve_gic_complex_user.rst +++ b/src/cython/doc/nerve_gic_complex_user.rst @@ -7,14 +7,13 @@ Cover complexes user manual Definition ---------- -.. include:: nerve_gic_complex_sum.rst +.. include:: nerve_gic_complex_sum.inc Visualizations of the simplicial complexes can be done with either neato (from `graphviz <http://www.graphviz.org/>`_), `geomview <http://www.geomview.org/>`_, `KeplerMapper <https://github.com/MLWave/kepler-mapper>`_. -Input point clouds are assumed to be -`OFF files <http://www.geomview.org/docs/html/OFF.html>`_. +Input point clouds are assumed to be OFF files (cf. :doc:`fileformats`). Covers ------ diff --git a/src/cython/doc/persistence_graphical_tools_sum.inc b/src/cython/doc/persistence_graphical_tools_sum.inc index 5577cf99..b412de56 100644 --- a/src/cython/doc/persistence_graphical_tools_sum.inc +++ b/src/cython/doc/persistence_graphical_tools_sum.inc @@ -1,12 +1,14 @@ -================================================================= =================================== =================================== -:Author: Vincent Rouvreau :Introduced in: GUDHI 2.0.0 :Copyright: GPL v3 -:Requires: matplotlib numpy scipy -================================================================= =================================== =================================== +.. table:: + :widths: 30 50 20 -+-----------------------------------------------------------------+-----------------------------------------------------------------------+ -| .. figure:: | These graphical tools comes on top of persistence results and allows | -| img/graphical_tools_representation.png | the user to build easily persistence barcode, diagram or density. | -| | | -+-----------------------------------------------------------------+-----------------------------------------------------------------------+ -| :doc:`persistence_graphical_tools_user` | :doc:`persistence_graphical_tools_ref` | -+-----------------------------------------------------------------+-----------------------------------------------------------------------+ + +-----------------------------------------------------------------+-----------------------------------------------------------------------+-----------------------------------------------+ + | .. figure:: | These graphical tools comes on top of persistence results and allows | :Author: Vincent Rouvreau | + | img/graphical_tools_representation.png | the user to build easily persistence barcode, diagram or density. | | + | | | :Introduced in: GUDHI 2.0.0 | + | | | | + | | | :Copyright: GPL v3 | + | | | | + | | | :Requires: matplotlib, numpy and scipy | + +-----------------------------------------------------------------+-----------------------------------------------------------------------+-----------------------------------------------+ + | * :doc:`persistence_graphical_tools_user` | * :doc:`persistence_graphical_tools_ref` | + +-----------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------+ diff --git a/src/cython/doc/persistent_cohomology_sum.inc b/src/cython/doc/persistent_cohomology_sum.inc index a26df1dc..20ca073c 100644 --- a/src/cython/doc/persistent_cohomology_sum.inc +++ b/src/cython/doc/persistent_cohomology_sum.inc @@ -1,27 +1,26 @@ -================================================================= =================================== =================================== -:Author: Clément Maria :Introduced in: GUDHI 2.0.0 :Copyright: GPL v3 -================================================================= =================================== =================================== +.. table:: + :widths: 30 50 20 -+-----------------------------------------------------------------+-----------------------------------------------------------------------+ -| .. figure:: | The theory of homology consists in attaching to a topological space | -| ../../doc/Persistent_cohomology/3DTorus_poch.png | a sequence of (homology) groups, capturing global topological | -| :figclass: align-center | features like connected components, holes, cavities, etc. Persistent | -| | homology studies the evolution -- birth, life and death -- of these | -| Rips Persistent Cohomology on a 3D | features when the topological space is changing. Consequently, the | -| Torus | theory is essentially composed of three elements: topological spaces, | -| | their homology groups and an evolution scheme. | -| | | -| | Computation of persistent cohomology using the algorithm of | -| | :cite:`DBLP:journals/dcg/SilvaMV11` and | -| | :cite:`DBLP:journals/corr/abs-1208-5018` and the Compressed | -| | Annotation Matrix implementation of | -| | :cite:`DBLP:conf/esa/BoissonnatDM13`. | -| | | -+-----------------------------------------------------------------+-----------------------------------------------------------------------+ -| :doc:`persistent_cohomology_user` | Please refer to each data structure that contains persistence | -| | feature for reference: | -| | | -| | * :doc:`simplex_tree_ref` | -| | * :doc:`cubical_complex_ref` | -| | * :doc:`periodic_cubical_complex_ref` | -+-----------------------------------------------------------------+-----------------------------------------------------------------------+ + +-----------------------------------------------------------------+-----------------------------------------------------------------------+-----------------------------------------------+ + | .. figure:: | The theory of homology consists in attaching to a topological space | :Author: Clément Maria | + | ../../doc/Persistent_cohomology/3DTorus_poch.png | a sequence of (homology) groups, capturing global topological | | + | :figclass: align-center | features like connected components, holes, cavities, etc. Persistent | :Introduced in: GUDHI 2.0.0 | + | | homology studies the evolution -- birth, life and death -- of these | | + | Rips Persistent Cohomology on a 3D | features when the topological space is changing. Consequently, the | :Copyright: GPL v3 | + | Torus | theory is essentially composed of three elements: topological spaces, | | + | | their homology groups and an evolution scheme. | | + | | | | + | | Computation of persistent cohomology using the algorithm of | | + | | :cite:`DBLP:journals/dcg/SilvaMV11` and | | + | | :cite:`DBLP:journals/corr/abs-1208-5018` and the Compressed | | + | | Annotation Matrix implementation of | | + | | :cite:`DBLP:conf/esa/BoissonnatDM13`. | | + | | | | + +-----------------------------------------------------------------+-----------------------------------------------------------------------+-----------------------------------------------+ + | * :doc:`persistent_cohomology_user` | Please refer to each data structure that contains persistence | + | | feature for reference: | + | | | + | | * :doc:`simplex_tree_ref` | + | | * :doc:`cubical_complex_ref` | + | | * :doc:`periodic_cubical_complex_ref` | + +-----------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------+ diff --git a/src/cython/doc/rips_complex_sum.inc b/src/cython/doc/rips_complex_sum.inc index ea26769a..e8e505e2 100644 --- a/src/cython/doc/rips_complex_sum.inc +++ b/src/cython/doc/rips_complex_sum.inc @@ -1,17 +1,16 @@ -===================================================================== =========================== =================================== -:Author: Clément Maria, Pawel Dlotko, Vincent Rouvreau, Marc Glisse :Introduced in: GUDHI 2.0.0 :Copyright: GPL v3 -===================================================================== =========================== =================================== +.. table:: + :widths: 30 50 20 -+----------------------------------------------------------------+------------------------------------------------------------------------+ -| .. figure:: | Rips complex is a simplicial complex constructed from a one skeleton | -| ../../doc/Rips_complex/rips_complex_representation.png | graph. | -| :figclass: align-center | | -| | The filtration value of each edge is computed from a user-given | -| Rips complex representation | distance function and is inserted until a user-given threshold | -| | value. | -| | | -| | This complex can be built from a point cloud and a distance function, | -| | or from a distance matrix. | -+----------------------------------------------------------------+------------------------------------------------------------------------+ -| :doc:`rips_complex_user` | :doc:`rips_complex_ref` | -+----------------------------------------------------------------+------------------------------------------------------------------------+ + +----------------------------------------------------------------+------------------------------------------------------------------------+----------------------------------------------------------------------+ + | .. figure:: | Rips complex is a simplicial complex constructed from a one skeleton | :Authors: Clément Maria, Pawel Dlotko, Vincent Rouvreau, Marc Glisse | + | ../../doc/Rips_complex/rips_complex_representation.png | graph. | | + | :figclass: align-center | | :Introduced in: GUDHI 2.0.0 | + | | The filtration value of each edge is computed from a user-given | | + | | distance function and is inserted until a user-given threshold | :Copyright: GPL v3 | + | | value. | | + | | | | + | | This complex can be built from a point cloud and a distance function, | | + | | or from a distance matrix. | | + +----------------------------------------------------------------+------------------------------------------------------------------------+----------------------------------------------------------------------+ + | * :doc:`rips_complex_user` | * :doc:`rips_complex_ref` | + +----------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------+ diff --git a/src/cython/doc/rips_complex_user.rst b/src/cython/doc/rips_complex_user.rst index e814b4c3..1d340dbe 100644 --- a/src/cython/doc/rips_complex_user.rst +++ b/src/cython/doc/rips_complex_user.rst @@ -50,8 +50,8 @@ by more than the length used to define "too close". A more general technique is to use a sparse approximation of the Rips introduced by Don Sheehy :cite:`sheehy13linear`. We are using the version described in :cite:`buchet16efficient` (except that we multiply all filtration -values by 2, to match the usual Rips complex), which proves a -:math:`\frac{1+\varepsilon}{1-\varepsilon}`-interleaving, although in practice the +values by 2, to match the usual Rips complex). :cite:`cavanna15geometric` proves +a :math:`\frac{1}{1-\varepsilon}`-interleaving, although in practice the error is usually smaller. A more intuitive presentation of the idea is available in :cite:`cavanna15geometric`, and in a video :cite:`cavanna15visualizing`. Passing an extra argument `sparse=0.3` at the diff --git a/src/cython/doc/simplex_tree_sum.inc b/src/cython/doc/simplex_tree_sum.inc index fb0e54c1..086c69d5 100644 --- a/src/cython/doc/simplex_tree_sum.inc +++ b/src/cython/doc/simplex_tree_sum.inc @@ -1,14 +1,13 @@ -================================================================= =================================== =================================== -:Author: Clément Maria :Introduced in: GUDHI 2.0.0 :Copyright: GPL v3 -================================================================= =================================== =================================== +.. table:: + :widths: 30 50 20 -+----------------------------------------------------------------+------------------------------------------------------------------------+ -| .. figure:: | The simplex tree is an efficient and flexible data structure for | -| ../../doc/Simplex_tree/Simplex_tree_representation.png | representing general (filtered) simplicial complexes. | -| :alt: Simplex tree representation | | -| :figclass: align-center | The data structure is described in | -| | :cite:`boissonnatmariasimplextreealgorithmica` | -| Simplex tree representation | | -+----------------------------------------------------------------+------------------------------------------------------------------------+ -| :doc:`simplex_tree_user` | :doc:`simplex_tree_ref` | -+----------------------------------------------------------------+------------------------------------------------------------------------+ + +----------------------------------------------------------------+------------------------------------------------------------------------+-----------------------------+ + | .. figure:: | The simplex tree is an efficient and flexible data structure for | :Author: Clément Maria | + | ../../doc/Simplex_tree/Simplex_tree_representation.png | representing general (filtered) simplicial complexes. | | + | :alt: Simplex tree representation | | :Introduced in: GUDHI 2.0.0 | + | :figclass: align-center | The data structure is described in | | + | | :cite:`boissonnatmariasimplextreealgorithmica` | :Copyright: GPL v3 | + | | | | + +----------------------------------------------------------------+------------------------------------------------------------------------+-----------------------------+ + | * :doc:`simplex_tree_user` | * :doc:`simplex_tree_ref` | + +----------------------------------------------------------------+------------------------------------------------------------------------------------------------------+ diff --git a/src/cython/doc/tangential_complex_sum.inc b/src/cython/doc/tangential_complex_sum.inc index 72b4d7ba..0f03ffb3 100644 --- a/src/cython/doc/tangential_complex_sum.inc +++ b/src/cython/doc/tangential_complex_sum.inc @@ -1,15 +1,14 @@ -================================================================= =================================== =================================== -:Author: Clément Jamin :Introduced in: GUDHI 2.0.0 :Copyright: GPL v3 -:Requires: CGAL :math:`\geq` 4.8.0 Eigen3 -================================================================= =================================== =================================== +.. table:: + :widths: 30 50 20 -+----------------------------------------------------------------+------------------------------------------------------------------------+ -| .. figure:: | A Tangential Delaunay complex is a simplicial complex designed to | -| ../../doc/Tangential_complex/tc_examples.png | reconstruct a :math:`k`-dimensional manifold embedded in :math:`d`- | -| :figclass: align-center | dimensional Euclidean space. The input is a point sample coming from | -| | an unknown manifold. The running time depends only linearly on the | -| Tangential complex representation | extrinsic dimension :math:`d` and exponentially on the intrinsic | -| | dimension :math:`k`. | -+----------------------------------------------------------------+------------------------------------------------------------------------+ -| :doc:`tangential_complex_user` | :doc:`tangential_complex_ref` | -+----------------------------------------------------------------+------------------------------------------------------------------------+ + +----------------------------------------------------------------+------------------------------------------------------------------------+------------------------------------+ + | .. figure:: | A Tangential Delaunay complex is a simplicial complex designed to | :Author: Clément Jamin | + | ../../doc/Tangential_complex/tc_examples.png | reconstruct a :math:`k`-dimensional manifold embedded in :math:`d`- | | + | :figclass: align-center | dimensional Euclidean space. The input is a point sample coming from | :Introduced in: GUDHI 2.0.0 | + | | an unknown manifold. The running time depends only linearly on the | | + | | extrinsic dimension :math:`d` and exponentially on the intrinsic | :Copyright: GPL v3 | + | | dimension :math:`k`. | | + | | | :Requires: CGAL :math:`\geq` 4.8.0 | + +----------------------------------------------------------------+------------------------------------------------------------------------+------------------------------------+ + | * :doc:`tangential_complex_user` | * :doc:`tangential_complex_ref` | + +----------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------+ diff --git a/src/cython/doc/witness_complex_sum.inc b/src/cython/doc/witness_complex_sum.inc index a8a126a0..49577745 100644 --- a/src/cython/doc/witness_complex_sum.inc +++ b/src/cython/doc/witness_complex_sum.inc @@ -1,19 +1,17 @@ -================================================================= =================================== =================================== -:Author: Siargey Kachanovich :Introduced in: GUDHI 2.0.0 :Copyright: GPL v3 -:Euclidean version requires: CGAL :math:`\geq` 4.6.0 Eigen3 -================================================================= =================================== =================================== +.. table:: + :widths: 30 50 20 -+-------------------------------------------------------------------+----------------------------------------------------------------------+ -| .. figure:: | Witness complex :math:`Wit(W,L)` is a simplicial complex defined on | -| ../../doc/Witness_complex/Witness_complex_representation.png | two sets of points in :math:`\mathbb{R}^D`. | -| :alt: Witness complex representation | | -| :figclass: align-center | The data structure is described in | -| | :cite:`boissonnatmariasimplextreealgorithmica`. | -| | | -| Witness complex representation | | -+-------------------------------------------------------------------+----------------------------------------------------------------------+ -| :doc:`witness_complex_user` | * :doc:`witness_complex_ref` | -| | * :doc:`strong_witness_complex_ref` | -| | * :doc:`euclidean_witness_complex_ref` | -| | * :doc:`euclidean_strong_witness_complex_ref` | -+-------------------------------------------------------------------+----------------------------------------------------------------------+ + +-------------------------------------------------------------------+----------------------------------------------------------------------+-----------------------------------------------------------------------------+ + | .. figure:: | Witness complex :math:`Wit(W,L)` is a simplicial complex defined on | :Author: Siargey Kachanovich | + | ../../doc/Witness_complex/Witness_complex_representation.png | two sets of points in :math:`\mathbb{R}^D`. | | + | :alt: Witness complex representation | | :Introduced in: GUDHI 2.0.0 | + | :figclass: align-center | The data structure is described in | | + | | :cite:`boissonnatmariasimplextreealgorithmica`. | :Copyright: GPL v3 | + | | | | + | | | :Requires: Eigen3 and CGAL :math:`\geq` 4.6.0 for Euclidean versions only | + +-------------------------------------------------------------------+----------------------------------------------------------------------+-----------------------------------------------------------------------------+ + | * :doc:`witness_complex_user` | * :doc:`witness_complex_ref` | + | | * :doc:`strong_witness_complex_ref` | + | | * :doc:`euclidean_witness_complex_ref` | + | | * :doc:`euclidean_strong_witness_complex_ref` | + +-------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------+ diff --git a/src/cython/example/witness_complex_from_nearest_landmark_table.py b/src/cython/example/witness_complex_from_nearest_landmark_table.py index e6b295ee..1b79d9b2 100755 --- a/src/cython/example/witness_complex_from_nearest_landmark_table.py +++ b/src/cython/example/witness_complex_from_nearest_landmark_table.py @@ -30,14 +30,14 @@ __license__ = "GPL v3" print("#####################################################################") print("WitnessComplex creation from nearest landmark table") -nearest_landmark_table = [[[0, 0], [1, 1], [2, 2], [3, 3], [4, 4]], - [[1, 0], [2, 1], [3, 2], [4, 3], [0, 4]], - [[2, 0], [3, 1], [4, 2], [0, 3], [1, 4]], - [[3, 0], [4, 1], [0, 2], [1, 3], [2, 4]], - [[4, 0], [0, 1], [1, 2], [2, 3], [3, 4]]] +nearest_landmark_table = [[[0, 0.0], [1, 0.1], [2, 0.2], [3, 0.3], [4, 0.4]], + [[1, 0.0], [2, 0.1], [3, 0.2], [4, 0.3], [0, 0.4]], + [[2, 0.0], [3, 0.1], [4, 0.2], [0, 0.3], [1, 0.4]], + [[3, 0.0], [4, 0.1], [0, 0.2], [1, 0.3], [2, 0.4]], + [[4, 0.0], [0, 0.1], [1, 0.2], [2, 0.3], [3, 0.4]]] witness_complex = StrongWitnessComplex(nearest_landmark_table=nearest_landmark_table) -simplex_tree = witness_complex.create_simplex_tree(max_alpha_square=4.1) +simplex_tree = witness_complex.create_simplex_tree(max_alpha_square=0.41) message = "Number of simplices: " + repr(simplex_tree.num_simplices()) print(message) diff --git a/src/cython/include/Rips_complex_interface.h b/src/cython/include/Rips_complex_interface.h index 1a6e2477..40aff299 100644 --- a/src/cython/include/Rips_complex_interface.h +++ b/src/cython/include/Rips_complex_interface.h @@ -54,23 +54,17 @@ class Rips_complex_interface { } void init_points_sparse(const std::vector<std::vector<double>>& points, double threshold, double epsilon) { - sparse_rips_complex_.emplace(points, Gudhi::Euclidean_distance(), epsilon); - threshold_ = threshold; + sparse_rips_complex_.emplace(points, Gudhi::Euclidean_distance(), epsilon, -std::numeric_limits<double>::infinity(), threshold); } void init_matrix_sparse(const std::vector<std::vector<double>>& matrix, double threshold, double epsilon) { - sparse_rips_complex_.emplace(matrix, epsilon); - threshold_ = threshold; + sparse_rips_complex_.emplace(matrix, epsilon, -std::numeric_limits<double>::infinity(), threshold); } void create_simplex_tree(Simplex_tree_interface<>* simplex_tree, int dim_max) { if (rips_complex_) rips_complex_->create_complex(*simplex_tree, dim_max); - else { + else sparse_rips_complex_->create_complex(*simplex_tree, dim_max); - // This pruning should be done much earlier! It isn't that useful for sparse Rips, - // but it would be inconsistent not to do it. - simplex_tree->prune_above_filtration(threshold_); - } simplex_tree->initialize_filtration(); } @@ -79,7 +73,6 @@ class Rips_complex_interface { // Anyway, storing a graph would make more sense. Or changing the interface completely so there is no such storage. boost::optional<Rips_complex<Simplex_tree_interface<>::Filtration_value>> rips_complex_; boost::optional<Sparse_rips_complex<Simplex_tree_interface<>::Filtration_value>> sparse_rips_complex_; - double threshold_; }; } // namespace rips_complex diff --git a/src/cython/include/Simplex_tree_interface.h b/src/cython/include/Simplex_tree_interface.h index 3481eeff..ca98517d 100644 --- a/src/cython/include/Simplex_tree_interface.h +++ b/src/cython/include/Simplex_tree_interface.h @@ -45,7 +45,7 @@ class Simplex_tree_interface : public Simplex_tree<SimplexTreeOptions> { using Simplex_handle = typename Base::Simplex_handle; using Insertion_result = typename std::pair<Simplex_handle, bool>; using Simplex = std::vector<Vertex_handle>; - using Complex = std::vector<std::pair<Simplex, Filtration_value>>; + using Filtered_simplices = std::vector<std::pair<Simplex, Filtration_value>>; public: bool find_simplex(const Simplex& vh) { @@ -94,9 +94,9 @@ class Simplex_tree_interface : public Simplex_tree<SimplexTreeOptions> { Base::initialize_filtration(); } - Complex get_filtration() { + Filtered_simplices get_filtration() { Base::initialize_filtration(); - Complex filtrations; + Filtered_simplices filtrations; for (auto f_simplex : Base::filtration_simplex_range()) { Simplex simplex; for (auto vertex : Base::simplex_vertex_range(f_simplex)) { @@ -107,8 +107,8 @@ class Simplex_tree_interface : public Simplex_tree<SimplexTreeOptions> { return filtrations; } - Complex get_skeleton(int dimension) { - Complex skeletons; + Filtered_simplices get_skeleton(int dimension) { + Filtered_simplices skeletons; for (auto f_simplex : Base::skeleton_simplex_range(dimension)) { Simplex simplex; for (auto vertex : Base::simplex_vertex_range(f_simplex)) { @@ -119,29 +119,25 @@ class Simplex_tree_interface : public Simplex_tree<SimplexTreeOptions> { return skeletons; } - Complex get_star(const Simplex& simplex) { - Complex star; + Filtered_simplices get_star(const Simplex& simplex) { + Filtered_simplices star; for (auto f_simplex : Base::star_simplex_range(Base::find(simplex))) { Simplex simplex_star; for (auto vertex : Base::simplex_vertex_range(f_simplex)) { - std::cout << vertex << " "; simplex_star.insert(simplex_star.begin(), vertex); } - std::cout << std::endl; star.push_back(std::make_pair(simplex_star, Base::filtration(f_simplex))); } return star; } - Complex get_cofaces(const Simplex& simplex, int dimension) { - Complex cofaces; + Filtered_simplices get_cofaces(const Simplex& simplex, int dimension) { + Filtered_simplices cofaces; for (auto f_simplex : Base::cofaces_simplex_range(Base::find(simplex), dimension)) { Simplex simplex_coface; for (auto vertex : Base::simplex_vertex_range(f_simplex)) { - std::cout << vertex << " "; simplex_coface.insert(simplex_coface.begin(), vertex); } - std::cout << std::endl; cofaces.push_back(std::make_pair(simplex_coface, Base::filtration(f_simplex))); } return cofaces; |