diff options
author | vrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2016-11-28 16:55:08 +0000 |
---|---|---|
committer | vrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2016-11-28 16:55:08 +0000 |
commit | 844f8b075d9143466040c4d46a181e4a0fcbbda4 (patch) | |
tree | e2ba83ae85a176e79fca013c15c0bc9a81e087a3 /src/cython | |
parent | af146a2e48c16855355ac599cbc617250727d244 (diff) |
Fix issues
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/ST_cythonize@1795 636b058d-ea47-450e-bf9e-a15bfbe3eedb
Former-commit-id: c4763818a5845eb884b245eca8c78ed60c1a28ca
Diffstat (limited to 'src/cython')
-rw-r--r-- | src/cython/cython/alpha_complex.pyx | 26 | ||||
-rw-r--r-- | src/cython/doc/index.rst | 5 | ||||
-rw-r--r-- | src/cython/doc/tangential_complex_sum.rst | 2 | ||||
-rw-r--r-- | src/cython/include/Alpha_complex_interface.h | 128 | ||||
-rw-r--r-- | src/cython/include/Simplex_tree_interface.h | 8 | ||||
-rw-r--r-- | src/cython/include/Tangential_complex_interface.h | 1 |
6 files changed, 18 insertions, 152 deletions
diff --git a/src/cython/cython/alpha_complex.pyx b/src/cython/cython/alpha_complex.pyx index 9bf7b257..ed518c38 100644 --- a/src/cython/cython/alpha_complex.pyx +++ b/src/cython/cython/alpha_complex.pyx @@ -37,27 +37,7 @@ cdef extern from "Alpha_complex_interface.h" namespace "Gudhi": Alpha_complex_interface(vector[vector[double]] points) # bool from_file is a workaround for cython to find the correct signature Alpha_complex_interface(string off_file, 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) void create_simplex_tree(Simplex_tree_interface_full_featured simplex_tree, double max_alpha_square) # AlphaComplex python interface @@ -119,7 +99,7 @@ cdef class AlphaComplex: """This function returns the point corresponding to a given vertex. :param vertex: The vertex. - :type vertex: int. + :type vertex: int :returns: list of float -- the point. """ cdef vector[double] point = self.thisptr.get_point(vertex) @@ -130,9 +110,9 @@ cdef class AlphaComplex: Triangulation. :param simplex_tree: The simplex tree to create (must be empty) - :type simplex tree: gudhi.SimplexTree. + :type simplex_tree: SimplexTree :param max_alpha_square: The maximum alpha square threshold the simplices shall not exceed. Default is set to infinity. - :type max_alpha_square: float. + :type max_alpha_square: float """ self.thisptr.create_simplex_tree(deref(simplex_tree.thisptr), max_alpha_square)
\ No newline at end of file diff --git a/src/cython/doc/index.rst b/src/cython/doc/index.rst index 89e09d70..91e31ff6 100644 --- a/src/cython/doc/index.rst +++ b/src/cython/doc/index.rst @@ -48,6 +48,11 @@ Simplex tree .. include:: simplex_tree_sum.rst +Tangential complex +================== + +.. include:: tangential_complex_sum.rst + Witness complex =============== diff --git a/src/cython/doc/tangential_complex_sum.rst b/src/cython/doc/tangential_complex_sum.rst index a2c0be0e..4e358a7b 100644 --- a/src/cython/doc/tangential_complex_sum.rst +++ b/src/cython/doc/tangential_complex_sum.rst @@ -12,5 +12,5 @@ | | extrinsic dimension :math:`d` and exponentially on the intrinsic | | | dimension :math:`k`. | +-------------------------------------------+----------------------------------------------------------------------+ -| :doc:`tangential_complex_user` | :doc:`tangential_complex_ref` | +| :doc:`tangential_complex_user` | :doc:`tangential_complex_ref` | +-------------------------------------------+----------------------------------------------------------------------+ diff --git a/src/cython/include/Alpha_complex_interface.h b/src/cython/include/Alpha_complex_interface.h index 07f5b5b4..15384206 100644 --- a/src/cython/include/Alpha_complex_interface.h +++ b/src/cython/include/Alpha_complex_interface.h @@ -27,7 +27,6 @@ #include <gudhi/Alpha_complex.h> #include <CGAL/Epick_d.h> -#include "Persistent_cohomology_interface.h" #include "Simplex_tree_interface.h" #include <vector> @@ -50,111 +49,14 @@ class Alpha_complex_interface { typedef typename Simplex_tree<>::Simplex_key Simplex_key; public: - Alpha_complex_interface(std::vector<std::vector<double>>&points) - : pcoh_(nullptr) { + Alpha_complex_interface(std::vector<std::vector<double>>&points) { alpha_complex_ = new Alpha_complex<Dynamic_kernel>(points); } - Alpha_complex_interface(std::string off_file_name, bool from_file = true) - : pcoh_(nullptr) { + Alpha_complex_interface(std::string off_file_name, bool from_file = true) { alpha_complex_ = new Alpha_complex<Dynamic_kernel>(off_file_name); } - 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<double> get_point(int vh) { std::vector<double> vd; try { @@ -167,38 +69,12 @@ class Alpha_complex_interface { return vd; } - std::vector<std::pair<int, std::pair<double, double>>> get_persistence(int homology_coeff_field, double min_persistence) { - if (pcoh_ != nullptr) { - delete pcoh_; - } - pcoh_ = new Persistent_cohomology_interface<Simplex_tree<>>(&simplex_tree_); - return pcoh_->get_persistence(homology_coeff_field, min_persistence); - } - - std::vector<int> get_betti_numbers() const { - if (pcoh_ != nullptr) { - return pcoh_->betti_numbers(); - } - std::vector<int> betti_numbers; - return betti_numbers; - } - - std::vector<int> get_persistent_betti_numbers(Filtration_value from, Filtration_value to) const { - if (pcoh_ != nullptr) { - return pcoh_->persistent_betti_numbers(from, to); - } - std::vector<int> persistent_betti_numbers; - return persistent_betti_numbers; - } - void create_simplex_tree(Simplex_tree_interface<>& simplex_tree, double max_alpha_square) { alpha_complex_->create_complex(simplex_tree, max_alpha_square); simplex_tree.initialize_filtration(); } private: - Simplex_tree<> simplex_tree_; - Persistent_cohomology_interface<Simplex_tree<>>* pcoh_; Alpha_complex<Dynamic_kernel>* alpha_complex_; }; diff --git a/src/cython/include/Simplex_tree_interface.h b/src/cython/include/Simplex_tree_interface.h index 06ec6d40..8e9dd966 100644 --- a/src/cython/include/Simplex_tree_interface.h +++ b/src/cython/include/Simplex_tree_interface.h @@ -28,6 +28,8 @@ #include <gudhi/Simplex_tree.h> #include <gudhi/Points_off_io.h> +#include "Persistent_cohomology_interface.h" + #include <vector> #include <utility> // std::pair #include <iostream> @@ -69,10 +71,8 @@ class Simplex_tree_interface : public Simplex_tree<SimplexTreeOptions> { for (auto f_simplex : Simplex_tree<SimplexTreeOptions>::filtration_simplex_range()) { Simplex simplex; for (auto vertex : Simplex_tree<SimplexTreeOptions>::simplex_vertex_range(f_simplex)) { - std::cout << " " << vertex; simplex.insert(simplex.begin(), vertex); } - std::cout << std::endl; filtered_tree.push_back(std::make_pair(simplex, Simplex_tree<SimplexTreeOptions>::filtration(f_simplex))); } return filtered_tree; @@ -137,6 +137,10 @@ class Simplex_tree_interface : public Simplex_tree<SimplexTreeOptions> { } } + void create_persistence(Gudhi::Persistent_cohomology_interface<Simplex_tree<SimplexTreeOptions>>* pcoh) { + pcoh = new Gudhi::Persistent_cohomology_interface<Simplex_tree<SimplexTreeOptions>>(*this); + } + }; struct Simplex_tree_options_mini : Simplex_tree_options_full_featured { diff --git a/src/cython/include/Tangential_complex_interface.h b/src/cython/include/Tangential_complex_interface.h index 645aad72..e9750e85 100644 --- a/src/cython/include/Tangential_complex_interface.h +++ b/src/cython/include/Tangential_complex_interface.h @@ -29,6 +29,7 @@ #include <CGAL/Epick_d.h> #include "Persistent_cohomology_interface.h" +#include "Simplex_tree_interface.h" #include <vector> #include <utility> // std::pair |