diff options
Diffstat (limited to 'src/cython')
-rw-r--r-- | src/cython/cython/strong_witness_complex.pyx | 81 | ||||
-rw-r--r-- | src/cython/doc/alpha_complex_user.rst | 8 | ||||
-rw-r--r-- | src/cython/doc/biblio.rst | 6 | ||||
-rw-r--r-- | src/cython/doc/cgal_citation.rst | 8 | ||||
-rw-r--r-- | src/cython/doc/cubical_complex_user.rst | 7 | ||||
-rw-r--r-- | src/cython/doc/how_to_cite_cgal.rst | 7 | ||||
-rw-r--r-- | src/cython/doc/index.rst | 7 | ||||
-rw-r--r-- | src/cython/doc/persistent_cohomology_user.rst | 7 | ||||
-rw-r--r-- | src/cython/doc/tangential_complex_user.rst | 7 | ||||
-rw-r--r-- | src/cython/doc/witness_complex_user.rst | 6 | ||||
-rw-r--r-- | src/cython/gudhi.pyx.in | 1 | ||||
-rw-r--r-- | src/cython/include/Simplex_tree_interface.h | 7 | ||||
-rw-r--r-- | src/cython/include/Strong_witness_complex_interface.h | 71 |
13 files changed, 196 insertions, 27 deletions
diff --git a/src/cython/cython/strong_witness_complex.pyx b/src/cython/cython/strong_witness_complex.pyx new file mode 100644 index 00000000..5febffbb --- /dev/null +++ b/src/cython/cython/strong_witness_complex.pyx @@ -0,0 +1,81 @@ +from cython cimport numeric +from libcpp.vector cimport vector +from libcpp.utility cimport pair + +"""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 <http://www.gnu.org/licenses/>. +""" + +__author__ = "Vincent Rouvreau" +__copyright__ = "Copyright (C) 2016 INRIA" +__license__ = "GPL v3" + +cdef extern from "Strong_witness_complex_interface.h" namespace "Gudhi": + cdef cppclass Strong_witness_complex_interface "Gudhi::witness_complex::Strong_witness_complex_interface": + Strong_witness_complex_interface(vector[vector[pair[size_t, double]]] nearest_landmark_table) + void create_simplex_tree(Simplex_tree_interface_full_featured* simplex_tree, double max_alpha_square) + void create_simplex_tree(Simplex_tree_interface_full_featured* simplex_tree, double max_alpha_square, + unsigned limit_dimension) + +# StrongWitnessComplex python interface +cdef class StrongWitnessComplex: + """StrongWitnessComplex is a simplicial complex constructed from ... + + """ + + cdef Strong_witness_complex_interface * thisptr + + # Fake constructor that does nothing but documenting the constructor + 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 + """ + + # The real cython constructor + def __cinit__(self, nearest_landmark_table=None): + if nearest_landmark_table is not None: + self.thisptr = new Strong_witness_complex_interface(nearest_landmark_table) + + def __dealloc__(self): + if self.thisptr != NULL: + del self.thisptr + + def __is_defined(self): + """Returns true if StrongWitnessComplex pointer is not NULL. + """ + return self.thisptr != NULL + + def create_simplex_tree(self, max_alpha_square, limit_dimension = -1): + """ + :param max_alpha_square: The maximum alpha square threshold the + simplices shall not exceed. Default is set to infinity. + :type max_alpha_square: float + :returns: A simplex tree created from the Delaunay Triangulation. + :rtype: SimplexTree + """ + simplex_tree = SimplexTree() + if limit_dimension is not -1: + self.thisptr.create_simplex_tree(simplex_tree.thisptr, max_alpha_square, limit_dimension) + else: + self.thisptr.create_simplex_tree(simplex_tree.thisptr, max_alpha_square) + return simplex_tree diff --git a/src/cython/doc/alpha_complex_user.rst b/src/cython/doc/alpha_complex_user.rst index f1c57248..68e53a77 100644 --- a/src/cython/doc/alpha_complex_user.rst +++ b/src/cython/doc/alpha_complex_user.rst @@ -196,4 +196,10 @@ the program output is: ([2, 3, 6], 36.5) ([2, 4, 6], 37.24489795918368) -.. :include: how_to_cite_cgal.rst +============== +CGAL citations +============== + +.. bibliography:: how_to_cite_cgal.bib + :filter: docnames + :style: unsrt diff --git a/src/cython/doc/biblio.rst b/src/cython/doc/biblio.rst deleted file mode 100644 index 3995e9c0..00000000 --- a/src/cython/doc/biblio.rst +++ /dev/null @@ -1,6 +0,0 @@ -Bibliography -************ - -.. bibliography:: bibliography.bib - :filter: docnames - :style: unsrt diff --git a/src/cython/doc/cgal_citation.rst b/src/cython/doc/cgal_citation.rst deleted file mode 100644 index bbc4ef9e..00000000 --- a/src/cython/doc/cgal_citation.rst +++ /dev/null @@ -1,8 +0,0 @@ -============== -CGAL citations -============== - -.. - bibliography:: how_to_cite_cgal.bib - :filter: docnames - :style: unsrt diff --git a/src/cython/doc/cubical_complex_user.rst b/src/cython/doc/cubical_complex_user.rst index 002a648b..692acdd9 100644 --- a/src/cython/doc/cubical_complex_user.rst +++ b/src/cython/doc/cubical_complex_user.rst @@ -153,4 +153,9 @@ Examples. End user programs are available in cython/example/ folder. -.. include:: biblio.rst +Bibliography +************ + +.. bibliography:: bibliography.bib + :filter: docnames + :style: unsrt diff --git a/src/cython/doc/how_to_cite_cgal.rst b/src/cython/doc/how_to_cite_cgal.rst deleted file mode 100644 index 192e0562..00000000 --- a/src/cython/doc/how_to_cite_cgal.rst +++ /dev/null @@ -1,7 +0,0 @@ -============== -CGAL citations -============== - -.. bibliography:: how_to_cite_cgal.bib - :filter: docnames - :style: unsrt diff --git a/src/cython/doc/index.rst b/src/cython/doc/index.rst index d0165588..fca63d65 100644 --- a/src/cython/doc/index.rst +++ b/src/cython/doc/index.rst @@ -79,4 +79,9 @@ Persistence graphical tools .. include:: persistence_graphical_tools_sum.rst -.. include:: biblio.rst +Bibliography +************ + +.. bibliography:: bibliography.bib + :filter: docnames + :style: unsrt diff --git a/src/cython/doc/persistent_cohomology_user.rst b/src/cython/doc/persistent_cohomology_user.rst index a68e9bdd..69be3b86 100644 --- a/src/cython/doc/persistent_cohomology_user.rst +++ b/src/cython/doc/persistent_cohomology_user.rst @@ -107,4 +107,9 @@ We provide several example files: run these examples with -h for details on thei * :download:`random_cubical_complex_persistence_example.py <../example/random_cubical_complex_persistence_example.py>` * :download:`tangential_complex_plain_homology_from_off_file_example.py <../example/tangential_complex_plain_homology_from_off_file_example.py>` -.. include:: biblio.rst +Bibliography +************ + +.. bibliography:: bibliography.bib + :filter: docnames + :style: unsrt diff --git a/src/cython/doc/tangential_complex_user.rst b/src/cython/doc/tangential_complex_user.rst index 6c3debb4..6a7e6e41 100644 --- a/src/cython/doc/tangential_complex_user.rst +++ b/src/cython/doc/tangential_complex_user.rst @@ -187,4 +187,9 @@ The output is: Tangential contains 4 vertices. Inconsistencies has been fixed. -.. include:: biblio.rst +Bibliography +************ + +.. bibliography:: bibliography.bib + :filter: docnames + :style: unsrt diff --git a/src/cython/doc/witness_complex_user.rst b/src/cython/doc/witness_complex_user.rst index 071d8ef5..72b8d839 100644 --- a/src/cython/doc/witness_complex_user.rst +++ b/src/cython/doc/witness_complex_user.rst @@ -81,5 +81,9 @@ Example2: Computing persistence using strong relaxed witness complex Here is an example of constructing a strong witness complex filtration and computing persistence on it: -.. include:: biblio.rst +Bibliography +************ +.. bibliography:: bibliography.bib + :filter: docnames + :style: unsrt diff --git a/src/cython/gudhi.pyx.in b/src/cython/gudhi.pyx.in index 2d743d4d..60bf0cd7 100644 --- a/src/cython/gudhi.pyx.in +++ b/src/cython/gudhi.pyx.in @@ -30,6 +30,7 @@ include "cython/cubical_complex.pyx" include "cython/periodic_cubical_complex.pyx" include "cython/persistence_graphical_tools.py" include "cython/witness_complex.pyx" +include "cython/strong_witness_complex.pyx" @GUDHI_CYTHON_ALPHA_COMPLEX@ @GUDHI_CYTHON_SUBSAMPLING@ @GUDHI_CYTHON_TANGENTIAL_COMPLEX@ diff --git a/src/cython/include/Simplex_tree_interface.h b/src/cython/include/Simplex_tree_interface.h index 19e02ca4..4f3096c0 100644 --- a/src/cython/include/Simplex_tree_interface.h +++ b/src/cython/include/Simplex_tree_interface.h @@ -59,6 +59,13 @@ class Simplex_tree_interface : public Simplex_tree<SimplexTreeOptions> { return (result.second); } + // Do not interface this function, only used in strong witness interface for complex creation + bool insert_simplex_and_subfaces(const std::vector<std::size_t>& complex, Filtration_value filtration = 0) { + Insertion_result result = Simplex_tree<SimplexTreeOptions>::insert_simplex_and_subfaces(complex, filtration); + Simplex_tree<SimplexTreeOptions>::initialize_filtration(); + return (result.second); + } + Filtration_value simplex_filtration(const Simplex& complex) { return Simplex_tree<SimplexTreeOptions>::filtration(Simplex_tree<SimplexTreeOptions>::find(complex)); } diff --git a/src/cython/include/Strong_witness_complex_interface.h b/src/cython/include/Strong_witness_complex_interface.h new file mode 100644 index 00000000..e59e58ea --- /dev/null +++ b/src/cython/include/Strong_witness_complex_interface.h @@ -0,0 +1,71 @@ +/* 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 <http://www.gnu.org/licenses/>. + */ + +#ifndef STRONG_WITNESS_COMPLEX_INTERFACE_H +#define STRONG_WITNESS_COMPLEX_INTERFACE_H + +#include <gudhi/Simplex_tree.h> +#include <gudhi/Strong_witness_complex.h> + +#include "Simplex_tree_interface.h" + +#include <vector> +#include <utility> // std::pair +#include <iostream> +#include <cstddef> + +namespace Gudhi { + +namespace witness_complex { + +class Strong_witness_complex_interface { + using Nearest_landmark_range = std::vector<std::pair<std::size_t, double>>; + using Nearest_landmark_table = std::vector<Nearest_landmark_range>; + + public: + Strong_witness_complex_interface(Nearest_landmark_table& nlt) { + witness_complex_ = new Strong_witness_complex<Nearest_landmark_table>(nlt); + } + + void create_simplex_tree(Simplex_tree_interface<>* simplex_tree, double max_alpha_square, + std::size_t limit_dimension) { + witness_complex_->create_complex(*simplex_tree, max_alpha_square, limit_dimension); + simplex_tree->initialize_filtration(); + } + + void create_simplex_tree(Simplex_tree_interface<>* simplex_tree, + double max_alpha_square) { + witness_complex_->create_complex(*simplex_tree, max_alpha_square, std::numeric_limits<std::size_t>::max()); + simplex_tree->initialize_filtration(); + } + + private: + Strong_witness_complex<Nearest_landmark_table>* witness_complex_; + +}; + +} // namespace witness_complex + +} // namespace Gudhi + +#endif // STRONG_WITNESS_COMPLEX_INTERFACE_H + |