diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Nerve_GIC/include/gudhi/GIC.h | 27 | ||||
-rw-r--r-- | src/cmake/modules/GUDHI_modules.cmake | 2 | ||||
-rw-r--r-- | src/cython/cython/nerve_gic.pyx | 21 |
3 files changed, 39 insertions, 11 deletions
diff --git a/src/Nerve_GIC/include/gudhi/GIC.h b/src/Nerve_GIC/include/gudhi/GIC.h index fea0b861..2c37dfae 100644 --- a/src/Nerve_GIC/include/gudhi/GIC.h +++ b/src/Nerve_GIC/include/gudhi/GIC.h @@ -226,7 +226,25 @@ class Cover_complex { void set_mask(int nodemask) { mask = nodemask; } public: - /** \brief Reads and stores the input point cloud. + + + /** \brief Reads and stores the input point cloud from vector stored in memory. + * + * @param[in] cloud input vector representing the point cloud. Each row is a point and each coordinate is a vector. + * + */ + template <class InputRange> + void set_point_cloud_from_range(InputRange const & cloud) { + n = cloud.size(); data_dimension = cloud[0].size(); point_cloud_name = "matrix"; + for(int i = 0; i < n; i++){ + point_cloud.emplace_back(cloud[i].begin(), cloud[i].begin() + data_dimension); + boost::add_vertex(one_skeleton_OFF); + vertices.push_back(boost::add_vertex(one_skeleton)); + cover.emplace_back(); + } + } + + /** \brief Reads and stores the input point cloud from .(n)OFF file. * * @param[in] off_file_name name of the input .OFF or .nOFF file. * @@ -964,7 +982,7 @@ class Cover_complex { * @param[in] color input vector of values. * */ - void set_color_from_vector(std::vector<double> color) { + void set_color_from_range(std::vector<double> color) { for (unsigned int i = 0; i < color.size(); i++) func_color.push_back(color[i]); } @@ -1108,7 +1126,7 @@ class Cover_complex { /** \brief Computes the extended persistence diagram of the complex. * */ - void compute_PD() { + Persistence_diagram compute_PD() { Simplex_tree st; // Compute max and min @@ -1159,6 +1177,7 @@ class Cover_complex { if (verbose) std::cout << " [" << birth << ", " << death << "]" << std::endl; } } + return PD; } public: @@ -1184,7 +1203,7 @@ class Cover_complex { Cboot.point_cloud.push_back(this->point_cloud[id]); Cboot.cover.emplace_back(); Cboot.func.push_back(this->func[id]); boost::add_vertex(Cboot.one_skeleton_OFF); Cboot.vertices.push_back(boost::add_vertex(Cboot.one_skeleton)); } - Cboot.set_color_from_vector(Cboot.func); + Cboot.set_color_from_range(Cboot.func); for (int j = 0; j < n; j++) { std::vector<double> dist(n); diff --git a/src/cmake/modules/GUDHI_modules.cmake b/src/cmake/modules/GUDHI_modules.cmake index f95d0c34..276fb2cc 100644 --- a/src/cmake/modules/GUDHI_modules.cmake +++ b/src/cmake/modules/GUDHI_modules.cmake @@ -17,7 +17,7 @@ function(add_gudhi_module file_path) endfunction(add_gudhi_module) option(WITH_GUDHI_BENCHMARK "Activate/desactivate benchmark compilation" OFF) -option(WITH_GUDHI_EXAMPLE "Activate/desactivate examples compilation and installation" OFF) +option(WITH_GUDHI_EXAMPLE "Activate/desactivate examples compilation and installation" ON) option(WITH_GUDHI_PYTHON "Activate/desactivate python module compilation and installation" ON) option(WITH_GUDHI_TEST "Activate/desactivate examples compilation and installation" ON) option(WITH_GUDHI_UTILITIES "Activate/desactivate utilities compilation and installation" ON) diff --git a/src/cython/cython/nerve_gic.pyx b/src/cython/cython/nerve_gic.pyx index 30a14d3b..01dd0a4b 100644 --- a/src/cython/cython/nerve_gic.pyx +++ b/src/cython/cython/nerve_gic.pyx @@ -38,14 +38,14 @@ cdef extern from "Nerve_gic_interface.h" namespace "Gudhi": double compute_distance_from_confidence_level(double alpha) void compute_distribution(int N) double compute_p_value() - void compute_PD() + vector[pair[double, double]] compute_PD() void find_simplices() void create_simplex_tree(Simplex_tree_interface_full_featured* simplex_tree) bool read_point_cloud(string off_file_name) double set_automatic_resolution() void set_color_from_coordinate(int k) void set_color_from_file(string color_file_name) - void set_color_from_vector(vector[double] color) + void set_color_from_range(vector[double] color) void set_cover_from_file(string cover_file_name) void set_cover_from_function() void set_cover_from_Euclidean_Voronoi(int m) @@ -67,6 +67,7 @@ cdef extern from "Nerve_gic_interface.h" namespace "Gudhi": void write_info() void plot_DOT() void plot_OFF() + void set_point_cloud_from_range(vector[vector[double]] cloud) # CoverComplex python interface cdef class CoverComplex: @@ -102,6 +103,14 @@ cdef class CoverComplex: """ return self.thisptr != NULL + def set_point_cloud_from_range(self, cloud): + """ Reads and stores the input point cloud from a vector stored in memory. + + :param cloud: Input vector containing the point cloud. + :type cloud: vector[vector[double]] + """ + return self.thisptr.set_point_cloud_from_range(cloud) + def compute_confidence_level_from_distance(self, distance): """Computes the confidence level of a specific bottleneck distance threshold. @@ -145,7 +154,7 @@ cdef class CoverComplex: def compute_PD(self): """Computes the extended persistence diagram of the complex. """ - self.thisptr.compute_PD() + return self.thisptr.compute_PD() def create_simplex_tree(self): """ @@ -162,7 +171,7 @@ cdef class CoverComplex: self.thisptr.find_simplices() def read_point_cloud(self, off_file): - """Reads and stores the input point cloud. + """Reads and stores the input point cloud from .(n)OFF file. :param off_file: Name of the input .OFF or .nOFF file. :type off_file: string @@ -206,14 +215,14 @@ cdef class CoverComplex: else: print("file " + color_file_name + " not found.") - def set_color_from_vector(self, color): + def set_color_from_range(self, color): """Computes the function used to color the nodes of the simplicial complex from a vector stored in memory. :param color: Input vector of values. :type color: vector[double] """ - self.thisptr.set_color_from_vector(color) + self.thisptr.set_color_from_range(color) def set_cover_from_file(self, cover_file_name): """Creates the cover C from a file containing the cover elements of |