From af52d14be2d742ee73df418dd8a8464e2f849d74 Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Wed, 12 Jun 2019 11:05:49 +0200 Subject: Only one constructor to clarify documentation about persistence_dim_max parameter --- .../include/gudhi/Persistent_cohomology.h | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/Persistent_cohomology/include/gudhi/Persistent_cohomology.h b/src/Persistent_cohomology/include/gudhi/Persistent_cohomology.h index c57174cb..689a17c0 100644 --- a/src/Persistent_cohomology/include/gudhi/Persistent_cohomology.h +++ b/src/Persistent_cohomology/include/gudhi/Persistent_cohomology.h @@ -98,9 +98,13 @@ class Persistent_cohomology { * * @param[in] cpx Complex for which the persistent homology is computed. * cpx is a model of FilteredComplex + * + * @param[in] persistence_dim_max if true, the persistent homology for the maximal dimension in the + * complex is computed. If false, it is ignored. Default is false. + * * @exception std::out_of_range In case the number of simplices is more than Simplex_key type numeric limit. */ - explicit Persistent_cohomology(FilteredComplex& cpx) + explicit Persistent_cohomology(FilteredComplex& cpx, bool persistence_dim_max = false) : cpx_(&cpx), dim_max_(cpx.dimension()), // upper bound on the dimension of the simplices coeff_field_(), // initialize the field coefficient structure. @@ -126,18 +130,6 @@ class Persistent_cohomology { ++idx_fil; dsets_.make_set(cpx_->key(sh)); } - } - - /** \brief Initializes the Persistent_cohomology class. - * - * @param[in] cpx Complex for which the persistent homology is compiuted. - * cpx is a model of FilteredComplex - * - * @param[in] persistence_dim_max if true, the persistent homology for the maximal dimension in the - * complex is computed. If false, it is ignored. Default is false. - */ - Persistent_cohomology(FilteredComplex& cpx, bool persistence_dim_max) - : Persistent_cohomology(cpx) { if (persistence_dim_max) { ++dim_max_; } -- cgit v1.2.3 From 2f85df31681bb808a39fbeff9d0787ba7f632052 Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Wed, 12 Jun 2019 11:44:01 +0200 Subject: Fix alpha complex 3d utilities and add links to utils pages --- .../doc/Intro_persistent_cohomology.h | 67 +++++++++++----------- 1 file changed, 35 insertions(+), 32 deletions(-) (limited to 'src') diff --git a/src/Persistent_cohomology/doc/Intro_persistent_cohomology.h b/src/Persistent_cohomology/doc/Intro_persistent_cohomology.h index 5fb9d4d2..3e0ad133 100644 --- a/src/Persistent_cohomology/doc/Intro_persistent_cohomology.h +++ b/src/Persistent_cohomology/doc/Intro_persistent_cohomology.h @@ -154,6 +154,8 @@ diagram. 3 1 0.104347 inf 3 2 0.138335 inf \endcode +More details on the Rips complex utilities dedicated page. + \li Persistent_cohomology/rips_multifield_persistence.cpp computes the Rips complex of a point cloud and outputs its persistence diagram with a family of field coefficients. @@ -166,6 +168,8 @@ The file should contain square or lower triangular distance matrix with semicolo The code do not check if it is dealing with a distance matrix. It is the user responsibility to provide a valid input. Please refer to data/distance_matrix/lower_triangular_distance_matrix.csv for an example of a file. +More details on the Rips complex utilities dedicated page. + \li Rips_complex/rips_correlation_matrix_persistence.cpp computes the Rips complex of a correlation matrix and outputs its persistence diagram. @@ -175,6 +179,8 @@ It is the user responsibility to ensure that this is the case. The input is to b triangular matrix. Please refer to data/correlation_matrix/lower_triangular_correlation_matrix.csv for an example of a file. +More details on the Rips complex utilities dedicated page. + \li Alpha_complex/alpha_complex_3d_persistence.cpp computes the persistent homology with \f$\mathbb{Z}/2\mathbb{Z}\f$ coefficients of the alpha complex on points sampling from an OFF file. @@ -185,48 +191,33 @@ Alpha_complex/alpha_complex_3d_persistence.cpp computes the persistent homol 2 1 0.0934117 1.00003 2 2 0.56444 1.03938 \endcode -\li -Alpha_complex/exact_alpha_complex_3d_persistence.cpp computes the persistent homology with -\f$\mathbb{Z}/2\mathbb{Z}\f$ coefficients of the alpha complex on points sampling from an OFF file. +More details on the Alpha complex utilities dedicated page. + Here, as CGAL computes the exact values, it is slower, but it is necessary when points are on a grid -for instance. -\code $> ./exact_alpha_complex_3d_persistence ../../data/points/sphere3D_pts_on_grid.off -p 2 -m 0.1 \endcode +for instance (the fast version `--fast` would give incorrect values). +\code $> ./alpha_complex_3d_persistence ../../data/points/sphere3D_pts_on_grid.off --exact -p 2 -m 0.1 \endcode \code Simplex_tree dim: 3 2 0 0 inf 2 2 0.0002 0.2028 \endcode -\li -Alpha_complex/weighted_alpha_complex_3d_persistence.cpp computes the persistent homology with +It can also compute the persistent homology with \f$\mathbb{Z}/2\mathbb{Z}\f$ coefficients of the weighted alpha complex on points sampling from an OFF file and a weights file. -\code $> ./weighted_alpha_complex_3d_persistence ../../data/points/tore3D_300.off -../../data/points/tore3D_300.weights -p 2 -m 0.45 \endcode +\code $> ./alpha_complex_3d_persistence ../../data/points/tore3D_300.off +--weight-file ../../data/points/tore3D_300.weights -p 2 -m 0.45 \endcode \code Simplex_tree dim: 3 2 0 -1 inf 2 1 -0.931784 0.000103311 2 1 -0.906588 2.60165e-05 2 2 -0.43556 0.0393798 \endcode -\li -Alpha_complex/alpha_complex_persistence.cpp computes the persistent homology with -\f$\mathbb{Z}/p\mathbb{Z}\f$ coefficients of the alpha complex on points sampling from an OFF file. -\code $> ./alpha_complex_persistence -r 32 -p 2 -m 0.45 ../../data/points/tore3D_300.off \endcode -\code Alpha complex is of dimension 3 - 9273 simplices - 300 vertices. -Simplex_tree dim: 3 -2 0 0 inf -2 1 0.0682162 1.0001 -2 1 0.0934117 1.00003 -2 2 0.56444 1.03938 \endcode - -\li -Alpha_complex/periodic_alpha_complex_3d_persistence.cpp computes the persistent homology with +One can also compute the persistent homology with \f$\mathbb{Z}/2\mathbb{Z}\f$ coefficients of the periodic alpha complex on points sampling from an OFF file. The second parameter is a \ref FileFormatsIsoCuboid file with coordinates of the periodic cuboid. Note that the lengths of the sides of the periodic cuboid have to be the same. -\code $> ./periodic_alpha_complex_3d_persistence ../../data/points/grid_10_10_10_in_0_1.off -../../data/points/iso_cuboid_3_in_0_1.txt -p 3 -m 1.0 \endcode -\code Periodic Delaunay computed. -Simplex_tree dim: 3 +\code $> ./alpha_complex_3d_persistence ../../data/points/grid_10_10_10_in_0_1.off +--cuboid-file ../../data/points/iso_cuboid_3_in_0_1.txt -p 3 -m 1.0 \endcode +\code Simplex_tree dim: 3 3 0 0 inf 3 1 0.0025 inf 3 1 0.0025 inf @@ -236,18 +227,17 @@ Simplex_tree dim: 3 3 2 0.005 inf 3 3 0.0075 inf \endcode -\li -Persistent_cohomology/weighted_periodic_alpha_complex_3d_persistence.cpp computes the persistent homology with +In order to compute the persistent homology with \f$\mathbb{Z}/2\mathbb{Z}\f$ coefficients of the periodic alpha complex on weighted points from an OFF file. The additional parameters of this program are:
(a) The file with the weights of points. The file consist of a sequence of numbers (as many as points). Note that the weight of each single point have to be bounded by 1/64 times the square of the cuboid edge length.
(b) A \ref FileFormatsIsoCuboid file with coordinates of the periodic cuboid. Note that the lengths of the sides of the periodic cuboid have to be the same.
-\code $> ./weighted_periodic_alpha_complex_3d_persistence ../../data/points/shifted_sphere.off -../../data/points/shifted_sphere.weights ../../data/points/iso_cuboid_3_in_0_10.txt 3 1.0 \endcode -\code Weighted Periodic Delaunay computed. -Simplex_tree dim: 3 +\code $> ./alpha_complex_3d_persistence ../../data/points/shifted_sphere.off +--weight-file ../../data/points/shifted_sphere.weights +--cuboid-file ../../data/points/iso_cuboid_3_in_0_10.txt -p 3 -m 1.0 \endcode +\code Simplex_tree dim: 3 3 0 -0.0001 inf 3 1 16.0264 inf 3 1 16.0273 inf @@ -257,6 +247,19 @@ Simplex_tree dim: 3 3 2 36.8838 inf 3 3 58.6783 inf \endcode +\li +Alpha_complex/alpha_complex_persistence.cpp computes the persistent homology with +\f$\mathbb{Z}/p\mathbb{Z}\f$ coefficients of the alpha complex on points sampling from an OFF file. +\code $> ./alpha_complex_persistence -r 32 -p 2 -m 0.45 ../../data/points/tore3D_300.off \endcode +\code Alpha complex is of dimension 3 - 9273 simplices - 300 vertices. +Simplex_tree dim: 3 +2 0 0 inf +2 1 0.0682162 1.0001 +2 1 0.0934117 1.00003 +2 2 0.56444 1.03938 \endcode + +More details on the Alpha complex utilities dedicated page. + \li Persistent_cohomology/plain_homology.cpp computes the plain homology of a simple simplicial complex without filtration values. -- cgit v1.2.3 From 76480abd3edd267077021ffb44fe45c34956f348 Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Wed, 12 Jun 2019 11:53:42 +0200 Subject: Rephrase --- src/Persistent_cohomology/doc/Intro_persistent_cohomology.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Persistent_cohomology/doc/Intro_persistent_cohomology.h b/src/Persistent_cohomology/doc/Intro_persistent_cohomology.h index 3e0ad133..3d28c93a 100644 --- a/src/Persistent_cohomology/doc/Intro_persistent_cohomology.h +++ b/src/Persistent_cohomology/doc/Intro_persistent_cohomology.h @@ -193,7 +193,7 @@ Alpha_complex/alpha_complex_3d_persistence.cpp computes the persistent homol More details on the Alpha complex utilities dedicated page. -Here, as CGAL computes the exact values, it is slower, but it is necessary when points are on a grid +CGAL can be forced to compute the exact values, it is slower, but it is necessary when points are on a grid for instance (the fast version `--fast` would give incorrect values). \code $> ./alpha_complex_3d_persistence ../../data/points/sphere3D_pts_on_grid.off --exact -p 2 -m 0.1 \endcode \code Simplex_tree dim: 3 -- cgit v1.2.3 From e0ba917bbb1a54d43642f14eccb0bb6af8792bc2 Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Thu, 13 Jun 2019 11:27:21 +0200 Subject: Modify plain_homology example to highlight persistence_dim_max parameter --- .../example/plain_homology.cpp | 26 ++++++++++++++-------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/Persistent_cohomology/example/plain_homology.cpp b/src/Persistent_cohomology/example/plain_homology.cpp index a2256060..be2dc4cc 100644 --- a/src/Persistent_cohomology/example/plain_homology.cpp +++ b/src/Persistent_cohomology/example/plain_homology.cpp @@ -50,26 +50,33 @@ int main() { ST st; /* Complex to build. */ - /* 1 3 */ - /* o---o */ - /* /X\ / */ + /* 1 3 5 */ + /* o---o---o */ + /* / \ / */ /* o---o o */ /* 2 0 4 */ - const short triangle012[] = {0, 1, 2}; + const short edge01[] = {0, 1}; + const short edge02[] = {0, 2}; + const short edge12[] = {1, 2}; const short edge03[] = {0, 3}; const short edge13[] = {1, 3}; + const short edge35[] = {3, 5}; const short vertex4[] = {4}; - st.insert_simplex_and_subfaces(triangle012); + st.insert_simplex_and_subfaces(edge01); + st.insert_simplex_and_subfaces(edge02); + st.insert_simplex_and_subfaces(edge12); st.insert_simplex_and_subfaces(edge03); st.insert_simplex(edge13); + st.insert_simplex_and_subfaces(edge35); st.insert_simplex(vertex4); // Sort the simplices in the order of the filtration st.initialize_filtration(); // Class for homology computation - Persistent_cohomology pcoh(st); + // We want persistent homology to be computed for the maximal dimension in the complex (persistence_dim_max = true) + Persistent_cohomology pcoh(st, true); // Initialize the coefficient field Z/2Z for homology pcoh.init_coefficients(2); @@ -82,13 +89,14 @@ int main() { // 2 0 0 inf // 2 0 0 inf // 2 1 0 inf - // means that in Z/2Z-homology, the Betti numbers are b0=2 and b1=1. + // 2 1 0 inf + // means that in Z/2Z-homology, the Betti numbers are b0=2 and b1=2. pcoh.output_diagram(); - // Print the Betti numbers are b0=2 and b1=1. + // Print the Betti numbers are b0=2 and b1=2. std::cout << std::endl; std::cout << "The Betti numbers are : "; - for (int i = 0; i < st.dimension(); i++) + for (int i = 0; i < 3; i++) std::cout << "b" << i << " = " << pcoh.betti_number(i) << " ; "; std::cout << std::endl; } -- cgit v1.2.3 From aaf2b79181c1b0f935d2b2110f0e7f48fb98b35b Mon Sep 17 00:00:00 2001 From: Vincent Rouvreau Date: Thu, 13 Jun 2019 17:56:22 +0200 Subject: Update src/Persistent_cohomology/example/plain_homology.cpp Co-Authored-By: Marc Glisse --- src/Persistent_cohomology/example/plain_homology.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Persistent_cohomology/example/plain_homology.cpp b/src/Persistent_cohomology/example/plain_homology.cpp index be2dc4cc..1c70ba5d 100644 --- a/src/Persistent_cohomology/example/plain_homology.cpp +++ b/src/Persistent_cohomology/example/plain_homology.cpp @@ -75,7 +75,8 @@ int main() { st.initialize_filtration(); // Class for homology computation - // We want persistent homology to be computed for the maximal dimension in the complex (persistence_dim_max = true) + // By default, since the complex has dimension 1, only 0-dimensional homology would be computed. + // Here we also want persistent homology to be computed for the maximal dimension in the complex (persistence_dim_max = true) Persistent_cohomology pcoh(st, true); // Initialize the coefficient field Z/2Z for homology -- cgit v1.2.3 From 9f249e001089af45186aaf0d196d6300705eee31 Mon Sep 17 00:00:00 2001 From: Vincent Rouvreau <10407034+VincentRouvreau@users.noreply.github.com> Date: Wed, 26 Jun 2019 11:38:54 +0200 Subject: Reverse #aedd692 that changed copyright year --- src/cython/cython/cubical_complex.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/cython/cython/cubical_complex.pyx b/src/cython/cython/cubical_complex.pyx index 53d79b92..509af6ca 100644 --- a/src/cython/cython/cubical_complex.pyx +++ b/src/cython/cython/cubical_complex.pyx @@ -13,7 +13,7 @@ from numpy import array as np_array Author(s): Vincent Rouvreau - Copyright (C) 2019 Inria + 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 -- cgit v1.2.3