From 5b6bebd9a8072d8998b0c741e5b40de0cfe5dc8e Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Fri, 12 Aug 2016 15:29:48 +0000 Subject: Move cython/src/* in cython/ git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/ST_cythonize@1436 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 8f971ef16ef6df597d5d3667db0eecbca94233b2 --- src/cython/doc/alpha_complex_sum.rst | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/cython/doc/alpha_complex_sum.rst (limited to 'src/cython/doc/alpha_complex_sum.rst') diff --git a/src/cython/doc/alpha_complex_sum.rst b/src/cython/doc/alpha_complex_sum.rst new file mode 100644 index 00000000..b608050e --- /dev/null +++ b/src/cython/doc/alpha_complex_sum.rst @@ -0,0 +1,21 @@ +===================================== ===================================== ===================================== +:Author: Vincent Rouvreau :Introduced in: GUDHI PYTHON 1.4.0 :Copyright: GPL v3 +===================================== ===================================== ===================================== + ++-------------------------------------------+----------------------------------------------------------------------+ +| .. image:: | Alpha_complex is a simplicial complex constructed from the finite | +| img/alpha_complex_representation.png | cells of a Delaunay Triangulation. | +| | | +| | The filtration value of each simplex is computed as the square of the| +| | circumradius of the simplex if the circumsphere is empty (the simplex| +| | 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 perfomances). | ++-------------------------------------------+----------------------------------------------------------------------+ +| :doc:`alpha_complex_user` | :doc:`alpha_complex_ref` | ++-------------------------------------------+----------------------------------------------------------------------+ -- cgit v1.2.3 From f843ef3f8e4ab4ce94a28ded6d8cafd37f2b2311 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Wed, 23 Nov 2016 11:49:15 +0000 Subject: Add tangential complex git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/ST_cythonize@1773 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: b47285aafaa430c883c8fe5432ac667d6cedaf37 --- src/cython/CMakeLists.txt | 10 +- src/cython/cython/alpha_complex.pyx | 2 +- src/cython/cython/tangential_complex.pyx | 363 +++++++++++++++++++++ src/cython/cythonize_gudhi.py.in | 4 +- src/cython/doc/alpha_complex_sum.rst | 2 +- src/cython/doc/persistence_graphical_tools_ref.rst | 8 +- src/cython/doc/persistence_graphical_tools_sum.rst | 4 +- src/cython/gudhi.pyx.in | 5 +- src/cython/include/Tangential_complex_interface.h | 220 +++++++++++++ 9 files changed, 602 insertions(+), 16 deletions(-) create mode 100644 src/cython/cython/tangential_complex.pyx create mode 100644 src/cython/include/Tangential_complex_interface.h (limited to 'src/cython/doc/alpha_complex_sum.rst') diff --git a/src/cython/CMakeLists.txt b/src/cython/CMakeLists.txt index 81fbe8fe..09ebb678 100644 --- a/src/cython/CMakeLists.txt +++ b/src/cython/CMakeLists.txt @@ -45,8 +45,8 @@ if(PYTHON_PATH AND CYTHON_PATH) file(COPY test DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) if (CGAL_FOUND) - if (NOT CGAL_VERSION VERSION_LESS 4.7.0) - # If CGAL_VERSION >= 4.7.0, include alpha complex + if (NOT CGAL_VERSION VERSION_LESS 4.8.0) + # If CGAL_VERSION >= 4.8.0, include alpha complex set(GUDHI_CYTHON_LIBRARIES "${GUDHI_CYTHON_LIBRARIES}'CGAL', ") set(GUDHI_CYTHON_LIBRARY_DIRS "${GUDHI_CYTHON_LIBRARY_DIRS}'${CGAL_LIBRARIES_DIR}', ") # GMP and GMPXX are not required, but if present, CGAL will link with them. @@ -62,10 +62,12 @@ if(PYTHON_PATH AND CYTHON_PATH) endif(GMP_FOUND) set(GUDHI_CYTHON_ALPHA_COMPLEX "include 'cython/alpha_complex.pyx'") - else (NOT CGAL_VERSION VERSION_LESS 4.7.0) + set(GUDHI_CYTHON_TANGENTIAL_COMPLEX "include 'cython/tangential_complex.pyx'") + else (NOT CGAL_VERSION VERSION_LESS 4.8.0) # Remove alpha complex unitary tests file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/test/test_alpha_complex.py) - endif (NOT CGAL_VERSION VERSION_LESS 4.7.0) + file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/test/test_tangential_complex.py) + endif (NOT CGAL_VERSION VERSION_LESS 4.8.0) endif (CGAL_FOUND) # Loop on INCLUDE_DIRECTORIES PROPERTY diff --git a/src/cython/cython/alpha_complex.pyx b/src/cython/cython/alpha_complex.pyx index af609863..85771300 100644 --- a/src/cython/cython/alpha_complex.pyx +++ b/src/cython/cython/alpha_complex.pyx @@ -32,7 +32,7 @@ __copyright__ = "Copyright (C) 2016 INRIA" __license__ = "GPL v3" cdef extern from "Alpha_complex_interface.h" namespace "Gudhi": - cdef cppclass Alpha_complex_interface "Gudhi::alphacomplex::Alpha_complex_interface": + cdef cppclass Alpha_complex_interface "Gudhi::alpha_complex::Alpha_complex_interface": Alpha_complex_interface(vector[vector[double]] points, double max_alpha_square) # bool from_file is a workaround for cython to find the correct signature Alpha_complex_interface(string off_file, double max_alpha_square, bool from_file) diff --git a/src/cython/cython/tangential_complex.pyx b/src/cython/cython/tangential_complex.pyx new file mode 100644 index 00000000..01782004 --- /dev/null +++ b/src/cython/cython/tangential_complex.pyx @@ -0,0 +1,363 @@ +from cython cimport numeric +from libcpp.vector cimport vector +from libcpp.utility cimport pair +from libcpp.string cimport string +from libcpp cimport bool +import os + +"""This file is part of the Gudhi Library. The Gudhi library + (Geometric Understanding in Higher Dimensions) is a generic C++ + library for computational topology. + + Author(s): Vincent Rouvreau + + Copyright (C) 2016 INRIA + + 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 . +""" + +__author__ = "Vincent Rouvreau" +__copyright__ = "Copyright (C) 2016 INRIA" +__license__ = "GPL v3" + +cdef extern from "Tangential_complex_interface.h" namespace "Gudhi": + cdef cppclass Tangential_complex_interface "Gudhi::tangential_complex::Tangential_complex_interface": + Tangential_complex_interface(vector[vector[double]] points, double max_alpha_square) + # bool from_file is a workaround for cython to find the correct signature + Tangential_complex_interface(string off_file, double max_alpha_square, bool from_file) + double filtration() + double simplex_filtration(vector[int] simplex) + void set_filtration(double filtration) + void initialize_filtration() + int num_vertices() + int num_simplices() + void set_dimension(int dimension) + int dimension() + bint find_simplex(vector[int] simplex) + bint insert_simplex_and_subfaces(vector[int] simplex, + double filtration) + vector[pair[vector[int], double]] get_filtered_tree() + vector[pair[vector[int], double]] get_skeleton_tree(int dimension) + vector[pair[vector[int], double]] get_star_tree(vector[int] simplex) + vector[pair[vector[int], double]] get_coface_tree(vector[int] simplex, + int dimension) + void remove_maximal_simplex(vector[int] simplex) + vector[double] get_point(int vertex) + vector[pair[int, pair[double, double]]] get_persistence(int homology_coeff_field, double min_persistence) + vector[int] get_betti_numbers() + vector[int] get_persistent_betti_numbers(double from_value, double to_value) + +# TangentialComplex python interface +cdef class TangentialComplex: + """TangentialComplex is a simplicial complex constructed from the finite cells + of a Delaunay Triangulation. + + The filtration value of each simplex is computed as the square of the + circumradius of the simplex if the circumsphere is empty (the simplex 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. + + .. note:: + + When Tangential_complex is constructed with an infinite value of alpha, the + complex is a Delaunay complex. + + """ + + cdef Tangential_complex_interface * thisptr + + # Fake constructor that does nothing but documenting the constructor + def __init__(self, points=None, off_file='', max_alpha_square=float('inf')): + """TangentialComplex constructor. + + :param points: A list of points in d-Dimension. + :type points: list of list of double + + Or + + :param off_file: An OFF file style name. + :type off_file: string + + :param max_alpha_square: Maximum Tangential square value. Default is :math:`\infty` + :type max_alpha_square: double + """ + + # The real cython constructor + def __cinit__(self, points=[], off_file='', max_alpha_square=float('inf')): + if off_file is not '': + if os.path.isfile(off_file): + self.thisptr = new Tangential_complex_interface(off_file, + max_alpha_square, True) + else: + print("file " + off_file + " not found.") + else: + self.thisptr = new Tangential_complex_interface(points, + max_alpha_square) + + + def __dealloc__(self): + if self.thisptr != NULL: + del self.thisptr + + def __is_defined(self): + """Returns true if TangentialComplex pointer is not NULL. + """ + return self.thisptr != NULL + + def get_filtration(self): + """This function returns the main simplicial complex filtration value. + + :returns: float -- the simplicial complex filtration value. + """ + return self.thisptr.filtration() + + def filtration(self, simplex): + """This function returns the simplicial complex filtration value for a + given N-simplex. + + :param simplex: The N-simplex, represented by a list of vertex. + :type simplex: list of int + :returns: float -- the simplicial complex filtration value. + """ + return self.thisptr.simplex_filtration(simplex) + + def set_filtration(self, filtration): + """This function sets the main simplicial complex filtration value. + + :param filtration: The filtration value. + :type filtration: float. + """ + self.thisptr.set_filtration( filtration) + + def initialize_filtration(self): + """This function initializes and sorts the simplicial complex + filtration vector. + + .. note:: + + This function must be launched before persistence, betti_numbers, + persistent_betti_numbers or get_filtered_tree after inserting or + removing simplices. + """ + self.thisptr.initialize_filtration() + + def num_vertices(self): + """This function returns the number of vertices of the simplicial + complex. + + :returns: int -- the simplicial complex number of vertices. + """ + return self.thisptr.num_vertices() + + def num_simplices(self): + """This function returns the number of simplices of the simplicial + complex. + + :returns: int -- the simplicial complex number of simplices. + """ + return self.thisptr.num_simplices() + + def dimension(self): + """This function returns the dimension of the simplicial complex. + + :returns: int -- the simplicial complex dimension. + """ + return self.thisptr.dimension() + + def set_dimension(self, dimension): + """This function sets the dimension of the simplicial complex. + + :param dimension: The new dimension value. + :type dimension: int. + """ + self.thisptr.set_dimension(dimension) + + def find(self, simplex): + """This function returns if the N-simplex was found in the simplicial + complex or not. + + :param simplex: The N-simplex to find, represented by a list of vertex. + :type simplex: list of int. + :returns: bool -- true if the simplex was found, false otherwise. + """ + cdef vector[int] complex + for i in simplex: + complex.push_back(i) + return self.thisptr.find_simplex(complex) + + def insert(self, simplex, filtration=0.0): + """This function inserts the given N-simplex with the given filtration + value (default value is '0.0'). + + :param simplex: The N-simplex to insert, represented by a list of + vertex. + :type simplex: list of int. + :param filtration: The filtration value of the simplex. + :type filtration: float. + :returns: bool -- true if the simplex was found, false otherwise. + """ + cdef vector[int] complex + for i in simplex: + complex.push_back(i) + return self.thisptr.insert_simplex_and_subfaces(complex, + filtration) + + def get_filtered_tree(self): + """This function returns the tree sorted by increasing filtration + values. + + :returns: list of tuples(simplex, filtration) -- the tree sorted by + increasing filtration values. + """ + cdef vector[pair[vector[int], double]] coface_tree \ + = self.thisptr.get_filtered_tree() + ct = [] + for filtered_complex in coface_tree: + v = [] + for vertex in filtered_complex.first: + v.append(vertex) + ct.append((v, filtered_complex.second)) + return ct + + def get_skeleton_tree(self, dimension): + """This function returns the tree skeleton of a maximum given + dimension. + + :param dimension: The skeleton dimension value. + :type dimension: int. + :returns: list of tuples(simplex, filtration) -- the skeleton tree + of a maximum dimension. + """ + cdef vector[pair[vector[int], double]] coface_tree \ + = self.thisptr.get_skeleton_tree(dimension) + ct = [] + for filtered_complex in coface_tree: + v = [] + for vertex in filtered_complex.first: + v.append(vertex) + ct.append((v, filtered_complex.second)) + return ct + + def get_star_tree(self, simplex): + """This function returns the star tree of a given N-simplex. + + :param simplex: The N-simplex, represented by a list of vertex. + :type simplex: list of int. + :returns: list of tuples(simplex, filtration) -- the star tree of a + simplex. + """ + cdef vector[int] complex + for i in simplex: + complex.push_back(i) + cdef vector[pair[vector[int], double]] coface_tree \ + = self.thisptr.get_star_tree(complex) + ct = [] + for filtered_complex in coface_tree: + v = [] + for vertex in filtered_complex.first: + v.append(vertex) + ct.append((v, filtered_complex.second)) + return ct + + def get_coface_tree(self, simplex, codimension): + """This function returns the coface tree of a given N-simplex with a + given codimension. + + :param simplex: The N-simplex, represented by a list of vertex. + :type simplex: list of int. + :param codimension: The codimension. If codimension = 0, all cofaces + are returned (equivalent of get_star_tree function) + :type codimension: int. + :returns: list of tuples(simplex, filtration) -- the coface tree of a + simplex. + """ + cdef vector[int] complex + for i in simplex: + complex.push_back(i) + cdef vector[pair[vector[int], double]] coface_tree \ + = self.thisptr.get_coface_tree(complex, codimension) + ct = [] + for filtered_complex in coface_tree: + v = [] + for vertex in filtered_complex.first: + v.append(vertex) + ct.append((v, filtered_complex.second)) + return ct + + def remove_maximal_simplex(self, simplex): + """This function removes a given maximal N-simplex from the simplicial + complex. + + :param simplex: The N-simplex, represented by a list of vertex. + :type simplex: list of int. + """ + self.thisptr.remove_maximal_simplex(simplex) + + def get_point(self, vertex): + """This function returns the point corresponding to a given vertex. + + :param vertex: The vertex. + :type vertex: int. + :returns: list of float -- the point. + """ + cdef vector[double] point = self.thisptr.get_point(vertex) + return point + + def persistence(self, homology_coeff_field=11, min_persistence=0.0): + """This function returns the persistence of the simplicial complex. + + :param homology_coeff_field: The homology coefficient field. Must be a + prime number + :type homology_coeff_field: int. + :param min_persistence: The minimum persistence value to take into + account (strictly greater than min_persistence). Default value is + 0.0. + Sets min_persistence to -1.0 to see all values. + :type min_persistence: float. + :note: list of pairs(dimension, pair(birth, death)) -- the + persistence of the simplicial complex. + """ + return self.thisptr.get_persistence(homology_coeff_field, min_persistence) + + def betti_numbers(self): + """This function returns the Betti numbers of the simplicial complex. + + :returns: list of int -- The Betti numbers ([B0, B1, ..., Bn]). + + :note: betti_numbers function requires persistence function to be + launched first. + """ + return self.thisptr.get_betti_numbers() + + def persistent_betti_numbers(self, from_value, to_value): + """This function returns the persistent Betti numbers of the + simplicial complex. + + :param from_value: The persistence birth limit to be added in the + numbers (persistent birth <= from_value). + :type from_value: float. + :param to_value: The persistence death limit to be added in the + numbers (persistent death > to_value). + :type to_value: float. + + :returns: list of int -- The persistent Betti numbers ([B0, B1, ..., + Bn]). + + :note: persistent_betti_numbers function requires persistence + function to be launched first. + """ + return self.thisptr.get_persistent_betti_numbers(from_value, to_value) diff --git a/src/cython/cythonize_gudhi.py.in b/src/cython/cythonize_gudhi.py.in index fb9a381e..46d19c2d 100644 --- a/src/cython/cythonize_gudhi.py.in +++ b/src/cython/cythonize_gudhi.py.in @@ -7,7 +7,7 @@ from Cython.Build import cythonize Author(s): Vincent Rouvreau - Copyright (C) 2016 INRIA Saclay (France) + Copyright (C) 2016 INRIA 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 @@ -24,7 +24,7 @@ from Cython.Build import cythonize """ __author__ = "Vincent Rouvreau" -__copyright__ = "Copyright (C) 2016 INRIA Saclay (France)" +__copyright__ = "Copyright (C) 2016 INRIA" __license__ = "GPL v3" gudhi = Extension( diff --git a/src/cython/doc/alpha_complex_sum.rst b/src/cython/doc/alpha_complex_sum.rst index b3689556..af6c087f 100644 --- a/src/cython/doc/alpha_complex_sum.rst +++ b/src/cython/doc/alpha_complex_sum.rst @@ -1,7 +1,7 @@ ===================================== ===================================== ===================================== :Author: Vincent Rouvreau :Introduced in: GUDHI 1.3.0 :Copyright: GPL v3 ===================================== ===================================== ===================================== -:Requires: CGAL &ge 4.7.0 Eigen3 +:Requires: CGAL ≥ 4.7.0 Eigen3 ===================================== ===================================== ===================================== +-------------------------------------------+----------------------------------------------------------------------+ diff --git a/src/cython/doc/persistence_graphical_tools_ref.rst b/src/cython/doc/persistence_graphical_tools_ref.rst index aa214edf..a12021c4 100644 --- a/src/cython/doc/persistence_graphical_tools_ref.rst +++ b/src/cython/doc/persistence_graphical_tools_ref.rst @@ -2,7 +2,7 @@ Persistence graphical tools reference manual ============================================ -.. automethod:: gudhi.__min_birth_max_death -.. automethod:: gudhi.show_palette_values -.. automethod:: gudhi.barcode_persistence -.. automethod:: gudhi.diagram_persistence \ No newline at end of file +.. autofunction:: gudhi.__min_birth_max_death +.. autofunction:: gudhi.show_palette_values +.. autofunction:: gudhi.barcode_persistence +.. autofunction:: gudhi.diagram_persistence diff --git a/src/cython/doc/persistence_graphical_tools_sum.rst b/src/cython/doc/persistence_graphical_tools_sum.rst index a6260032..a4ee4398 100644 --- a/src/cython/doc/persistence_graphical_tools_sum.rst +++ b/src/cython/doc/persistence_graphical_tools_sum.rst @@ -1,7 +1,7 @@ ===================================== ===================================== ===================================== :Author: Vincent Rouvreau :Introduced in: GUDHI 1.4.0 :Copyright: GPL v3 ===================================== ===================================== ===================================== -:Requires: Matplotlib Numpy +:Requires: Matplotlib Numpy ===================================== ===================================== ===================================== +---------------------------------------------+----------------------------------------------------------------------+ @@ -9,5 +9,5 @@ | img/graphical_tools_representation.png | the user to build easily barcode and persistence diagram. | | | | +---------------------------------------------+----------------------------------------------------------------------+ -| :doc:`persistence_graphical_tools_user` | * :doc:`persistence_graphical_tools_ref` | +| :doc:`persistence_graphical_tools_user` | :doc:`persistence_graphical_tools_ref` | +---------------------------------------------+----------------------------------------------------------------------+ diff --git a/src/cython/gudhi.pyx.in b/src/cython/gudhi.pyx.in index 1b8a669b..09d765b6 100644 --- a/src/cython/gudhi.pyx.in +++ b/src/cython/gudhi.pyx.in @@ -4,7 +4,7 @@ Author(s): Vincent Rouvreau - Copyright (C) 2016 INRIA Saclay (France) + Copyright (C) 2016 INRIA 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 @@ -21,7 +21,7 @@ """ __author__ = "Vincent Rouvreau" -__copyright__ = "Copyright (C) 2016 INRIA Saclay (France)" +__copyright__ = "Copyright (C) 2016 INRIA" __license__ = "GPL v3" include "cython/simplex_tree.pyx" @@ -32,3 +32,4 @@ include "cython/periodic_cubical_complex.pyx" include "cython/persistence_graphical_tools.py" include "cython/witness_complex.pyx" @GUDHI_CYTHON_ALPHA_COMPLEX@ +@GUDHI_CYTHON_TANGENTIAL_COMPLEX@ diff --git a/src/cython/include/Tangential_complex_interface.h b/src/cython/include/Tangential_complex_interface.h new file mode 100644 index 00000000..645aad72 --- /dev/null +++ b/src/cython/include/Tangential_complex_interface.h @@ -0,0 +1,220 @@ +/* This file is part of the Gudhi Library. The Gudhi library + * (Geometric Understanding in Higher Dimensions) is a generic C++ + * library for computational topology. + * + * Author(s): Vincent Rouvreau + * + * Copyright (C) 2016 INRIA + * + * 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 . + */ + +#ifndef TANGENTIAL_COMPLEX_INTERFACE_H +#define TANGENTIAL_COMPLEX_INTERFACE_H + +#include +#include +#include +#include + +#include "Persistent_cohomology_interface.h" + +#include +#include // std::pair +#include + +namespace Gudhi { + +namespace tangential_complex { + +class Tangential_complex_interface { + using Dynamic_kernel = CGAL::Epick_d< CGAL::Dynamic_dimension_tag >; + using Point_d = Dynamic_kernel::Point_d; + typedef typename Simplex_tree<>::Simplex_handle Simplex_handle; + typedef typename std::pair Insertion_result; + using Simplex = std::vector; + using Filtered_complex = std::pair; + using Complex_tree = std::vector; + using TC = Tangential_complex; + + public: + Tangential_complex_interface(std::vector>&points, double max_alpha_square) + : pcoh_(nullptr) { + Dynamic_kernel k; + unsigned intrisic_dim = 0; + if (points.size() > 0) + intrisic_dim = points[0].size(); + + tangential_complex_ = new TC(points, intrisic_dim, k); + tangential_complex_->create_complex(simplex_tree_, max_alpha_square); + simplex_tree_.initialize_filtration(); + } + + Tangential_complex_interface(std::string off_file_name, double max_alpha_square, bool from_file = true) + : pcoh_(nullptr) { + Gudhi::Points_off_reader off_reader(off_file_name); + Dynamic_kernel k; + unsigned intrisic_dim = 0; + std::vector points = off_reader.get_point_cloud(); + if (points.size() > 0) + intrisic_dim = points[0].size(); + + tangential_complex_ = new TC(points, intrisic_dim, k); + tangential_complex_->create_complex(simplex_tree_, max_alpha_square); + simplex_tree_.initialize_filtration(); + } + + bool find_simplex(const Simplex& vh) { + return (simplex_tree_.find(vh) != simplex_tree_.null_simplex()); + } + + bool insert_simplex_and_subfaces(const Simplex& complex, Filtration_value filtration = 0) { + Insertion_result result = simplex_tree_.insert_simplex_and_subfaces(complex, filtration); + return (result.second); + } + + Filtration_value simplex_filtration(const Simplex& complex) { + return simplex_tree_.filtration(simplex_tree_.find(complex)); + } + + void remove_maximal_simplex(const Simplex& complex) { + return simplex_tree_.remove_maximal_simplex(simplex_tree_.find(complex)); + } + + Complex_tree get_filtered_tree() { + Complex_tree filtered_tree; + for (auto f_simplex : simplex_tree_.filtration_simplex_range()) { + Simplex simplex; + for (auto vertex : simplex_tree_.simplex_vertex_range(f_simplex)) { + simplex.insert(simplex.begin(), vertex); + } + filtered_tree.push_back(std::make_pair(simplex, simplex_tree_.filtration(f_simplex))); + } + return filtered_tree; + + } + + Complex_tree get_skeleton_tree(int dimension) { + Complex_tree skeleton_tree; + for (auto f_simplex : simplex_tree_.skeleton_simplex_range(dimension)) { + Simplex simplex; + for (auto vertex : simplex_tree_.simplex_vertex_range(f_simplex)) { + simplex.insert(simplex.begin(), vertex); + } + skeleton_tree.push_back(std::make_pair(simplex, simplex_tree_.filtration(f_simplex))); + } + return skeleton_tree; + } + + Complex_tree get_star_tree(const Simplex& complex) { + Complex_tree star_tree; + for (auto f_simplex : simplex_tree_.star_simplex_range(simplex_tree_.find(complex))) { + Simplex simplex; + for (auto vertex : simplex_tree_.simplex_vertex_range(f_simplex)) { + simplex.insert(simplex.begin(), vertex); + } + star_tree.push_back(std::make_pair(simplex, simplex_tree_.filtration(f_simplex))); + } + return star_tree; + } + + Complex_tree get_coface_tree(const Simplex& complex, int dimension) { + Complex_tree coface_tree; + for (auto f_simplex : simplex_tree_.cofaces_simplex_range(simplex_tree_.find(complex), dimension)) { + Simplex simplex; + for (auto vertex : simplex_tree_.simplex_vertex_range(f_simplex)) { + simplex.insert(simplex.begin(), vertex); + } + coface_tree.push_back(std::make_pair(simplex, simplex_tree_.filtration(f_simplex))); + } + return coface_tree; + } + + // Specific to Witness complex because no inheritance + Filtration_value filtration() const { + return simplex_tree_.filtration(); + } + + void set_filtration(Filtration_value fil) { + simplex_tree_.set_filtration(fil); + } + + void initialize_filtration() { + simplex_tree_.initialize_filtration(); + } + + size_t num_vertices() const { + return simplex_tree_.num_vertices(); + } + + size_t num_simplices() { + return simplex_tree_.num_simplices(); + } + + int dimension() const { + return simplex_tree_.dimension(); + } + + void set_dimension(int dimension) { + simplex_tree_.set_dimension(dimension); + } + + std::vector get_point(int vh) { + std::vector vd; + try { + Point_d ph = tangential_complex_->get_point(vh); + for (auto coord = ph.cartesian_begin(); coord < ph.cartesian_end(); coord++) + vd.push_back(*coord); + } catch (std::out_of_range outofrange) { + // std::out_of_range is thrown in case not found. Other exceptions must be re-thrown + } + return vd; + } + + std::vector>> get_persistence(int homology_coeff_field, double min_persistence) { + if (pcoh_ != nullptr) { + delete pcoh_; + } + pcoh_ = new Persistent_cohomology_interface>(&simplex_tree_); + return pcoh_->get_persistence(homology_coeff_field, min_persistence); + } + + std::vector get_betti_numbers() const { + if (pcoh_ != nullptr) { + return pcoh_->betti_numbers(); + } + std::vector betti_numbers; + return betti_numbers; + } + + std::vector get_persistent_betti_numbers(Filtration_value from, Filtration_value to) const { + if (pcoh_ != nullptr) { + return pcoh_->persistent_betti_numbers(from, to); + } + std::vector persistent_betti_numbers; + return persistent_betti_numbers; + } + + private: + Simplex_tree<> simplex_tree_; + Persistent_cohomology_interface>* pcoh_; + TC* tangential_complex_; +}; + +} // namespace tangential_complex + +} // namespace Gudhi + +#endif // TANGENTIAL_COMPLEX_INTERFACE_H + -- cgit v1.2.3 From 0921d31dec497b21a3b2805790ef295e90566e3d Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Thu, 2 Feb 2017 07:58:53 +0000 Subject: Change doc html theme. Change tables git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/ST_cythonize@2047 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: aaa29b8f610d506efc3762ad17c4fd768e74d399 --- src/cython/CMakeLists.txt | 6 +- src/cython/cython/rips_complex.pyx | 20 +--- src/cython/doc/alpha_complex_sum.rst | 43 ++++--- src/cython/doc/alpha_complex_user.rst | 16 ++- src/cython/doc/biblio.rst | 3 +- src/cython/doc/bottleneck_distance_sum.rst | 28 ++--- src/cython/doc/bottleneck_distance_user.rst | 2 +- src/cython/doc/conf.py | 2 +- src/cython/doc/cubical_complex_sum.rst | 25 ++-- src/cython/doc/cubical_complex_user.rst | 14 ++- src/cython/doc/index.rst | 6 +- src/cython/doc/persistence_graphical_tools_sum.rst | 23 ++-- src/cython/doc/persistent_cohomology_sum.rst | 50 ++++---- src/cython/doc/rips_complex_ref.rst | 10 ++ src/cython/doc/rips_complex_sum.rst | 17 +++ src/cython/doc/rips_complex_user.rst | 133 +++++++++++++++++++++ src/cython/doc/simplex_tree_sum.rst | 25 ++-- src/cython/doc/tangential_complex_sum.rst | 29 +++-- src/cython/doc/tangential_complex_user.rst | 7 ++ src/cython/doc/witness_complex_sum.rst | 48 ++++---- 20 files changed, 338 insertions(+), 169 deletions(-) create mode 100644 src/cython/doc/rips_complex_ref.rst create mode 100644 src/cython/doc/rips_complex_sum.rst create mode 100644 src/cython/doc/rips_complex_user.rst (limited to 'src/cython/doc/alpha_complex_sum.rst') diff --git a/src/cython/CMakeLists.txt b/src/cython/CMakeLists.txt index 6c49c800..72be7b30 100644 --- a/src/cython/CMakeLists.txt +++ b/src/cython/CMakeLists.txt @@ -101,7 +101,7 @@ if(PYTHON_PATH AND CYTHON_PATH) WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND python "${CMAKE_CURRENT_BINARY_DIR}/cythonize_gudhi.py" "build_ext" "--inplace") - add_custom_target(cythonize_gudhi ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/gudhi.so" + add_custom_target(cython ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/gudhi.so" COMMENT "Do not forget to add ${CMAKE_CURRENT_BINARY_DIR}/gudhi.so to your PYTHONPATH before using examples") # Unitary tests are available through py.test @@ -135,11 +135,11 @@ if(PYTHON_PATH AND CYTHON_PATH) file(COPY "${CMAKE_SOURCE_DIR}/data/bitmap/3d_torus.txt" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/doc/") file(COPY "${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/doc/") if (UNIX) - add_custom_target(html + add_custom_target(sphinx WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc COMMAND make html && make doctest) else (UNIX) - add_custom_target(html + add_custom_target(sphinx WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc COMMAND make.bat html) endif (UNIX) diff --git a/src/cython/cython/rips_complex.pyx b/src/cython/cython/rips_complex.pyx index 2e739ac3..7e04ca4b 100644 --- a/src/cython/cython/rips_complex.pyx +++ b/src/cython/cython/rips_complex.pyx @@ -40,22 +40,10 @@ cdef extern from "Rips_complex_interface.h" namespace "Gudhi": # RipsComplex python interface cdef class RipsComplex: - """RipsComplex is a simplicial complex constructed from the finite cells - of a Delaunay Triangulation. - - The filtration value of each simplex is computed as the square of the - circumradius of the simplex if the circumsphere is empty (the simplex 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. - - .. note:: - - When Rips_complex is constructed with an infinite value of alpha, the - complex is a Delaunay complex. - + """The data structure is a one skeleton graph, or Rips graph, containing + edges when the edge length is less or equal to a given threshold. Edge + length is computed from a user given point cloud with a given distance + function, or a distance matrix. """ cdef Rips_complex_interface * thisptr diff --git a/src/cython/doc/alpha_complex_sum.rst b/src/cython/doc/alpha_complex_sum.rst index af6c087f..0ccbcc21 100644 --- a/src/cython/doc/alpha_complex_sum.rst +++ b/src/cython/doc/alpha_complex_sum.rst @@ -1,23 +1,22 @@ -===================================== ===================================== ===================================== -:Author: Vincent Rouvreau :Introduced in: GUDHI 1.3.0 :Copyright: GPL v3 -===================================== ===================================== ===================================== -:Requires: CGAL ≥ 4.7.0 Eigen3 -===================================== ===================================== ===================================== +================================================================= =================================== =================================== +:Author: Vincent Rouvreau :Introduced in: GUDHI 1.3.0 :Copyright: GPL v3 +:Requires: CGAL :math:`\geq` 4.7.0 Eigen3 +================================================================= =================================== =================================== -+-------------------------------------------+----------------------------------------------------------------------+ -| .. image:: | Alpha_complex is a simplicial complex constructed from the finite | -| img/alpha_complex_representation.png | cells of a Delaunay Triangulation. | -| | | -| | The filtration value of each simplex is computed as the square of the| -| | circumradius of the simplex if the circumsphere is empty (the simplex| -| | 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 perfomances). | -+-------------------------------------------+----------------------------------------------------------------------+ -| :doc:`alpha_complex_user` | :doc:`alpha_complex_ref` | -+-------------------------------------------+----------------------------------------------------------------------+ ++----------------------------------------------------------------+------------------------------------------------------------------------+ +| .. figure:: | Alpha_complex is a simplicial complex constructed from the finite | +| img/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 perfomances). | ++----------------------------------------------------------------+------------------------------------------------------------------------+ +| :doc:`alpha_complex_user` | :doc:`alpha_complex_ref` | ++----------------------------------------------------------------+------------------------------------------------------------------------+ diff --git a/src/cython/doc/alpha_complex_user.rst b/src/cython/doc/alpha_complex_user.rst index 1ca96b6e..f1c57248 100644 --- a/src/cython/doc/alpha_complex_user.rst +++ b/src/cython/doc/alpha_complex_user.rst @@ -74,11 +74,13 @@ Data structure In order to build the alpha complex, first, a Simplex tree is built from the cells of a Delaunay Triangulation. (The filtration value is set to NaN, which stands for unknown value): -.. image:: +.. figure:: img/alpha_complex_doc.png - :align: center + :figclass: align-center :alt: Simplex tree structure construction example + Simplex tree structure construction example + Filtration value computation algorithm ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -87,9 +89,9 @@ Filtration value computation algorithm **if** filtration(:math:`\sigma`) is NaN **then** filtration(:math:`\sigma`) = :math:`\alpha^2(\sigma)` **end if** - + *//propagate alpha filtration value* - + **for all** :math:`\tau` face of :math:`\sigma` **if** filtration(:math:`\tau`) is not NaN **then** filtration(:math:`\tau`) = filtration(:math:`\sigma`) @@ -109,11 +111,13 @@ From the example above, it means the algorithm looks into each triangle ([0,1,2] computes the filtration value of the triangle, and then propagates the filtration value as described here: -.. image:: +.. figure:: img/alpha_complex_doc_420.png - :align: center + :figclass: align-center :alt: Filtration value propagation example + Filtration value propagation example + Dimension 1 ^^^^^^^^^^^ diff --git a/src/cython/doc/biblio.rst b/src/cython/doc/biblio.rst index b8e733ed..3995e9c0 100644 --- a/src/cython/doc/biblio.rst +++ b/src/cython/doc/biblio.rst @@ -1,6 +1,5 @@ -============ Bibliography -============ +************ .. bibliography:: bibliography.bib :filter: docnames diff --git a/src/cython/doc/bottleneck_distance_sum.rst b/src/cython/doc/bottleneck_distance_sum.rst index 6cffa122..6fec9b7e 100644 --- a/src/cython/doc/bottleneck_distance_sum.rst +++ b/src/cython/doc/bottleneck_distance_sum.rst @@ -1,15 +1,15 @@ -===================================== ===================================== ===================================== -:Author: Francois Godi :Introduced in: GUDHI 1.4.0 :Copyright: GPL v3 -===================================== ===================================== ===================================== -:Requires: CGAL ≥ 4.8.0 -===================================== ===================================== ===================================== +================================================================= =================================== =================================== +:Author: François Godi :Introduced in: GUDHI 2.0.0 :Copyright: GPL v3 +:Requires: CGAL :math:`\geq` 4.8.0 +================================================================= =================================== =================================== -+-------------------------------------------+----------------------------------------------------------------------+ -| .. image:: | Bottleneck distance measures the similarity between two persistence | -| img/perturb_pd.png | diagrams. It's the shortest distance b for which there exists a | -| | perfect matching between the points of the two diagrams (+ all the | -| | diagonal points) such that any couple of matched points are at | -| | distance at most b. | -+-------------------------------------------+----------------------------------------------------------------------+ -| :doc:`bottleneck_distance_user` | :doc:`bottleneck_distance_ref` | -+-------------------------------------------+----------------------------------------------------------------------+ ++-----------------------------------------------------------------+----------------------------------------------------------------------+ +| .. figure:: | Bottleneck distance measures the similarity between two persistence | +| img/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` | :doc:`bottleneck_distance_ref` | ++-----------------------------------------------------------------+----------------------------------------------------------------------+ diff --git a/src/cython/doc/bottleneck_distance_user.rst b/src/cython/doc/bottleneck_distance_user.rst index 08c6e451..3bc170f4 100644 --- a/src/cython/doc/bottleneck_distance_user.rst +++ b/src/cython/doc/bottleneck_distance_user.rst @@ -8,7 +8,7 @@ Definition Function -------- -.. automethod:: gudhi.bottleneck_distance +.. autofunction:: gudhi.bottleneck_distance Basic example diff --git a/src/cython/doc/conf.py b/src/cython/doc/conf.py index 8b42ce37..680377b3 100755 --- a/src/cython/doc/conf.py +++ b/src/cython/doc/conf.py @@ -114,7 +114,7 @@ pygments_style = 'sphinx' # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. -html_theme = 'default' +html_theme = 'bizstyle' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the diff --git a/src/cython/doc/cubical_complex_sum.rst b/src/cython/doc/cubical_complex_sum.rst index 98e23849..399c2357 100644 --- a/src/cython/doc/cubical_complex_sum.rst +++ b/src/cython/doc/cubical_complex_sum.rst @@ -1,12 +1,15 @@ -===================================== ===================================== ===================================== -:Author: Pawel Dlotko :Introduced in: GUDHI 1.3.0 :Copyright: GPL v3 -===================================== ===================================== ===================================== +================================================================= =================================== =================================== +:Author: Pawel Dlotko :Introduced in: GUDHI 1.3.0 :Copyright: GPL v3 +================================================================= =================================== =================================== -+---------------------------------------------+----------------------------------------------------------------------+ -| .. image:: | The cubical complex is an example of a structured complex useful in | -| img/Cubical_complex_representation.png | computational mathematics (specially rigorous numerics) and image | -| | analysis. | -+---------------------------------------------+----------------------------------------------------------------------+ -| :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 | +| img/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` | ++-----------------------------------------------------------------+----------------------------------------------------------------------+ diff --git a/src/cython/doc/cubical_complex_user.rst b/src/cython/doc/cubical_complex_user.rst index 16712de5..809aaddf 100644 --- a/src/cython/doc/cubical_complex_user.rst +++ b/src/cython/doc/cubical_complex_user.rst @@ -5,7 +5,7 @@ Definition ---------- ===================================== ===================================== ===================================== -:Author: Pawel Dlotko :Introduced in: GUDHI PYTHON 1.4.0 :Copyright: GPL v3 +:Author: Pawel Dlotko :Introduced in: GUDHI PYTHON 1.3.0 :Copyright: GPL v3 ===================================== ===================================== ===================================== +---------------------------------------------+----------------------------------------------------------------------+ @@ -59,10 +59,12 @@ of filtration. This, together with dimension of :math:`\mathcal{K}` and the size directions, allows to determine, dimension, neighborhood, boundary and coboundary of every cube :math:`C \in \mathcal{K}`. -.. image:: +.. figure:: img/Cubical_complex_representation.png - :align: center :alt: Cubical complex. + :figclass: align-center + + Cubical complex. Note that the cubical complex in the figure above is, in a natural way, a product of one dimensional cubical complexes in :math:`\mathbb{R}`. The number of all cubes in each direction is equal :math:`2n+1`, where :math:`n` is @@ -85,10 +87,12 @@ bitmap (2 in the example below). Next d lines are the numbers of top dimensional in the example below). Next, in lexicographical order, the filtration of top dimensional cubes is given (1 4 6 8 20 4 7 6 5 in the example below). -.. image:: +.. figure:: img/exampleBitmap.png - :align: center :alt: Example of a input data. + :figclass: align-center + + Example of a input data. The input file for the following complex is: diff --git a/src/cython/doc/index.rst b/src/cython/doc/index.rst index bd138fd5..236ef3a4 100644 --- a/src/cython/doc/index.rst +++ b/src/cython/doc/index.rst @@ -11,7 +11,6 @@ GUDHI's documentation Introduction ************ -:doc:`biblio` The Gudhi library (Geometry Understanding in Higher Dimensions) is a generic open source C++ library for Computational Topology and Topological Data @@ -44,6 +43,11 @@ Cubical complex .. include:: cubical_complex_sum.rst +Rips complex +============ + +.. include:: rips_complex_sum.rst + Simplex tree ============ diff --git a/src/cython/doc/persistence_graphical_tools_sum.rst b/src/cython/doc/persistence_graphical_tools_sum.rst index a4ee4398..d602daa7 100644 --- a/src/cython/doc/persistence_graphical_tools_sum.rst +++ b/src/cython/doc/persistence_graphical_tools_sum.rst @@ -1,13 +1,12 @@ -===================================== ===================================== ===================================== -:Author: Vincent Rouvreau :Introduced in: GUDHI 1.4.0 :Copyright: GPL v3 -===================================== ===================================== ===================================== -:Requires: Matplotlib Numpy -===================================== ===================================== ===================================== +================================================================= =================================== =================================== +:Author: Vincent Rouvreau :Introduced in: GUDHI 2.0.0 :Copyright: GPL v3 +:Requires: Matplotlib Numpy +================================================================= =================================== =================================== -+---------------------------------------------+----------------------------------------------------------------------+ -| .. image:: | These graphical tools comes on top of persistence results and allows | -| img/graphical_tools_representation.png | the user to build easily barcode and persistence diagram. | -| | | -+---------------------------------------------+----------------------------------------------------------------------+ -| :doc:`persistence_graphical_tools_user` | :doc:`persistence_graphical_tools_ref` | -+---------------------------------------------+----------------------------------------------------------------------+ ++-----------------------------------------------------------------+-----------------------------------------------------------------------+ +| .. figure:: | These graphical tools comes on top of persistence results and allows | +| img/graphical_tools_representation.png | the user to build easily barcode and persistence diagram. | +| | | ++-----------------------------------------------------------------+-----------------------------------------------------------------------+ +| :doc:`persistence_graphical_tools_user` | :doc:`persistence_graphical_tools_ref` | ++-----------------------------------------------------------------+-----------------------------------------------------------------------+ diff --git a/src/cython/doc/persistent_cohomology_sum.rst b/src/cython/doc/persistent_cohomology_sum.rst index cf3029fc..5d059b00 100644 --- a/src/cython/doc/persistent_cohomology_sum.rst +++ b/src/cython/doc/persistent_cohomology_sum.rst @@ -1,25 +1,27 @@ -===================================== ===================================== ===================================== -:Author: Clément Maria :Introduced in: GUDHI 1.0.0 :Copyright: GPL v3 -===================================== ===================================== ===================================== +================================================================= =================================== =================================== +:Author: Clément Maria :Introduced in: GUDHI 1.0.0 :Copyright: GPL v3 +================================================================= =================================== =================================== -+---------------------------------------------+----------------------------------------------------------------------+ -| .. image:: | The theory of homology consists in attaching to a topological space | -| img/3DTorus_poch.png | a sequence of (homology) groups, capturing global topological | -| | features like connected components, holes, cavities, etc. Persistent | -| | homology studies the evolution -- birth, life and death -- of these | -| | features when the topological space is changing. Consequently, the | -| | 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` | -+---------------------------------------------+----------------------------------------------------------------------+ ++-----------------------------------------------------------------+-----------------------------------------------------------------------+ +| .. figure:: | The theory of homology consists in attaching to a topological space | +| img/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` | ++-----------------------------------------------------------------+-----------------------------------------------------------------------+ diff --git a/src/cython/doc/rips_complex_ref.rst b/src/cython/doc/rips_complex_ref.rst new file mode 100644 index 00000000..b17dc4e0 --- /dev/null +++ b/src/cython/doc/rips_complex_ref.rst @@ -0,0 +1,10 @@ +============================= +Rips complex reference manual +============================= + +.. autoclass:: gudhi.RipsComplex + :members: + :undoc-members: + :show-inheritance: + + .. automethod:: gudhi.RipsComplex.__init__ diff --git a/src/cython/doc/rips_complex_sum.rst b/src/cython/doc/rips_complex_sum.rst new file mode 100644 index 00000000..ad57e54e --- /dev/null +++ b/src/cython/doc/rips_complex_sum.rst @@ -0,0 +1,17 @@ +================================================================= =================================== =================================== +:Author: Clément Maria, Pawel Dlotko, Vincent Rouvreau :Introduced in: GUDHI 1.0.0 :Copyright: GPL v3 +================================================================= =================================== =================================== + ++----------------------------------------------------------------+------------------------------------------------------------------------+ +| .. figure:: | Rips_complex is a simplicial complex constructed from a one skeleton | +| img/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` | ++----------------------------------------------------------------+------------------------------------------------------------------------+ diff --git a/src/cython/doc/rips_complex_user.rst b/src/cython/doc/rips_complex_user.rst new file mode 100644 index 00000000..be9481de --- /dev/null +++ b/src/cython/doc/rips_complex_user.rst @@ -0,0 +1,133 @@ +========================= +Rips complex user manual +========================= +Definition +---------- + +======================================================= ===================================== ===================================== +:Authors: Clément Maria, Pawel Dlotko, Vincent Rouvreau :Introduced in: GUDHI 2.0.0 :Copyright: GPL v3 +======================================================= ===================================== ===================================== + ++-------------------------------------------+----------------------------------------------------------------------+ +| :doc:`rips_complex_user` | :doc:`rips_complex_ref` | ++-------------------------------------------+----------------------------------------------------------------------+ + +`Rips complex `_ is a one skeleton graph that allows to +construct a simplicial complex from it. The input can be a point cloud with a given distance function, or a distance +matrix. + +The filtration value of each edge is computed from a user-given distance function, or directly from the distance +matrix. + +All edges that have a filtration value strictly greater than a given threshold value are not inserted into the complex. + +When creating a simplicial complex from this one skeleton graph, Rips inserts the one skeleton 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). + +.. figure:: + img/rips_complex_representation.png + :align: center + + Rips-complex one skeleton 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 :math:`max(filtration(4,5), filtration(4,6), filtration(5,6))`. And so on for simplex (0,1,2,3). + +If the Rips_complex interfaces are not detailed enough for your need, please refer to rips_persistence_step_by_step.cpp +example, where the graph construction over the Simplex_tree is more detailed. + +Point cloud and distance function +--------------------------------- + +Example from a point cloud and a distance function +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This example builds the one skeleton graph from the given points, threshold value, and distance function. Then it +creates a :doc:`Simplex_tree ` with it. + +Then, it is asked to display information about the simplicial complex. + +.. testcode:: + + import gudhi + rips_complex = gudhi.RipsComplex(points=[[1, 1], [7, 0], [4, 6], [9, 6], [0, 14], [2, 19], [9, 17]], + max_edge_length=12.0) + + simplex_tree = rips_complex.create_simplex_tree(max_dimension=1) + result_str = 'Rips complex is of dimension ' + repr(simplex_tree.dimension()) + ' - ' + \ + repr(simplex_tree.num_simplices()) + ' simplices - ' + \ + repr(simplex_tree.num_vertices()) + ' vertices.' + print(result_str) + for filtered_value in simplex_tree.get_filtered_tree(): + print(filtered_value) + +The output is: + +.. testoutput:: + + Rips complex is of dimension 1 - 18 simplices - 7 vertices. + ([0], 0.0) + ([1], 0.0) + ([2], 0.0) + ([3], 0.0) + ([4], 0.0) + ([5], 0.0) + ([6], 0.0) + ([2, 3], 5.0) + ([4, 5], 5.385164807134504) + ([0, 2], 5.830951894845301) + ([0, 1], 6.082762530298219) + ([1, 3], 6.324555320336759) + ([1, 2], 6.708203932499369) + ([5, 6], 7.280109889280518) + ([2, 4], 8.94427190999916) + ([0, 3], 9.433981132056603) + ([4, 6], 9.486832980505138) + ([3, 6], 11.0) + +Example from OFF file +^^^^^^^^^^^^^^^^^^^^^ + +This example builds the :doc:`Rips_complex ` from the given points in an OFF file, threshold value, +and distance function. Then it creates a :doc:`Simplex_tree ` with it. + +Then, it is asked to display information about the Rips complex. + + +.. testcode:: + + import gudhi + rips_complex = gudhi.RipsComplex(off_file='alphacomplexdoc.off', max_edge_length=12.0) + simplex_tree = rips_complex.create_simplex_tree(max_dimension=1) + result_str = 'Rips complex is of dimension ' + repr(simplex_tree.dimension()) + ' - ' + \ + repr(simplex_tree.num_simplices()) + ' simplices - ' + \ + repr(simplex_tree.num_vertices()) + ' vertices.' + print(result_str) + for filtered_value in simplex_tree.get_filtered_tree(): + print(filtered_value) + +the program output is: + +.. testoutput:: + + Rips complex is of dimension 1 - 18 simplices - 7 vertices. + ([0], 0.0) + ([1], 0.0) + ([2], 0.0) + ([3], 0.0) + ([4], 0.0) + ([5], 0.0) + ([6], 0.0) + ([2, 3], 5.0) + ([4, 5], 5.385164807134504) + ([0, 2], 5.830951894845301) + ([0, 1], 6.082762530298219) + ([1, 3], 6.324555320336759) + ([1, 2], 6.708203932499369) + ([5, 6], 7.280109889280518) + ([2, 4], 8.94427190999916) + ([0, 3], 9.433981132056603) + ([4, 6], 9.486832980505138) + ([3, 6], 11.0) diff --git a/src/cython/doc/simplex_tree_sum.rst b/src/cython/doc/simplex_tree_sum.rst index 0f34888a..b79cf4fd 100644 --- a/src/cython/doc/simplex_tree_sum.rst +++ b/src/cython/doc/simplex_tree_sum.rst @@ -1,13 +1,14 @@ -===================================== ===================================== ===================================== -:Author: Clément Maria :Introduced in: GUDHI 1.0.0 :Copyright: GPL v3 -===================================== ===================================== ===================================== +================================================================= =================================== =================================== +:Author: Clément Maria :Introduced in: GUDHI 1.0.0 :Copyright: GPL v3 +================================================================= =================================== =================================== -+-------------------------------------------+----------------------------------------------------------------------+ -| .. image:: | The simplex tree is an efficient and flexible data structure for | -| img/Simplex_tree_representation.png | representing general (filtered) simplicial complexes. | -| | | -| | The data structure is described in | -| | :cite:`boissonnatmariasimplextreealgorithmica` | -+-------------------------------------------+----------------------------------------------------------------------+ -| :doc:`simplex_tree_user` | :doc:`simplex_tree_ref` | -+-------------------------------------------+----------------------------------------------------------------------+ ++----------------------------------------------------------------+------------------------------------------------------------------------+ +| .. figure:: | The simplex tree is an efficient and flexible data structure for | +| img/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` | ++----------------------------------------------------------------+------------------------------------------------------------------------+ diff --git a/src/cython/doc/tangential_complex_sum.rst b/src/cython/doc/tangential_complex_sum.rst index 4e358a7b..2b05bc10 100644 --- a/src/cython/doc/tangential_complex_sum.rst +++ b/src/cython/doc/tangential_complex_sum.rst @@ -1,16 +1,15 @@ -===================================== ===================================== ===================================== -:Author: Clément Jamin :Introduced in: GUDHI 1.4.0 :Copyright: GPL v3 -===================================== ===================================== ===================================== -:Requires: CGAL ≥ 4.8.0 Eigen3 -===================================== ===================================== ===================================== +================================================================= =================================== =================================== +:Author: Clément Jamin :Introduced in: GUDHI 2.0.0 :Copyright: GPL v3 +:Requires: CGAL :math:`\geq` 4.8.0 Eigen3 +================================================================= =================================== =================================== -+-------------------------------------------+----------------------------------------------------------------------+ -| .. image:: | A Tangential Delaunay complex is a simplicial complex designed to | -| img/tc_examples.png | reconstruct a :math:`k`-dimensional manifold embedded in :math:`d`- | -| | dimensional Euclidean space. The input is a point sample coming from | -| | an unknown manifold. The running time depends only linearly on the | -| | 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 | +| img/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` | ++----------------------------------------------------------------+------------------------------------------------------------------------+ diff --git a/src/cython/doc/tangential_complex_user.rst b/src/cython/doc/tangential_complex_user.rst index 7b6c9e79..2679528c 100644 --- a/src/cython/doc/tangential_complex_user.rst +++ b/src/cython/doc/tangential_complex_user.rst @@ -26,6 +26,7 @@ example, with :math:`k = 1` and :math:`d = 2`. The input data is 4 points .. figure:: img/tc_example_01.png :alt: The input :figclass: align-center + The input For each point :math:`p`, estimate its tangent subspace :math:`T_p` (e.g. @@ -34,8 +35,10 @@ using PCA). .. figure:: img/tc_example_02.png :alt: The estimated normals :figclass: align-center + The estimated normals + Let us add the Voronoi diagram of the points in orange. For each point :math:`p`, construct its star in the Delaunay triangulation of :math:`P` restricted to :math:`T_p`. @@ -43,6 +46,7 @@ restricted to :math:`T_p`. .. figure:: img/tc_example_03.png :alt: The Voronoi diagram :figclass: align-center + The Voronoi diagram The Tangential Delaunay complex is the union of those stars. @@ -62,6 +66,7 @@ Let us take the same example. .. figure:: img/tc_example_07_before.png :alt: Before :figclass: align-center + Before Let us slightly move the tangent subspace :math:`T_q` @@ -69,6 +74,7 @@ Let us slightly move the tangent subspace :math:`T_q` .. figure:: img/tc_example_07_after.png :alt: After :figclass: align-center + After Now, the star of :math:`Q` contains :math:`QP`, but the star of :math:`P` does @@ -77,6 +83,7 @@ not contain :math:`QP`. We have an inconsistency. .. figure:: img/tc_example_08.png :alt: After :figclass: align-center + After One way to solve inconsistencies is to randomly perturb the positions of the diff --git a/src/cython/doc/witness_complex_sum.rst b/src/cython/doc/witness_complex_sum.rst index 005a5a41..22ef36ea 100644 --- a/src/cython/doc/witness_complex_sum.rst +++ b/src/cython/doc/witness_complex_sum.rst @@ -1,25 +1,25 @@ -===================================== ===================================== ===================================== -:Author: Siargey Kachanovich :Introduced in: GUDHI 1.3.0 :Copyright: GPL v3 -===================================== ===================================== ===================================== +================================================================= =================================== =================================== +:Author: Siargey Kachanovich :Introduced in: GUDHI 1.3.0 :Copyright: GPL v3 +================================================================= =================================== =================================== -+---------------------------------------------+----------------------------------------------------------------------+ -| .. image:: | Witness complex :math:`Wit(W,L)` is a simplicial complex defined on | -| img/Witness_complex_representation.png | two sets of points in :math:`\mathbb{R}^D`:Wit(W,L)` is a simplicial | -| | complex defined on two sets of points in :math:`\mathbb{R}^D`: | -| | | -| | * :math:`W` set of **witnesses** and | -| | * :math:`L \subseteq W` set of **landmarks**. | -| | | -| | The simplices are based on landmarks and a simplex belongs to the | -| | witness complex if and only if it is witnessed, that is: | -| | | -| | :math:`\sigma \subset L` is witnessed if there exists a point | -| | :math:`w \in W` such that w is closer to the vertices of | -| | :math:`\sigma` than other points in :math:`L` and all of its faces | -| | are witnessed as well. | -| | | -| | The data structure is described in | -| | :cite:`boissonnatmariasimplextreealgorithmica`. | -+---------------------------------------------+----------------------------------------------------------------------+ -| :doc:`witness_complex_user` | :doc:`witness_complex_ref` | -+---------------------------------------------+----------------------------------------------------------------------+ ++-----------------------------------------------------------------+----------------------------------------------------------------------+ +| .. image:: | Witness complex :math:`Wit(W,L)` is a simplicial complex defined on | +| img/Witness_complex_representation.png | two sets of points in :math:`\mathbb{R}^D`:Wit(W,L)` is a simplicial | +| | complex defined on two sets of points in :math:`\mathbb{R}^D`: | +| | | +| | * :math:`W` set of **witnesses** and | +| | * :math:`L \subseteq W` set of **landmarks**. | +| | | +| | The simplices are based on landmarks and a simplex belongs to the | +| | witness complex if and only if it is witnessed, that is: | +| | | +| | :math:`\sigma \subset L` is witnessed if there exists a point | +| | :math:`w \in W` such that w is closer to the vertices of | +| | :math:`\sigma` than other points in :math:`L` and all of its faces | +| | are witnessed as well. | +| | | +| | The data structure is described in | +| | :cite:`boissonnatmariasimplextreealgorithmica`. | ++-----------------------------------------------------------------+----------------------------------------------------------------------+ +| :doc:`witness_complex_user` | :doc:`witness_complex_ref` | ++-----------------------------------------------------------------+----------------------------------------------------------------------+ -- cgit v1.2.3 From 83b319fd05b8bbba8549eea2069ad9b4cfd41525 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Wed, 22 Feb 2017 10:57:52 +0000 Subject: Code review fix (revision numbers for python version) git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/ST_cythonize@2090 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 4a0ed2167cc2efdb5a08f91866ee071daa062b61 --- src/cython/doc/alpha_complex_sum.rst | 2 +- src/cython/doc/cubical_complex_sum.rst | 2 +- src/cython/doc/cubical_complex_user.rst | 2 +- src/cython/doc/persistent_cohomology_sum.rst | 2 +- src/cython/doc/persistent_cohomology_user.rst | 2 +- src/cython/doc/rips_complex_sum.rst | 2 +- src/cython/doc/simplex_tree_sum.rst | 2 +- src/cython/doc/witness_complex_sum.rst | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src/cython/doc/alpha_complex_sum.rst') diff --git a/src/cython/doc/alpha_complex_sum.rst b/src/cython/doc/alpha_complex_sum.rst index 0ccbcc21..8437e901 100644 --- a/src/cython/doc/alpha_complex_sum.rst +++ b/src/cython/doc/alpha_complex_sum.rst @@ -1,5 +1,5 @@ ================================================================= =================================== =================================== -:Author: Vincent Rouvreau :Introduced in: GUDHI 1.3.0 :Copyright: GPL v3 +:Author: Vincent Rouvreau :Introduced in: GUDHI 2.0.0 :Copyright: GPL v3 :Requires: CGAL :math:`\geq` 4.7.0 Eigen3 ================================================================= =================================== =================================== diff --git a/src/cython/doc/cubical_complex_sum.rst b/src/cython/doc/cubical_complex_sum.rst index 399c2357..3ddf6375 100644 --- a/src/cython/doc/cubical_complex_sum.rst +++ b/src/cython/doc/cubical_complex_sum.rst @@ -1,5 +1,5 @@ ================================================================= =================================== =================================== -:Author: Pawel Dlotko :Introduced in: GUDHI 1.3.0 :Copyright: GPL v3 +:Author: Pawel Dlotko :Introduced in: GUDHI 2.0.0 :Copyright: GPL v3 ================================================================= =================================== =================================== +-----------------------------------------------------------------+----------------------------------------------------------------------+ diff --git a/src/cython/doc/cubical_complex_user.rst b/src/cython/doc/cubical_complex_user.rst index 809aaddf..002a648b 100644 --- a/src/cython/doc/cubical_complex_user.rst +++ b/src/cython/doc/cubical_complex_user.rst @@ -5,7 +5,7 @@ Definition ---------- ===================================== ===================================== ===================================== -:Author: Pawel Dlotko :Introduced in: GUDHI PYTHON 1.3.0 :Copyright: GPL v3 +:Author: Pawel Dlotko :Introduced in: GUDHI PYTHON 2.0.0 :Copyright: GPL v3 ===================================== ===================================== ===================================== +---------------------------------------------+----------------------------------------------------------------------+ diff --git a/src/cython/doc/persistent_cohomology_sum.rst b/src/cython/doc/persistent_cohomology_sum.rst index 5d059b00..d1f79cb4 100644 --- a/src/cython/doc/persistent_cohomology_sum.rst +++ b/src/cython/doc/persistent_cohomology_sum.rst @@ -1,5 +1,5 @@ ================================================================= =================================== =================================== -:Author: Clément Maria :Introduced in: GUDHI 1.0.0 :Copyright: GPL v3 +:Author: Clément Maria :Introduced in: GUDHI 2.0.0 :Copyright: GPL v3 ================================================================= =================================== =================================== +-----------------------------------------------------------------+-----------------------------------------------------------------------+ diff --git a/src/cython/doc/persistent_cohomology_user.rst b/src/cython/doc/persistent_cohomology_user.rst index d264a011..1e1cc5e8 100644 --- a/src/cython/doc/persistent_cohomology_user.rst +++ b/src/cython/doc/persistent_cohomology_user.rst @@ -4,7 +4,7 @@ Persistent cohomology user manual Definition ---------- ===================================== ===================================== ===================================== -:Author: Clément Maria :Introduced in: GUDHI PYTHON 1.4.0 :Copyright: GPL v3 +:Author: Clément Maria :Introduced in: GUDHI PYTHON 2.0.0 :Copyright: GPL v3 ===================================== ===================================== ===================================== +---------------------------------------------+----------------------------------------------------------------------+ diff --git a/src/cython/doc/rips_complex_sum.rst b/src/cython/doc/rips_complex_sum.rst index eae6b499..2b65fc19 100644 --- a/src/cython/doc/rips_complex_sum.rst +++ b/src/cython/doc/rips_complex_sum.rst @@ -1,5 +1,5 @@ ================================================================= =================================== =================================== -:Author: Clément Maria, Pawel Dlotko, Vincent Rouvreau :Introduced in: GUDHI 1.0.0 :Copyright: GPL v3 +:Author: Clément Maria, Pawel Dlotko, Vincent Rouvreau :Introduced in: GUDHI 2.0.0 :Copyright: GPL v3 ================================================================= =================================== =================================== +----------------------------------------------------------------+------------------------------------------------------------------------+ diff --git a/src/cython/doc/simplex_tree_sum.rst b/src/cython/doc/simplex_tree_sum.rst index b79cf4fd..3174fb62 100644 --- a/src/cython/doc/simplex_tree_sum.rst +++ b/src/cython/doc/simplex_tree_sum.rst @@ -1,5 +1,5 @@ ================================================================= =================================== =================================== -:Author: Clément Maria :Introduced in: GUDHI 1.0.0 :Copyright: GPL v3 +:Author: Clément Maria :Introduced in: GUDHI 2.0.0 :Copyright: GPL v3 ================================================================= =================================== =================================== +----------------------------------------------------------------+------------------------------------------------------------------------+ diff --git a/src/cython/doc/witness_complex_sum.rst b/src/cython/doc/witness_complex_sum.rst index 22ef36ea..1b20d4bc 100644 --- a/src/cython/doc/witness_complex_sum.rst +++ b/src/cython/doc/witness_complex_sum.rst @@ -1,5 +1,5 @@ ================================================================= =================================== =================================== -:Author: Siargey Kachanovich :Introduced in: GUDHI 1.3.0 :Copyright: GPL v3 +:Author: Siargey Kachanovich :Introduced in: GUDHI 2.0.0 :Copyright: GPL v3 ================================================================= =================================== =================================== +-----------------------------------------------------------------+----------------------------------------------------------------------+ -- cgit v1.2.3