From 300914816e3e5d347efd9eaa5d06c236ad81511e Mon Sep 17 00:00:00 2001 From: cjamin Date: Thu, 5 Oct 2017 08:26:50 +0000 Subject: Move some utils + update doc so that utilities are shown as examples git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/add_utils_in_gudhi_v2@2756 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: a707d174a382da7efad3d12a73bb66d2c90da599 --- src/Rips_complex/utilities/CMakeLists.txt | 21 +++ src/Rips_complex/utilities/README | 66 +++++++++ .../utilities/rips_distance_matrix_persistence.cpp | 144 ++++++++++++++++++++ src/Rips_complex/utilities/rips_persistence.cpp | 147 +++++++++++++++++++++ 4 files changed, 378 insertions(+) create mode 100644 src/Rips_complex/utilities/CMakeLists.txt create mode 100644 src/Rips_complex/utilities/README create mode 100644 src/Rips_complex/utilities/rips_distance_matrix_persistence.cpp create mode 100644 src/Rips_complex/utilities/rips_persistence.cpp (limited to 'src/Rips_complex') diff --git a/src/Rips_complex/utilities/CMakeLists.txt b/src/Rips_complex/utilities/CMakeLists.txt new file mode 100644 index 00000000..baa571fa --- /dev/null +++ b/src/Rips_complex/utilities/CMakeLists.txt @@ -0,0 +1,21 @@ +cmake_minimum_required(VERSION 2.6) +project(Rips_complex_utilities) + +add_executable(rips_distance_matrix_persistence rips_distance_matrix_persistence.cpp) +target_link_libraries(rips_distance_matrix_persistence ${Boost_PROGRAM_OPTIONS_LIBRARY}) + +add_executable(rips_persistence rips_persistence.cpp) +target_link_libraries(rips_persistence ${Boost_PROGRAM_OPTIONS_LIBRARY}) + +if (TBB_FOUND) + target_link_libraries(rips_distance_matrix_persistence ${TBB_LIBRARIES}) + target_link_libraries(rips_persistence ${TBB_LIBRARIES}) +endif() + +add_test(NAME Rips_complex_utility_from_rips_distance_matrix COMMAND $ + "${CMAKE_SOURCE_DIR}/data/distance_matrix/full_square_distance_matrix.csv" "-r" "1.0" "-d" "3" "-p" "3" "-m" "0") +add_test(NAME Rips_complex_utility_from_rips_on_tore_3D COMMAND $ + "${CMAKE_SOURCE_DIR}/data/points/tore3D_1307.off" "-r" "0.25" "-m" "0.5" "-d" "3" "-p" "3") + +install(TARGETS rips_distance_matrix_persistence DESTINATION bin) +install(TARGETS rips_persistence DESTINATION bin) diff --git a/src/Rips_complex/utilities/README b/src/Rips_complex/utilities/README new file mode 100644 index 00000000..ddb7860f --- /dev/null +++ b/src/Rips_complex/utilities/README @@ -0,0 +1,66 @@ +# Rips_complex # + +## `rips_persistence` ## +This program computes the persistent homology with coefficient field *Z/pZ* of a Rips complex defined on a set of input points. The output diagram contains one bar per line, written with the convention: + +`p dim b d` + +where `dim` is the dimension of the homological feature, `b` and `d` are respectively the birth and death of the feature, and `p` is the characteristic of the field *Z/pZ* used for homology coefficients (`p = p1*...*pr` is the product of prime numbers *pi* such that the homology feature exists in homology with *Z/piZ* coefficients). + +**Usage** +`rips_persistence [options] ` + +**Allowed options** + +* `-h [ --help ]` Produce help message +* `-r [ --max-edge-length ]` (default = inf) Maximal length of an edge for the Rips complex construction. +* `-d [ --cpx-dimension ]` (default = 1) Maximal dimension of the Rips complex we want to compute. +* `-p [ --field-charac ]` (default = 11) Characteristic p of the coefficient field Z/pZ for computing homology. +* `-m [ --min-persistence ]` (default = 0) Minimal lifetime of homology feature to be recorded. Enter a negative value to see zero length intervals. + +**Example 1 with Z/2Z coefficients** +`rips_persistence ../../data/points/tore3D_1307.off -r 0.25 -m 0.5 -d 3 -p 2` + +outputs: +``` +2 0 0 inf +2 1 0.0983494 inf +2 1 0.104347 inf +2 2 0.138335 inf +``` + +**Example 2 with Z/3Z coefficients** + +rips_persistence ../../data/points/tore3D_1307.off -r 0.25 -m 0.5 -d 3 -p 3 + +outputs: +``` +3 0 0 inf +3 1 0.0983494 inf +3 1 0.104347 inf +3 2 0.138335 inf +``` + + + + +## `rips_distance_matrix_persistence` ## +Same as `rips_persistence` but taking an distance matrix as input. + +**Example** +`rips_distance_matrix_persistence data/distance_matrix/full_square_distance_matrix.csv -r 15 -d 3 -p 3 -m 0` + +outputs: +``` +The complex contains 46 simplices + and has dimension 3 +3 0 0 inf +3 0 0 8.94427 +3 0 0 7.28011 +3 0 0 6.08276 +3 0 0 5.83095 +3 0 0 5.38516 +3 0 0 5 +3 1 11 12.0416 +3 1 6.32456 6.7082 +``` diff --git a/src/Rips_complex/utilities/rips_distance_matrix_persistence.cpp b/src/Rips_complex/utilities/rips_distance_matrix_persistence.cpp new file mode 100644 index 00000000..d38808c7 --- /dev/null +++ b/src/Rips_complex/utilities/rips_distance_matrix_persistence.cpp @@ -0,0 +1,144 @@ +/* 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): Pawel Dlotko, 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 . + */ + +#include +#include +#include +#include + +#include + +#include +#include +#include // infinity + +// Types definition +using Simplex_tree = Gudhi::Simplex_tree; +using Filtration_value = Simplex_tree::Filtration_value; +using Rips_complex = Gudhi::rips_complex::Rips_complex; +using Field_Zp = Gudhi::persistent_cohomology::Field_Zp; +using Persistent_cohomology = Gudhi::persistent_cohomology::Persistent_cohomology; +using Distance_matrix = std::vector>; + +void program_options(int argc, char * argv[] + , std::string & csv_matrix_file + , std::string & filediag + , Filtration_value & threshold + , int & dim_max + , int & p + , Filtration_value & min_persistence); + +int main(int argc, char * argv[]) { + std::string csv_matrix_file; + std::string filediag; + Filtration_value threshold; + int dim_max; + int p; + Filtration_value min_persistence; + + program_options(argc, argv, csv_matrix_file, filediag, threshold, dim_max, p, min_persistence); + + Distance_matrix distances = Gudhi::read_lower_triangular_matrix_from_csv_file(csv_matrix_file); + Rips_complex rips_complex_from_file(distances, threshold); + + // Construct the Rips complex in a Simplex Tree + Simplex_tree simplex_tree; + + rips_complex_from_file.create_complex(simplex_tree, dim_max); + std::cout << "The complex contains " << simplex_tree.num_simplices() << " simplices \n"; + std::cout << " and has dimension " << simplex_tree.dimension() << " \n"; + + // Sort the simplices in the order of the filtration + simplex_tree.initialize_filtration(); + + // Compute the persistence diagram of the complex + Persistent_cohomology pcoh(simplex_tree); + // initializes the coefficient field for homology + pcoh.init_coefficients(p); + + pcoh.compute_persistent_cohomology(min_persistence); + + // Output the diagram in filediag + if (filediag.empty()) { + pcoh.output_diagram(); + } else { + std::ofstream out(filediag); + pcoh.output_diagram(out); + out.close(); + } + return 0; +} + +void program_options(int argc, char * argv[] + , std::string & csv_matrix_file + , std::string & filediag + , Filtration_value & threshold + , int & dim_max + , int & p + , Filtration_value & min_persistence) { + namespace po = boost::program_options; + po::options_description hidden("Hidden options"); + hidden.add_options() + ("input-file", po::value(&csv_matrix_file), + "Name of file containing a distance matrix. Can be square or lower triangular matrix. Separator is ';'."); + + po::options_description visible("Allowed options", 100); + visible.add_options() + ("help,h", "produce help message") + ("output-file,o", po::value(&filediag)->default_value(std::string()), + "Name of file in which the persistence diagram is written. Default print in std::cout") + ("max-edge-length,r", + po::value(&threshold)->default_value(std::numeric_limits::infinity()), + "Maximal length of an edge for the Rips complex construction.") + ("cpx-dimension,d", po::value(&dim_max)->default_value(1), + "Maximal dimension of the Rips complex we want to compute.") + ("field-charac,p", po::value(&p)->default_value(11), + "Characteristic p of the coefficient field Z/pZ for computing homology.") + ("min-persistence,m", po::value(&min_persistence), + "Minimal lifetime of homology feature to be recorded. Default is 0. Enter a negative value to see zero length intervals"); + + po::positional_options_description pos; + pos.add("input-file", 1); + + po::options_description all; + all.add(visible).add(hidden); + + po::variables_map vm; + po::store(po::command_line_parser(argc, argv). + options(all).positional(pos).run(), vm); + po::notify(vm); + + if (vm.count("help") || !vm.count("input-file")) { + std::cout << std::endl; + std::cout << "Compute the persistent homology with coefficient field Z/pZ \n"; + std::cout << "of a Rips complex defined on a set of distance matrix.\n \n"; + std::cout << "The output diagram contains one bar per line, written with the convention: \n"; + std::cout << " p dim b d \n"; + std::cout << "where dim is the dimension of the homological feature,\n"; + std::cout << "b and d are respectively the birth and death of the feature and \n"; + std::cout << "p is the characteristic of the field Z/pZ used for homology coefficients." << std::endl << std::endl; + + std::cout << "Usage: " << argv[0] << " [options] input-file" << std::endl << std::endl; + std::cout << visible << std::endl; + std::abort(); + } +} diff --git a/src/Rips_complex/utilities/rips_persistence.cpp b/src/Rips_complex/utilities/rips_persistence.cpp new file mode 100644 index 00000000..d504798b --- /dev/null +++ b/src/Rips_complex/utilities/rips_persistence.cpp @@ -0,0 +1,147 @@ +/* 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): Clément Maria + * + * Copyright (C) 2014 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 . + */ + +#include +#include +#include +#include +#include + +#include + +#include +#include +#include // infinity + +// Types definition +using Simplex_tree = Gudhi::Simplex_tree; +using Filtration_value = Simplex_tree::Filtration_value; +using Rips_complex = Gudhi::rips_complex::Rips_complex; +using Field_Zp = Gudhi::persistent_cohomology::Field_Zp; +using Persistent_cohomology = Gudhi::persistent_cohomology::Persistent_cohomology; +using Point = std::vector; +using Points_off_reader = Gudhi::Points_off_reader; + +void program_options(int argc, char * argv[] + , std::string & off_file_points + , std::string & filediag + , Filtration_value & threshold + , int & dim_max + , int & p + , Filtration_value & min_persistence); + +int main(int argc, char * argv[]) { + std::string off_file_points; + std::string filediag; + Filtration_value threshold; + int dim_max; + int p; + Filtration_value min_persistence; + + program_options(argc, argv, off_file_points, filediag, threshold, dim_max, p, min_persistence); + + Points_off_reader off_reader(off_file_points); + Rips_complex rips_complex_from_file(off_reader.get_point_cloud(), threshold, Gudhi::Euclidean_distance()); + + // Construct the Rips complex in a Simplex Tree + Simplex_tree simplex_tree; + + rips_complex_from_file.create_complex(simplex_tree, dim_max); + std::cout << "The complex contains " << simplex_tree.num_simplices() << " simplices \n"; + std::cout << " and has dimension " << simplex_tree.dimension() << " \n"; + + // Sort the simplices in the order of the filtration + simplex_tree.initialize_filtration(); + + // Compute the persistence diagram of the complex + Persistent_cohomology pcoh(simplex_tree); + // initializes the coefficient field for homology + pcoh.init_coefficients(p); + + pcoh.compute_persistent_cohomology(min_persistence); + + // Output the diagram in filediag + if (filediag.empty()) { + pcoh.output_diagram(); + } else { + std::ofstream out(filediag); + pcoh.output_diagram(out); + out.close(); + } + + return 0; +} + +void program_options(int argc, char * argv[] + , std::string & off_file_points + , std::string & filediag + , Filtration_value & threshold + , int & dim_max + , int & p + , Filtration_value & min_persistence) { + namespace po = boost::program_options; + po::options_description hidden("Hidden options"); + hidden.add_options() + ("input-file", po::value(&off_file_points), + "Name of an OFF file containing a point set.\n"); + + po::options_description visible("Allowed options", 100); + visible.add_options() + ("help,h", "produce help message") + ("output-file,o", po::value(&filediag)->default_value(std::string()), + "Name of file in which the persistence diagram is written. Default print in std::cout") + ("max-edge-length,r", + po::value(&threshold)->default_value(std::numeric_limits::infinity()), + "Maximal length of an edge for the Rips complex construction.") + ("cpx-dimension,d", po::value(&dim_max)->default_value(1), + "Maximal dimension of the Rips complex we want to compute.") + ("field-charac,p", po::value(&p)->default_value(11), + "Characteristic p of the coefficient field Z/pZ for computing homology.") + ("min-persistence,m", po::value(&min_persistence), + "Minimal lifetime of homology feature to be recorded. Default is 0. Enter a negative value to see zero length intervals"); + + po::positional_options_description pos; + pos.add("input-file", 1); + + po::options_description all; + all.add(visible).add(hidden); + + po::variables_map vm; + po::store(po::command_line_parser(argc, argv). + options(all).positional(pos).run(), vm); + po::notify(vm); + + if (vm.count("help") || !vm.count("input-file")) { + std::cout << std::endl; + std::cout << "Compute the persistent homology with coefficient field Z/pZ \n"; + std::cout << "of a Rips complex defined on a set of input points.\n \n"; + std::cout << "The output diagram contains one bar per line, written with the convention: \n"; + std::cout << " p dim b d \n"; + std::cout << "where dim is the dimension of the homological feature,\n"; + std::cout << "b and d are respectively the birth and death of the feature and \n"; + std::cout << "p is the characteristic of the field Z/pZ used for homology coefficients." << std::endl << std::endl; + + std::cout << "Usage: " << argv[0] << " [options] input-file" << std::endl << std::endl; + std::cout << visible << std::endl; + std::abort(); + } +} -- cgit v1.2.3 From 8428e315efa22a1b40eb996c98eff671f91a9b27 Mon Sep 17 00:00:00 2001 From: cjamin Date: Wed, 15 Nov 2017 14:20:30 +0000 Subject: Fixes according to Marc's review git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/add_utils_in_gudhi_v2@2881 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 84870193cb05cabd8c756a3bbc49083e4d739525 --- src/Alpha_complex/utilities/README | 10 +- src/Bottleneck_distance/example/CMakeLists.txt | 12 +- src/Bottleneck_distance/example/README | 19 +++ .../alpha_rips_persistence_bottleneck_distance.cpp | 190 +++++++++++++++++++++ .../example/bottleneck_read_file_example.cpp | 50 ------ src/Bottleneck_distance/utilities/CMakeLists.txt | 11 +- src/Bottleneck_distance/utilities/README | 19 +-- .../alpha_rips_persistence_bottleneck_distance.cpp | 190 --------------------- .../utilities/bottleneck_read_file_example.cpp | 50 ++++++ src/Rips_complex/utilities/README | 2 +- 10 files changed, 281 insertions(+), 272 deletions(-) create mode 100644 src/Bottleneck_distance/example/README create mode 100644 src/Bottleneck_distance/example/alpha_rips_persistence_bottleneck_distance.cpp delete mode 100644 src/Bottleneck_distance/example/bottleneck_read_file_example.cpp delete mode 100644 src/Bottleneck_distance/utilities/alpha_rips_persistence_bottleneck_distance.cpp create mode 100644 src/Bottleneck_distance/utilities/bottleneck_read_file_example.cpp (limited to 'src/Rips_complex') diff --git a/src/Alpha_complex/utilities/README b/src/Alpha_complex/utilities/README index 30e1b187..abb17bf7 100644 --- a/src/Alpha_complex/utilities/README +++ b/src/Alpha_complex/utilities/README @@ -5,14 +5,14 @@ This program computes the persistent homology with coefficient field Z/pZ of the `p dim b d` -where `dim` is the dimension of the homological feature, `b` and `d` are respectively the birth and death of the feature, and `p` is the characteristic of the field *Z/pZ* used for homology coefficients (`p = p1*...*pr` is the product of prime numbers *pi* such that the homology feature exists in homology with *Z/piZ* coefficients). +where `dim` is the dimension of the homological feature, `b` and `d` are respectively the birth and death of the feature, and `p` is the characteristic of the field *Z/pZ* used for homology coefficients (`p` must be a prime number). **Usage** `alpha_complex_3d_persistence

` where `` is the path to the input point cloud in OFF format. `

` is the characteristic p of the coefficient field *Z/pZ* for computing homology. It must be a stricly positive integer. -`` is the minimal lifetime of homology feature to be recorded. Enter a negative value to see zero length intervals. It must be a floating-point number >= -1. +`` is the minimal lifetime of homology feature to be recorded. Enter a negative value to see zero length intervals. **Example** `alpha_complex_3d_persistence ../../data/points/tore3D_300.off 2 0.45` @@ -45,14 +45,14 @@ This program computes the persistent homology with coefficient field Z/pZ of the `p dim b d` -where `dim` is the dimension of the homological feature, `b` and `d` are respectively the birth and death of the feature, and `p` is the characteristic of the field *Z/pZ* used for homology coefficients (`p = p1*...*pr` is the product of prime numbers *pi* such that the homology feature exists in homology with *Z/piZ* coefficients). +where `dim` is the dimension of the homological feature, `b` and `d` are respectively the birth and death of the feature, and `p` is the characteristic of the field *Z/pZ* used for homology coefficients (`p` must be a prime number). **Usage** `periodic_alpha_complex_3d_persistence

` where `` is the path to the input point cloud in OFF format. `

` is the characteristic p of the coefficient field *Z/pZ* for computing homology. It must be a stricly positive integer. -`` is the minimal lifetime of homology feature to be recorded. Enter a negative value to see zero length intervals. It must be a floating-point number >= -1. +`` is the minimal lifetime of homology feature to be recorded. Enter a negative value to see zero length intervals. **Example** `periodic_alpha_complex_3d_persistence ../../data/points/grid_10_10_10_in_0_1.off ../../data/points/iso_cuboid_3_in_0_1.txt 3 1.0` @@ -93,7 +93,7 @@ This program computes the persistent homology with coefficient field Z/pZ of the `p dim b d` -where `dim` is the dimension of the homological feature, `b` and `d` are respectively the birth and death of the feature, and `p` is the characteristic of the field *Z/pZ* used for homology coefficients (`p = p1*...*pr` is the product of prime numbers pi such that the homology feature exists in homology with Z/piZ coefficients). +where `dim` is the dimension of the homological feature, `b` and `d` are respectively the birth and death of the feature, and `p` is the characteristic of the field *Z/pZ* used for homology coefficients (`p` must be a prime number). **Usage** `alpha_complex_persistence [options] ` diff --git a/src/Bottleneck_distance/example/CMakeLists.txt b/src/Bottleneck_distance/example/CMakeLists.txt index 6a602dbb..9677f5c5 100644 --- a/src/Bottleneck_distance/example/CMakeLists.txt +++ b/src/Bottleneck_distance/example/CMakeLists.txt @@ -3,15 +3,15 @@ project(Bottleneck_distance_examples) if (NOT CGAL_VERSION VERSION_LESS 4.8.1) add_executable (bottleneck_basic_example bottleneck_basic_example.cpp) - add_executable (bottleneck_read_file_example bottleneck_read_file_example.cpp) + add_executable (alpha_rips_persistence_bottleneck_distance alpha_rips_persistence_bottleneck_distance.cpp) + target_link_libraries(alpha_rips_persistence_bottleneck_distance ${Boost_PROGRAM_OPTIONS_LIBRARY}) add_test(NAME Bottleneck_distance_example_basic COMMAND $) + add_test(NAME Bottleneck_distance_example_alpha_rips_persistence_bottleneck + COMMAND $ + "${CMAKE_SOURCE_DIR}/data/points/tore3D_1307.off" "-r" "0.15" "-m" "0.12" "-d" "3" "-p" "3") - add_test(NAME Bottleneck_read_file_example - COMMAND $ - "${CMAKE_SOURCE_DIR}/data/persistence_diagram/first.pers" "${CMAKE_SOURCE_DIR}/data/persistence_diagram/second.pers") - - install(TARGETS bottleneck_read_file_example DESTINATION bin) install(TARGETS bottleneck_basic_example DESTINATION bin) + install(TARGETS alpha_rips_persistence_bottleneck_distance DESTINATION bin) endif (NOT CGAL_VERSION VERSION_LESS 4.8.1) diff --git a/src/Bottleneck_distance/example/README b/src/Bottleneck_distance/example/README new file mode 100644 index 00000000..0e314608 --- /dev/null +++ b/src/Bottleneck_distance/example/README @@ -0,0 +1,19 @@ +# Bottleneck_distance # + +## `alpha_rips_persistence_bottleneck_distance` ## +This program computes the persistent homology with coefficient field Z/pZ of a Rips complex defined on a set of input points. The output diagram contains one bar per line, written with the convention: + +`p dim b d` + +where `dim` is the dimension of the homological feature, `b` and `d` are respectively the birth and death of the feature, and `p` is the characteristic of the field *Z/pZ* used for homology coefficients. + +Usage: +`alpha_rips_persistence_bottleneck_distance [options] ` + +Allowed options: + +* `-h [ --help ]` Produce help message +* `-r [ --max-edge-length ]` (default = inf) Maximal length of an edge for the Rips complex construction.` +* `-d [ --cpx-dimension ]` (default = 1) Maximal dimension of the Rips complex we want to compute.` +* `-p [ --field-charac ]` (default = 11) Characteristic p of the coefficient field Z/pZ for computing homology. +* `-m [ --min-persistence ]` (default = 0) Minimal lifetime of homology feature to be recorded. Enter a negative value to see zero length intervals. diff --git a/src/Bottleneck_distance/example/alpha_rips_persistence_bottleneck_distance.cpp b/src/Bottleneck_distance/example/alpha_rips_persistence_bottleneck_distance.cpp new file mode 100644 index 00000000..fd164b22 --- /dev/null +++ b/src/Bottleneck_distance/example/alpha_rips_persistence_bottleneck_distance.cpp @@ -0,0 +1,190 @@ +/* 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) 2017 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 . + */ + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include +#include +#include // infinity +#include // for pair +#include // for transform + + +// Types definition +using Simplex_tree = Gudhi::Simplex_tree; +using Filtration_value = Simplex_tree::Filtration_value; +using Rips_complex = Gudhi::rips_complex::Rips_complex; +using Field_Zp = Gudhi::persistent_cohomology::Field_Zp; +using Persistent_cohomology = Gudhi::persistent_cohomology::Persistent_cohomology; +using Kernel = CGAL::Epick_d< CGAL::Dynamic_dimension_tag >; +using Point_d = Kernel::Point_d; +using Points_off_reader = Gudhi::Points_off_reader; + +void program_options(int argc, char * argv[] + , std::string & off_file_points + , Filtration_value & threshold + , int & dim_max + , int & p + , Filtration_value & min_persistence); + +static inline std::pair compute_root_square(std::pair input) { + return std::make_pair(std::sqrt(input.first), std::sqrt(input.second)); +} + +int main(int argc, char * argv[]) { + std::string off_file_points; + Filtration_value threshold; + int dim_max; + int p; + Filtration_value min_persistence; + + program_options(argc, argv, off_file_points, threshold, dim_max, p, min_persistence); + + Points_off_reader off_reader(off_file_points); + + // -------------------------------------------- + // Rips persistence + // -------------------------------------------- + Rips_complex rips_complex(off_reader.get_point_cloud(), threshold, Gudhi::Euclidean_distance()); + + // Construct the Rips complex in a Simplex Tree + Simplex_tree rips_stree; + + rips_complex.create_complex(rips_stree, dim_max); + std::cout << "The Rips complex contains " << rips_stree.num_simplices() << " simplices and has dimension " + << rips_stree.dimension() << " \n"; + + // Sort the simplices in the order of the filtration + rips_stree.initialize_filtration(); + + // Compute the persistence diagram of the complex + Persistent_cohomology rips_pcoh(rips_stree); + // initializes the coefficient field for homology + rips_pcoh.init_coefficients(p); + rips_pcoh.compute_persistent_cohomology(min_persistence); + + // rips_pcoh.output_diagram(); + + // -------------------------------------------- + // Alpha persistence + // -------------------------------------------- + Gudhi::alpha_complex::Alpha_complex alpha_complex(off_reader.get_point_cloud()); + + Simplex_tree alpha_stree; + alpha_complex.create_complex(alpha_stree, threshold * threshold); + std::cout << "The Alpha complex contains " << alpha_stree.num_simplices() << " simplices and has dimension " + << alpha_stree.dimension() << " \n"; + + // Sort the simplices in the order of the filtration + alpha_stree.initialize_filtration(); + + // Compute the persistence diagram of the complex + Persistent_cohomology alpha_pcoh(alpha_stree); + // initializes the coefficient field for homology + alpha_pcoh.init_coefficients(p); + alpha_pcoh.compute_persistent_cohomology(min_persistence * min_persistence); + + // alpha_pcoh.output_diagram(); + + // -------------------------------------------- + // Bottleneck distance between both persistence + // -------------------------------------------- + double max_b_distance {}; + for (int dim = 0; dim < dim_max; dim ++) { + std::vector< std::pair< Filtration_value , Filtration_value > > rips_intervals; + std::vector< std::pair< Filtration_value , Filtration_value > > alpha_intervals; + rips_intervals = rips_pcoh.intervals_in_dimension(dim); + alpha_intervals = alpha_pcoh.intervals_in_dimension(dim); + std::transform(alpha_intervals.begin(), alpha_intervals.end(), alpha_intervals.begin(), compute_root_square); + + double bottleneck_distance = Gudhi::persistence_diagram::bottleneck_distance(rips_intervals, alpha_intervals); + std::cout << "In dimension " << dim << ", bottleneck distance = " << bottleneck_distance << std::endl; + if (bottleneck_distance > max_b_distance) + max_b_distance = bottleneck_distance; + } + std::cout << "================================================================================" << std::endl; + std::cout << "Bottleneck distance is " << max_b_distance << std::endl; + + return 0; +} + +void program_options(int argc, char * argv[] + , std::string & off_file_points + , Filtration_value & threshold + , int & dim_max + , int & p + , Filtration_value & min_persistence) { + namespace po = boost::program_options; + po::options_description hidden("Hidden options"); + hidden.add_options() + ("input-file", po::value(&off_file_points), + "Name of an OFF file containing a point set.\n"); + + po::options_description visible("Allowed options", 100); + visible.add_options() + ("help,h", "produce help message") + ("max-edge-length,r", + po::value(&threshold)->default_value(std::numeric_limits::infinity()), + "Maximal length of an edge for the Rips complex construction.") + ("cpx-dimension,d", po::value(&dim_max)->default_value(1), + "Maximal dimension of the Rips complex we want to compute.") + ("field-charac,p", po::value(&p)->default_value(11), + "Characteristic p of the coefficient field Z/pZ for computing homology.") + ("min-persistence,m", po::value(&min_persistence), + "Minimal lifetime of homology feature to be recorded. Default is 0. Enter a negative value to see zero length intervals"); + + po::positional_options_description pos; + pos.add("input-file", 1); + + po::options_description all; + all.add(visible).add(hidden); + + po::variables_map vm; + po::store(po::command_line_parser(argc, argv). + options(all).positional(pos).run(), vm); + po::notify(vm); + + if (vm.count("help") || !vm.count("input-file")) { + std::cout << std::endl; + std::cout << "Compute the persistent homology with coefficient field Z/pZ \n"; + std::cout << "of a Rips complex defined on a set of input points.\n \n"; + std::cout << "The output diagram contains one bar per line, written with the convention: \n"; + std::cout << " p dim b d \n"; + std::cout << "where dim is the dimension of the homological feature,\n"; + std::cout << "b and d are respectively the birth and death of the feature and \n"; + std::cout << "p is the characteristic of the field Z/pZ used for homology coefficients." << std::endl << std::endl; + + std::cout << "Usage: " << argv[0] << " [options] input-file" << std::endl << std::endl; + std::cout << visible << std::endl; + std::abort(); + } +} diff --git a/src/Bottleneck_distance/example/bottleneck_read_file_example.cpp b/src/Bottleneck_distance/example/bottleneck_read_file_example.cpp deleted file mode 100644 index 24d73c57..00000000 --- a/src/Bottleneck_distance/example/bottleneck_read_file_example.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/* This file is part of the Gudhi Library. The Gudhi library - * (Geometric Understanding in Higher Dimensions) is a generic C++ - * library for computational topology. - * - * Authors: Francois Godi, small modifications by Pawel Dlotko - * - * Copyright (C) 2015 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 . - */ - -#include -#include -#include -#include -#include // for pair -#include -#include // for numeric_limits - -int main(int argc, char** argv) { - if (argc < 3) { - std::cout << "To run this program please provide as an input two files with persistence diagrams. Each file" << - " should contain a birth-death pair per line. Third, optional parameter is an error bound on a bottleneck" << - " distance (set by default to the smallest positive double value). If you set the error bound to 0, be" << - " aware this version is exact but expensive. The program will now terminate \n"; - return -1; - } - std::vector> diag1 = Gudhi::read_persistence_intervals_in_dimension(argv[1]); - std::vector> diag2 = Gudhi::read_persistence_intervals_in_dimension(argv[2]); - - double tolerance = std::numeric_limits::min(); - if (argc == 4) { - tolerance = atof(argv[3]); - } - double b = Gudhi::persistence_diagram::bottleneck_distance(diag1, diag2, tolerance); - std::cout << "The distance between the diagrams is : " << b << ". The tolerance is : " << tolerance << std::endl; - - return 0; -} diff --git a/src/Bottleneck_distance/utilities/CMakeLists.txt b/src/Bottleneck_distance/utilities/CMakeLists.txt index 634b2479..decdc789 100644 --- a/src/Bottleneck_distance/utilities/CMakeLists.txt +++ b/src/Bottleneck_distance/utilities/CMakeLists.txt @@ -2,16 +2,15 @@ cmake_minimum_required(VERSION 2.6) project(Bottleneck_distance_utilities) if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1) - add_executable (alpha_rips_persistence_bottleneck_distance alpha_rips_persistence_bottleneck_distance.cpp) - target_link_libraries(alpha_rips_persistence_bottleneck_distance ${Boost_PROGRAM_OPTIONS_LIBRARY}) + add_executable (bottleneck_read_file_example bottleneck_read_file_example.cpp) if (TBB_FOUND) target_link_libraries(alpha_rips_persistence_bottleneck_distance ${TBB_LIBRARIES}) endif(TBB_FOUND) - add_test(NAME Bottleneck_distance_example_alpha_rips_persistence_bottleneck - COMMAND $ - "${CMAKE_SOURCE_DIR}/data/points/tore3D_1307.off" "-r" "0.15" "-m" "0.12" "-d" "3" "-p" "3") + add_test(NAME Bottleneck_read_file_example + COMMAND $ + "${CMAKE_SOURCE_DIR}/data/persistence_diagram/first.pers" "${CMAKE_SOURCE_DIR}/data/persistence_diagram/second.pers") - install(TARGETS alpha_rips_persistence_bottleneck_distance DESTINATION bin) + install(TARGETS bottleneck_read_file_example DESTINATION bin) endif (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1) diff --git a/src/Bottleneck_distance/utilities/README b/src/Bottleneck_distance/utilities/README index 4c9b0735..cfdccf0b 100644 --- a/src/Bottleneck_distance/utilities/README +++ b/src/Bottleneck_distance/utilities/README @@ -1,19 +1,10 @@ # Bottleneck_distance # -## `alpha_rips_persistence_bottleneck_distance` ## -This program computes the persistent homology with coefficient field Z/pZ of a Rips complex defined on a set of input points. The output diagram contains one bar per line, written with the convention: - -`p dim b d` - -where `dim` is the dimension of the homological feature, `b` and `d` are respectively the birth and death of the feature, and `p` is the characteristic of the field *Z/pZ* used for homology coefficients. +## `bottleneck_read_file_example` ## +This program computes the Bottleneck distance between two persistence diagram files. Usage: -`alpha_rips_persistence_bottleneck_distance [options] ` - -Allowed options: +`bottleneck_read_file_example []` -* `-h [ --help ]` Produce help message -* `-r [ --max-edge-length ]` (default = inf) Maximal length of an edge for the Rips complex construction.` -* `-d [ --cpx-dimension ]` (default = 1) Maximal dimension of the Rips complex we want to compute.` -* `-p [ --field-charac ]` (default = 11) Characteristic p of the coefficient field Z/pZ for computing homology. -* `-m [ --min-persistence ]` (default = 0) Minimal lifetime of homology feature to be recorded. Enter a negative value to see zero length intervals. \ No newline at end of file + and must be in the format described [here](http://gudhi.gforge.inria.fr/doc/latest/fileformats.html#FileFormatsPers). + is an error bound on the bottleneck distance (set by default to the smallest positive double value). diff --git a/src/Bottleneck_distance/utilities/alpha_rips_persistence_bottleneck_distance.cpp b/src/Bottleneck_distance/utilities/alpha_rips_persistence_bottleneck_distance.cpp deleted file mode 100644 index fd164b22..00000000 --- a/src/Bottleneck_distance/utilities/alpha_rips_persistence_bottleneck_distance.cpp +++ /dev/null @@ -1,190 +0,0 @@ -/* 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) 2017 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 . - */ - -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - -#include -#include -#include // infinity -#include // for pair -#include // for transform - - -// Types definition -using Simplex_tree = Gudhi::Simplex_tree; -using Filtration_value = Simplex_tree::Filtration_value; -using Rips_complex = Gudhi::rips_complex::Rips_complex; -using Field_Zp = Gudhi::persistent_cohomology::Field_Zp; -using Persistent_cohomology = Gudhi::persistent_cohomology::Persistent_cohomology; -using Kernel = CGAL::Epick_d< CGAL::Dynamic_dimension_tag >; -using Point_d = Kernel::Point_d; -using Points_off_reader = Gudhi::Points_off_reader; - -void program_options(int argc, char * argv[] - , std::string & off_file_points - , Filtration_value & threshold - , int & dim_max - , int & p - , Filtration_value & min_persistence); - -static inline std::pair compute_root_square(std::pair input) { - return std::make_pair(std::sqrt(input.first), std::sqrt(input.second)); -} - -int main(int argc, char * argv[]) { - std::string off_file_points; - Filtration_value threshold; - int dim_max; - int p; - Filtration_value min_persistence; - - program_options(argc, argv, off_file_points, threshold, dim_max, p, min_persistence); - - Points_off_reader off_reader(off_file_points); - - // -------------------------------------------- - // Rips persistence - // -------------------------------------------- - Rips_complex rips_complex(off_reader.get_point_cloud(), threshold, Gudhi::Euclidean_distance()); - - // Construct the Rips complex in a Simplex Tree - Simplex_tree rips_stree; - - rips_complex.create_complex(rips_stree, dim_max); - std::cout << "The Rips complex contains " << rips_stree.num_simplices() << " simplices and has dimension " - << rips_stree.dimension() << " \n"; - - // Sort the simplices in the order of the filtration - rips_stree.initialize_filtration(); - - // Compute the persistence diagram of the complex - Persistent_cohomology rips_pcoh(rips_stree); - // initializes the coefficient field for homology - rips_pcoh.init_coefficients(p); - rips_pcoh.compute_persistent_cohomology(min_persistence); - - // rips_pcoh.output_diagram(); - - // -------------------------------------------- - // Alpha persistence - // -------------------------------------------- - Gudhi::alpha_complex::Alpha_complex alpha_complex(off_reader.get_point_cloud()); - - Simplex_tree alpha_stree; - alpha_complex.create_complex(alpha_stree, threshold * threshold); - std::cout << "The Alpha complex contains " << alpha_stree.num_simplices() << " simplices and has dimension " - << alpha_stree.dimension() << " \n"; - - // Sort the simplices in the order of the filtration - alpha_stree.initialize_filtration(); - - // Compute the persistence diagram of the complex - Persistent_cohomology alpha_pcoh(alpha_stree); - // initializes the coefficient field for homology - alpha_pcoh.init_coefficients(p); - alpha_pcoh.compute_persistent_cohomology(min_persistence * min_persistence); - - // alpha_pcoh.output_diagram(); - - // -------------------------------------------- - // Bottleneck distance between both persistence - // -------------------------------------------- - double max_b_distance {}; - for (int dim = 0; dim < dim_max; dim ++) { - std::vector< std::pair< Filtration_value , Filtration_value > > rips_intervals; - std::vector< std::pair< Filtration_value , Filtration_value > > alpha_intervals; - rips_intervals = rips_pcoh.intervals_in_dimension(dim); - alpha_intervals = alpha_pcoh.intervals_in_dimension(dim); - std::transform(alpha_intervals.begin(), alpha_intervals.end(), alpha_intervals.begin(), compute_root_square); - - double bottleneck_distance = Gudhi::persistence_diagram::bottleneck_distance(rips_intervals, alpha_intervals); - std::cout << "In dimension " << dim << ", bottleneck distance = " << bottleneck_distance << std::endl; - if (bottleneck_distance > max_b_distance) - max_b_distance = bottleneck_distance; - } - std::cout << "================================================================================" << std::endl; - std::cout << "Bottleneck distance is " << max_b_distance << std::endl; - - return 0; -} - -void program_options(int argc, char * argv[] - , std::string & off_file_points - , Filtration_value & threshold - , int & dim_max - , int & p - , Filtration_value & min_persistence) { - namespace po = boost::program_options; - po::options_description hidden("Hidden options"); - hidden.add_options() - ("input-file", po::value(&off_file_points), - "Name of an OFF file containing a point set.\n"); - - po::options_description visible("Allowed options", 100); - visible.add_options() - ("help,h", "produce help message") - ("max-edge-length,r", - po::value(&threshold)->default_value(std::numeric_limits::infinity()), - "Maximal length of an edge for the Rips complex construction.") - ("cpx-dimension,d", po::value(&dim_max)->default_value(1), - "Maximal dimension of the Rips complex we want to compute.") - ("field-charac,p", po::value(&p)->default_value(11), - "Characteristic p of the coefficient field Z/pZ for computing homology.") - ("min-persistence,m", po::value(&min_persistence), - "Minimal lifetime of homology feature to be recorded. Default is 0. Enter a negative value to see zero length intervals"); - - po::positional_options_description pos; - pos.add("input-file", 1); - - po::options_description all; - all.add(visible).add(hidden); - - po::variables_map vm; - po::store(po::command_line_parser(argc, argv). - options(all).positional(pos).run(), vm); - po::notify(vm); - - if (vm.count("help") || !vm.count("input-file")) { - std::cout << std::endl; - std::cout << "Compute the persistent homology with coefficient field Z/pZ \n"; - std::cout << "of a Rips complex defined on a set of input points.\n \n"; - std::cout << "The output diagram contains one bar per line, written with the convention: \n"; - std::cout << " p dim b d \n"; - std::cout << "where dim is the dimension of the homological feature,\n"; - std::cout << "b and d are respectively the birth and death of the feature and \n"; - std::cout << "p is the characteristic of the field Z/pZ used for homology coefficients." << std::endl << std::endl; - - std::cout << "Usage: " << argv[0] << " [options] input-file" << std::endl << std::endl; - std::cout << visible << std::endl; - std::abort(); - } -} diff --git a/src/Bottleneck_distance/utilities/bottleneck_read_file_example.cpp b/src/Bottleneck_distance/utilities/bottleneck_read_file_example.cpp new file mode 100644 index 00000000..9dd52b31 --- /dev/null +++ b/src/Bottleneck_distance/utilities/bottleneck_read_file_example.cpp @@ -0,0 +1,50 @@ +/* This file is part of the Gudhi Library. The Gudhi library + * (Geometric Understanding in Higher Dimensions) is a generic C++ + * library for computational topology. + * + * Authors: Francois Godi, small modifications by Pawel Dlotko + * + * Copyright (C) 2015 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 . + */ + +#include +#include +#include +#include +#include // for pair +#include +#include // for numeric_limits + +int main(int argc, char** argv) { + if (argc < 3) { + std::cout << "To run this program please provide as an input two files with persistence diagrams. Each file" << + " should contain a birth-death pair per line. Third, optional parameter is an error bound on the bottleneck" << + " distance (set by default to the smallest positive double value). If you set the error bound to 0, be" << + " aware this version is exact but expensive. The program will now terminate \n"; + return -1; + } + std::vector> diag1 = Gudhi::read_persistence_intervals_in_dimension(argv[1]); + std::vector> diag2 = Gudhi::read_persistence_intervals_in_dimension(argv[2]); + + double tolerance = std::numeric_limits::min(); + if (argc == 4) { + tolerance = atof(argv[3]); + } + double b = Gudhi::persistence_diagram::bottleneck_distance(diag1, diag2, tolerance); + std::cout << "The distance between the diagrams is : " << b << ". The tolerance is : " << tolerance << std::endl; + + return 0; +} diff --git a/src/Rips_complex/utilities/README b/src/Rips_complex/utilities/README index ddb7860f..93ec3658 100644 --- a/src/Rips_complex/utilities/README +++ b/src/Rips_complex/utilities/README @@ -5,7 +5,7 @@ This program computes the persistent homology with coefficient field *Z/pZ* of a `p dim b d` -where `dim` is the dimension of the homological feature, `b` and `d` are respectively the birth and death of the feature, and `p` is the characteristic of the field *Z/pZ* used for homology coefficients (`p = p1*...*pr` is the product of prime numbers *pi* such that the homology feature exists in homology with *Z/piZ* coefficients). +where `dim` is the dimension of the homological feature, `b` and `d` are respectively the birth and death of the feature, and `p` is the characteristic of the field *Z/pZ* used for homology coefficients (`p` must be a prime number). **Usage** `rips_persistence [options] ` -- cgit v1.2.3 From aafe601c247c78a474c6af110ca5b34540a34f44 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Thu, 16 Nov 2017 08:31:26 +0000 Subject: Code review : Homogenize alpha shape examples command line git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/add_utils_in_gudhi_v2@2887 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 8c692434eb48c525047bc34a6fab7d7c1af64d56 --- src/Alpha_complex/utilities/CMakeLists.txt | 19 ++- src/Alpha_complex/utilities/README | 89 +++++++++------ .../utilities/alpha_complex_3d_helper.h | 8 +- .../utilities/alpha_complex_3d_persistence.cpp | 115 ++++++++++++------- .../utilities/alpha_complex_persistence.cpp | 63 +++++----- .../exact_alpha_complex_3d_persistence.cpp | 107 ++++++++++------- .../periodic_alpha_complex_3d_persistence.cpp | 124 ++++++++++++-------- .../weighted_alpha_complex_3d_persistence.cpp | 127 +++++++++++++-------- src/Bottleneck_distance/utilities/CMakeLists.txt | 3 + src/Rips_complex/utilities/README | 3 +- 10 files changed, 406 insertions(+), 252 deletions(-) (limited to 'src/Rips_complex') diff --git a/src/Alpha_complex/utilities/CMakeLists.txt b/src/Alpha_complex/utilities/CMakeLists.txt index 18699650..cefc1ad6 100644 --- a/src/Alpha_complex/utilities/CMakeLists.txt +++ b/src/Alpha_complex/utilities/CMakeLists.txt @@ -3,11 +3,11 @@ project(Alpha_complex_utilities) if(CGAL_FOUND) add_executable(alpha_complex_3d_persistence alpha_complex_3d_persistence.cpp) - target_link_libraries(alpha_complex_3d_persistence ${CGAL_LIBRARY}) + target_link_libraries(alpha_complex_3d_persistence ${CGAL_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY}) add_executable(exact_alpha_complex_3d_persistence exact_alpha_complex_3d_persistence.cpp) - target_link_libraries(exact_alpha_complex_3d_persistence ${CGAL_LIBRARY}) + target_link_libraries(exact_alpha_complex_3d_persistence ${CGAL_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY}) add_executable(weighted_alpha_complex_3d_persistence weighted_alpha_complex_3d_persistence.cpp) - target_link_libraries(weighted_alpha_complex_3d_persistence ${CGAL_LIBRARY}) + target_link_libraries(weighted_alpha_complex_3d_persistence ${CGAL_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY}) if (TBB_FOUND) target_link_libraries(alpha_complex_3d_persistence ${TBB_LIBRARIES}) @@ -16,11 +16,11 @@ if(CGAL_FOUND) endif(TBB_FOUND) add_test(NAME Alpha_complex_utilities_alpha_complex_3d_persistence COMMAND $ - "${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off" "2" "0.45") + "${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off" "-p" "2" "-m" "0.45") add_test(NAME Alpha_complex_utilities_exact_alpha_complex_3d COMMAND $ - "${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off" "2" "0.45") + "${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off" "-p" "2" "-m" "0.45") add_test(NAME Alpha_complex_utilities_weighted_alpha_complex_3d COMMAND $ - "${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off" "${CMAKE_SOURCE_DIR}/data/points/tore3D_300.weights" "2" "0.45") + "${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off" "${CMAKE_SOURCE_DIR}/data/points/tore3D_300.weights" "-p" "2" "-m" "0.45") install(TARGETS alpha_complex_3d_persistence DESTINATION bin) install(TARGETS exact_alpha_complex_3d_persistence DESTINATION bin) @@ -28,11 +28,10 @@ if(CGAL_FOUND) if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.7.0) add_executable (alpha_complex_persistence alpha_complex_persistence.cpp) - target_link_libraries(alpha_complex_persistence - ${CGAL_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY}) + target_link_libraries(alpha_complex_persistence ${CGAL_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY}) add_executable(periodic_alpha_complex_3d_persistence periodic_alpha_complex_3d_persistence.cpp) - target_link_libraries(periodic_alpha_complex_3d_persistence ${CGAL_LIBRARY}) + target_link_libraries(periodic_alpha_complex_3d_persistence ${CGAL_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY}) if (TBB_FOUND) target_link_libraries(alpha_complex_persistence ${TBB_LIBRARIES}) @@ -41,7 +40,7 @@ if(CGAL_FOUND) add_test(NAME Alpha_complex_utilities_alpha_complex_persistence COMMAND $ "${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off" "-p" "2" "-m" "0.45") add_test(NAME Alpha_complex_utilities_periodic_alpha_complex_3d_persistence COMMAND $ - "${CMAKE_SOURCE_DIR}/data/points/grid_10_10_10_in_0_1.off" "${CMAKE_SOURCE_DIR}/data/points/iso_cuboid_3_in_0_1.txt" "2" "0") + "${CMAKE_SOURCE_DIR}/data/points/grid_10_10_10_in_0_1.off" "${CMAKE_SOURCE_DIR}/data/points/iso_cuboid_3_in_0_1.txt" "-p" "2" "-m" "0") install(TARGETS alpha_complex_persistence DESTINATION bin) install(TARGETS periodic_alpha_complex_3d_persistence DESTINATION bin) diff --git a/src/Alpha_complex/utilities/README b/src/Alpha_complex/utilities/README index 6e7d16b7..c3dd170b 100644 --- a/src/Alpha_complex/utilities/README +++ b/src/Alpha_complex/utilities/README @@ -8,22 +8,24 @@ This program computes the persistent homology with coefficient field Z/pZ of the where `dim` is the dimension of the homological feature, `b` and `d` are respectively the birth and death of the feature, and `p` is the characteristic of the field *Z/pZ* used for homology coefficients (`p` must be a prime number). **Usage** -`alpha_complex_3d_persistence

` -where -`` is the path to the input point cloud in OFF format. -`

` is the characteristic p of the coefficient field *Z/pZ* for computing homology. It must be a stricly positive integer. -`` is the minimal lifetime of homology feature to be recorded. Enter a negative value to see zero length intervals. +`alpha_complex_3d_persistence [options] ` + +**Allowed options** +* `-h [ --help ]` Produce help message +* `-o [ --output-file ]` Name of file in which the persistence diagram is written. Default print in standard output. +* `-p [ --field-charac ]` (default=11) Characteristic p of the coefficient field Z/pZ for computing homology. +* `-m [ --min-persistence ]` (default = 0) Minimal lifetime of homology feature to be recorded. Enter a negative value to see zero length intervals. **Example** -`alpha_complex_3d_persistence ../../data/points/tore3D_300.off 2 0.45` +`alpha_complex_3d_persistence ../../data/points/tore3D_300.off -p 2 -m 0.45` outputs: ``` 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 +2 0 0 inf +2 1 0.0682162 1.0001 +2 1 0.0934117 1.00003 +2 2 0.56444 1.03938 ``` Here we retrieve expected Betti numbers on a tore 3D: @@ -48,21 +50,34 @@ Same as `alpha_complex_3d_persistence`, but using exact computation. It is slowe Same as `alpha_complex_3d_persistence`, but using weighted points. **Usage** -`weighted_alpha_complex_3d_persistence

` -where -`` is the path to the input point cloud in OFF format. -`` is the path to the file containing the weights of the points (one value per line). -`

` is the characteristic p of the coefficient field *Z/pZ* for computing homology. It must be a stricly positive integer. -`` is the minimal lifetime of homology feature to be recorded. Enter a negative value to see zero length intervals. +`weighted_alpha_complex_3d_persistence [options] ` +**Allowed options** +* `-h [ --help ]` Produce help message +* `-o [ --output-file ]` Name of file in which the persistence diagram is written. Default print in standard output. +* `-p [ --field-charac ]` (default=11) Characteristic p of the coefficient field Z/pZ for computing homology. +* `-m [ --min-persistence ]` (default = 0) Minimal lifetime of homology feature to be recorded. Enter a negative value to see zero length intervals. +**Example** +`weighted_alpha_complex_3d_persistence ../../data/points/tore3D_300.off ../../data/points/tore3D_300.weights -p 2 -m 0.45` -## `periodic_alpha_complex_3d_persistence` ## -This program computes the persistent homology with coefficient field Z/pZ of the 3D periodic alpha complex built from a 3D point cloud. The output diagram contains one bar per line, written with the convention: +outputs: +``` +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 +``` -`p dim b d` +N.B.: +* Weights values are explained on CGAL [Alpha shape](https://doc.cgal.org/latest/Alpha_shapes_3/index.html#title0) +and [Regular triangulation](https://doc.cgal.org/latest/Triangulation_3/index.html#Triangulation3secclassRegulartriangulation) documentation. +* Filtration values are alpha square values. -where `dim` is the dimension of the homological feature, `b` and `d` are respectively the birth and death of the feature, and `p` is the characteristic of the field *Z/pZ* used for homology coefficients (`p` must be a prime number). + +## `periodic_alpha_complex_3d_persistence` ## +Same as `alpha_complex_3d_persistence`, but using periodic alpha shape 3d. **Usage** `periodic_alpha_complex_3d_persistence

` @@ -72,21 +87,31 @@ where `

` is the characteristic p of the coefficient field *Z/pZ* for computing homology. It must be a stricly positive integer. `` is the minimal lifetime of homology feature to be recorded. Enter a negative value to see zero length intervals. +**Usage** +`./periodic_alpha_complex_3d_persistence [options] input-file cuboid-file` + +**Allowed options** +* `-h [ --help ]` Produce help message +* `-o [ --output-file ]` Name of file in which the persistence diagram is written. Default print in standard output. +* `-p [ --field-charac ]` (default=11) Characteristic p of the coefficient field Z/pZ for computing homology. +* `-m [ --min-persistence ]` (default = 0) Minimal lifetime of homology feature to be recorded. Enter a negative value to see zero length intervals + + **Example** -`periodic_alpha_complex_3d_persistence ../../data/points/grid_10_10_10_in_0_1.off ../../data/points/iso_cuboid_3_in_0_1.txt 3 1.0` +`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` outputs: ``` Periodic Delaunay computed. Simplex_tree dim: 3 -3 0 0 inf -3 1 0.0025 inf -3 1 0.0025 inf -3 1 0.0025 inf -3 2 0.005 inf -3 2 0.005 inf -3 2 0.005 inf -3 3 0.0075 inf +3 0 0 inf +3 1 0.0025 inf +3 1 0.0025 inf +3 1 0.0025 inf +3 2 0.005 inf +3 2 0.005 inf +3 2 0.005 inf +3 3 0.0075 inf ``` Here we retrieve expected Betti numbers on an 3D iso-oriented cuboids: @@ -98,14 +123,12 @@ Betti numbers[3] = 1 ``` N.B.: -* `periodic_alpha_complex_3d_persistence` only accepts OFF files in dimension 3. -* In this example, the periodic cube is hard coded to { x = [0,1]; y = [0,1]; z = [0,1] } +* Cuboid file must be in the format described [here](http://gudhi.gforge.inria.fr/doc/latest/fileformats.html#FileFormatsIsoCuboid). * Filtration values are alpha square values. - ## `alpha_complex_persistence` ## This program computes the persistent homology with coefficient field Z/pZ of the dD alpha complex built from a dD point cloud. The output diagram contains one bar per line, written with the convention: @@ -119,7 +142,7 @@ where `dim` is the dimension of the homological feature, `b` and `d` are respect **Allowed options** * `-h [ --help ]` Produce help message -* `-o [ --output-file ]` Name of file in which the persistence diagram is written. By default, print in std::cout. +* `-o [ --output-file ]` Name of file in which the persistence diagram is written. Default print in standard output. * `-r [ --max-alpha-square-value ]` (default = inf) Maximal alpha square value for the Alpha complex construction. * `-p [ --field-charac ]` (default = 11) Characteristic p of the coefficient field Z/pZ for computing homology. * `-m [ --min-persistence ]` (default = 0) Minimal lifetime of homology feature to be recorded. Enter a negative value to see zero length intervals. diff --git a/src/Alpha_complex/utilities/alpha_complex_3d_helper.h b/src/Alpha_complex/utilities/alpha_complex_3d_helper.h index 7865e4ec..6b3b7d5d 100644 --- a/src/Alpha_complex/utilities/alpha_complex_3d_helper.h +++ b/src/Alpha_complex/utilities/alpha_complex_3d_helper.h @@ -23,7 +23,7 @@ #ifndef ALPHA_COMPLEX_3D_HELPER_H_ #define ALPHA_COMPLEX_3D_HELPER_H_ -template +template Vertex_list from_cell(const Cell_handle& ch) { Vertex_list the_list; for (auto i = 0; i < 4; i++) { @@ -35,7 +35,7 @@ Vertex_list from_cell(const Cell_handle& ch) { return the_list; } -template +template Vertex_list from_facet(const Facet& fct) { Vertex_list the_list; for (auto i = 0; i < 4; i++) { @@ -49,7 +49,7 @@ Vertex_list from_facet(const Facet& fct) { return the_list; } -template +template Vertex_list from_edge(const Edge_3& edg) { Vertex_list the_list; for (auto i = 0; i < 4; i++) { @@ -63,7 +63,7 @@ Vertex_list from_edge(const Edge_3& edg) { return the_list; } -template +template Vertex_list from_vertex(const Vertex_handle& vh) { Vertex_list the_list; #ifdef DEBUG_TRACES diff --git a/src/Alpha_complex/utilities/alpha_complex_3d_persistence.cpp b/src/Alpha_complex/utilities/alpha_complex_3d_persistence.cpp index f63ff0f6..f2085ab2 100644 --- a/src/Alpha_complex/utilities/alpha_complex_3d_persistence.cpp +++ b/src/Alpha_complex/utilities/alpha_complex_3d_persistence.cpp @@ -20,6 +20,7 @@ * along with this program. If not, see . */ +#include #include #include @@ -56,10 +57,10 @@ using Point_3 = Kernel::Point_3; // filtration with alpha values needed type definition using Alpha_value_type = Alpha_shape_3::FT; using Object = CGAL::Object; -using Dispatch = CGAL::Dispatch_output_iterator< - CGAL::cpp11::tuple, - CGAL::cpp11::tuple >, - std::back_insert_iterator< std::vector > > >; +using Dispatch = + CGAL::Dispatch_output_iterator, + CGAL::cpp11::tuple >, + std::back_insert_iterator > > >; using Cell_handle = Alpha_shape_3::Cell_handle; using Facet = Alpha_shape_3::Facet; using Edge_3 = Alpha_shape_3::Edge; @@ -70,42 +71,28 @@ using Vertex_list = std::list; using ST = Gudhi::Simplex_tree; using Filtration_value = ST::Filtration_value; using Simplex_tree_vertex = ST::Vertex_handle; -using Alpha_shape_simplex_tree_map = std::map; +using Alpha_shape_simplex_tree_map = std::map; using Alpha_shape_simplex_tree_pair = std::pair; -using Simplex_tree_vector_vertex = std::vector< Simplex_tree_vertex >; -using PCOH = Gudhi::persistent_cohomology::Persistent_cohomology< ST, Gudhi::persistent_cohomology::Field_Zp >; - -void usage(const std::string& progName) { - std::cerr << "Usage:\n" << progName << " path_to_OFF_file coeff_field_characteristic[integer " << - "> 0] min_persistence[float >= -1.0]\n"; - std::cerr << " path_to_OFF_file is the path to your points cloud in OFF format.\n"; - exit(-1); -} +using Simplex_tree_vector_vertex = std::vector; +using PCOH = Gudhi::persistent_cohomology::Persistent_cohomology; -int main(int argc, char * const argv[]) { - // program args management - if (argc != 4) { - std::cerr << "Error: Number of arguments (" << argc << ") is not correct\n"; - usage(argv[0]); - } +void program_options(int argc, char *argv[], std::string &off_file_points, std::string &output_file_diag, + int &coeff_field_characteristic, Filtration_value &min_persistence); - int coeff_field_characteristic = atoi(argv[2]); +int main(int argc, char **argv) { + std::string off_file_points; + std::string output_file_diag; + int coeff_field_characteristic; + Filtration_value min_persistence; - Filtration_value min_persistence = 0.0; - int returnedScanValue = sscanf(argv[3], "%f", &min_persistence); - if ((returnedScanValue == EOF) || (min_persistence < -1.0)) { - std::cerr << "Error: " << argv[3] << " is not correct\n"; - usage(argv[0]); - } + program_options(argc, argv, off_file_points, output_file_diag, coeff_field_characteristic, min_persistence); - // Read points from file - std::string offInputFile(argv[1]); // Read the OFF file (input file name given as parameter) and triangulate points - Gudhi::Points_3D_off_reader off_reader(offInputFile); + Gudhi::Points_3D_off_reader off_reader(off_file_points); // Check the read operation was correct if (!off_reader.is_valid()) { - std::cerr << "Unable to read file " << offInputFile << std::endl; - usage(argv[0]); + std::cerr << "Unable to read file " << off_file_points << std::endl; + exit(-1); } // Retrieve the triangulation @@ -143,28 +130,28 @@ int main(int argc, char * const argv[]) { Filtration_value filtration_max = 0.0; for (auto object_iterator : the_objects) { // Retrieve Alpha shape vertex list from object - if (const Cell_handle * cell = CGAL::object_cast(&object_iterator)) { + if (const Cell_handle *cell = CGAL::object_cast(&object_iterator)) { vertex_list = from_cell(*cell); count_cells++; if (dim_max < 3) { // Cell is of dim 3 dim_max = 3; } - } else if (const Facet * facet = CGAL::object_cast(&object_iterator)) { + } else if (const Facet *facet = CGAL::object_cast(&object_iterator)) { vertex_list = from_facet(*facet); count_facets++; if (dim_max < 2) { // Facet is of dim 2 dim_max = 2; } - } else if (const Edge_3 * edge = CGAL::object_cast(&object_iterator)) { + } else if (const Edge_3 *edge = CGAL::object_cast(&object_iterator)) { vertex_list = from_edge(*edge); count_edges++; if (dim_max < 1) { // Edge_3 is of dim 1 dim_max = 1; } - } else if (const Vertex_handle * vertex = CGAL::object_cast(&object_iterator)) { + } else if (const Vertex_handle *vertex = CGAL::object_cast(&object_iterator)) { count_vertices++; vertex_list = from_vertex(*vertex); } @@ -190,7 +177,7 @@ int main(int argc, char * const argv[]) { } } // Construction of the simplex_tree - Filtration_value filtr = /*std::sqrt*/(*the_alpha_value_iterator); + Filtration_value filtr = /*std::sqrt*/ (*the_alpha_value_iterator); #ifdef DEBUG_TRACES std::cout << "filtration = " << filtr << std::endl; #endif // DEBUG_TRACES @@ -211,7 +198,6 @@ int main(int argc, char * const argv[]) { std::cout << "facets \t\t" << count_facets << std::endl; std::cout << "cells \t\t" << count_cells << std::endl; - std::cout << "Information of the Simplex Tree: " << std::endl; std::cout << " Number of vertices = " << simplex_tree.num_vertices() << " "; std::cout << " Number of simplices = " << simplex_tree.num_simplices() << std::endl << std::endl; @@ -236,7 +222,58 @@ int main(int argc, char * const argv[]) { pcoh.compute_persistent_cohomology(min_persistence); - pcoh.output_diagram(); + // Output the diagram in filediag + if (output_file_diag.empty()) { + pcoh.output_diagram(); + } else { + std::cout << "Result in file: " << output_file_diag << std::endl; + std::ofstream out(output_file_diag); + pcoh.output_diagram(out); + out.close(); + } return 0; } + +void program_options(int argc, char *argv[], std::string &off_file_points, std::string &output_file_diag, + int &coeff_field_characteristic, Filtration_value &min_persistence) { + namespace po = boost::program_options; + po::options_description hidden("Hidden options"); + hidden.add_options()("input-file", po::value(&off_file_points), + "Name of file containing a point set. Format is one point per line: X1 ... Xd "); + + po::options_description visible("Allowed options", 100); + visible.add_options()("help,h", "produce help message")( + "output-file,o", po::value(&output_file_diag)->default_value(std::string()), + "Name of file in which the persistence diagram is written. Default print in std::cout")( + "field-charac,p", po::value(&coeff_field_characteristic)->default_value(11), + "Characteristic p of the coefficient field Z/pZ for computing homology.")( + "min-persistence,m", po::value(&min_persistence), + "Minimal lifetime of homology feature to be recorded. Default is 0. Enter a negative value to see zero length " + "intervals"); + + po::positional_options_description pos; + pos.add("input-file", 1); + + po::options_description all; + all.add(visible).add(hidden); + + po::variables_map vm; + po::store(po::command_line_parser(argc, argv).options(all).positional(pos).run(), vm); + po::notify(vm); + + if (vm.count("help") || !vm.count("input-file")) { + std::cout << std::endl; + std::cout << "Compute the persistent homology with coefficient field Z/pZ \n"; + std::cout << "of a 3D Alpha complex defined on a set of input points.\n \n"; + std::cout << "The output diagram contains one bar per line, written with the convention: \n"; + std::cout << " p dim b d \n"; + std::cout << "where dim is the dimension of the homological feature,\n"; + std::cout << "b and d are respectively the birth and death of the feature and \n"; + std::cout << "p is the characteristic of the field Z/pZ used for homology coefficients." << std::endl << std::endl; + + std::cout << "Usage: " << argv[0] << " [options] input-file" << std::endl << std::endl; + std::cout << visible << std::endl; + std::abort(); + } +} diff --git a/src/Alpha_complex/utilities/alpha_complex_persistence.cpp b/src/Alpha_complex/utilities/alpha_complex_persistence.cpp index 9e84e91f..2105220a 100644 --- a/src/Alpha_complex/utilities/alpha_complex_persistence.cpp +++ b/src/Alpha_complex/utilities/alpha_complex_persistence.cpp @@ -14,12 +14,9 @@ using Simplex_tree = Gudhi::Simplex_tree<>; using Filtration_value = Simplex_tree::Filtration_value; -void program_options(int argc, char * argv[] - , std::string & off_file_points - , std::string & output_file_diag - , Filtration_value & alpha_square_max_value - , int & coeff_field_characteristic - , Filtration_value & min_persistence); +void program_options(int argc, char *argv[], std::string &off_file_points, std::string &output_file_diag, + Filtration_value &alpha_square_max_value, int &coeff_field_characteristic, + Filtration_value &min_persistence); int main(int argc, char **argv) { std::string off_file_points; @@ -28,13 +25,13 @@ int main(int argc, char **argv) { int coeff_field_characteristic; Filtration_value min_persistence; - program_options(argc, argv, off_file_points, output_file_diag, alpha_square_max_value, - coeff_field_characteristic, min_persistence); + program_options(argc, argv, off_file_points, output_file_diag, alpha_square_max_value, coeff_field_characteristic, + min_persistence); // ---------------------------------------------------------------------------- // Init of an alpha complex from an OFF file // ---------------------------------------------------------------------------- - using Kernel = CGAL::Epick_d< CGAL::Dynamic_dimension_tag >; + using Kernel = CGAL::Epick_d; Gudhi::alpha_complex::Alpha_complex alpha_complex_from_file(off_file_points); Simplex_tree simplex; @@ -42,17 +39,16 @@ int main(int argc, char **argv) { // ---------------------------------------------------------------------------- // Display information about the alpha complex // ---------------------------------------------------------------------------- - std::cout << "Simplicial complex is of dimension " << simplex.dimension() << - " - " << simplex.num_simplices() << " simplices - " << - simplex.num_vertices() << " vertices." << std::endl; + std::cout << "Simplicial complex is of dimension " << simplex.dimension() << " - " << simplex.num_simplices() + << " simplices - " << simplex.num_vertices() << " vertices." << std::endl; // Sort the simplices in the order of the filtration simplex.initialize_filtration(); std::cout << "Simplex_tree dim: " << simplex.dimension() << std::endl; // Compute the persistence diagram of the complex - Gudhi::persistent_cohomology::Persistent_cohomology< Simplex_tree, - Gudhi::persistent_cohomology::Field_Zp > pcoh(simplex); + Gudhi::persistent_cohomology::Persistent_cohomology pcoh( + simplex); // initializes the coefficient field for homology pcoh.init_coefficients(coeff_field_characteristic); @@ -72,30 +68,26 @@ int main(int argc, char **argv) { return 0; } -void program_options(int argc, char * argv[] - , std::string & off_file_points - , std::string & output_file_diag - , Filtration_value & alpha_square_max_value - , int & coeff_field_characteristic - , Filtration_value & min_persistence) { +void program_options(int argc, char *argv[], std::string &off_file_points, std::string &output_file_diag, + Filtration_value &alpha_square_max_value, int &coeff_field_characteristic, + Filtration_value &min_persistence) { namespace po = boost::program_options; po::options_description hidden("Hidden options"); - hidden.add_options() - ("input-file", po::value(&off_file_points), - "Name of file containing a point set. Format is one point per line: X1 ... Xd "); + hidden.add_options()("input-file", po::value(&off_file_points), + "Name of file containing a point set. Format is one point per line: X1 ... Xd "); po::options_description visible("Allowed options", 100); - visible.add_options() - ("help,h", "produce help message") - ("output-file,o", po::value(&output_file_diag)->default_value(std::string()), - "Name of file in which the persistence diagram is written. Default print in std::cout") - ("max-alpha-square-value,r", - po::value(&alpha_square_max_value)->default_value(std::numeric_limits::infinity()), - "Maximal alpha square value for the Alpha complex construction.") - ("field-charac,p", po::value(&coeff_field_characteristic)->default_value(11), - "Characteristic p of the coefficient field Z/pZ for computing homology.") - ("min-persistence,m", po::value(&min_persistence), - "Minimal lifetime of homology feature to be recorded. Default is 0. Enter a negative value to see zero length intervals"); + visible.add_options()("help,h", "produce help message")( + "output-file,o", po::value(&output_file_diag)->default_value(std::string()), + "Name of file in which the persistence diagram is written. Default print in std::cout")( + "max-alpha-square-value,r", po::value(&alpha_square_max_value) + ->default_value(std::numeric_limits::infinity()), + "Maximal alpha square value for the Alpha complex construction.")( + "field-charac,p", po::value(&coeff_field_characteristic)->default_value(11), + "Characteristic p of the coefficient field Z/pZ for computing homology.")( + "min-persistence,m", po::value(&min_persistence), + "Minimal lifetime of homology feature to be recorded. Default is 0. Enter a negative value to see zero length " + "intervals"); po::positional_options_description pos; pos.add("input-file", 1); @@ -104,8 +96,7 @@ void program_options(int argc, char * argv[] all.add(visible).add(hidden); po::variables_map vm; - po::store(po::command_line_parser(argc, argv). - options(all).positional(pos).run(), vm); + po::store(po::command_line_parser(argc, argv).options(all).positional(pos).run(), vm); po::notify(vm); if (vm.count("help") || !vm.count("input-file")) { diff --git a/src/Alpha_complex/utilities/exact_alpha_complex_3d_persistence.cpp b/src/Alpha_complex/utilities/exact_alpha_complex_3d_persistence.cpp index 8ce68406..7919c7fd 100644 --- a/src/Alpha_complex/utilities/exact_alpha_complex_3d_persistence.cpp +++ b/src/Alpha_complex/utilities/exact_alpha_complex_3d_persistence.cpp @@ -20,6 +20,7 @@ * along with this program. If not, see . */ +#include #include #include @@ -40,7 +41,7 @@ #include #include -#include "../utilities/alpha_complex_3d_helper.h" +#include "alpha_complex_3d_helper.h" // Alpha_shape_3 templates type definitions using Kernel = CGAL::Exact_predicates_inexact_constructions_kernel; @@ -57,10 +58,10 @@ using Point_3 = Kernel::Point_3; // filtration with alpha values needed type definition using Alpha_value_type = Alpha_shape_3::FT; using Object = CGAL::Object; -using Dispatch = CGAL::Dispatch_output_iterator< - CGAL::cpp11::tuple, - CGAL::cpp11::tuple >, - std::back_insert_iterator< std::vector > > >; +using Dispatch = + CGAL::Dispatch_output_iterator, + CGAL::cpp11::tuple >, + std::back_insert_iterator > > >; using Cell_handle = Alpha_shape_3::Cell_handle; using Facet = Alpha_shape_3::Facet; using Edge_3 = Alpha_shape_3::Edge; @@ -71,42 +72,28 @@ using Vertex_list = std::list; using ST = Gudhi::Simplex_tree; using Filtration_value = ST::Filtration_value; using Simplex_tree_vertex = ST::Vertex_handle; -using Alpha_shape_simplex_tree_map = std::map; +using Alpha_shape_simplex_tree_map = std::map; using Alpha_shape_simplex_tree_pair = std::pair; -using Simplex_tree_vector_vertex = std::vector< Simplex_tree_vertex >; -using PCOH = Gudhi::persistent_cohomology::Persistent_cohomology< ST, Gudhi::persistent_cohomology::Field_Zp >; - -void usage(char * const progName) { - std::cerr << "Usage:\n" << progName << " path_to_OFF_file coeff_field_characteristic[integer " << - "> 0] min_persistence[float >= -1.0]\n"; - std::cerr << " path_to_OFF_file is the path to your points cloud in OFF format.\n"; - exit(-1); -} +using Simplex_tree_vector_vertex = std::vector; +using PCOH = Gudhi::persistent_cohomology::Persistent_cohomology; -int main(int argc, char * const argv[]) { - // program args management - if (argc != 4) { - std::cerr << "Error: Number of arguments (" << argc << ") is not correct\n"; - usage(argv[0]); - } +void program_options(int argc, char *argv[], std::string &off_file_points, std::string &output_file_diag, + int &coeff_field_characteristic, Filtration_value &min_persistence); - int coeff_field_characteristic = atoi(argv[2]); +int main(int argc, char **argv) { + std::string off_file_points; + std::string output_file_diag; + int coeff_field_characteristic; + Filtration_value min_persistence; - Filtration_value min_persistence = 0.0; - int returnedScanValue = sscanf(argv[3], "%f", &min_persistence); - if ((returnedScanValue == EOF) || (min_persistence < -1.0)) { - std::cerr << "Error: " << argv[3] << " is not correct\n"; - usage(argv[0]); - } + program_options(argc, argv, off_file_points, output_file_diag, coeff_field_characteristic, min_persistence); - // Read points from file - std::string offInputFile(argv[1]); // Read the OFF file (input file name given as parameter) and triangulate points - Gudhi::Points_3D_off_reader off_reader(offInputFile); + Gudhi::Points_3D_off_reader off_reader(off_file_points); // Check the read operation was correct if (!off_reader.is_valid()) { - std::cerr << "Unable to read file " << offInputFile << std::endl; - usage(argv[0]); + std::cerr << "Unable to read file " << off_file_points << std::endl; + exit(-1); } // Retrieve the triangulation @@ -144,28 +131,28 @@ int main(int argc, char * const argv[]) { Filtration_value filtration_max = 0.0; for (auto object_iterator : the_objects) { // Retrieve Alpha shape vertex list from object - if (const Cell_handle * cell = CGAL::object_cast(&object_iterator)) { + if (const Cell_handle *cell = CGAL::object_cast(&object_iterator)) { vertex_list = from_cell(*cell); count_cells++; if (dim_max < 3) { // Cell is of dim 3 dim_max = 3; } - } else if (const Facet * facet = CGAL::object_cast(&object_iterator)) { + } else if (const Facet *facet = CGAL::object_cast(&object_iterator)) { vertex_list = from_facet(*facet); count_facets++; if (dim_max < 2) { // Facet is of dim 2 dim_max = 2; } - } else if (const Edge_3 * edge = CGAL::object_cast(&object_iterator)) { + } else if (const Edge_3 *edge = CGAL::object_cast(&object_iterator)) { vertex_list = from_edge(*edge); count_edges++; if (dim_max < 1) { // Edge_3 is of dim 1 dim_max = 1; } - } else if (const Vertex_handle * vertex = CGAL::object_cast(&object_iterator)) { + } else if (const Vertex_handle *vertex = CGAL::object_cast(&object_iterator)) { count_vertices++; vertex_list = from_vertex(*vertex); } @@ -192,7 +179,7 @@ int main(int argc, char * const argv[]) { } // Construction of the simplex_tree // you can also use the_alpha_value_iterator->exact() - Filtration_value filtr = /*std::sqrt*/CGAL::to_double(the_alpha_value_iterator->exact()); + Filtration_value filtr = /*std::sqrt*/ CGAL::to_double(the_alpha_value_iterator->exact()); #ifdef DEBUG_TRACES std::cout << "filtration = " << filtr << std::endl; #endif // DEBUG_TRACES @@ -213,7 +200,6 @@ int main(int argc, char * const argv[]) { std::cout << "facets \t\t" << count_facets << std::endl; std::cout << "cells \t\t" << count_cells << std::endl; - std::cout << "Information of the Simplex Tree: " << std::endl; std::cout << " Number of vertices = " << simplex_tree.num_vertices() << " "; std::cout << " Number of simplices = " << simplex_tree.num_simplices() << std::endl << std::endl; @@ -242,3 +228,46 @@ int main(int argc, char * const argv[]) { return 0; } + +void program_options(int argc, char *argv[], std::string &off_file_points, std::string &output_file_diag, + int &coeff_field_characteristic, Filtration_value &min_persistence) { + namespace po = boost::program_options; + po::options_description hidden("Hidden options"); + hidden.add_options()("input-file", po::value(&off_file_points), + "Name of file containing a point set. Format is one point per line: X1 ... Xd "); + + po::options_description visible("Allowed options", 100); + visible.add_options()("help,h", "produce help message")( + "output-file,o", po::value(&output_file_diag)->default_value(std::string()), + "Name of file in which the persistence diagram is written. Default print in std::cout")( + "field-charac,p", po::value(&coeff_field_characteristic)->default_value(11), + "Characteristic p of the coefficient field Z/pZ for computing homology.")( + "min-persistence,m", po::value(&min_persistence), + "Minimal lifetime of homology feature to be recorded. Default is 0. Enter a negative value to see zero length " + "intervals"); + + po::positional_options_description pos; + pos.add("input-file", 1); + + po::options_description all; + all.add(visible).add(hidden); + + po::variables_map vm; + po::store(po::command_line_parser(argc, argv).options(all).positional(pos).run(), vm); + po::notify(vm); + + if (vm.count("help") || !vm.count("input-file")) { + std::cout << std::endl; + std::cout << "Compute the persistent homology with coefficient field Z/pZ \n"; + std::cout << "of a 3D Alpha complex defined on a set of input points.\n \n"; + std::cout << "The output diagram contains one bar per line, written with the convention: \n"; + std::cout << " p dim b d \n"; + std::cout << "where dim is the dimension of the homological feature,\n"; + std::cout << "b and d are respectively the birth and death of the feature and \n"; + std::cout << "p is the characteristic of the field Z/pZ used for homology coefficients." << std::endl << std::endl; + + std::cout << "Usage: " << argv[0] << " [options] input-file" << std::endl << std::endl; + std::cout << visible << std::endl; + std::abort(); + } +} diff --git a/src/Alpha_complex/utilities/periodic_alpha_complex_3d_persistence.cpp b/src/Alpha_complex/utilities/periodic_alpha_complex_3d_persistence.cpp index 8140a3c5..10b62f75 100644 --- a/src/Alpha_complex/utilities/periodic_alpha_complex_3d_persistence.cpp +++ b/src/Alpha_complex/utilities/periodic_alpha_complex_3d_persistence.cpp @@ -20,6 +20,7 @@ * along with this program. If not, see . */ +#include #include #include @@ -63,10 +64,10 @@ using Point_3 = PK::Point_3; // filtration with alpha values needed type definition using Alpha_value_type = Alpha_shape_3::FT; using Object = CGAL::Object; -using Dispatch = CGAL::Dispatch_output_iterator< - CGAL::cpp11::tuple, - CGAL::cpp11::tuple >, - std::back_insert_iterator< std::vector > > >; +using Dispatch = + CGAL::Dispatch_output_iterator, + CGAL::cpp11::tuple >, + std::back_insert_iterator > > >; using Cell_handle = Alpha_shape_3::Cell_handle; using Facet = Alpha_shape_3::Facet; using Edge_3 = Alpha_shape_3::Edge; @@ -77,54 +78,41 @@ using Vertex_list = std::list; using ST = Gudhi::Simplex_tree; using Filtration_value = ST::Filtration_value; using Simplex_tree_vertex = ST::Vertex_handle; -using Alpha_shape_simplex_tree_map = std::map; +using Alpha_shape_simplex_tree_map = std::map; using Alpha_shape_simplex_tree_pair = std::pair; -using Simplex_tree_vector_vertex = std::vector< Simplex_tree_vertex >; -using Persistent_cohomology = Gudhi::persistent_cohomology::Persistent_cohomology< - ST, Gudhi::persistent_cohomology::Field_Zp >; - -void usage(char * const progName) { - std::cerr << "Usage:\n" << progName << " path_to_OFF_file path_to_iso_cuboid_3_file coeff_field_characteristic[" << - "integer > 0] min_persistence[float >= -1.0]\n" << - " path_to_OFF_file is the path to your points cloud in OFF format.\n" << - " path_to_iso_cuboid_3_file is the path to the iso cuboid file with the following format :\n" << - " x_min y_min z_min x_max y_max z_max\n" << - " In this example, the periodic cube will be " << - "{ x = [x_min,x_max]; y = [y_min,y_max]; z = [z_min,z_max] }.\n" << - " For more information, please refer to\n" << - " https://doc.cgal.org/latest/Kernel_23/classCGAL_1_1Iso__cuboid__3.html\n"; - - exit(-1); -} +using Simplex_tree_vector_vertex = std::vector; +using Persistent_cohomology = + Gudhi::persistent_cohomology::Persistent_cohomology; -int main(int argc, char * const argv[]) { - // program args management - if (argc != 5) { - std::cerr << "Error: Number of arguments (" << argc << ") is not correct\n"; - usage(argv[0]); - } +void program_options(int argc, char *argv[], std::string &off_file_points, std::string &cuboid_file, + std::string &output_file_diag, int &coeff_field_characteristic, Filtration_value &min_persistence); - int coeff_field_characteristic = atoi(argv[3]); - Filtration_value min_persistence = strtof(argv[4], nullptr); +int main(int argc, char **argv) { + std::string off_file_points; + std::string cuboid_file; + std::string output_file_diag; + int coeff_field_characteristic; + Filtration_value min_persistence; + + program_options(argc, argv, off_file_points, cuboid_file, output_file_diag, coeff_field_characteristic, + min_persistence); - // Read points from file - std::string offInputFile(argv[1]); // Read the OFF file (input file name given as parameter) and triangulate points - Gudhi::Points_3D_off_reader off_reader(offInputFile); + Gudhi::Points_3D_off_reader off_reader(off_file_points); // Check the read operation was correct if (!off_reader.is_valid()) { - std::cerr << "Unable to read file " << offInputFile << std::endl; - usage(argv[0]); + std::cerr << "Unable to read OFF file " << off_file_points << std::endl; + exit(-1); } // Read iso_cuboid_3 information from file - std::ifstream iso_cuboid_str(argv[2]); + std::ifstream iso_cuboid_str(cuboid_file); double x_min, y_min, z_min, x_max, y_max, z_max; if (iso_cuboid_str.good()) { iso_cuboid_str >> x_min >> y_min >> z_min >> x_max >> y_max >> z_max; } else { - std::cerr << "Unable to read file " << argv[2] << std::endl; - usage(argv[0]); + std::cerr << "Unable to read file " << cuboid_file << std::endl; + exit(-1); } // Retrieve the triangulation @@ -168,29 +156,29 @@ int main(int argc, char * const argv[]) { Filtration_value filtration_max = 0.0; for (auto object_iterator : the_objects) { // Retrieve Alpha shape vertex list from object - if (const Cell_handle * cell = CGAL::object_cast(&object_iterator)) { + if (const Cell_handle *cell = CGAL::object_cast(&object_iterator)) { vertex_list = from_cell(*cell); count_cells++; if (dim_max < 3) { // Cell is of dim 3 dim_max = 3; } - } else if (const Facet * facet = CGAL::object_cast(&object_iterator)) { + } else if (const Facet *facet = CGAL::object_cast(&object_iterator)) { vertex_list = from_facet(*facet); count_facets++; if (dim_max < 2) { // Facet is of dim 2 dim_max = 2; } - } else if (const Edge_3 * edge = CGAL::object_cast(&object_iterator)) { + } else if (const Edge_3 *edge = CGAL::object_cast(&object_iterator)) { vertex_list = from_edge(*edge); count_edges++; if (dim_max < 1) { // Edge_3 is of dim 1 dim_max = 1; } - } else if (const Alpha_shape_3::Vertex_handle * vertex = - CGAL::object_cast(&object_iterator)) { + } else if (const Alpha_shape_3::Vertex_handle *vertex = + CGAL::object_cast(&object_iterator)) { count_vertices++; vertex_list = from_vertex(*vertex); } @@ -216,7 +204,7 @@ int main(int argc, char * const argv[]) { } } // Construction of the simplex_tree - Filtration_value filtr = /*std::sqrt*/(*the_alpha_value_iterator); + Filtration_value filtr = /*std::sqrt*/ (*the_alpha_value_iterator); #ifdef DEBUG_TRACES std::cout << "filtration = " << filtr << std::endl; #endif // DEBUG_TRACES @@ -237,7 +225,6 @@ int main(int argc, char * const argv[]) { std::cout << "facets \t\t" << count_facets << std::endl; std::cout << "cells \t\t" << count_cells << std::endl; - std::cout << "Information of the Simplex Tree: " << std::endl; std::cout << " Number of vertices = " << simplex_tree.num_vertices() << " "; std::cout << " Number of simplices = " << simplex_tree.num_simplices() << std::endl << std::endl; @@ -266,3 +253,50 @@ int main(int argc, char * const argv[]) { return 0; } + +void program_options(int argc, char *argv[], std::string &off_file_points, std::string &cuboid_file, + std::string &output_file_diag, int &coeff_field_characteristic, + Filtration_value &min_persistence) { + namespace po = boost::program_options; + po::options_description hidden("Hidden options"); + hidden.add_options()("input-file", po::value(&off_file_points), + "Name of file containing a point set. Format is one point per line: X1 ... Xd ")( + "cuboid-file", po::value(&cuboid_file), + "Name of file describing the periodic domain. Format is: min_hx min_hy min_hz\nmax_hx max_hy max_hz"); + + po::options_description visible("Allowed options", 100); + visible.add_options()("help,h", "produce help message")( + "output-file,o", po::value(&output_file_diag)->default_value(std::string()), + "Name of file in which the persistence diagram is written. Default print in std::cout")( + "field-charac,p", po::value(&coeff_field_characteristic)->default_value(11), + "Characteristic p of the coefficient field Z/pZ for computing homology.")( + "min-persistence,m", po::value(&min_persistence), + "Minimal lifetime of homology feature to be recorded. Default is 0. Enter a negative value to see zero length " + "intervals"); + + po::positional_options_description pos; + pos.add("input-file", 1); + pos.add("cuboid-file", 2); + + po::options_description all; + all.add(visible).add(hidden); + + po::variables_map vm; + po::store(po::command_line_parser(argc, argv).options(all).positional(pos).run(), vm); + po::notify(vm); + + if (vm.count("help") || !vm.count("input-file") || !vm.count("cuboid-file")) { + std::cout << std::endl; + std::cout << "Compute the persistent homology with coefficient field Z/pZ \n"; + std::cout << "of a periodic 3D Alpha complex defined on a set of input points.\n \n"; + std::cout << "The output diagram contains one bar per line, written with the convention: \n"; + std::cout << " p dim b d \n"; + std::cout << "where dim is the dimension of the homological feature,\n"; + std::cout << "b and d are respectively the birth and death of the feature and \n"; + std::cout << "p is the characteristic of the field Z/pZ used for homology coefficients." << std::endl << std::endl; + + std::cout << "Usage: " << argv[0] << " [options] input-file cuboid-file" << std::endl << std::endl; + std::cout << visible << std::endl; + std::abort(); + } +} diff --git a/src/Alpha_complex/utilities/weighted_alpha_complex_3d_persistence.cpp b/src/Alpha_complex/utilities/weighted_alpha_complex_3d_persistence.cpp index a4ecf9da..293170f7 100644 --- a/src/Alpha_complex/utilities/weighted_alpha_complex_3d_persistence.cpp +++ b/src/Alpha_complex/utilities/weighted_alpha_complex_3d_persistence.cpp @@ -20,6 +20,7 @@ * along with this program. If not, see . */ +#include #include #include @@ -42,7 +43,7 @@ #include #include -#include "../utilities/alpha_complex_3d_helper.h" +#include "alpha_complex_3d_helper.h" // Traits using Kernel = CGAL::Exact_predicates_inexact_constructions_kernel; @@ -60,10 +61,10 @@ using Weighted_point_3 = Gt::Weighted_point; // filtration with alpha values needed type definition using Alpha_value_type = Alpha_shape_3::FT; using Object = CGAL::Object; -using Dispatch = CGAL::Dispatch_output_iterator< - CGAL::cpp11::tuple, - CGAL::cpp11::tuple >, - std::back_insert_iterator< std::vector > > >; +using Dispatch = + CGAL::Dispatch_output_iterator, + CGAL::cpp11::tuple >, + std::back_insert_iterator > > >; using Cell_handle = Alpha_shape_3::Cell_handle; using Facet = Alpha_shape_3::Facet; using Edge_3 = Alpha_shape_3::Edge; @@ -74,48 +75,38 @@ using Vertex_list = std::list; using ST = Gudhi::Simplex_tree; using Filtration_value = ST::Filtration_value; using Simplex_tree_vertex = ST::Vertex_handle; -using Alpha_shape_simplex_tree_map = std::map; +using Alpha_shape_simplex_tree_map = std::map; using Alpha_shape_simplex_tree_pair = std::pair; -using Simplex_tree_vector_vertex = std::vector< Simplex_tree_vertex >; -using Persistent_cohomology = Gudhi::persistent_cohomology::Persistent_cohomology< - ST, Gudhi::persistent_cohomology::Field_Zp >; - -void usage(char * const progName) { - std::cerr << "Usage:\n" << progName << " path_to_OFF_file path_to_weight_file coeff_field_characteristic[integer " << - "> 0] min_persistence[float >= -1.0]\n"; - std::cerr << " path_to_OFF_file is the path to your points cloud in OFF format.\n"; - std::cerr << " path_to_weight_file is the path to the weights of your points cloud (one value per line.)\n"; - std::cerr << " Weights values are explained on CGAL documentation:\n"; - std::cerr << " https://doc.cgal.org/latest/Alpha_shapes_3/index.html#title0\n"; - std::cerr << " https://doc.cgal.org/latest/Triangulation_3/index.html#Triangulation3secclassRegulartriangulation\n"; - exit(-1); -} +using Simplex_tree_vector_vertex = std::vector; +using Persistent_cohomology = + Gudhi::persistent_cohomology::Persistent_cohomology; -int main(int argc, char * const argv[]) { - // program args management - if (argc != 5) { - std::cerr << "Error: Number of arguments (" << argc << ") is not correct\n"; - usage(argv[0]); - } +void program_options(int argc, char *argv[], std::string &off_file_points, std::string &weight_file, + std::string &output_file_diag, int &coeff_field_characteristic, Filtration_value &min_persistence); - int coeff_field_characteristic = atoi(argv[3]); - Filtration_value min_persistence = strtof(argv[4], nullptr); +int main(int argc, char **argv) { + std::string off_file_points; + std::string weight_file; + std::string output_file_diag; + int coeff_field_characteristic; + Filtration_value min_persistence; + + program_options(argc, argv, off_file_points, weight_file, output_file_diag, coeff_field_characteristic, + min_persistence); - // Read points from file - std::string offInputFile(argv[1]); // Read the OFF file (input file name given as parameter) and triangulate points - Gudhi::Points_3D_off_reader off_reader(offInputFile); + Gudhi::Points_3D_off_reader off_reader(off_file_points); // Check the read operation was correct if (!off_reader.is_valid()) { - std::cerr << "Unable to read file " << offInputFile << std::endl; - usage(argv[0]); + std::cerr << "Unable to read OFF file " << off_file_points << std::endl; + exit(-1); } // Retrieve the triangulation std::vector lp = off_reader.get_point_cloud(); // Read weights information from file - std::ifstream weights_ifstr(argv[2]); + std::ifstream weights_ifstr(weight_file); std::vector wp; if (weights_ifstr.good()) { double weight = 0.0; @@ -127,12 +118,12 @@ int main(int argc, char * const argv[]) { index++; } if (index != lp.size()) { - std::cerr << "Bad number of weights in file " << argv[2] << std::endl; - usage(argv[0]); + std::cerr << "Bad number of weights in file " << weight_file << std::endl; + exit(-1); } } else { - std::cerr << "Unable to read file " << argv[2] << std::endl; - usage(argv[0]); + std::cerr << "Unable to read weights file " << weight_file << std::endl; + exit(-1); } // alpha shape construction from points. CGAL has a strange behavior in REGULARIZED mode. @@ -167,29 +158,29 @@ int main(int argc, char * const argv[]) { Filtration_value filtration_max = 0.0; for (auto object_iterator : the_objects) { // Retrieve Alpha shape vertex list from object - if (const Cell_handle * cell = CGAL::object_cast(&object_iterator)) { + if (const Cell_handle *cell = CGAL::object_cast(&object_iterator)) { vertex_list = from_cell(*cell); count_cells++; if (dim_max < 3) { // Cell is of dim 3 dim_max = 3; } - } else if (const Facet * facet = CGAL::object_cast(&object_iterator)) { + } else if (const Facet *facet = CGAL::object_cast(&object_iterator)) { vertex_list = from_facet(*facet); count_facets++; if (dim_max < 2) { // Facet is of dim 2 dim_max = 2; } - } else if (const Edge_3 * edge = CGAL::object_cast(&object_iterator)) { + } else if (const Edge_3 *edge = CGAL::object_cast(&object_iterator)) { vertex_list = from_edge(*edge); count_edges++; if (dim_max < 1) { // Edge_3 is of dim 1 dim_max = 1; } - } else if (const Alpha_shape_3::Vertex_handle * vertex = - CGAL::object_cast(&object_iterator)) { + } else if (const Alpha_shape_3::Vertex_handle *vertex = + CGAL::object_cast(&object_iterator)) { count_vertices++; vertex_list = from_vertex(*vertex); } @@ -215,7 +206,7 @@ int main(int argc, char * const argv[]) { } } // Construction of the simplex_tree - Filtration_value filtr = /*std::sqrt*/(*the_alpha_value_iterator); + Filtration_value filtr = /*std::sqrt*/ (*the_alpha_value_iterator); #ifdef DEBUG_TRACES std::cout << "filtration = " << filtr << std::endl; #endif // DEBUG_TRACES @@ -236,7 +227,6 @@ int main(int argc, char * const argv[]) { std::cout << "facets \t\t" << count_facets << std::endl; std::cout << "cells \t\t" << count_cells << std::endl; - std::cout << "Information of the Simplex Tree: " << std::endl; std::cout << " Number of vertices = " << simplex_tree.num_vertices() << " "; std::cout << " Number of simplices = " << simplex_tree.num_simplices() << std::endl << std::endl; @@ -265,3 +255,50 @@ int main(int argc, char * const argv[]) { return 0; } + +void program_options(int argc, char *argv[], std::string &off_file_points, std::string &weight_file, + std::string &output_file_diag, int &coeff_field_characteristic, + Filtration_value &min_persistence) { + namespace po = boost::program_options; + po::options_description hidden("Hidden options"); + hidden.add_options()("input-file", po::value(&off_file_points), + "Name of file containing a point set. Format is one point per line: X1 ... Xd ")( + "weight-file", po::value(&weight_file), + "Name of file containing a point weights. Format is one weigt per line: W1\n...\nWn "); + + po::options_description visible("Allowed options", 100); + visible.add_options()("help,h", "produce help message")( + "output-file,o", po::value(&output_file_diag)->default_value(std::string()), + "Name of file in which the persistence diagram is written. Default print in std::cout")( + "field-charac,p", po::value(&coeff_field_characteristic)->default_value(11), + "Characteristic p of the coefficient field Z/pZ for computing homology.")( + "min-persistence,m", po::value(&min_persistence), + "Minimal lifetime of homology feature to be recorded. Default is 0. Enter a negative value to see zero length " + "intervals"); + + po::positional_options_description pos; + pos.add("input-file", 1); + pos.add("weight-file", 2); + + po::options_description all; + all.add(visible).add(hidden); + + po::variables_map vm; + po::store(po::command_line_parser(argc, argv).options(all).positional(pos).run(), vm); + po::notify(vm); + + if (vm.count("help") || !vm.count("input-file") || !vm.count("weight-file")) { + std::cout << std::endl; + std::cout << "Compute the persistent homology with coefficient field Z/pZ \n"; + std::cout << "of a weighted 3D Alpha complex defined on a set of input points.\n \n"; + std::cout << "The output diagram contains one bar per line, written with the convention: \n"; + std::cout << " p dim b d \n"; + std::cout << "where dim is the dimension of the homological feature,\n"; + std::cout << "b and d are respectively the birth and death of the feature and \n"; + std::cout << "p is the characteristic of the field Z/pZ used for homology coefficients." << std::endl << std::endl; + + std::cout << "Usage: " << argv[0] << " [options] input-file weight-file" << std::endl << std::endl; + std::cout << visible << std::endl; + std::abort(); + } +} diff --git a/src/Bottleneck_distance/utilities/CMakeLists.txt b/src/Bottleneck_distance/utilities/CMakeLists.txt index cdf76c85..063b6ae3 100644 --- a/src/Bottleneck_distance/utilities/CMakeLists.txt +++ b/src/Bottleneck_distance/utilities/CMakeLists.txt @@ -3,6 +3,9 @@ project(Bottleneck_distance_utilities) if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1) add_executable (bottleneck_read_file bottleneck_read_file.cpp) + if (TBB_FOUND) + target_link_libraries(bottleneck_read_file ${TBB_LIBRARIES}) + endif(TBB_FOUND) add_test(NAME Bottleneck_distance_utilities_Bottleneck_read_file COMMAND $ diff --git a/src/Rips_complex/utilities/README b/src/Rips_complex/utilities/README index 93ec3658..ca10424d 100644 --- a/src/Rips_complex/utilities/README +++ b/src/Rips_complex/utilities/README @@ -13,6 +13,7 @@ where `dim` is the dimension of the homological feature, `b` and `d` are respect **Allowed options** * `-h [ --help ]` Produce help message +* `-o [ --output-file ]` Name of file in which the persistence diagram is written. Default print in standard output. * `-r [ --max-edge-length ]` (default = inf) Maximal length of an edge for the Rips complex construction. * `-d [ --cpx-dimension ]` (default = 1) Maximal dimension of the Rips complex we want to compute. * `-p [ --field-charac ]` (default = 11) Characteristic p of the coefficient field Z/pZ for computing homology. @@ -45,7 +46,7 @@ outputs: ## `rips_distance_matrix_persistence` ## -Same as `rips_persistence` but taking an distance matrix as input. +Same as `rips_persistence` but taking a distance matrix as input. **Example** `rips_distance_matrix_persistence data/distance_matrix/full_square_distance_matrix.csv -r 15 -d 3 -p 3 -m 0` -- cgit v1.2.3 From 50842cbc95006c8ff1a9066fa9431999025c4688 Mon Sep 17 00:00:00 2001 From: cjamin Date: Wed, 22 Nov 2017 16:34:52 +0000 Subject: b => birth + d => death git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/add_utils_in_gudhi_v2@2943 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 6ec0292942fcc14c1ef53b8ff9d1182b8f07a287 --- src/Alpha_complex/utilities/README | 346 ++++++++++++++++----------------- src/Bottleneck_distance/example/README | 4 +- src/Rips_complex/utilities/README | 4 +- src/Witness_complex/utilities/README | 8 +- 4 files changed, 181 insertions(+), 181 deletions(-) (limited to 'src/Rips_complex') diff --git a/src/Alpha_complex/utilities/README b/src/Alpha_complex/utilities/README index 0d3d6bfc..1cd2ca95 100644 --- a/src/Alpha_complex/utilities/README +++ b/src/Alpha_complex/utilities/README @@ -1,177 +1,177 @@ -# Alpha_complex # - -## `alpha_complex_3d_persistence` ## -This program computes the persistent homology with coefficient field Z/pZ of the 3D alpha complex built from a 3D point cloud. The output diagram contains one bar per line, written with the convention: - -`p dim b d` - -where `dim` is the dimension of the homological feature, `b` and `d` are respectively the birth and death of the feature, and `p` is the characteristic of the field *Z/pZ* used for homology coefficients (`p` must be a prime number). - -**Usage** -`alpha_complex_3d_persistence [options] ` +# Alpha_complex # + +## `alpha_complex_3d_persistence` ## +This program computes the persistent homology with coefficient field Z/pZ of the 3D alpha complex built from a 3D point cloud. The output diagram contains one bar per line, written with the convention: + +`p dim birth death` + +where `dim` is the dimension of the homological feature, `birth` and `death` are respectively the birth and death of the feature, and `p` is the characteristic of the field *Z/pZ* used for homology coefficients (`p` must be a prime number). + +**Usage** +`alpha_complex_3d_persistence [options] ` where -`` is the path to the input point cloud in [nOFF ASCII format](http://www.geomview.org/docs/html/OFF.html). - -**Allowed options** - -* `-h [ --help ]` Produce help message -* `-o [ --output-file ]` Name of file in which the persistence diagram is written. Default print in standard output. -* `-p [ --field-charac ]` (default=11) Characteristic p of the coefficient field Z/pZ for computing homology. -* `-m [ --min-persistence ]` (default = 0) Minimal lifetime of homology feature to be recorded. Enter a negative value to see zero length intervals. - -**Example** -`alpha_complex_3d_persistence ../../data/points/tore3D_300.off -p 2 -m 0.45` - -outputs: -``` -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 -``` - -Here we retrieve expected Betti numbers on a tore 3D: -``` -Betti numbers[0] = 1 -Betti numbers[1] = 2 -Betti numbers[2] = 1 -``` - -N.B.: -* `alpha_complex_3d_persistence` only accepts OFF files in dimension 3. -* Filtration values are alpha square values. - - - -## `exact_alpha_complex_3d_persistence` ## -Same as `alpha_complex_3d_persistence`, but using exact computation. It is slower, but it is necessary when points are on a grid for instance. - - - -## `weighted_alpha_complex_3d_persistence` ## -Same as `alpha_complex_3d_persistence`, but using weighted points. - -**Usage** -`weighted_alpha_complex_3d_persistence [options] ` +`` is the path to the input point cloud in [nOFF ASCII format](http://www.geomview.org/docs/html/OFF.html). + +**Allowed options** + +* `-h [ --help ]` Produce help message +* `-o [ --output-file ]` Name of file in which the persistence diagram is written. Default print in standard output. +* `-p [ --field-charac ]` (default=11) Characteristic p of the coefficient field Z/pZ for computing homology. +* `-m [ --min-persistence ]` (default = 0) Minimal lifetime of homology feature to be recorded. Enter a negative value to see zero length intervals. + +**Example** +`alpha_complex_3d_persistence ../../data/points/tore3D_300.off -p 2 -m 0.45` + +outputs: +``` +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 +``` + +Here we retrieve expected Betti numbers on a tore 3D: +``` +Betti numbers[0] = 1 +Betti numbers[1] = 2 +Betti numbers[2] = 1 +``` + +N.B.: +* `alpha_complex_3d_persistence` only accepts OFF files in dimension 3. +* Filtration values are alpha square values. + + + +## `exact_alpha_complex_3d_persistence` ## +Same as `alpha_complex_3d_persistence`, but using exact computation. It is slower, but it is necessary when points are on a grid for instance. + + + +## `weighted_alpha_complex_3d_persistence` ## +Same as `alpha_complex_3d_persistence`, but using weighted points. + +**Usage** +`weighted_alpha_complex_3d_persistence [options] ` +where +`` is the path to the input point cloud in [nOFF ASCII format](http://www.geomview.org/docs/html/OFF.html). +`` is the path to the file containing the weights of the points (one value per line). + +**Allowed options** + +* `-h [ --help ]` Produce help message +* `-o [ --output-file ]` Name of file in which the persistence diagram is written. Default print in standard output. +* `-p [ --field-charac ]` (default=11) Characteristic p of the coefficient field Z/pZ for computing homology. +* `-m [ --min-persistence ]` (default = 0) Minimal lifetime of homology feature to be recorded. Enter a negative value to see zero length intervals. + +**Example** +`weighted_alpha_complex_3d_persistence ../../data/points/tore3D_300.off ../../data/points/tore3D_300.weights -p 2 -m 0.45` + +outputs: +``` +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 +``` + +N.B.: +* Weights values are explained on CGAL [Alpha shape](https://doc.cgal.org/latest/Alpha_shapes_3/index.html#title0) +and [Regular triangulation](https://doc.cgal.org/latest/Triangulation_3/index.html#Triangulation3secclassRegulartriangulation) documentation. +* Filtration values are alpha square values. + + +## `periodic_alpha_complex_3d_persistence` ## +Same as `alpha_complex_3d_persistence`, but using periodic alpha shape 3d. +Refer to the [CGAL's 3D Periodic Triangulations User Manual](https://doc.cgal.org/latest/Periodic_3_triangulation_3/index.html) for more details. + +**Usage** +`periodic_alpha_complex_3d_persistence [options] ` where `` is the path to the input point cloud in [nOFF ASCII format](http://www.geomview.org/docs/html/OFF.html). -`` is the path to the file containing the weights of the points (one value per line). - -**Allowed options** - -* `-h [ --help ]` Produce help message -* `-o [ --output-file ]` Name of file in which the persistence diagram is written. Default print in standard output. -* `-p [ --field-charac ]` (default=11) Characteristic p of the coefficient field Z/pZ for computing homology. -* `-m [ --min-persistence ]` (default = 0) Minimal lifetime of homology feature to be recorded. Enter a negative value to see zero length intervals. - -**Example** -`weighted_alpha_complex_3d_persistence ../../data/points/tore3D_300.off ../../data/points/tore3D_300.weights -p 2 -m 0.45` - -outputs: -``` -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 -``` - -N.B.: -* Weights values are explained on CGAL [Alpha shape](https://doc.cgal.org/latest/Alpha_shapes_3/index.html#title0) -and [Regular triangulation](https://doc.cgal.org/latest/Triangulation_3/index.html#Triangulation3secclassRegulartriangulation) documentation. -* Filtration values are alpha square values. - - -## `periodic_alpha_complex_3d_persistence` ## -Same as `alpha_complex_3d_persistence`, but using periodic alpha shape 3d. -Refer to the [CGAL's 3D Periodic Triangulations User Manual](https://doc.cgal.org/latest/Periodic_3_triangulation_3/index.html) for more details. - -**Usage** -`periodic_alpha_complex_3d_persistence [options] ` -where -`` is the path to the input point cloud in [nOFF ASCII format](http://www.geomview.org/docs/html/OFF.html). -`` is the path to the file describing the periodic domain. It must be in the format described [here](http://gudhi.gforge.inria.fr/doc/latest/fileformats.html#FileFormatsIsoCuboid). - -**Allowed options** - -* `-h [ --help ]` Produce help message -* `-o [ --output-file ]` Name of file in which the persistence diagram is written. Default print in standard output. -* `-p [ --field-charac ]` (default=11) Characteristic p of the coefficient field Z/pZ for computing homology. -* `-m [ --min-persistence ]` (default = 0) Minimal lifetime of homology feature to be recorded. Enter a negative value to see zero length intervals - - -**Example** -`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` - -outputs: -``` -Periodic Delaunay computed. -Simplex_tree dim: 3 -3 0 0 inf -3 1 0.0025 inf -3 1 0.0025 inf -3 1 0.0025 inf -3 2 0.005 inf -3 2 0.005 inf -3 2 0.005 inf -3 3 0.0075 inf -``` - -Here we retrieve expected Betti numbers on an 3D iso-oriented cuboids: -``` -Betti numbers[0] = 1 -Betti numbers[1] = 3 -Betti numbers[2] = 3 -Betti numbers[3] = 1 -``` - -N.B.: -* Cuboid file must be in the format described [here](http://gudhi.gforge.inria.fr/doc/latest/fileformats.html#FileFormatsIsoCuboid). -* Filtration values are alpha square values. - - - - -## `alpha_complex_persistence` ## -This program computes the persistent homology with coefficient field Z/pZ of the dD alpha complex built from a dD point cloud. The output diagram contains one bar per line, written with the convention: - -`p dim b d` - -where `dim` is the dimension of the homological feature, `b` and `d` are respectively the birth and death of the feature, and `p` is the characteristic of the field *Z/pZ* used for homology coefficients (`p` must be a prime number). - -**Usage** -`alpha_complex_persistence [options] ` +`` is the path to the file describing the periodic domain. It must be in the format described [here](http://gudhi.gforge.inria.fr/doc/latest/fileformats.html#FileFormatsIsoCuboid). + +**Allowed options** + +* `-h [ --help ]` Produce help message +* `-o [ --output-file ]` Name of file in which the persistence diagram is written. Default print in standard output. +* `-p [ --field-charac ]` (default=11) Characteristic p of the coefficient field Z/pZ for computing homology. +* `-m [ --min-persistence ]` (default = 0) Minimal lifetime of homology feature to be recorded. Enter a negative value to see zero length intervals + + +**Example** +`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` + +outputs: +``` +Periodic Delaunay computed. +Simplex_tree dim: 3 +3 0 0 inf +3 1 0.0025 inf +3 1 0.0025 inf +3 1 0.0025 inf +3 2 0.005 inf +3 2 0.005 inf +3 2 0.005 inf +3 3 0.0075 inf +``` + +Here we retrieve expected Betti numbers on an 3D iso-oriented cuboids: +``` +Betti numbers[0] = 1 +Betti numbers[1] = 3 +Betti numbers[2] = 3 +Betti numbers[3] = 1 +``` + +N.B.: +* Cuboid file must be in the format described [here](http://gudhi.gforge.inria.fr/doc/latest/fileformats.html#FileFormatsIsoCuboid). +* Filtration values are alpha square values. + + + + +## `alpha_complex_persistence` ## +This program computes the persistent homology with coefficient field Z/pZ of the dD alpha complex built from a dD point cloud. The output diagram contains one bar per line, written with the convention: + +`p dim birth death` + +where `dim` is the dimension of the homological feature, `birth` and `death` are respectively the birth and death of the feature, and `p` is the characteristic of the field *Z/pZ* used for homology coefficients (`p` must be a prime number). + +**Usage** +`alpha_complex_persistence [options] ` where -`` is the path to the input point cloud in [nOFF ASCII format](http://www.geomview.org/docs/html/OFF.html). - -**Allowed options** - -* `-h [ --help ]` Produce help message -* `-o [ --output-file ]` Name of file in which the persistence diagram is written. Default print in standard output. -* `-r [ --max-alpha-square-value ]` (default = inf) Maximal alpha square value for the Alpha complex construction. -* `-p [ --field-charac ]` (default = 11) Characteristic p of the coefficient field Z/pZ for computing homology. -* `-m [ --min-persistence ]` (default = 0) Minimal lifetime of homology feature to be recorded. Enter a negative value to see zero length intervals. - -**Example** -`alpha_complex_persistence -r 32 -p 2 -m 0.45 ../../data/points/tore3D_300.off` - -outputs: -``` -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 -``` - -Here we retrieve expected Betti numbers on a tore 3D: -``` -Betti numbers[0] = 1 -Betti numbers[1] = 2 -Betti numbers[2] = 1 -``` - -N.B.: -* Filtration values are alpha square values. +`` is the path to the input point cloud in [nOFF ASCII format](http://www.geomview.org/docs/html/OFF.html). + +**Allowed options** + +* `-h [ --help ]` Produce help message +* `-o [ --output-file ]` Name of file in which the persistence diagram is written. Default print in standard output. +* `-r [ --max-alpha-square-value ]` (default = inf) Maximal alpha square value for the Alpha complex construction. +* `-p [ --field-charac ]` (default = 11) Characteristic p of the coefficient field Z/pZ for computing homology. +* `-m [ --min-persistence ]` (default = 0) Minimal lifetime of homology feature to be recorded. Enter a negative value to see zero length intervals. + +**Example** +`alpha_complex_persistence -r 32 -p 2 -m 0.45 ../../data/points/tore3D_300.off` + +outputs: +``` +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 +``` + +Here we retrieve expected Betti numbers on a tore 3D: +``` +Betti numbers[0] = 1 +Betti numbers[1] = 2 +Betti numbers[2] = 1 +``` + +N.B.: +* Filtration values are alpha square values. diff --git a/src/Bottleneck_distance/example/README b/src/Bottleneck_distance/example/README index 0e314608..01bcd74a 100644 --- a/src/Bottleneck_distance/example/README +++ b/src/Bottleneck_distance/example/README @@ -3,9 +3,9 @@ ## `alpha_rips_persistence_bottleneck_distance` ## This program computes the persistent homology with coefficient field Z/pZ of a Rips complex defined on a set of input points. The output diagram contains one bar per line, written with the convention: -`p dim b d` +`p dim birth death` -where `dim` is the dimension of the homological feature, `b` and `d` are respectively the birth and death of the feature, and `p` is the characteristic of the field *Z/pZ* used for homology coefficients. +where `dim` is the dimension of the homological feature, `birth` and `death` are respectively the birth and death of the feature, and `p` is the characteristic of the field *Z/pZ* used for homology coefficients. Usage: `alpha_rips_persistence_bottleneck_distance [options] ` diff --git a/src/Rips_complex/utilities/README b/src/Rips_complex/utilities/README index ca10424d..c839a5f4 100644 --- a/src/Rips_complex/utilities/README +++ b/src/Rips_complex/utilities/README @@ -3,9 +3,9 @@ ## `rips_persistence` ## This program computes the persistent homology with coefficient field *Z/pZ* of a Rips complex defined on a set of input points. The output diagram contains one bar per line, written with the convention: -`p dim b d` +`p dim birth death` -where `dim` is the dimension of the homological feature, `b` and `d` are respectively the birth and death of the feature, and `p` is the characteristic of the field *Z/pZ* used for homology coefficients (`p` must be a prime number). +where `dim` is the dimension of the homological feature, `birth` and `death` are respectively the birth and death of the feature, and `p` is the characteristic of the field *Z/pZ* used for homology coefficients (`p` must be a prime number). **Usage** `rips_persistence [options] ` diff --git a/src/Witness_complex/utilities/README b/src/Witness_complex/utilities/README index d8dc9ca7..952d4983 100644 --- a/src/Witness_complex/utilities/README +++ b/src/Witness_complex/utilities/README @@ -3,9 +3,9 @@ ## `weak_witness_persistence` ## This program computes the persistent homology with coefficient field *Z/pZ* of a Weak witness complex defined on a set of input points. The output diagram contains one bar per line, written with the convention: -`p dim b d` +`p dim birth death` -where `dim` is the dimension of the homological feature, `b` and `d` are respectively the birth and death of the feature, and `p` is the characteristic of the field *Z/pZ* used for homology coefficients. +where `dim` is the dimension of the homological feature, `birth` and `death` are respectively the birth and death of the feature, and `p` is the characteristic of the field *Z/pZ* used for homology coefficients. *Usage* `weak_witness_persistence [options] ` @@ -39,9 +39,9 @@ N.B.: output is random as the 20 landmarks are chosen randomly. ## `strong_witness_persistence` ## This program computes the persistent homology with coefficient field *Z/pZ* of a Strong witness complex defined on a set of input points. The output diagram contains one bar per line, written with the convention: -`p dim b d` +`p dim birth death` -where `dim` is the dimension of the homological feature, `b` and `d` are respectively the birth and death of the feature, and `p` is the characteristic of the field *Z/pZ* used for homology coefficients. +where `dim` is the dimension of the homological feature, `birth` and `death` are respectively the birth and death of the feature, and `p` is the characteristic of the field *Z/pZ* used for homology coefficients. *Usage* `strong_witness_persistence [options] ` -- cgit v1.2.3 From 5a4e31ee8607b54e81b1a64faaa8ce42f0309690 Mon Sep 17 00:00:00 2001 From: cjamin Date: Wed, 22 Nov 2017 16:51:57 +0000 Subject: Add precisions git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/add_utils_in_gudhi_v2@2944 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 7017c186aaad9702b72886348e5bfefa5a17160f --- src/Rips_complex/utilities/README | 2 ++ src/Witness_complex/utilities/README | 2 ++ 2 files changed, 4 insertions(+) (limited to 'src/Rips_complex') diff --git a/src/Rips_complex/utilities/README b/src/Rips_complex/utilities/README index c839a5f4..1a6f2b95 100644 --- a/src/Rips_complex/utilities/README +++ b/src/Rips_complex/utilities/README @@ -19,6 +19,8 @@ where `dim` is the dimension of the homological feature, `birth` and `death` are * `-p [ --field-charac ]` (default = 11) Characteristic p of the coefficient field Z/pZ for computing homology. * `-m [ --min-persistence ]` (default = 0) Minimal lifetime of homology feature to be recorded. Enter a negative value to see zero length intervals. +Beware: this program may use a lot of RAM and take a lot of time if `max-edge-length` is set to a large value. + **Example 1 with Z/2Z coefficients** `rips_persistence ../../data/points/tore3D_1307.off -r 0.25 -m 0.5 -d 3 -p 2` diff --git a/src/Witness_complex/utilities/README b/src/Witness_complex/utilities/README index 952d4983..1141033e 100644 --- a/src/Witness_complex/utilities/README +++ b/src/Witness_complex/utilities/README @@ -1,5 +1,7 @@ # Witness_complex # +For more details about the witness complex, please read the [user manual of the package](http://gudhi.gforge.inria.fr/doc/latest/group__witness__complex.html). + ## `weak_witness_persistence` ## This program computes the persistent homology with coefficient field *Z/pZ* of a Weak witness complex defined on a set of input points. The output diagram contains one bar per line, written with the convention: -- cgit v1.2.3 From 82ef91226635da17bda03b5581f0740de3282ab6 Mon Sep 17 00:00:00 2001 From: cjamin Date: Fri, 24 Nov 2017 08:10:47 +0000 Subject: Describe CSV matrix file git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/add_utils_in_gudhi_v2@2950 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: bfad995548f0336c38da0de9c04f5eeaafd67570 --- src/Rips_complex/utilities/README | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/Rips_complex') diff --git a/src/Rips_complex/utilities/README b/src/Rips_complex/utilities/README index 1a6f2b95..4d20c806 100644 --- a/src/Rips_complex/utilities/README +++ b/src/Rips_complex/utilities/README @@ -48,7 +48,12 @@ outputs: ## `rips_distance_matrix_persistence` ## -Same as `rips_persistence` but taking a distance matrix as input. +Same as `rips_persistence` but taking a distance matrix as input. + +**Usage** +`rips_persistence [options] ` +where +`` is the path to the file containing a distance matrix. Can be square or lower triangular matrix. Separator is ';'. **Example** `rips_distance_matrix_persistence data/distance_matrix/full_square_distance_matrix.csv -r 15 -d 3 -p 3 -m 0` -- cgit v1.2.3 From aa5760623c2d769c01567f5c7f07d52fabc3e2d9 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Tue, 19 Dec 2017 09:52:37 +0000 Subject: Add a function for unitary tests to test floating point values equality w/wo epsilon values git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/persistence_representation_integration_cmake_improvement@3083 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 835037fd6efea4fbfc9a494df3015186232388bf --- src/Alpha_complex/test/Alpha_complex_unit_test.cpp | 19 +++--- .../test/persistence_heat_maps_test.cpp | 72 ++++++++-------------- src/Rips_complex/test/test_rips_complex.cpp | 25 ++++---- src/cmake/modules/GUDHI_test_coverage.cmake | 14 ++++- src/common/include/gudhi/Debug_utils.h | 2 +- src/common/include/gudhi/Unitary_tests_utils.h | 39 ++++++++++++ 6 files changed, 96 insertions(+), 75 deletions(-) create mode 100644 src/common/include/gudhi/Unitary_tests_utils.h (limited to 'src/Rips_complex') diff --git a/src/Alpha_complex/test/Alpha_complex_unit_test.cpp b/src/Alpha_complex/test/Alpha_complex_unit_test.cpp index 166373fe..c3ad1a9c 100644 --- a/src/Alpha_complex/test/Alpha_complex_unit_test.cpp +++ b/src/Alpha_complex/test/Alpha_complex_unit_test.cpp @@ -23,6 +23,7 @@ #define BOOST_TEST_DYN_LINK #define BOOST_TEST_MODULE "alpha_complex" #include +#include #include #include @@ -36,7 +37,7 @@ // to construct a simplex_tree from Delaunay_triangulation #include #include -#include +#include // Use dynamic_dimension_tag for the user to be able to set dimension typedef CGAL::Epick_d< CGAL::Dynamic_dimension_tag > Kernel_d; @@ -96,10 +97,6 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(Alpha_complex_from_OFF_file, TestedKernel, list_of BOOST_CHECK(simplex_tree_59.num_simplices() == 23); } -bool are_almost_the_same(float a, float b) { - return std::fabs(a - b) < std::numeric_limits::epsilon(); -} - // Use static dimension_tag for the user not to be able to set dimension typedef CGAL::Epick_d< CGAL::Dimension_tag<4> > Kernel_4; typedef Kernel_4::Point_d Point_4; @@ -166,16 +163,16 @@ BOOST_AUTO_TEST_CASE(Alpha_complex_from_points) { for (auto f_simplex : simplex_tree.filtration_simplex_range()) { switch (simplex_tree.dimension(f_simplex)) { case 0: - BOOST_CHECK(are_almost_the_same(simplex_tree.filtration(f_simplex), 0.0)); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(simplex_tree.filtration(f_simplex), 0.0); break; case 1: - BOOST_CHECK(are_almost_the_same(simplex_tree.filtration(f_simplex), 1.0/2.0)); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(simplex_tree.filtration(f_simplex), 1.0/2.0); break; case 2: - BOOST_CHECK(are_almost_the_same(simplex_tree.filtration(f_simplex), 2.0/3.0)); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(simplex_tree.filtration(f_simplex), 2.0/3.0); break; case 3: - BOOST_CHECK(are_almost_the_same(simplex_tree.filtration(f_simplex), 3.0/4.0)); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(simplex_tree.filtration(f_simplex), 3.0/4.0); break; default: BOOST_CHECK(false); // Shall not happen @@ -239,10 +236,10 @@ BOOST_AUTO_TEST_CASE(Alpha_complex_from_points) { for (auto f_simplex : simplex_tree.filtration_simplex_range()) { switch (simplex_tree.dimension(f_simplex)) { case 0: - BOOST_CHECK(are_almost_the_same(simplex_tree.filtration(f_simplex), 0.0)); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(simplex_tree.filtration(f_simplex), 0.0); break; case 1: - BOOST_CHECK(are_almost_the_same(simplex_tree.filtration(f_simplex), 1.0/2.0)); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(simplex_tree.filtration(f_simplex), 1.0/2.0); break; default: BOOST_CHECK(false); // Shall not happen diff --git a/src/Persistence_representations/test/persistence_heat_maps_test.cpp b/src/Persistence_representations/test/persistence_heat_maps_test.cpp index 1f1502f5..4da13b86 100644 --- a/src/Persistence_representations/test/persistence_heat_maps_test.cpp +++ b/src/Persistence_representations/test/persistence_heat_maps_test.cpp @@ -25,12 +25,15 @@ #include #include #include +#include #include using namespace Gudhi; using namespace Gudhi::Persistence_representations; +double epsilon = 0.0005; + BOOST_AUTO_TEST_CASE(check_construction_of_heat_maps) { std::vector > filter = create_Gaussian_filter(100, 1); Persistence_heat_maps p("data/file_with_diagram", filter, false, 1000, 0, 1); @@ -139,28 +142,15 @@ BOOST_AUTO_TEST_CASE(check_distance_for_heat_maps) { Persistence_heat_maps q("data/file_with_diagram_1", filter, false, 1000, 0, 1); Persistence_heat_maps r("data/file_with_diagram_2", filter, false, 1000, 0, 1); - // cerr << p.distance( p ) << endl; - // cerr << p.distance( q ) << endl; - // cerr << p.distance( r ) << endl; - // cerr << q.distance( p ) << endl; - // cerr << q.distance( q ) << endl; - // cerr << q.distance( r ) << endl; - // cerr << r.distance( p ) << endl; - // cerr << r.distance( q ) << endl; - // cerr << r.distance( r ) << endl; - // 0 624.183 415.815 - // 624.183 0 528.06Z - // 415.815 528.066 0 - - BOOST_CHECK(fabs(p.distance(p) - 0) < 0.0005); - BOOST_CHECK(fabs(p.distance(q) - 624.183) < 0.0005); - BOOST_CHECK(fabs(p.distance(r) - 415.815) < 0.0005); - BOOST_CHECK(fabs(q.distance(p) - 624.183) < 0.0005); - BOOST_CHECK(fabs(q.distance(q) - 0) < 0.0005); - BOOST_CHECK(fabs(q.distance(r) - 528.066) < 0.0005); - BOOST_CHECK(fabs(r.distance(p) - 415.815) < 0.0005); - BOOST_CHECK(fabs(r.distance(q) - 528.066) < 0.0005); - BOOST_CHECK(fabs(r.distance(r) - 0) < 0.0005); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.distance(p), 0., epsilon); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.distance(q), 624.183, epsilon); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.distance(r), 415.815, epsilon); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(q.distance(p), 624.183, epsilon); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(q.distance(q), 0., epsilon); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(q.distance(r), 528.066, epsilon); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(r.distance(p), 415.815, epsilon); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(r.distance(q), 528.066, epsilon); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(r.distance(r), 0., epsilon); } BOOST_AUTO_TEST_CASE(check_projections_to_R_for_heat_maps) { @@ -169,13 +159,9 @@ BOOST_AUTO_TEST_CASE(check_projections_to_R_for_heat_maps) { Persistence_heat_maps q("data/file_with_diagram_1", filter, false, 1000, 0, 1); Persistence_heat_maps r("data/file_with_diagram_2", filter, false, 1000, 0, 1); - // cerr << p.project_to_R(0) << endl; - // cerr << q.project_to_R(0) << endl; - // cerr << r.project_to_R(0) << endl; - - BOOST_CHECK(fabs(p.project_to_R(0) - 44.3308) < 0.0005); - BOOST_CHECK(fabs(q.project_to_R(0) - 650.568) < 0.0005); - BOOST_CHECK(fabs(r.project_to_R(0) - 429.287) < 0.0005); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.project_to_R(0), 44.3308, epsilon); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(q.project_to_R(0), 650.568, epsilon); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(r.project_to_R(0), 429.287, epsilon); } BOOST_AUTO_TEST_CASE(check_scalar_products_for_heat_maps) { @@ -184,25 +170,15 @@ BOOST_AUTO_TEST_CASE(check_scalar_products_for_heat_maps) { Persistence_heat_maps q("data/file_with_diagram_1", filter, false, 1000, 0, 1); Persistence_heat_maps r("data/file_with_diagram_2", filter, false, 1000, 0, 1); - // cerr << p.compute_scalar_product( p ) << endl; - // cerr << p.compute_scalar_product( q ) << endl; - // cerr << p.compute_scalar_product( r ) << endl; - // cerr << q.compute_scalar_product( p ) << endl; - // cerr << q.compute_scalar_product( q ) << endl; - // cerr << q.compute_scalar_product( r ) << endl; - // cerr << r.compute_scalar_product( p ) << endl; - // cerr << r.compute_scalar_product( q ) << endl; - // cerr << r.compute_scalar_product( r ) << endl; - - BOOST_CHECK(fabs(p.compute_scalar_product(p) - 0.0345687) < 0.0005); - BOOST_CHECK(fabs(p.compute_scalar_product(q) - 0.0509357) < 0.0005); - BOOST_CHECK(fabs(p.compute_scalar_product(r) - 0.0375608) < 0.0005); - BOOST_CHECK(fabs(q.compute_scalar_product(p) - 0.0509357) < 0.0005); - BOOST_CHECK(fabs(q.compute_scalar_product(q) - 1.31293) < 0.0005); - BOOST_CHECK(fabs(q.compute_scalar_product(r) - 0.536799) < 0.0005); - BOOST_CHECK(fabs(r.compute_scalar_product(p) - 0.0375608) < 0.0005); - BOOST_CHECK(fabs(r.compute_scalar_product(q) - 0.536799) < 0.0005); - BOOST_CHECK(fabs(r.compute_scalar_product(r) - 0.672907) < 0.0005); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.compute_scalar_product(p), 0.0345687, epsilon); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.compute_scalar_product(q), 0.0509357, epsilon); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.compute_scalar_product(r), 0.0375608, epsilon); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(q.compute_scalar_product(p), 0.0509357, epsilon); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(q.compute_scalar_product(q), 1.31293 , epsilon); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(q.compute_scalar_product(r), 0.536799 , epsilon); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(r.compute_scalar_product(p), 0.0375608, epsilon); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(r.compute_scalar_product(q), 0.536799 , epsilon); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(r.compute_scalar_product(r), 0.672907 , epsilon); } BOOST_AUTO_TEST_CASE(check_arythmetic_operations_for_heat_maps) { diff --git a/src/Rips_complex/test/test_rips_complex.cpp b/src/Rips_complex/test/test_rips_complex.cpp index fc83f5f7..89afbc25 100644 --- a/src/Rips_complex/test/test_rips_complex.cpp +++ b/src/Rips_complex/test/test_rips_complex.cpp @@ -36,6 +36,7 @@ #include #include #include +#include // Type definitions using Point = std::vector; @@ -44,10 +45,6 @@ using Filtration_value = Simplex_tree::Filtration_value; using Rips_complex = Gudhi::rips_complex::Rips_complex; using Distance_matrix = std::vector>; -bool are_almost_the_same(float a, float b) { - return std::fabs(a - b) < std::numeric_limits::epsilon(); -} - BOOST_AUTO_TEST_CASE(RIPS_DOC_OFF_file) { // ---------------------------------------------------------------------------- // @@ -92,7 +89,7 @@ BOOST_AUTO_TEST_CASE(RIPS_DOC_OFF_file) { std::cout << ") - distance =" << Gudhi::Euclidean_distance()(vp.at(0), vp.at(1)) << " - filtration =" << st.filtration(f_simplex) << std::endl; BOOST_CHECK(vp.size() == 2); - BOOST_CHECK(are_almost_the_same(st.filtration(f_simplex), Gudhi::Euclidean_distance()(vp.at(0), vp.at(1)))); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(st.filtration(f_simplex), Gudhi::Euclidean_distance()(vp.at(0), vp.at(1))); } } @@ -113,14 +110,14 @@ BOOST_AUTO_TEST_CASE(RIPS_DOC_OFF_file) { Simplex_tree::Filtration_value f12 = st2.filtration(st2.find({1, 2})); Simplex_tree::Filtration_value f012 = st2.filtration(st2.find({0, 1, 2})); std::cout << "f012= " << f012 << " | f01= " << f01 << " - f02= " << f02 << " - f12= " << f12 << std::endl; - BOOST_CHECK(are_almost_the_same(f012, std::max(f01, std::max(f02,f12)))); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(f012, std::max(f01, std::max(f02,f12))); Simplex_tree::Filtration_value f45 = st2.filtration(st2.find({4, 5})); Simplex_tree::Filtration_value f56 = st2.filtration(st2.find({5, 6})); Simplex_tree::Filtration_value f46 = st2.filtration(st2.find({4, 6})); Simplex_tree::Filtration_value f456 = st2.filtration(st2.find({4, 5, 6})); std::cout << "f456= " << f456 << " | f45= " << f45 << " - f56= " << f56 << " - f46= " << f46 << std::endl; - BOOST_CHECK(are_almost_the_same(f456, std::max(f45, std::max(f56,f46)))); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(f456, std::max(f45, std::max(f56,f46))); const int DIMENSION_3 = 3; Simplex_tree st3; @@ -140,7 +137,7 @@ BOOST_AUTO_TEST_CASE(RIPS_DOC_OFF_file) { Simplex_tree::Filtration_value f0123 = st3.filtration(st3.find({0, 1, 2, 3})); std::cout << "f0123= " << f0123 << " | f012= " << f012 << " - f123= " << f123 << " - f013= " << f013 << " - f023= " << f023 << std::endl; - BOOST_CHECK(are_almost_the_same(f0123, std::max(f012, std::max(f123, std::max(f013, f023))))); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(f0123, std::max(f012, std::max(f123, std::max(f013, f023)))); } @@ -219,12 +216,12 @@ BOOST_AUTO_TEST_CASE(Rips_complex_from_points) { std::cout << "dimension(" << st.dimension(f_simplex) << ") - f = " << st.filtration(f_simplex) << std::endl; switch (st.dimension(f_simplex)) { case 0: - BOOST_CHECK(are_almost_the_same(st.filtration(f_simplex), 0.0)); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(st.filtration(f_simplex), 0.0); break; case 1: case 2: case 3: - BOOST_CHECK(are_almost_the_same(st.filtration(f_simplex), 2.0)); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(st.filtration(f_simplex), 2.0); break; default: BOOST_CHECK(false); // Shall not happen @@ -276,7 +273,7 @@ BOOST_AUTO_TEST_CASE(Rips_doc_csv_file) { } std::cout << ") - filtration =" << st.filtration(f_simplex) << std::endl; BOOST_CHECK(vvh.size() == 2); - BOOST_CHECK(are_almost_the_same(st.filtration(f_simplex), distances[vvh.at(0)][vvh.at(1)])); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(st.filtration(f_simplex), distances[vvh.at(0)][vvh.at(1)]); } } @@ -297,14 +294,14 @@ BOOST_AUTO_TEST_CASE(Rips_doc_csv_file) { Simplex_tree::Filtration_value f12 = st2.filtration(st2.find({1, 2})); Simplex_tree::Filtration_value f012 = st2.filtration(st2.find({0, 1, 2})); std::cout << "f012= " << f012 << " | f01= " << f01 << " - f02= " << f02 << " - f12= " << f12 << std::endl; - BOOST_CHECK(are_almost_the_same(f012, std::max(f01, std::max(f02,f12)))); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(f012, std::max(f01, std::max(f02,f12))); Simplex_tree::Filtration_value f45 = st2.filtration(st2.find({4, 5})); Simplex_tree::Filtration_value f56 = st2.filtration(st2.find({5, 6})); Simplex_tree::Filtration_value f46 = st2.filtration(st2.find({4, 6})); Simplex_tree::Filtration_value f456 = st2.filtration(st2.find({4, 5, 6})); std::cout << "f456= " << f456 << " | f45= " << f45 << " - f56= " << f56 << " - f46= " << f46 << std::endl; - BOOST_CHECK(are_almost_the_same(f456, std::max(f45, std::max(f56,f46)))); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(f456, std::max(f45, std::max(f56,f46))); const int DIMENSION_3 = 3; Simplex_tree st3; @@ -324,7 +321,7 @@ BOOST_AUTO_TEST_CASE(Rips_doc_csv_file) { Simplex_tree::Filtration_value f0123 = st3.filtration(st3.find({0, 1, 2, 3})); std::cout << "f0123= " << f0123 << " | f012= " << f012 << " - f123= " << f123 << " - f013= " << f013 << " - f023= " << f023 << std::endl; - BOOST_CHECK(are_almost_the_same(f0123, std::max(f012, std::max(f123, std::max(f013, f023))))); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(f0123, std::max(f012, std::max(f123, std::max(f013, f023)))); } diff --git a/src/cmake/modules/GUDHI_test_coverage.cmake b/src/cmake/modules/GUDHI_test_coverage.cmake index ce171a0e..bea5b2d6 100644 --- a/src/cmake/modules/GUDHI_test_coverage.cmake +++ b/src/cmake/modules/GUDHI_test_coverage.cmake @@ -8,7 +8,19 @@ if (GPROF_PATH) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg") endif() +if (DEBUG_TRACES) + # Make CTest more verbose with DEBUG_TRACES - no XML output + set(GUDHI_UT_LOG_LEVEL "--log_level=all") + set(GUDHI_UT_REPORT_LEVEL "--report_level=detailed") +else() + set(GUDHI_UT_LOG_FORMAT "--log_format=XML") + set(GUDHI_UT_LOG_SINK "--log_sink=${CMAKE_BINARY_DIR}/${unitary_test}_UT.xml") + set(GUDHI_UT_LOG_LEVEL "--log_level=test_suite") + set(GUDHI_UT_REPORT_LEVEL "--report_level=no") +endif() + function(gudhi_add_coverage_test unitary_test) add_test(NAME ${unitary_test} COMMAND $ - "--log_format=XML" "--log_sink=${CMAKE_BINARY_DIR}/${unitary_test}_UT.xml" "--log_level=test_suite" "--report_level=no") + ${GUDHI_UT_LOG_FORMAT} ${GUDHI_UT_LOG_SINK} + ${GUDHI_UT_LOG_LEVEL} ${GUDHI_UT_REPORT_LEVEL}) endfunction() diff --git a/src/common/include/gudhi/Debug_utils.h b/src/common/include/gudhi/Debug_utils.h index 8ed3b7b3..f9d9c50c 100644 --- a/src/common/include/gudhi/Debug_utils.h +++ b/src/common/include/gudhi/Debug_utils.h @@ -4,7 +4,7 @@ * * Author(s): David Salinas * - * Copyright (C) 2014 INRIA Sophia Antipolis-Mediterranee (France) + * Copyright (C) 2014 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 diff --git a/src/common/include/gudhi/Unitary_tests_utils.h b/src/common/include/gudhi/Unitary_tests_utils.h new file mode 100644 index 00000000..7ae5d356 --- /dev/null +++ b/src/common/include/gudhi/Unitary_tests_utils.h @@ -0,0 +1,39 @@ +/* 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) 2017 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 UNITARY_TESTS_UTILS_H_ +#define UNITARY_TESTS_UTILS_H_ + +#include + +#include + +template +void GUDHI_TEST_FLOAT_EQUALITY_CHECK(FloatingType a, FloatingType b, + FloatingType epsilon = std::numeric_limits::epsilon()) { +#ifdef DEBUG_TRACES + std::cout << "GUDHI_TEST_FLOAT_EQUALITY_CHECK - " << a << " versus " << b + << " | diff = " << std::fabs(a - b) << " - epsilon = " << epsilon << std::endl; +#endif + BOOST_CHECK(std::fabs(a - b) < epsilon); +} + +#endif // UNITARY_TESTS_UTILS_H_ -- cgit v1.2.3 From d8f04fab98dcb46ba7b300048311bf9e8b0ab3d2 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Mon, 22 Jan 2018 13:51:28 +0000 Subject: Fix cpplint git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@3149 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: e1cc797f8c24015168a1f84430666e8a156ababa --- src/Bottleneck_distance/include/gudhi/Bottleneck.h | 4 +- .../include/gudhi/Neighbors_finder.h | 1 + .../include/gudhi/read_persistence_from_file.h | 15 ++-- .../utilities/rips_distance_matrix_persistence.cpp | 61 +++++++--------- src/Rips_complex/utilities/rips_persistence.cpp | 60 ++++++--------- .../example/cech_complex_cgal_mini_sphere_3d.cpp | 85 +++++++++------------- .../example/graph_expansion_with_blocker.cpp | 40 +++++----- src/Simplex_tree/example/simple_simplex_tree.cpp | 84 +++++++++------------ .../include/gudhi/Kd_tree_search.h | 3 +- .../example/example_strong_witness_complex_off.cpp | 22 +++--- .../example/example_witness_complex_sphere.cpp | 24 +++--- .../utilities/strong_witness_persistence.cpp | 69 +++++++----------- .../utilities/weak_witness_persistence.cpp | 69 +++++++----------- src/common/include/gudhi/Unitary_tests_utils.h | 1 + 14 files changed, 223 insertions(+), 315 deletions(-) (limited to 'src/Rips_complex') diff --git a/src/Bottleneck_distance/include/gudhi/Bottleneck.h b/src/Bottleneck_distance/include/gudhi/Bottleneck.h index 8c97dce9..7aee07bb 100644 --- a/src/Bottleneck_distance/include/gudhi/Bottleneck.h +++ b/src/Bottleneck_distance/include/gudhi/Bottleneck.h @@ -46,7 +46,7 @@ double bottleneck_distance_approx(Persistence_graph& g, double e) { if (step <= b_lower_bound || step >= b_upper_bound) // Avoid precision problem break; m.set_r(step); - while (m.multi_augment()) {}; // compute a maximum matching (in the graph corresponding to the current r) + while (m.multi_augment()) {} // compute a maximum matching (in the graph corresponding to the current r) if (m.perfect()) { m = biggest_unperfect; b_upper_bound = step; @@ -68,7 +68,7 @@ double bottleneck_distance_exact(Persistence_graph& g) { while (lower_bound_i != upper_bound_i) { long step = lower_bound_i + static_cast ((upper_bound_i - lower_bound_i - 1) / alpha); m.set_r(sd.at(step)); - while (m.multi_augment()) {}; // compute a maximum matching (in the graph corresponding to the current r) + while (m.multi_augment()) {} // compute a maximum matching (in the graph corresponding to the current r) if (m.perfect()) { m = biggest_unperfect; upper_bound_i = step; diff --git a/src/Bottleneck_distance/include/gudhi/Neighbors_finder.h b/src/Bottleneck_distance/include/gudhi/Neighbors_finder.h index dc804630..87c7cee5 100644 --- a/src/Bottleneck_distance/include/gudhi/Neighbors_finder.h +++ b/src/Bottleneck_distance/include/gudhi/Neighbors_finder.h @@ -32,6 +32,7 @@ #include #include +#include // for std::max namespace Gudhi { diff --git a/src/Persistence_representations/include/gudhi/read_persistence_from_file.h b/src/Persistence_representations/include/gudhi/read_persistence_from_file.h index 450c223c..83b89d0e 100644 --- a/src/Persistence_representations/include/gudhi/read_persistence_from_file.h +++ b/src/Persistence_representations/include/gudhi/read_persistence_from_file.h @@ -23,6 +23,8 @@ #ifndef READ_PERSISTENCE_FROM_FILE_H_ #define READ_PERSISTENCE_FROM_FILE_H_ +#include + #include #include #include @@ -30,7 +32,7 @@ #include #include #include -#include +#include // for std::numeric_limits<> namespace Gudhi { namespace Persistence_representations { @@ -72,16 +74,9 @@ std::vector > read_persistence_intervals_in_one_dimens std::cout << "COnsidering interval : " << barcode_initial[i].first << " " << barcode_initial[i].second << std::endl; } - // if ( barcode_initial[i].first == barcode_initial[i].second ) - //{ - // if ( dbg )std::cout << "It has zero length \n"; - // continue;//zero length intervals are not relevant, so we skip all of them. - //} - if (barcode_initial[i].first > - barcode_initial[i] - .second) // note that in this case barcode_initial[i].second != std::numeric_limits::infinity() - { + if (barcode_initial[i].first > barcode_initial[i].second) { + // note that in this case barcode_initial[i].second != std::numeric_limits::infinity() if (dbg) std::cout << "Swap and enter \n"; // swap them to make sure that birth < death final_barcode.push_back(std::pair(barcode_initial[i].second, barcode_initial[i].first)); diff --git a/src/Rips_complex/utilities/rips_distance_matrix_persistence.cpp b/src/Rips_complex/utilities/rips_distance_matrix_persistence.cpp index d38808c7..ca3c0327 100644 --- a/src/Rips_complex/utilities/rips_distance_matrix_persistence.cpp +++ b/src/Rips_complex/utilities/rips_distance_matrix_persistence.cpp @@ -1,5 +1,5 @@ -/* This file is part of the Gudhi Library. The Gudhi library - * (Geometric Understanding in Higher Dimensions) is a generic C++ +/* 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): Pawel Dlotko, Vincent Rouvreau @@ -36,18 +36,13 @@ using Simplex_tree = Gudhi::Simplex_tree; using Field_Zp = Gudhi::persistent_cohomology::Field_Zp; -using Persistent_cohomology = Gudhi::persistent_cohomology::Persistent_cohomology; +using Persistent_cohomology = Gudhi::persistent_cohomology::Persistent_cohomology; using Distance_matrix = std::vector>; -void program_options(int argc, char * argv[] - , std::string & csv_matrix_file - , std::string & filediag - , Filtration_value & threshold - , int & dim_max - , int & p - , Filtration_value & min_persistence); +void program_options(int argc, char* argv[], std::string& csv_matrix_file, std::string& filediag, + Filtration_value& threshold, int& dim_max, int& p, Filtration_value& min_persistence); -int main(int argc, char * argv[]) { +int main(int argc, char* argv[]) { std::string csv_matrix_file; std::string filediag; Filtration_value threshold; @@ -88,33 +83,28 @@ int main(int argc, char * argv[]) { return 0; } -void program_options(int argc, char * argv[] - , std::string & csv_matrix_file - , std::string & filediag - , Filtration_value & threshold - , int & dim_max - , int & p - , Filtration_value & min_persistence) { +void program_options(int argc, char* argv[], std::string& csv_matrix_file, std::string& filediag, + Filtration_value& threshold, int& dim_max, int& p, Filtration_value& min_persistence) { namespace po = boost::program_options; po::options_description hidden("Hidden options"); - hidden.add_options() - ("input-file", po::value(&csv_matrix_file), - "Name of file containing a distance matrix. Can be square or lower triangular matrix. Separator is ';'."); + hidden.add_options()( + "input-file", po::value(&csv_matrix_file), + "Name of file containing a distance matrix. Can be square or lower triangular matrix. Separator is ';'."); po::options_description visible("Allowed options", 100); - visible.add_options() - ("help,h", "produce help message") - ("output-file,o", po::value(&filediag)->default_value(std::string()), - "Name of file in which the persistence diagram is written. Default print in std::cout") - ("max-edge-length,r", - po::value(&threshold)->default_value(std::numeric_limits::infinity()), - "Maximal length of an edge for the Rips complex construction.") - ("cpx-dimension,d", po::value(&dim_max)->default_value(1), - "Maximal dimension of the Rips complex we want to compute.") - ("field-charac,p", po::value(&p)->default_value(11), - "Characteristic p of the coefficient field Z/pZ for computing homology.") - ("min-persistence,m", po::value(&min_persistence), - "Minimal lifetime of homology feature to be recorded. Default is 0. Enter a negative value to see zero length intervals"); + visible.add_options()("help,h", "produce help message")( + "output-file,o", po::value(&filediag)->default_value(std::string()), + "Name of file in which the persistence diagram is written. Default print in std::cout")( + "max-edge-length,r", + po::value(&threshold)->default_value(std::numeric_limits::infinity()), + "Maximal length of an edge for the Rips complex construction.")( + "cpx-dimension,d", po::value(&dim_max)->default_value(1), + "Maximal dimension of the Rips complex we want to compute.")( + "field-charac,p", po::value(&p)->default_value(11), + "Characteristic p of the coefficient field Z/pZ for computing homology.")( + "min-persistence,m", po::value(&min_persistence), + "Minimal lifetime of homology feature to be recorded. Default is 0. Enter a negative value to see zero length " + "intervals"); po::positional_options_description pos; pos.add("input-file", 1); @@ -123,8 +113,7 @@ void program_options(int argc, char * argv[] all.add(visible).add(hidden); po::variables_map vm; - po::store(po::command_line_parser(argc, argv). - options(all).positional(pos).run(), vm); + po::store(po::command_line_parser(argc, argv).options(all).positional(pos).run(), vm); po::notify(vm); if (vm.count("help") || !vm.count("input-file")) { diff --git a/src/Rips_complex/utilities/rips_persistence.cpp b/src/Rips_complex/utilities/rips_persistence.cpp index d504798b..8405c014 100644 --- a/src/Rips_complex/utilities/rips_persistence.cpp +++ b/src/Rips_complex/utilities/rips_persistence.cpp @@ -1,5 +1,5 @@ -/* This file is part of the Gudhi Library. The Gudhi library - * (Geometric Understanding in Higher Dimensions) is a generic C++ +/* 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): Clément Maria @@ -37,19 +37,14 @@ using Simplex_tree = Gudhi::Simplex_tree; using Field_Zp = Gudhi::persistent_cohomology::Field_Zp; -using Persistent_cohomology = Gudhi::persistent_cohomology::Persistent_cohomology; +using Persistent_cohomology = Gudhi::persistent_cohomology::Persistent_cohomology; using Point = std::vector; using Points_off_reader = Gudhi::Points_off_reader; -void program_options(int argc, char * argv[] - , std::string & off_file_points - , std::string & filediag - , Filtration_value & threshold - , int & dim_max - , int & p - , Filtration_value & min_persistence); +void program_options(int argc, char* argv[], std::string& off_file_points, std::string& filediag, + Filtration_value& threshold, int& dim_max, int& p, Filtration_value& min_persistence); -int main(int argc, char * argv[]) { +int main(int argc, char* argv[]) { std::string off_file_points; std::string filediag; Filtration_value threshold; @@ -91,33 +86,27 @@ int main(int argc, char * argv[]) { return 0; } -void program_options(int argc, char * argv[] - , std::string & off_file_points - , std::string & filediag - , Filtration_value & threshold - , int & dim_max - , int & p - , Filtration_value & min_persistence) { +void program_options(int argc, char* argv[], std::string& off_file_points, std::string& filediag, + Filtration_value& threshold, int& dim_max, int& p, Filtration_value& min_persistence) { namespace po = boost::program_options; po::options_description hidden("Hidden options"); - hidden.add_options() - ("input-file", po::value(&off_file_points), - "Name of an OFF file containing a point set.\n"); + hidden.add_options()("input-file", po::value(&off_file_points), + "Name of an OFF file containing a point set.\n"); po::options_description visible("Allowed options", 100); - visible.add_options() - ("help,h", "produce help message") - ("output-file,o", po::value(&filediag)->default_value(std::string()), - "Name of file in which the persistence diagram is written. Default print in std::cout") - ("max-edge-length,r", - po::value(&threshold)->default_value(std::numeric_limits::infinity()), - "Maximal length of an edge for the Rips complex construction.") - ("cpx-dimension,d", po::value(&dim_max)->default_value(1), - "Maximal dimension of the Rips complex we want to compute.") - ("field-charac,p", po::value(&p)->default_value(11), - "Characteristic p of the coefficient field Z/pZ for computing homology.") - ("min-persistence,m", po::value(&min_persistence), - "Minimal lifetime of homology feature to be recorded. Default is 0. Enter a negative value to see zero length intervals"); + visible.add_options()("help,h", "produce help message")( + "output-file,o", po::value(&filediag)->default_value(std::string()), + "Name of file in which the persistence diagram is written. Default print in std::cout")( + "max-edge-length,r", + po::value(&threshold)->default_value(std::numeric_limits::infinity()), + "Maximal length of an edge for the Rips complex construction.")( + "cpx-dimension,d", po::value(&dim_max)->default_value(1), + "Maximal dimension of the Rips complex we want to compute.")( + "field-charac,p", po::value(&p)->default_value(11), + "Characteristic p of the coefficient field Z/pZ for computing homology.")( + "min-persistence,m", po::value(&min_persistence), + "Minimal lifetime of homology feature to be recorded. Default is 0. Enter a negative value to see zero length " + "intervals"); po::positional_options_description pos; pos.add("input-file", 1); @@ -126,8 +115,7 @@ void program_options(int argc, char * argv[] all.add(visible).add(hidden); po::variables_map vm; - po::store(po::command_line_parser(argc, argv). - options(all).positional(pos).run(), vm); + po::store(po::command_line_parser(argc, argv).options(all).positional(pos).run(), vm); po::notify(vm); if (vm.count("help") || !vm.count("input-file")) { diff --git a/src/Simplex_tree/example/cech_complex_cgal_mini_sphere_3d.cpp b/src/Simplex_tree/example/cech_complex_cgal_mini_sphere_3d.cpp index 217e251f..9bd51106 100644 --- a/src/Simplex_tree/example/cech_complex_cgal_mini_sphere_3d.cpp +++ b/src/Simplex_tree/example/cech_complex_cgal_mini_sphere_3d.cpp @@ -1,5 +1,5 @@ -/* This file is part of the Gudhi Library. The Gudhi library - * (Geometric Understanding in Higher Dimensions) is a generic C++ +/* 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): Clément Maria @@ -33,7 +33,7 @@ #include #include -#include // infinity +#include // infinity #include // for pair #include @@ -50,15 +50,14 @@ using Vertex_handle = Simplex_tree::Vertex_handle; using Simplex_handle = Simplex_tree::Simplex_handle; using Filtration_value = Simplex_tree::Filtration_value; using Siblings = Simplex_tree::Siblings; -using Graph_t = boost::adjacency_list < boost::vecS, boost::vecS, boost::undirectedS -, boost::property < Gudhi::vertex_filtration_t, Filtration_value > -, boost::property < Gudhi::edge_filtration_t, Filtration_value > ->; -using Edge_t = std::pair< Vertex_handle, Vertex_handle >; +using Graph_t = boost::adjacency_list, + boost::property >; +using Edge_t = std::pair; -using Kernel = CGAL::Epick_d< CGAL::Dimension_tag<3> >; +using Kernel = CGAL::Epick_d >; using Point = Kernel::Point_d; -using Traits = CGAL::Min_sphere_of_points_d_traits_d; +using Traits = CGAL::Min_sphere_of_points_d_traits_d; using Min_sphere = CGAL::Min_sphere_of_spheres_d; using Points_off_reader = Gudhi::Points_off_reader; @@ -76,7 +75,7 @@ class Cech_blocker { std::cout << vertex << ", "; #endif // DEBUG_TRACES } - Min_sphere ms(points.begin(),points.end()); + Min_sphere ms(points.begin(), points.end()); Filtration_value radius = ms.radius(); #if DEBUG_TRACES std::cout << "] - radius = " << radius << " - returns " << (radius > threshold_) << std::endl; @@ -85,24 +84,20 @@ class Cech_blocker { return (radius > threshold_); } Cech_blocker(Simplex_tree& simplex_tree, Filtration_value threshold, const std::vector& point_cloud) - : simplex_tree_(simplex_tree), - threshold_(threshold), - point_cloud_(point_cloud) { } + : simplex_tree_(simplex_tree), threshold_(threshold), point_cloud_(point_cloud) {} + private: Simplex_tree simplex_tree_; Filtration_value threshold_; std::vector point_cloud_; }; -template< typename InputPointRange> -Graph_t compute_proximity_graph(InputPointRange &points, Filtration_value threshold); +template +Graph_t compute_proximity_graph(InputPointRange& points, Filtration_value threshold); -void program_options(int argc, char * argv[] - , std::string & off_file_points - , Filtration_value & threshold - , int & dim_max); +void program_options(int argc, char* argv[], std::string& off_file_points, Filtration_value& threshold, int& dim_max); -int main(int argc, char * argv[]) { +int main(int argc, char* argv[]) { std::string off_file_points; Filtration_value threshold; int dim_max; @@ -115,7 +110,7 @@ int main(int argc, char * argv[]) { // Compute the proximity graph of the points Graph_t prox_graph = compute_proximity_graph(off_reader.get_point_cloud(), threshold); - //Min_sphere sph1(off_reader.get_point_cloud()[0], off_reader.get_point_cloud()[1], off_reader.get_point_cloud()[2]); + // Min_sphere sph1(off_reader.get_point_cloud()[0], off_reader.get_point_cloud()[1], off_reader.get_point_cloud()[2]); // Construct the Rips complex in a Simplex Tree Simplex_tree st; // insert the proximity graph in the simplex tree @@ -135,7 +130,8 @@ int main(int argc, char * argv[]) { std::cout << "* The complex contains " << st.num_simplices() << " simplices - dimension=" << st.dimension() << "\n"; std::cout << "* Iterator on Simplices in the filtration, with [filtration value]:\n"; for (auto f_simplex : st.filtration_simplex_range()) { - std::cout << " " << "[" << st.filtration(f_simplex) << "] "; + std::cout << " " + << "[" << st.filtration(f_simplex) << "] "; for (auto vertex : st.simplex_vertex_range(f_simplex)) { std::cout << static_cast(vertex) << " "; } @@ -145,24 +141,19 @@ int main(int argc, char * argv[]) { return 0; } -void program_options(int argc, char * argv[] - , std::string & off_file_points - , Filtration_value & threshold - , int & dim_max) { +void program_options(int argc, char* argv[], std::string& off_file_points, Filtration_value& threshold, int& dim_max) { namespace po = boost::program_options; po::options_description hidden("Hidden options"); - hidden.add_options() - ("input-file", po::value(&off_file_points), - "Name of an OFF file containing a 3d point set.\n"); + hidden.add_options()("input-file", po::value(&off_file_points), + "Name of an OFF file containing a 3d point set.\n"); po::options_description visible("Allowed options", 100); - visible.add_options() - ("help,h", "produce help message") - ("max-edge-length,r", - po::value(&threshold)->default_value(std::numeric_limits::infinity()), - "Maximal length of an edge for the Cech complex construction.") - ("cpx-dimension,d", po::value(&dim_max)->default_value(1), - "Maximal dimension of the Cech complex we want to compute."); + visible.add_options()("help,h", "produce help message")( + "max-edge-length,r", + po::value(&threshold)->default_value(std::numeric_limits::infinity()), + "Maximal length of an edge for the Cech complex construction.")( + "cpx-dimension,d", po::value(&dim_max)->default_value(1), + "Maximal dimension of the Cech complex we want to compute."); po::positional_options_description pos; pos.add("input-file", 1); @@ -171,8 +162,7 @@ void program_options(int argc, char * argv[] all.add(visible).add(hidden); po::variables_map vm; - po::store(po::command_line_parser(argc, argv). - options(all).positional(pos).run(), vm); + po::store(po::command_line_parser(argc, argv).options(all).positional(pos).run(), vm); po::notify(vm); if (vm.count("help") || !vm.count("input-file")) { @@ -194,10 +184,10 @@ void program_options(int argc, char * argv[] * The type PointCloud furnishes .begin() and .end() methods, that return * iterators with value_type Point. */ -template< typename InputPointRange> -Graph_t compute_proximity_graph(InputPointRange &points, Filtration_value threshold) { - std::vector< Edge_t > edges; - std::vector< Filtration_value > edges_fil; +template +Graph_t compute_proximity_graph(InputPointRange& points, Filtration_value threshold) { + std::vector edges; + std::vector edges_fil; Kernel k; Vertex_handle idx_u, idx_v; @@ -217,16 +207,13 @@ Graph_t compute_proximity_graph(InputPointRange &points, Filtration_value thresh ++idx_u; } - Graph_t skel_graph(edges.begin() - , edges.end() - , edges_fil.begin() - , idx_u); // number of points labeled from 0 to idx_u-1 + Graph_t skel_graph(edges.begin(), edges.end(), edges_fil.begin(), + idx_u); // number of points labeled from 0 to idx_u-1 auto vertex_prop = boost::get(Gudhi::vertex_filtration_t(), skel_graph); boost::graph_traits::vertex_iterator vi, vi_end; - for (std::tie(vi, vi_end) = boost::vertices(skel_graph); - vi != vi_end; ++vi) { + for (std::tie(vi, vi_end) = boost::vertices(skel_graph); vi != vi_end; ++vi) { boost::put(vertex_prop, *vi, 0.); } diff --git a/src/Simplex_tree/example/graph_expansion_with_blocker.cpp b/src/Simplex_tree/example/graph_expansion_with_blocker.cpp index 86bfb8cb..0d458cbd 100644 --- a/src/Simplex_tree/example/graph_expansion_with_blocker.cpp +++ b/src/Simplex_tree/example/graph_expansion_with_blocker.cpp @@ -27,8 +27,7 @@ using Simplex_tree = Gudhi::Simplex_tree<>; using Simplex_handle = Simplex_tree::Simplex_handle; -int main(int argc, char * const argv[]) { - +int main(int argc, char* const argv[]) { // Construct the Simplex Tree with a 1-skeleton graph example Simplex_tree simplexTree; @@ -45,33 +44,32 @@ int main(int argc, char * const argv[]) { simplexTree.insert_simplex({5, 6}, 10.); simplexTree.insert_simplex({6}, 10.); - simplexTree.expansion_with_blockers(3, [&](Simplex_handle sh){ - bool result = false; - std::cout << "Blocker on ["; - // User can loop on the vertices from the given simplex_handle i.e. - for (auto vertex : simplexTree.simplex_vertex_range(sh)) { - // We block the expansion, if the vertex '6' is in the given list of vertices - if (vertex == 6) - result = true; - std::cout << vertex << ", "; - } - std::cout << "] ( " << simplexTree.filtration(sh); - // User can re-assign a new filtration value directly in the blocker (default is the maximal value of boudaries) - simplexTree.assign_filtration(sh, simplexTree.filtration(sh) + 1.); + simplexTree.expansion_with_blockers(3, [&](Simplex_handle sh) { + bool result = false; + std::cout << "Blocker on ["; + // User can loop on the vertices from the given simplex_handle i.e. + for (auto vertex : simplexTree.simplex_vertex_range(sh)) { + // We block the expansion, if the vertex '6' is in the given list of vertices + if (vertex == 6) result = true; + std::cout << vertex << ", "; + } + std::cout << "] ( " << simplexTree.filtration(sh); + // User can re-assign a new filtration value directly in the blocker (default is the maximal value of boudaries) + simplexTree.assign_filtration(sh, simplexTree.filtration(sh) + 1.); - std::cout << " + 1. ) = " << result << std::endl; + std::cout << " + 1. ) = " << result << std::endl; - return result; - }); + return result; + }); std::cout << "********************************************************************\n"; std::cout << "* The complex contains " << simplexTree.num_simplices() << " simplices"; std::cout << " - dimension " << simplexTree.dimension() << "\n"; std::cout << "* Iterator on Simplices in the filtration, with [filtration value]:\n"; for (auto f_simplex : simplexTree.filtration_simplex_range()) { - std::cout << " " << "[" << simplexTree.filtration(f_simplex) << "] "; - for (auto vertex : simplexTree.simplex_vertex_range(f_simplex)) - std::cout << "(" << vertex << ")"; + std::cout << " " + << "[" << simplexTree.filtration(f_simplex) << "] "; + for (auto vertex : simplexTree.simplex_vertex_range(f_simplex)) std::cout << "(" << vertex << ")"; std::cout << std::endl; } diff --git a/src/Simplex_tree/example/simple_simplex_tree.cpp b/src/Simplex_tree/example/simple_simplex_tree.cpp index b6b65b88..828977c2 100644 --- a/src/Simplex_tree/example/simple_simplex_tree.cpp +++ b/src/Simplex_tree/example/simple_simplex_tree.cpp @@ -30,10 +30,10 @@ using Simplex_tree = Gudhi::Simplex_tree<>; using Vertex_handle = Simplex_tree::Vertex_handle; using Filtration_value = Simplex_tree::Filtration_value; -using typeVectorVertex = std::vector< Vertex_handle >; -using typePairSimplexBool = std::pair< Simplex_tree::Simplex_handle, bool >; +using typeVectorVertex = std::vector; +using typePairSimplexBool = std::pair; -int main(int argc, char * const argv[]) { +int main(int argc, char* const argv[]) { const Filtration_value FIRST_FILTRATION_VALUE = 0.1; const Filtration_value SECOND_FILTRATION_VALUE = 0.2; const Filtration_value THIRD_FILTRATION_VALUE = 0.3; @@ -54,7 +54,7 @@ int main(int argc, char * const argv[]) { // ++ FIRST std::cout << " * INSERT 0" << std::endl; - typeVectorVertex firstSimplexVector = { 0 }; + typeVectorVertex firstSimplexVector = {0}; typePairSimplexBool returnValue = simplexTree.insert_simplex(firstSimplexVector, Filtration_value(FIRST_FILTRATION_VALUE)); @@ -66,9 +66,8 @@ int main(int argc, char * const argv[]) { // ++ SECOND std::cout << " * INSERT 1" << std::endl; - typeVectorVertex secondSimplexVector = { 1 }; - returnValue = - simplexTree.insert_simplex(secondSimplexVector, Filtration_value(FIRST_FILTRATION_VALUE)); + typeVectorVertex secondSimplexVector = {1}; + returnValue = simplexTree.insert_simplex(secondSimplexVector, Filtration_value(FIRST_FILTRATION_VALUE)); if (returnValue.second == true) { std::cout << " + 1 INSERTED" << std::endl; @@ -78,9 +77,8 @@ int main(int argc, char * const argv[]) { // ++ THIRD std::cout << " * INSERT (0,1)" << std::endl; - typeVectorVertex thirdSimplexVector = { 0, 1 }; - returnValue = - simplexTree.insert_simplex(thirdSimplexVector, Filtration_value(SECOND_FILTRATION_VALUE)); + typeVectorVertex thirdSimplexVector = {0, 1}; + returnValue = simplexTree.insert_simplex(thirdSimplexVector, Filtration_value(SECOND_FILTRATION_VALUE)); if (returnValue.second == true) { std::cout << " + (0,1) INSERTED" << std::endl; @@ -90,9 +88,8 @@ int main(int argc, char * const argv[]) { // ++ FOURTH std::cout << " * INSERT 2" << std::endl; - typeVectorVertex fourthSimplexVector = { 2 }; - returnValue = - simplexTree.insert_simplex(fourthSimplexVector, Filtration_value(FIRST_FILTRATION_VALUE)); + typeVectorVertex fourthSimplexVector = {2}; + returnValue = simplexTree.insert_simplex(fourthSimplexVector, Filtration_value(FIRST_FILTRATION_VALUE)); if (returnValue.second == true) { std::cout << " + 2 INSERTED" << std::endl; @@ -102,9 +99,8 @@ int main(int argc, char * const argv[]) { // ++ FIFTH std::cout << " * INSERT (2,0)" << std::endl; - typeVectorVertex fifthSimplexVector = { 2, 0 }; - returnValue = - simplexTree.insert_simplex(fifthSimplexVector, Filtration_value(SECOND_FILTRATION_VALUE)); + typeVectorVertex fifthSimplexVector = {2, 0}; + returnValue = simplexTree.insert_simplex(fifthSimplexVector, Filtration_value(SECOND_FILTRATION_VALUE)); if (returnValue.second == true) { std::cout << " + (2,0) INSERTED" << std::endl; @@ -114,9 +110,8 @@ int main(int argc, char * const argv[]) { // ++ SIXTH std::cout << " * INSERT (2,1)" << std::endl; - typeVectorVertex sixthSimplexVector = { 2, 1 }; - returnValue = - simplexTree.insert_simplex(sixthSimplexVector, Filtration_value(SECOND_FILTRATION_VALUE)); + typeVectorVertex sixthSimplexVector = {2, 1}; + returnValue = simplexTree.insert_simplex(sixthSimplexVector, Filtration_value(SECOND_FILTRATION_VALUE)); if (returnValue.second == true) { std::cout << " + (2,1) INSERTED" << std::endl; @@ -126,9 +121,8 @@ int main(int argc, char * const argv[]) { // ++ SEVENTH std::cout << " * INSERT (2,1,0)" << std::endl; - typeVectorVertex seventhSimplexVector = { 2, 1, 0 }; - returnValue = - simplexTree.insert_simplex(seventhSimplexVector, Filtration_value(THIRD_FILTRATION_VALUE)); + typeVectorVertex seventhSimplexVector = {2, 1, 0}; + returnValue = simplexTree.insert_simplex(seventhSimplexVector, Filtration_value(THIRD_FILTRATION_VALUE)); if (returnValue.second == true) { std::cout << " + (2,1,0) INSERTED" << std::endl; @@ -138,9 +132,8 @@ int main(int argc, char * const argv[]) { // ++ EIGHTH std::cout << " * INSERT 3" << std::endl; - typeVectorVertex eighthSimplexVector = { 3 }; - returnValue = - simplexTree.insert_simplex(eighthSimplexVector, Filtration_value(FIRST_FILTRATION_VALUE)); + typeVectorVertex eighthSimplexVector = {3}; + returnValue = simplexTree.insert_simplex(eighthSimplexVector, Filtration_value(FIRST_FILTRATION_VALUE)); if (returnValue.second == true) { std::cout << " + 3 INSERTED" << std::endl; @@ -150,9 +143,8 @@ int main(int argc, char * const argv[]) { // ++ NINETH std::cout << " * INSERT (3,0)" << std::endl; - typeVectorVertex ninethSimplexVector = { 3, 0 }; - returnValue = - simplexTree.insert_simplex(ninethSimplexVector, Filtration_value(SECOND_FILTRATION_VALUE)); + typeVectorVertex ninethSimplexVector = {3, 0}; + returnValue = simplexTree.insert_simplex(ninethSimplexVector, Filtration_value(SECOND_FILTRATION_VALUE)); if (returnValue.second == true) { std::cout << " + (3,0) INSERTED" << std::endl; @@ -162,7 +154,7 @@ int main(int argc, char * const argv[]) { // ++ TENTH std::cout << " * INSERT 0 (already inserted)" << std::endl; - typeVectorVertex tenthSimplexVector = { 0 }; + typeVectorVertex tenthSimplexVector = {0}; // With a different filtration value returnValue = simplexTree.insert_simplex(tenthSimplexVector, Filtration_value(FOURTH_FILTRATION_VALUE)); @@ -174,9 +166,8 @@ int main(int argc, char * const argv[]) { // ++ ELEVENTH std::cout << " * INSERT (2,1,0) (already inserted)" << std::endl; - typeVectorVertex eleventhSimplexVector = { 2, 1, 0 }; - returnValue = - simplexTree.insert_simplex(eleventhSimplexVector, Filtration_value(FOURTH_FILTRATION_VALUE)); + typeVectorVertex eleventhSimplexVector = {2, 1, 0}; + returnValue = simplexTree.insert_simplex(eleventhSimplexVector, Filtration_value(FOURTH_FILTRATION_VALUE)); if (returnValue.second == true) { std::cout << " + (2,1,0) INSERTED" << std::endl; @@ -192,9 +183,9 @@ int main(int argc, char * const argv[]) { std::cout << " - dimension " << simplexTree.dimension() << "\n"; std::cout << "* Iterator on Simplices in the filtration, with [filtration value]:\n"; for (auto f_simplex : simplexTree.filtration_simplex_range()) { - std::cout << " " << "[" << simplexTree.filtration(f_simplex) << "] "; - for (auto vertex : simplexTree.simplex_vertex_range(f_simplex)) - std::cout << "(" << vertex << ")"; + std::cout << " " + << "[" << simplexTree.filtration(f_simplex) << "] "; + for (auto vertex : simplexTree.simplex_vertex_range(f_simplex)) std::cout << "(" << vertex << ")"; std::cout << std::endl; } // [0.1] 0 @@ -217,7 +208,7 @@ int main(int argc, char * const argv[]) { else std::cout << "***- NO IT ISN'T\n"; - typeVectorVertex unknownSimplexVector = { 15 }; + typeVectorVertex unknownSimplexVector = {15}; simplexFound = simplexTree.find(unknownSimplexVector); std::cout << "**************IS THE SIMPLEX {15} IN THE SIMPLEX TREE ?\n"; if (simplexFound != simplexTree.null_simplex()) @@ -232,7 +223,7 @@ int main(int argc, char * const argv[]) { else std::cout << "***- NO IT ISN'T\n"; - typeVectorVertex otherSimplexVector = { 1, 15 }; + typeVectorVertex otherSimplexVector = {1, 15}; simplexFound = simplexTree.find(otherSimplexVector); std::cout << "**************IS THE SIMPLEX {15,1} IN THE SIMPLEX TREE ?\n"; if (simplexFound != simplexTree.null_simplex()) @@ -240,7 +231,7 @@ int main(int argc, char * const argv[]) { else std::cout << "***- NO IT ISN'T\n"; - typeVectorVertex invSimplexVector = { 1, 2, 0 }; + typeVectorVertex invSimplexVector = {1, 2, 0}; simplexFound = simplexTree.find(invSimplexVector); std::cout << "**************IS THE SIMPLEX {1,2,0} IN THE SIMPLEX TREE ?\n"; if (simplexFound != simplexTree.null_simplex()) @@ -248,7 +239,7 @@ int main(int argc, char * const argv[]) { else std::cout << "***- NO IT ISN'T\n"; - simplexFound = simplexTree.find({ 0, 1 }); + simplexFound = simplexTree.find({0, 1}); std::cout << "**************IS THE SIMPLEX {0,1} IN THE SIMPLEX TREE ?\n"; if (simplexFound != simplexTree.null_simplex()) std::cout << "***+ YES IT IS!\n"; @@ -256,23 +247,20 @@ int main(int argc, char * const argv[]) { std::cout << "***- NO IT ISN'T\n"; std::cout << "**************COFACES OF {0,1} IN CODIMENSION 1 ARE\n"; - for (auto& simplex : simplexTree.cofaces_simplex_range(simplexTree.find({0,1}), 1)) { - for (auto vertex : simplexTree.simplex_vertex_range(simplex)) - std::cout << "(" << vertex << ")"; + for (auto& simplex : simplexTree.cofaces_simplex_range(simplexTree.find({0, 1}), 1)) { + for (auto vertex : simplexTree.simplex_vertex_range(simplex)) std::cout << "(" << vertex << ")"; std::cout << std::endl; } std::cout << "**************STARS OF {0,1} ARE\n"; - for (auto& simplex : simplexTree.star_simplex_range(simplexTree.find({0,1}))) { - for (auto vertex : simplexTree.simplex_vertex_range(simplex)) - std::cout << "(" << vertex << ")"; + for (auto& simplex : simplexTree.star_simplex_range(simplexTree.find({0, 1}))) { + for (auto vertex : simplexTree.simplex_vertex_range(simplex)) std::cout << "(" << vertex << ")"; std::cout << std::endl; } std::cout << "**************BOUNDARIES OF {0,1,2} ARE\n"; - for (auto& simplex : simplexTree.boundary_simplex_range(simplexTree.find({0,1,2}))) { - for (auto vertex : simplexTree.simplex_vertex_range(simplex)) - std::cout << "(" << vertex << ")"; + for (auto& simplex : simplexTree.boundary_simplex_range(simplexTree.find({0, 1, 2}))) { + for (auto vertex : simplexTree.simplex_vertex_range(simplex)) std::cout << "(" << vertex << ")"; std::cout << std::endl; } diff --git a/src/Spatial_searching/include/gudhi/Kd_tree_search.h b/src/Spatial_searching/include/gudhi/Kd_tree_search.h index ef428002..96bbeb36 100644 --- a/src/Spatial_searching/include/gudhi/Kd_tree_search.h +++ b/src/Spatial_searching/include/gudhi/Kd_tree_search.h @@ -271,8 +271,7 @@ class Kd_tree_search { m_tree.search(it, Fuzzy_sphere(p, radius, eps, m_tree.traits())); } - int tree_depth() const - { + int tree_depth() const { return m_tree.root()->depth(); } diff --git a/src/Witness_complex/example/example_strong_witness_complex_off.cpp b/src/Witness_complex/example/example_strong_witness_complex_off.cpp index bc069654..346bef6d 100644 --- a/src/Witness_complex/example/example_strong_witness_complex_off.cpp +++ b/src/Witness_complex/example/example_strong_witness_complex_off.cpp @@ -39,10 +39,9 @@ using Point_d = typename K::Point_d; using Witness_complex = Gudhi::witness_complex::Euclidean_strong_witness_complex; using Point_vector = std::vector; -int main(int argc, char * const argv[]) { +int main(int argc, char* const argv[]) { if (argc != 5) { - std::cerr << "Usage: " << argv[0] - << " path_to_point_file number_of_landmarks max_squared_alpha limit_dimension\n"; + std::cerr << "Usage: " << argv[0] << " path_to_point_file number_of_landmarks max_squared_alpha limit_dimension\n"; return 0; } @@ -56,9 +55,9 @@ int main(int argc, char * const argv[]) { Point_vector point_vector, landmarks; Gudhi::Points_off_reader off_reader(file_name); if (!off_reader.is_valid()) { - std::cerr << "Strong witness complex - Unable to read file " << file_name << "\n"; - exit(-1); // ----- >> - } + std::cerr << "Strong witness complex - Unable to read file " << file_name << "\n"; + exit(-1); // ----- >> + } point_vector = Point_vector(off_reader.get_point_cloud()); std::cout << "Successfully read " << point_vector.size() << " points.\n"; @@ -66,16 +65,15 @@ int main(int argc, char * const argv[]) { // Choose landmarks (decomment one of the following two lines) // Gudhi::subsampling::pick_n_random_points(point_vector, nbL, std::back_inserter(landmarks)); - Gudhi::subsampling::choose_n_farthest_points(K(), point_vector, nbL, Gudhi::subsampling::random_starting_point, std::back_inserter(landmarks)); - + Gudhi::subsampling::choose_n_farthest_points(K(), point_vector, nbL, Gudhi::subsampling::random_starting_point, + std::back_inserter(landmarks)); + // Compute witness complex start = clock(); - Witness_complex witness_complex(landmarks, - point_vector); + Witness_complex witness_complex(landmarks, point_vector); witness_complex.create_complex(simplex_tree, alpha2, lim_dim); end = clock(); - std::cout << "Strong witness complex took " - << static_cast(end - start) / CLOCKS_PER_SEC << " s. \n"; + std::cout << "Strong witness complex took " << static_cast(end - start) / CLOCKS_PER_SEC << " s. \n"; std::cout << "Number of simplices is: " << simplex_tree.num_simplices() << "\n"; } diff --git a/src/Witness_complex/example/example_witness_complex_sphere.cpp b/src/Witness_complex/example/example_witness_complex_sphere.cpp index a66da3f9..a6e9b11a 100644 --- a/src/Witness_complex/example/example_witness_complex_sphere.cpp +++ b/src/Witness_complex/example/example_witness_complex_sphere.cpp @@ -42,27 +42,25 @@ /** Write a gnuplot readable file. * Data range is a random access range of pairs (arg, value) */ -template < typename Data_range > -void write_data(Data_range & data, std::string filename) { +template +void write_data(Data_range& data, std::string filename) { std::ofstream ofs(filename, std::ofstream::out); - for (auto entry : data) - ofs << entry.first << ", " << entry.second << "\n"; + for (auto entry : data) ofs << entry.first << ", " << entry.second << "\n"; ofs.close(); } -int main(int argc, char * const argv[]) { +int main(int argc, char* const argv[]) { using Kernel = CGAL::Epick_d; using Witness_complex = Gudhi::witness_complex::Euclidean_witness_complex; if (argc != 2) { - std::cerr << "Usage: " << argv[0] - << " number_of_landmarks \n"; + std::cerr << "Usage: " << argv[0] << " number_of_landmarks \n"; return 0; } int number_of_landmarks = atoi(argv[1]); - std::vector< std::pair > l_time; + std::vector > l_time; // Generate points for (int nbP = 500; nbP < 10000; nbP += 500) { @@ -77,16 +75,16 @@ int main(int argc, char * const argv[]) { // Choose landmarks start = clock(); // Gudhi::subsampling::pick_n_random_points(point_vector, number_of_landmarks, std::back_inserter(landmarks)); - Gudhi::subsampling::choose_n_farthest_points(K(), point_vector, number_of_landmarks, Gudhi::subsampling::random_starting_point, std::back_inserter(landmarks)); + Gudhi::subsampling::choose_n_farthest_points(K(), point_vector, number_of_landmarks, + Gudhi::subsampling::random_starting_point, + std::back_inserter(landmarks)); // Compute witness complex - Witness_complex witness_complex(landmarks, - point_vector); + Witness_complex witness_complex(landmarks, point_vector); witness_complex.create_complex(simplex_tree, 0); end = clock(); double time = static_cast(end - start) / CLOCKS_PER_SEC; - std::cout << "Witness complex for " << number_of_landmarks << " landmarks took " - << time << " s. \n"; + std::cout << "Witness complex for " << number_of_landmarks << " landmarks took " << time << " s. \n"; std::cout << "Number of simplices is: " << simplex_tree.num_simplices() << "\n"; l_time.push_back(std::make_pair(nbP, time)); } diff --git a/src/Witness_complex/utilities/strong_witness_persistence.cpp b/src/Witness_complex/utilities/strong_witness_persistence.cpp index e3e0c1ee..2fba631b 100644 --- a/src/Witness_complex/utilities/strong_witness_persistence.cpp +++ b/src/Witness_complex/utilities/strong_witness_persistence.cpp @@ -47,16 +47,10 @@ using Filtration_value = SimplexTree::Filtration_value; using Field_Zp = Gudhi::persistent_cohomology::Field_Zp; using Persistent_cohomology = Gudhi::persistent_cohomology::Persistent_cohomology; -void program_options(int argc, char * argv[] - , int & nbL - , std::string & file_name - , std::string & filediag - , Filtration_value & max_squared_alpha - , int & p - , int & dim_max - , Filtration_value & min_persistence); - -int main(int argc, char * argv[]) { +void program_options(int argc, char* argv[], int& nbL, std::string& file_name, std::string& filediag, + Filtration_value& max_squared_alpha, int& p, int& dim_max, Filtration_value& min_persistence); + +int main(int argc, char* argv[]) { std::string file_name; std::string filediag; Filtration_value max_squared_alpha; @@ -70,8 +64,8 @@ int main(int argc, char * argv[]) { Point_vector witnesses, landmarks; Gudhi::Points_off_reader off_reader(file_name); if (!off_reader.is_valid()) { - std::cerr << "Witness complex - Unable to read file " << file_name << "\n"; - exit(-1); // ----- >> + std::cerr << "Witness complex - Unable to read file " << file_name << "\n"; + exit(-1); // ----- >> } witnesses = Point_vector(off_reader.get_point_cloud()); std::cout << "Successfully read " << witnesses.size() << " points.\n"; @@ -79,11 +73,11 @@ int main(int argc, char * argv[]) { // Choose landmarks (decomment one of the following two lines) // Gudhi::subsampling::pick_n_random_points(point_vector, nbL, std::back_inserter(landmarks)); - Gudhi::subsampling::choose_n_farthest_points(K(), witnesses, nbL, Gudhi::subsampling::random_starting_point, std::back_inserter(landmarks)); + Gudhi::subsampling::choose_n_farthest_points(K(), witnesses, nbL, Gudhi::subsampling::random_starting_point, + std::back_inserter(landmarks)); // Compute witness complex - Strong_witness_complex strong_witness_complex(landmarks, - witnesses); + Strong_witness_complex strong_witness_complex(landmarks, witnesses); strong_witness_complex.create_complex(simplex_tree, max_squared_alpha, lim_d); @@ -112,37 +106,28 @@ int main(int argc, char * argv[]) { return 0; } -void program_options(int argc, char * argv[] - , int & nbL - , std::string & file_name - , std::string & filediag - , Filtration_value & max_squared_alpha - , int & p - , int & dim_max - , Filtration_value & min_persistence) { +void program_options(int argc, char* argv[], int& nbL, std::string& file_name, std::string& filediag, + Filtration_value& max_squared_alpha, int& p, int& dim_max, Filtration_value& min_persistence) { namespace po = boost::program_options; po::options_description hidden("Hidden options"); - hidden.add_options() - ("input-file", po::value(&file_name), - "Name of file containing a point set in off format."); + hidden.add_options()("input-file", po::value(&file_name), + "Name of file containing a point set in off format."); po::options_description visible("Allowed options", 100); Filtration_value default_alpha = std::numeric_limits::infinity(); - visible.add_options() - ("help,h", "produce help message") - ("landmarks,l", po::value(&nbL), - "Number of landmarks to choose from the point cloud.") - ("output-file,o", po::value(&filediag)->default_value(std::string()), - "Name of file in which the persistence diagram is written. Default print in std::cout") - ("max-sq-alpha,a", po::value(&max_squared_alpha)->default_value(default_alpha), - "Maximal squared relaxation parameter.") - ("field-charac,p", po::value(&p)->default_value(11), - "Characteristic p of the coefficient field Z/pZ for computing homology.") - ("min-persistence,m", po::value(&min_persistence)->default_value(0), - "Minimal lifetime of homology feature to be recorded. Default is 0. Enter a negative value to see zero length intervals") - ("cpx-dimension,d", po::value(&dim_max)->default_value(std::numeric_limits::max()), - "Maximal dimension of the strong witness complex we want to compute."); + visible.add_options()("help,h", "produce help message")("landmarks,l", po::value(&nbL), + "Number of landmarks to choose from the point cloud.")( + "output-file,o", po::value(&filediag)->default_value(std::string()), + "Name of file in which the persistence diagram is written. Default print in std::cout")( + "max-sq-alpha,a", po::value(&max_squared_alpha)->default_value(default_alpha), + "Maximal squared relaxation parameter.")( + "field-charac,p", po::value(&p)->default_value(11), + "Characteristic p of the coefficient field Z/pZ for computing homology.")( + "min-persistence,m", po::value(&min_persistence)->default_value(0), + "Minimal lifetime of homology feature to be recorded. Default is 0. Enter a negative value to see zero length " + "intervals")("cpx-dimension,d", po::value(&dim_max)->default_value(std::numeric_limits::max()), + "Maximal dimension of the strong witness complex we want to compute."); po::positional_options_description pos; pos.add("input-file", 1); @@ -151,8 +136,7 @@ void program_options(int argc, char * argv[] all.add(visible).add(hidden); po::variables_map vm; - po::store(po::command_line_parser(argc, argv). - options(all).positional(pos).run(), vm); + po::store(po::command_line_parser(argc, argv).options(all).positional(pos).run(), vm); po::notify(vm); if (vm.count("help") || !vm.count("input-file")) { @@ -170,4 +154,3 @@ void program_options(int argc, char * argv[] std::abort(); } } - diff --git a/src/Witness_complex/utilities/weak_witness_persistence.cpp b/src/Witness_complex/utilities/weak_witness_persistence.cpp index a63b0837..23fa93aa 100644 --- a/src/Witness_complex/utilities/weak_witness_persistence.cpp +++ b/src/Witness_complex/utilities/weak_witness_persistence.cpp @@ -47,16 +47,10 @@ using Filtration_value = SimplexTree::Filtration_value; using Field_Zp = Gudhi::persistent_cohomology::Field_Zp; using Persistent_cohomology = Gudhi::persistent_cohomology::Persistent_cohomology; -void program_options(int argc, char * argv[] - , int & nbL - , std::string & file_name - , std::string & filediag - , Filtration_value & max_squared_alpha - , int & p - , int & dim_max - , Filtration_value & min_persistence); - -int main(int argc, char * argv[]) { +void program_options(int argc, char* argv[], int& nbL, std::string& file_name, std::string& filediag, + Filtration_value& max_squared_alpha, int& p, int& dim_max, Filtration_value& min_persistence); + +int main(int argc, char* argv[]) { std::string file_name; std::string filediag; Filtration_value max_squared_alpha; @@ -70,8 +64,8 @@ int main(int argc, char * argv[]) { Point_vector witnesses, landmarks; Gudhi::Points_off_reader off_reader(file_name); if (!off_reader.is_valid()) { - std::cerr << "Witness complex - Unable to read file " << file_name << "\n"; - exit(-1); // ----- >> + std::cerr << "Witness complex - Unable to read file " << file_name << "\n"; + exit(-1); // ----- >> } witnesses = Point_vector(off_reader.get_point_cloud()); std::cout << "Successfully read " << witnesses.size() << " points.\n"; @@ -79,11 +73,11 @@ int main(int argc, char * argv[]) { // Choose landmarks (decomment one of the following two lines) // Gudhi::subsampling::pick_n_random_points(point_vector, nbL, std::back_inserter(landmarks)); - Gudhi::subsampling::choose_n_farthest_points(K(), witnesses, nbL, Gudhi::subsampling::random_starting_point, std::back_inserter(landmarks)); + Gudhi::subsampling::choose_n_farthest_points(K(), witnesses, nbL, Gudhi::subsampling::random_starting_point, + std::back_inserter(landmarks)); // Compute witness complex - Witness_complex witness_complex(landmarks, - witnesses); + Witness_complex witness_complex(landmarks, witnesses); witness_complex.create_complex(simplex_tree, max_squared_alpha, lim_d); @@ -112,38 +106,28 @@ int main(int argc, char * argv[]) { return 0; } - -void program_options(int argc, char * argv[] - , int & nbL - , std::string & file_name - , std::string & filediag - , Filtration_value & max_squared_alpha - , int & p - , int & dim_max - , Filtration_value & min_persistence) { +void program_options(int argc, char* argv[], int& nbL, std::string& file_name, std::string& filediag, + Filtration_value& max_squared_alpha, int& p, int& dim_max, Filtration_value& min_persistence) { namespace po = boost::program_options; po::options_description hidden("Hidden options"); - hidden.add_options() - ("input-file", po::value(&file_name), - "Name of file containing a point set in off format."); + hidden.add_options()("input-file", po::value(&file_name), + "Name of file containing a point set in off format."); Filtration_value default_alpha = std::numeric_limits::infinity(); po::options_description visible("Allowed options", 100); - visible.add_options() - ("help,h", "produce help message") - ("landmarks,l", po::value(&nbL), - "Number of landmarks to choose from the point cloud.") - ("output-file,o", po::value(&filediag)->default_value(std::string()), - "Name of file in which the persistence diagram is written. Default print in std::cout") - ("max-sq-alpha,a", po::value(&max_squared_alpha)->default_value(default_alpha), - "Maximal squared relaxation parameter.") - ("field-charac,p", po::value(&p)->default_value(11), - "Characteristic p of the coefficient field Z/pZ for computing homology.") - ("min-persistence,m", po::value(&min_persistence)->default_value(0), - "Minimal lifetime of homology feature to be recorded. Default is 0. Enter a negative value to see zero length intervals") - ("cpx-dimension,d", po::value(&dim_max)->default_value(std::numeric_limits::max()), - "Maximal dimension of the weak witness complex we want to compute."); + visible.add_options()("help,h", "produce help message")("landmarks,l", po::value(&nbL), + "Number of landmarks to choose from the point cloud.")( + "output-file,o", po::value(&filediag)->default_value(std::string()), + "Name of file in which the persistence diagram is written. Default print in std::cout")( + "max-sq-alpha,a", po::value(&max_squared_alpha)->default_value(default_alpha), + "Maximal squared relaxation parameter.")( + "field-charac,p", po::value(&p)->default_value(11), + "Characteristic p of the coefficient field Z/pZ for computing homology.")( + "min-persistence,m", po::value(&min_persistence)->default_value(0), + "Minimal lifetime of homology feature to be recorded. Default is 0. Enter a negative value to see zero length " + "intervals")("cpx-dimension,d", po::value(&dim_max)->default_value(std::numeric_limits::max()), + "Maximal dimension of the weak witness complex we want to compute."); po::positional_options_description pos; pos.add("input-file", 1); @@ -152,8 +136,7 @@ void program_options(int argc, char * argv[] all.add(visible).add(hidden); po::variables_map vm; - po::store(po::command_line_parser(argc, argv). - options(all).positional(pos).run(), vm); + po::store(po::command_line_parser(argc, argv).options(all).positional(pos).run(), vm); po::notify(vm); if (vm.count("help") || !vm.count("input-file")) { diff --git a/src/common/include/gudhi/Unitary_tests_utils.h b/src/common/include/gudhi/Unitary_tests_utils.h index 7ae5d356..8394a062 100644 --- a/src/common/include/gudhi/Unitary_tests_utils.h +++ b/src/common/include/gudhi/Unitary_tests_utils.h @@ -25,6 +25,7 @@ #include #include +#include // for std::numeric_limits<> template void GUDHI_TEST_FLOAT_EQUALITY_CHECK(FloatingType a, FloatingType b, -- cgit v1.2.3 From b674e9a5fae8bdbb22eadb9a7c0013ce84451743 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Fri, 26 Jan 2018 14:55:28 +0000 Subject: Move documentation Copyright in footer Removed from each module git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@3167 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 7595f2d18cdc3773bbd96fa9fed414876ff9fdc7 --- src/Alpha_complex/doc/Intro_alpha_complex.h | 4 +--- src/Bitmap_cubical_complex/doc/Gudhi_Cubical_Complex_doc.h | 1 - src/Contraction/include/gudhi/Edge_contraction.h | 4 ---- src/Nerve_GIC/doc/Intro_graph_induced_complex.h | 1 - .../doc/Persistence_representations_doc.h | 1 - src/Persistent_cohomology/doc/Intro_persistent_cohomology.h | 1 - src/Rips_complex/doc/Intro_rips_complex.h | 2 -- src/Simplex_tree/doc/Intro_simplex_tree.h | 1 - src/Skeleton_blocker/include/gudhi/Skeleton_blocker.h | 3 --- src/Spatial_searching/doc/Intro_spatial_searching.h | 2 -- src/Subsampling/doc/Intro_subsampling.h | 2 -- src/Tangential_complex/doc/Intro_tangential_complex.h | 2 -- src/Witness_complex/doc/Witness_complex_doc.h | 3 --- src/common/doc/footer.html | 10 ++-------- 14 files changed, 3 insertions(+), 34 deletions(-) (limited to 'src/Rips_complex') diff --git a/src/Alpha_complex/doc/Intro_alpha_complex.h b/src/Alpha_complex/doc/Intro_alpha_complex.h index cf1a946a..a08663ca 100644 --- a/src/Alpha_complex/doc/Intro_alpha_complex.h +++ b/src/Alpha_complex/doc/Intro_alpha_complex.h @@ -31,7 +31,7 @@ namespace alpha_complex { /** \defgroup alpha_complex Alpha complex * * \author Vincent Rouvreau - * + * * @{ * * \section definition Definition @@ -195,8 +195,6 @@ namespace alpha_complex { * * \include Alpha_complex/alphaoffreader_for_doc_32.txt * - * \copyright GNU General Public License v3. - * \verbatim Contact: gudhi-users@lists.gforge.inria.fr \endverbatim */ /** @} */ // end defgroup alpha_complex diff --git a/src/Bitmap_cubical_complex/doc/Gudhi_Cubical_Complex_doc.h b/src/Bitmap_cubical_complex/doc/Gudhi_Cubical_Complex_doc.h index ee84e201..a5d7b60f 100644 --- a/src/Bitmap_cubical_complex/doc/Gudhi_Cubical_Complex_doc.h +++ b/src/Bitmap_cubical_complex/doc/Gudhi_Cubical_Complex_doc.h @@ -105,7 +105,6 @@ namespace cubical_complex { * \section BitmapExamples Examples * End user programs are available in example/Bitmap_cubical_complex and utilities/Bitmap_cubical_complex folders. * - * \copyright GNU General Public License v3. */ /** @} */ // end defgroup cubical_complex diff --git a/src/Contraction/include/gudhi/Edge_contraction.h b/src/Contraction/include/gudhi/Edge_contraction.h index 61f2d945..cf9a2c27 100644 --- a/src/Contraction/include/gudhi/Edge_contraction.h +++ b/src/Contraction/include/gudhi/Edge_contraction.h @@ -210,7 +210,6 @@ int main (int argc, char *argv[]) } \endcode - \verbatim ./example/Contraction/RipsContraction ../../data/SO3_10000.off 0.3 [ 50%] [100%] Built target SkeletonBlockerIteration @@ -223,9 +222,6 @@ Time to simplify and enumerate simplices: 3.166621s wall, 3.150000s user + 0.010000s system = 3.160000s CPU (99.8%) \endverbatim - - -\copyright GNU General Public License v3. */ /** @} */ // end defgroup } // namespace contraction diff --git a/src/Nerve_GIC/doc/Intro_graph_induced_complex.h b/src/Nerve_GIC/doc/Intro_graph_induced_complex.h index 344cb031..f2409087 100644 --- a/src/Nerve_GIC/doc/Intro_graph_induced_complex.h +++ b/src/Nerve_GIC/doc/Intro_graph_induced_complex.h @@ -176,7 +176,6 @@ namespace cover_complex { * * \image html "funcGICvisu.jpg" "Visualization with neato" * - * \copyright GNU General Public License v3. */ /** @} */ // end defgroup cover_complex diff --git a/src/Persistence_representations/doc/Persistence_representations_doc.h b/src/Persistence_representations/doc/Persistence_representations_doc.h index 978fb5bd..d781211a 100644 --- a/src/Persistence_representations/doc/Persistence_representations_doc.h +++ b/src/Persistence_representations/doc/Persistence_representations_doc.h @@ -250,7 +250,6 @@ namespace Persistence_representations { absolute value of differences between coordinates. A scalar product is a sum of products of values at the corresponding positions of two vectors. - \copyright GNU General Public License v3. */ /** @} */ // end defgroup Persistence_representations diff --git a/src/Persistent_cohomology/doc/Intro_persistent_cohomology.h b/src/Persistent_cohomology/doc/Intro_persistent_cohomology.h index ceaea505..4dbe82c7 100644 --- a/src/Persistent_cohomology/doc/Intro_persistent_cohomology.h +++ b/src/Persistent_cohomology/doc/Intro_persistent_cohomology.h @@ -248,7 +248,6 @@ Simplex_tree dim: 3 Persistent_cohomology/plain_homology.cpp computes the plain homology of a simple simplicial complex without filtration values. - \copyright GNU General Public License v3. */ } // namespace persistent_cohomology diff --git a/src/Rips_complex/doc/Intro_rips_complex.h b/src/Rips_complex/doc/Intro_rips_complex.h index 124dfec9..8c517516 100644 --- a/src/Rips_complex/doc/Intro_rips_complex.h +++ b/src/Rips_complex/doc/Intro_rips_complex.h @@ -146,8 +146,6 @@ namespace rips_complex { * * \include Rips_complex/full_skeleton_rips_for_doc.txt * - * \copyright GNU General Public License v3. - * \verbatim Contact: gudhi-users@lists.gforge.inria.fr \endverbatim */ /** @} */ // end defgroup rips_complex diff --git a/src/Simplex_tree/doc/Intro_simplex_tree.h b/src/Simplex_tree/doc/Intro_simplex_tree.h index 769491d9..6b80d1c9 100644 --- a/src/Simplex_tree/doc/Intro_simplex_tree.h +++ b/src/Simplex_tree/doc/Intro_simplex_tree.h @@ -79,7 +79,6 @@ Number of vertices = 10 Number of simplices = 98 \endcode * 1 incidence relations in a complex. It is consequently faster when accessing the boundary of a simplex, but is less * compact and harder to construct from scratch. * - * \copyright GNU General Public License v3. * @} */ diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker.h index 32fe411c..aca2aa57 100644 --- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker.h +++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker.h @@ -239,9 +239,6 @@ their collaboration to write the two initial papers about this data-structure and also Dominique for leaving him use a prototype. - -\copyright GNU General Public License v3. - @} */ } // namespace skeleton_blocker diff --git a/src/Spatial_searching/doc/Intro_spatial_searching.h b/src/Spatial_searching/doc/Intro_spatial_searching.h index 1ee5e92e..52ed65e4 100644 --- a/src/Spatial_searching/doc/Intro_spatial_searching.h +++ b/src/Spatial_searching/doc/Intro_spatial_searching.h @@ -50,8 +50,6 @@ namespace spatial_searching { * * \include Spatial_searching/example_spatial_searching.cpp * - * \copyright GNU General Public License v3. - * \verbatim Contact: gudhi-users@lists.gforge.inria.fr \endverbatim */ /** @} */ // end defgroup spatial_searching diff --git a/src/Subsampling/doc/Intro_subsampling.h b/src/Subsampling/doc/Intro_subsampling.h index c84616dd..ab9cdc37 100644 --- a/src/Subsampling/doc/Intro_subsampling.h +++ b/src/Subsampling/doc/Intro_subsampling.h @@ -58,8 +58,6 @@ namespace subsampling { * This example outputs a subset of 100 points picked randomly. * * \include Subsampling/example_pick_n_random_points.cpp - * \copyright GNU General Public License v3. - * \verbatim Contact: gudhi-users@lists.gforge.inria.fr \endverbatim */ /** @} */ // end defgroup subsampling diff --git a/src/Tangential_complex/doc/Intro_tangential_complex.h b/src/Tangential_complex/doc/Intro_tangential_complex.h index 3d687c1d..00e00c52 100644 --- a/src/Tangential_complex/doc/Intro_tangential_complex.h +++ b/src/Tangential_complex/doc/Intro_tangential_complex.h @@ -107,8 +107,6 @@ dimensions are known at compile-time. \include Tangential_complex/example_with_perturb.cpp -\copyright GNU General Public License v3. -\verbatim Contact: gudhi-users@lists.gforge.inria.fr \endverbatim */ /** @} */ // end defgroup tangential_complex diff --git a/src/Witness_complex/doc/Witness_complex_doc.h b/src/Witness_complex/doc/Witness_complex_doc.h index 5d5c0735..62203054 100644 --- a/src/Witness_complex/doc/Witness_complex_doc.h +++ b/src/Witness_complex/doc/Witness_complex_doc.h @@ -117,9 +117,6 @@ int main(int argc, char * const argv[]) { \include Witness_complex/example_nearest_landmark_table.cpp - \copyright GNU General Public License v3. - - */ #endif // WITNESS_COMPLEX_DOC_H_ diff --git a/src/common/doc/footer.html b/src/common/doc/footer.html index 7b4cdc5c..a557922b 100644 --- a/src/common/doc/footer.html +++ b/src/common/doc/footer.html @@ -6,24 +6,18 @@ $projectname  Version $projectnumber  - $projectbrief + - Copyright : GPL v3 $generatedby - doxygen $doxygenversion + Doxygen $doxygenversion - -

- -- cgit v1.2.3 From c2d46e0e6cfea1927875219bd5e03962cef7b010 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Mon, 29 Jan 2018 16:31:18 +0000 Subject: Fix doc issue for utilities part on the web site git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@3176 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 3bafd9e13a5646ca93023144705d3ac7ed7c9b3a --- src/Alpha_complex/utilities/README | 148 ++++++++++----------- src/Bitmap_cubical_complex/utilities/README | 42 ++++-- src/Bottleneck_distance/utilities/README | 32 ++++- src/Nerve_GIC/doc/Intro_graph_induced_complex.h | 6 +- src/Nerve_GIC/include/gudhi/GIC.h | 11 +- .../utilities/KeplerMapperVisuFromTxtFile.py | 97 ++++++++------ src/Nerve_GIC/utilities/covercomplex.md | 73 ++++++++++ src/Rips_complex/utilities/README | 67 ++++------ src/Witness_complex/utilities/README | 70 +++++----- src/common/utilities/README | 46 +++++-- 10 files changed, 365 insertions(+), 227 deletions(-) create mode 100644 src/Nerve_GIC/utilities/covercomplex.md (limited to 'src/Rips_complex') diff --git a/src/Alpha_complex/utilities/README b/src/Alpha_complex/utilities/README index 1cd2ca95..56bce602 100644 --- a/src/Alpha_complex/utilities/README +++ b/src/Alpha_complex/utilities/README @@ -1,16 +1,35 @@ -# Alpha_complex # - -## `alpha_complex_3d_persistence` ## +--- +layout: page +title: "Alpha complex" +meta_title: "alphacomplex" +subheadline: "" +teaser: "" +permalink: "/alphacomplex/" +--- +{::comment} +These flags above are here for web site generation, please let them. +cf. https://gitlab.inria.fr/GUDHI/website +Must be in conformity with _data/navigation.yml +{:/comment} + + + +## alpha_complex_3d_persistence ## This program computes the persistent homology with coefficient field Z/pZ of the 3D alpha complex built from a 3D point cloud. The output diagram contains one bar per line, written with the convention: -`p dim birth death` +``` +p dim birth death +``` where `dim` is the dimension of the homological feature, `birth` and `death` are respectively the birth and death of the feature, and `p` is the characteristic of the field *Z/pZ* used for homology coefficients (`p` must be a prime number). **Usage** -`alpha_complex_3d_persistence [options] ` -where -`` is the path to the input point cloud in [nOFF ASCII format](http://www.geomview.org/docs/html/OFF.html). + +``` + alpha_complex_3d_persistence [options] +``` + +where `` is the path to the input point cloud in [nOFF ASCII format](http://www.geomview.org/docs/html/OFF.html). **Allowed options** @@ -20,43 +39,38 @@ where * `-m [ --min-persistence ]` (default = 0) Minimal lifetime of homology feature to be recorded. Enter a negative value to see zero length intervals. **Example** -`alpha_complex_3d_persistence ../../data/points/tore3D_300.off -p 2 -m 0.45` -outputs: ``` -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 +alpha_complex_3d_persistence ../../data/points/tore3D_300.off -p 2 -m 0.45 ``` -Here we retrieve expected Betti numbers on a tore 3D: -``` -Betti numbers[0] = 1 -Betti numbers[1] = 2 -Betti numbers[2] = 1 -``` +N.B.: -N.B.: * `alpha_complex_3d_persistence` only accepts OFF files in dimension 3. * Filtration values are alpha square values. +## exact_alpha_complex_3d_persistence ## + +Same as `alpha_complex_3d_persistence`, but using exact computation. +It is slower, but it is necessary when points are on a grid for instance. -## `exact_alpha_complex_3d_persistence` ## -Same as `alpha_complex_3d_persistence`, but using exact computation. It is slower, but it is necessary when points are on a grid for instance. +## weighted_alpha_complex_3d_persistence ## -## `weighted_alpha_complex_3d_persistence` ## Same as `alpha_complex_3d_persistence`, but using weighted points. **Usage** -`weighted_alpha_complex_3d_persistence [options] ` + +``` + weighted_alpha_complex_3d_persistence [options] +``` + where -`` is the path to the input point cloud in [nOFF ASCII format](http://www.geomview.org/docs/html/OFF.html). -`` is the path to the file containing the weights of the points (one value per line). + +* `` is the path to the input point cloud in [nOFF ASCII format](http://www.geomview.org/docs/html/OFF.html). +* `` is the path to the file containing the weights of the points (one value per line). **Allowed options** @@ -66,32 +80,33 @@ where * `-m [ --min-persistence ]` (default = 0) Minimal lifetime of homology feature to be recorded. Enter a negative value to see zero length intervals. **Example** -`weighted_alpha_complex_3d_persistence ../../data/points/tore3D_300.off ../../data/points/tore3D_300.weights -p 2 -m 0.45` -outputs: ``` -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 + weighted_alpha_complex_3d_persistence ../../data/points/tore3D_300.off ../../data/points/tore3D_300.weights -p 2 -m 0.45 ``` + N.B.: + * Weights values are explained on CGAL [Alpha shape](https://doc.cgal.org/latest/Alpha_shapes_3/index.html#title0) and [Regular triangulation](https://doc.cgal.org/latest/Triangulation_3/index.html#Triangulation3secclassRegulartriangulation) documentation. * Filtration values are alpha square values. -## `periodic_alpha_complex_3d_persistence` ## +## periodic_alpha_complex_3d_persistence ## Same as `alpha_complex_3d_persistence`, but using periodic alpha shape 3d. Refer to the [CGAL's 3D Periodic Triangulations User Manual](https://doc.cgal.org/latest/Periodic_3_triangulation_3/index.html) for more details. **Usage** -`periodic_alpha_complex_3d_persistence [options] ` + +``` + periodic_alpha_complex_3d_persistence [options] +``` + where -`` is the path to the input point cloud in [nOFF ASCII format](http://www.geomview.org/docs/html/OFF.html). -`` is the path to the file describing the periodic domain. It must be in the format described [here](http://gudhi.gforge.inria.fr/doc/latest/fileformats.html#FileFormatsIsoCuboid). + +* `` is the path to the input point cloud in [nOFF ASCII format](http://www.geomview.org/docs/html/OFF.html). +* `` is the path to the file describing the periodic domain. It must be in the format described [here](http://gudhi.gforge.inria.fr/doc/latest/fileformats.html#FileFormatsIsoCuboid). **Allowed options** @@ -102,46 +117,36 @@ where **Example** -`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` -outputs: ``` -Periodic Delaunay computed. -Simplex_tree dim: 3 -3 0 0 inf -3 1 0.0025 inf -3 1 0.0025 inf -3 1 0.0025 inf -3 2 0.005 inf -3 2 0.005 inf -3 2 0.005 inf -3 3 0.0075 inf +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 ``` -Here we retrieve expected Betti numbers on an 3D iso-oriented cuboids: -``` -Betti numbers[0] = 1 -Betti numbers[1] = 3 -Betti numbers[2] = 3 -Betti numbers[3] = 1 -``` +N.B.: -N.B.: * Cuboid file must be in the format described [here](http://gudhi.gforge.inria.fr/doc/latest/fileformats.html#FileFormatsIsoCuboid). * Filtration values are alpha square values. +## alpha_complex_persistence ## -## `alpha_complex_persistence` ## -This program computes the persistent homology with coefficient field Z/pZ of the dD alpha complex built from a dD point cloud. The output diagram contains one bar per line, written with the convention: +This program computes the persistent homology with coefficient field Z/pZ of the dD alpha complex built from a dD point cloud. +The output diagram contains one bar per line, written with the convention: -`p dim birth death` +``` + p dim birth death +``` -where `dim` is the dimension of the homological feature, `birth` and `death` are respectively the birth and death of the feature, and `p` is the characteristic of the field *Z/pZ* used for homology coefficients (`p` must be a prime number). +where `dim` is the dimension of the homological feature, `birth` and `death` are respectively the birth and death of the feature, +and `p` is the characteristic of the field *Z/pZ* used for homology coefficients (`p` must be a prime number). **Usage** -`alpha_complex_persistence [options] ` + +``` + alpha_complex_persistence [options] +``` + where `` is the path to the input point cloud in [nOFF ASCII format](http://www.geomview.org/docs/html/OFF.html). @@ -154,24 +159,11 @@ where * `-m [ --min-persistence ]` (default = 0) Minimal lifetime of homology feature to be recorded. Enter a negative value to see zero length intervals. **Example** -`alpha_complex_persistence -r 32 -p 2 -m 0.45 ../../data/points/tore3D_300.off` -outputs: ``` -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 -``` - -Here we retrieve expected Betti numbers on a tore 3D: -``` -Betti numbers[0] = 1 -Betti numbers[1] = 2 -Betti numbers[2] = 1 + alpha_complex_persistence -r 32 -p 2 -m 0.45 ../../data/points/tore3D_300.off ``` N.B.: + * Filtration values are alpha square values. diff --git a/src/Bitmap_cubical_complex/utilities/README b/src/Bitmap_cubical_complex/utilities/README index ddff7034..393b2654 100644 --- a/src/Bitmap_cubical_complex/utilities/README +++ b/src/Bitmap_cubical_complex/utilities/README @@ -1,18 +1,40 @@ -# Bitmap_cubical_complex # +--- +layout: page +title: "Bitmap cubical complex" +meta_title: "cubicalcomplex" +subheadline: "" +teaser: "" +permalink: "/cubicalcomplex/" +--- +{::comment} +These flags above are here for web site generation, please let them. +cf. https://gitlab.inria.fr/GUDHI/website +Must be in conformity with _data/navigation.yml +{:/comment} -## `cubical_complex_persistence` ## -This program computes persistent homology, by using the Bitmap_cubical_complex class, of cubical complexes provided in text files in Perseus style. See [here](http://gudhi.gforge.inria.fr/doc/latest/fileformats.html#FileFormatsPerseus) for a description of the file format. -Example: +## cubical_complex_persistence ## +This program computes persistent homology, by using the Bitmap_cubical_complex class, of cubical complexes provided in text files in Perseus style. +See [here](http://gudhi.gforge.inria.fr/doc/latest/fileformats.html#FileFormatsPerseus) for a description of the file format. -* Create a Cubical Complex from the Perseus style file `CubicalTwoSphere.txt`, computes Persistence cohomology from it and writes the results in a persistence file `CubicalTwoSphere.txt_persistence`: -`cubical_complex_persistence data/bitmap/CubicalTwoSphere.txt` +**Example** -## `periodic_cubical_complex_persistence` ## +``` + cubical_complex_persistence data/bitmap/CubicalTwoSphere.txt +``` + +* Creates a Cubical Complex from the Perseus style file `CubicalTwoSphere.txt`, +computes Persistence cohomology from it and writes the results in a persistence file `CubicalTwoSphere.txt_persistence`. + +## periodic_cubical_complex_persistence ## Same as above, but with periodic boundary conditions. -Example: +**Example** + +``` + periodic_cubical_complex_persistence data/bitmap/3d_torus.txt +``` -* Create a Periodical Cubical Complex from the Perseus style file `3d_torus.txt`, computes Persistence cohomology from it and writes the results in a persistence file `3d_torus.txt_persistence`: -`periodic_cubical_complex_persistence data/bitmap/3d_torus.txt` +* Creates a Periodical Cubical Complex from the Perseus style file `3d_torus.txt`, +computes Persistence cohomology from it and writes the results in a persistence file `3d_torus.txt_persistence`. diff --git a/src/Bottleneck_distance/utilities/README b/src/Bottleneck_distance/utilities/README index d9fdd252..04e1c4bd 100644 --- a/src/Bottleneck_distance/utilities/README +++ b/src/Bottleneck_distance/utilities/README @@ -1,10 +1,30 @@ -# Bottleneck_distance # +--- +layout: page +title: "Bottleneck distance" +meta_title: "bottleneckdistance" +subheadline: "" +teaser: "" +permalink: "/bottleneckdistance/" +--- +{::comment} +These flags above are here for web site generation, please let them. +cf. https://gitlab.inria.fr/GUDHI/website +Must be in conformity with _data/navigation.yml +{:/comment} + + + +## bottleneck_read_file_example ## -## `bottleneck_read_file_example` ## This program computes the Bottleneck distance between two persistence diagram files. -Usage: -`bottleneck_read_file_example []` +**Usage** + +``` + bottleneck_read_file_example [] +``` + where -`` and `` must be in the format described [here](http://gudhi.gforge.inria.fr/doc/latest/fileformats.html#FileFormatsPers). -`` is an error bound on the bottleneck distance (set by default to the smallest positive double value). + +* `` and `` must be in the format described [here](http://gudhi.gforge.inria.fr/doc/latest/fileformats.html#FileFormatsPers). +* `` is an error bound on the bottleneck distance (set by default to the smallest positive double value). diff --git a/src/Nerve_GIC/doc/Intro_graph_induced_complex.h b/src/Nerve_GIC/doc/Intro_graph_induced_complex.h index f2409087..474f0f0e 100644 --- a/src/Nerve_GIC/doc/Intro_graph_induced_complex.h +++ b/src/Nerve_GIC/doc/Intro_graph_induced_complex.h @@ -77,8 +77,8 @@ namespace cover_complex { * * \include Nerve_GIC/Nerve.txt * - * The program also writes a file SC.txt. The first three lines in this file are the location of the input point cloud - * and the function used to compute the cover. + * The program also writes a file ../../data/points/human_sc.txt. The first three lines in this file are the location + * of the input point cloud and the function used to compute the cover. * The fourth line contains the number of vertices nv and edges ne of the Nerve. * The next nv lines represent the vertices. Each line contains the vertex ID, * the number of data points it contains, and their average color function value. @@ -118,7 +118,7 @@ namespace cover_complex { * * the program outputs SC.off. Using e.g. * - * \code $> geomview SC.off + * \code $> geomview ../../data/points/human_sc.off * \endcode * * one can obtain the following visualization: diff --git a/src/Nerve_GIC/include/gudhi/GIC.h b/src/Nerve_GIC/include/gudhi/GIC.h index 58831bbf..ff95b913 100644 --- a/src/Nerve_GIC/include/gudhi/GIC.h +++ b/src/Nerve_GIC/include/gudhi/GIC.h @@ -934,7 +934,7 @@ class Cover_complex { } graphic << "}"; graphic.close(); - std::cout << ".dot file generated. It can be visualized with e.g. neato." << std::endl; + std::cout << mapp << " file generated. It can be visualized with e.g. neato." << std::endl; } public: // Create a .txt file that can be compiled with KeplerMapper. @@ -944,7 +944,7 @@ class Cover_complex { void write_info() { int num_simplices = simplices.size(); int num_edges = 0; - std::string mapp = point_cloud_name + "_sc.dot"; + std::string mapp = point_cloud_name + "_sc.txt"; std::ofstream graphic(mapp.c_str()); for (int i = 0; i < num_simplices; i++) @@ -970,7 +970,8 @@ class Cover_complex { if (cover_color[simplices[i][0]].first > mask && cover_color[simplices[i][1]].first > mask) graphic << name2id[simplices[i][0]] << " " << name2id[simplices[i][1]] << std::endl; graphic.close(); - std::cout << ".txt generated. It can be visualized with e.g. python KeplerMapperVisuFromTxtFile.py and firefox." + std::cout << mapp + << " generated. It can be visualized with e.g. python KeplerMapperVisuFromTxtFile.py and firefox." << std::endl; } @@ -988,7 +989,7 @@ class Cover_complex { std::vector > edges, faces; int numsimplices = simplices.size(); - std::string mapp = point_cloud_name + "_sc.dot"; + std::string mapp = point_cloud_name + "_sc.off"; std::ofstream graphic(mapp.c_str()); graphic << "OFF" << std::endl; @@ -1016,7 +1017,7 @@ class Cover_complex { for (int i = 0; i < numfaces; i++) graphic << 3 << " " << faces[i][0] << " " << faces[i][1] << " " << faces[i][2] << std::endl; graphic.close(); - std::cout << ".off generated. It can be visualized with e.g. geomview." << std::endl; + std::cout << mapp << " generated. It can be visualized with e.g. geomview." << std::endl; } // ******************************************************************************************************************* diff --git a/src/Nerve_GIC/utilities/KeplerMapperVisuFromTxtFile.py b/src/Nerve_GIC/utilities/KeplerMapperVisuFromTxtFile.py index d2897774..c811f610 100755 --- a/src/Nerve_GIC/utilities/KeplerMapperVisuFromTxtFile.py +++ b/src/Nerve_GIC/utilities/KeplerMapperVisuFromTxtFile.py @@ -3,6 +3,7 @@ import km import numpy as np from collections import defaultdict +import argparse """This file is part of the Gudhi Library. The Gudhi library (Geometric Understanding in Higher Dimensions) is a generic C++ @@ -30,43 +31,59 @@ __author__ = "Mathieu Carriere" __copyright__ = "Copyright (C) 2017 INRIA" __license__ = "GPL v3" -network = {} -mapper = km.KeplerMapper(verbose=0) -data = np.zeros((3,3)) -projected_data = mapper.fit_transform( data, projection="sum", scaler=None ) - -f = open('SC.txt','r') -nodes = defaultdict(list) -links = defaultdict(list) -custom = defaultdict(list) - -dat = f.readline() -lens = f.readline() -color = f.readline(); -param = [float(i) for i in f.readline().split(" ")] - -nums = [int(i) for i in f.readline().split(" ")] -num_nodes = nums[0] -num_edges = nums[1] - -for i in range(0,num_nodes): - point = [float(j) for j in f.readline().split(" ")] - nodes[ str(int(point[0])) ] = [ int(point[0]), point[1], int(point[2]) ] - links[ str(int(point[0])) ] = [] - custom[ int(point[0]) ] = point[1] - -m = min([custom[i] for i in range(0,num_nodes)]) -M = max([custom[i] for i in range(0,num_nodes)]) - -for i in range(0,num_edges): - edge = [int(j) for j in f.readline().split(" ")] - links[ str(edge[0]) ].append( str(edge[1]) ) - links[ str(edge[1]) ].append( str(edge[0]) ) - -network["nodes"] = nodes -network["links"] = links -network["meta"] = lens - -mapper.visualize(network, color_function = color, path_html="SC.html", title=dat, -graph_link_distance=30, graph_gravity=0.1, graph_charge=-120, custom_tooltips=custom, width_html=0, -height_html=0, show_tooltips=True, show_title=True, show_meta=True, res=param[0],gain=param[1], minimum=m,maximum=M) +parser = argparse.ArgumentParser(description='Creates an html Keppler Mapper ' + 'file to visualize a SC.txt file.', + epilog='Example: ' + './KeplerMapperVisuFromTxtFile.py ' + '-f ../../data/points/human.off_sc.txt' + '- Constructs an human.off_sc.html file.') +parser.add_argument("-f", "--file", type=str, required=True) + +args = parser.parse_args() + +with open(args.file, 'r') as f: + network = {} + mapper = km.KeplerMapper(verbose=0) + data = np.zeros((3,3)) + projected_data = mapper.fit_transform( data, projection="sum", scaler=None ) + + nodes = defaultdict(list) + links = defaultdict(list) + custom = defaultdict(list) + + dat = f.readline() + lens = f.readline() + color = f.readline(); + param = [float(i) for i in f.readline().split(" ")] + + nums = [int(i) for i in f.readline().split(" ")] + num_nodes = nums[0] + num_edges = nums[1] + + for i in range(0,num_nodes): + point = [float(j) for j in f.readline().split(" ")] + nodes[ str(int(point[0])) ] = [ int(point[0]), point[1], int(point[2]) ] + links[ str(int(point[0])) ] = [] + custom[ int(point[0]) ] = point[1] + + m = min([custom[i] for i in range(0,num_nodes)]) + M = max([custom[i] for i in range(0,num_nodes)]) + + for i in range(0,num_edges): + edge = [int(j) for j in f.readline().split(" ")] + links[ str(edge[0]) ].append( str(edge[1]) ) + links[ str(edge[1]) ].append( str(edge[0]) ) + + network["nodes"] = nodes + network["links"] = links + network["meta"] = lens + + html_output_filename = args.file.rsplit('.', 1)[0] + '.html' + mapper.visualize(network, color_function = color, path_html=html_output_filename, title=dat, + graph_link_distance=30, graph_gravity=0.1, graph_charge=-120, custom_tooltips=custom, width_html=0, + height_html=0, show_tooltips=True, show_title=True, show_meta=True, res=param[0],gain=param[1], minimum=m,maximum=M) + message = repr(html_output_filename) + " is generated. You can now use your favorite web browser to visualize it." + print(message) + + + f.close() diff --git a/src/Nerve_GIC/utilities/covercomplex.md b/src/Nerve_GIC/utilities/covercomplex.md new file mode 100644 index 00000000..692e44e7 --- /dev/null +++ b/src/Nerve_GIC/utilities/covercomplex.md @@ -0,0 +1,73 @@ +--- +layout: page +title: "Cover complex" +meta_title: "covercomplex" +subheadline: "" +teaser: "" +permalink: "/covercomplex/" +--- +{::comment} +These flags above are here for web site generation, please let them. +cf. https://gitlab.inria.fr/GUDHI/website +Must be in conformity with _data/navigation.yml +{:/comment} + + + +## Nerve ## +This program builds the Nerve of a point cloud sampled on an OFF file. +The cover C comes from the preimages of intervals covering a coordinate function, +which are then refined into their connected components using the triangulation of the .OFF file. + +The program also writes a file SC.txt. +The first three lines in this file are the location of the input point cloud and the function used to compute the cover. +The fourth line contains the number of vertices nv and edges ne of the Nerve. The next nv lines represent the vertices. +Each line contains the vertex ID, the number of data points it contains, and their average color function value. +Finally, the next ne lines represent the edges, characterized by the ID of their vertices. + +**Usage** + +`Nerve coordinate resolution gain [--v]` + +where + +* `coordinate` is the coordinate function to cover +* `resolution` is the number of the intervals +* `gain` is the gain for each interval +* `--v` is optional, it activates verbose mode. + +**Example** + +`Nerve ../../data/points/human.off 2 10 0.3` + +* Builds the Nerve of a point cloud sampled on a 3D human shape (human.off). +The cover C comes from the preimages of intervals (10 intervals with gain 0.3) covering the height function (coordinate 2). + +`python KeplerMapperVisuFromTxtFile.py -f ../../data/points/human.off_sc.txt` + +* Constructs `human.off_sc.html` file. You can now use your favorite web browser to visualize it. + +## VoronoiGIC ## + +This util builds the Graph Induced Complex (GIC) of a point cloud. +It subsamples *N* points in the point cloud, which act as seeds of a geodesic Voronoï diagram. +Each cell of the diagram is then an element of C. + +The program also writes a file `*_sc.off`, that is an OFF file that can be visualized with GeomView. + +**Usage** + +`VoroniGIC samples_number [--v]` + +where + +* `samples_number` is the number of samples to take from the point cloud +* `--v` is optional, it activates verbose mode. + +**Example** + +`VoroniGIC ../../data/points/human.off 700` + +* Builds the Voronoi Graph Induced Complex with 700 subsamples from `human.off` file. +`../../data/points/human_sc.off` can be visualized with GeomView. + diff --git a/src/Rips_complex/utilities/README b/src/Rips_complex/utilities/README index 4d20c806..44a37543 100644 --- a/src/Rips_complex/utilities/README +++ b/src/Rips_complex/utilities/README @@ -1,6 +1,20 @@ -# Rips_complex # - -## `rips_persistence` ## +--- +layout: page +title: "Rips complex" +meta_title: "ripscomplex" +subheadline: "" +teaser: "" +permalink: "/ripscomplex/" +--- +{::comment} +These flags above are here for web site generation, please let them. +cf. https://gitlab.inria.fr/GUDHI/website +Must be in conformity with _data/navigation.yml +{:/comment} + + + +## rips_persistence ## This program computes the persistent homology with coefficient field *Z/pZ* of a Rips complex defined on a set of input points. The output diagram contains one bar per line, written with the convention: `p dim birth death` @@ -8,6 +22,7 @@ This program computes the persistent homology with coefficient field *Z/pZ* of a where `dim` is the dimension of the homological feature, `birth` and `death` are respectively the birth and death of the feature, and `p` is the characteristic of the field *Z/pZ* used for homology coefficients (`p` must be a prime number). **Usage** + `rips_persistence [options] ` **Allowed options** @@ -22,53 +37,25 @@ where `dim` is the dimension of the homological feature, `birth` and `death` are Beware: this program may use a lot of RAM and take a lot of time if `max-edge-length` is set to a large value. **Example 1 with Z/2Z coefficients** -`rips_persistence ../../data/points/tore3D_1307.off -r 0.25 -m 0.5 -d 3 -p 2` -outputs: -``` -2 0 0 inf -2 1 0.0983494 inf -2 1 0.104347 inf -2 2 0.138335 inf -``` +`rips_persistence ../../data/points/tore3D_1307.off -r 0.25 -m 0.5 -d 3 -p 2` **Example 2 with Z/3Z coefficients** -rips_persistence ../../data/points/tore3D_1307.off -r 0.25 -m 0.5 -d 3 -p 3 - -outputs: -``` -3 0 0 inf -3 1 0.0983494 inf -3 1 0.104347 inf -3 2 0.138335 inf -``` +`rips_persistence ../../data/points/tore3D_1307.off -r 0.25 -m 0.5 -d 3 -p 3` +## rips_distance_matrix_persistence ## +Same as `rips_persistence` but taking a distance matrix as input. -## `rips_distance_matrix_persistence` ## -Same as `rips_persistence` but taking a distance matrix as input. - **Usage** -`rips_persistence [options] ` -where + +`rips_persistence [options] ` + +where `` is the path to the file containing a distance matrix. Can be square or lower triangular matrix. Separator is ';'. **Example** -`rips_distance_matrix_persistence data/distance_matrix/full_square_distance_matrix.csv -r 15 -d 3 -p 3 -m 0` -outputs: -``` -The complex contains 46 simplices - and has dimension 3 -3 0 0 inf -3 0 0 8.94427 -3 0 0 7.28011 -3 0 0 6.08276 -3 0 0 5.83095 -3 0 0 5.38516 -3 0 0 5 -3 1 11 12.0416 -3 1 6.32456 6.7082 -``` +`rips_distance_matrix_persistence data/distance_matrix/full_square_distance_matrix.csv -r 15 -d 3 -p 3 -m 0` diff --git a/src/Witness_complex/utilities/README b/src/Witness_complex/utilities/README index 1141033e..5cdb1f88 100644 --- a/src/Witness_complex/utilities/README +++ b/src/Witness_complex/utilities/README @@ -1,18 +1,34 @@ -# Witness_complex # +--- +layout: page +title: "Witness complex" +meta_title: "witnesscomplex" +subheadline: "" +teaser: "" +permalink: "/witnesscomplex/" +--- +{::comment} +These flags above are here for web site generation, please let them. +cf. https://gitlab.inria.fr/GUDHI/website +Must be in conformity with _data/navigation.yml +{:/comment} + For more details about the witness complex, please read the [user manual of the package](http://gudhi.gforge.inria.fr/doc/latest/group__witness__complex.html). -## `weak_witness_persistence` ## -This program computes the persistent homology with coefficient field *Z/pZ* of a Weak witness complex defined on a set of input points. The output diagram contains one bar per line, written with the convention: +## weak_witness_persistence ## +This program computes the persistent homology with coefficient field *Z/pZ* of a Weak witness complex defined on a set of input points. +The output diagram contains one bar per line, written with the convention: `p dim birth death` -where `dim` is the dimension of the homological feature, `birth` and `death` are respectively the birth and death of the feature, and `p` is the characteristic of the field *Z/pZ* used for homology coefficients. +where `dim` is the dimension of the homological feature, `birth` and `death` are respectively the birth and death of the feature, +and `p` is the characteristic of the field *Z/pZ* used for homology coefficients. + +**Usage** -*Usage* `weak_witness_persistence [options] ` -*Allowed options* +**Allowed options** * `-h [ --help ]` Produce help message * `-l [ --landmarks ]` Number of landmarks to choose from the point cloud. @@ -22,33 +38,28 @@ where `dim` is the dimension of the homological feature, `birth` and `death` are * `-m [ --min-persistence ]` (default = 0) Minimal lifetime of homology feature to be recorded. Enter a negative value to see zero length intervals. * `-d [ --cpx-dimension ]` (default = 2147483647) Maximal dimension of the weak witness complex we want to compute. -*Example* -`weak_witness_persistence data/points/tore3D_1307.off -l 20 -a 0.5 -m 0.006` +**Example** -outputs: -``` -Successfully read 1307 points. -Ambient dimension is 3. -The complex contains 732 simplices and has dimension 8 -11 0 0 inf -11 1 0 inf -11 2 0.0275251 0.0534586 -11 1 0 0.0239952 -``` +`weak_witness_persistence data/points/tore3D_1307.off -l 20 -a 0.5 -m 0.006` N.B.: output is random as the 20 landmarks are chosen randomly. -## `strong_witness_persistence` ## -This program computes the persistent homology with coefficient field *Z/pZ* of a Strong witness complex defined on a set of input points. The output diagram contains one bar per line, written with the convention: + +## strong_witness_persistence ## + +This program computes the persistent homology with coefficient field *Z/pZ* of a Strong witness complex defined on a set of input points. +The output diagram contains one bar per line, written with the convention: `p dim birth death` -where `dim` is the dimension of the homological feature, `birth` and `death` are respectively the birth and death of the feature, and `p` is the characteristic of the field *Z/pZ* used for homology coefficients. +where `dim` is the dimension of the homological feature, `birth` and `death` are respectively the birth and death of the feature, +and `p` is the characteristic of the field *Z/pZ* used for homology coefficients. + +**Usage** -*Usage* `strong_witness_persistence [options] ` -*Allowed options* +**Allowed options** * `-h [ --help ]` Produce help message * `-l [ --landmarks ]` Number of landmarks to choose from the point cloud. @@ -58,17 +69,8 @@ where `dim` is the dimension of the homological feature, `birth` and `death` are * `-m [ --min-persistence ]` (default = 0) Minimal lifetime of homology feature to be recorded. Enter a negative value to see zero length intervals. * `-d [ --cpx-dimension ]` (default = 2147483647) Maximal dimension of the weak witness complex we want to compute. -*Example* -`strong_witness_persistence data/points/tore3D_1307.off -l 20 -a 0.5 -m 0.06` +**Example** -outputs: -``` -Successfully read 1307 points. -Ambient dimension is 3. -The complex contains 1836 simplices and has dimension 8 -11 0 0 inf -11 1 0.00674748 inf -11 2 0.0937751 0.235354 -``` +`strong_witness_persistence data/points/tore3D_1307.off -l 20 -a 0.5 -m 0.06` N.B.: output is random as the 20 landmarks are chosen randomly. diff --git a/src/common/utilities/README b/src/common/utilities/README index 18fa8cc4..f39c63b8 100644 --- a/src/common/utilities/README +++ b/src/common/utilities/README @@ -1,19 +1,43 @@ -# Pointset generator # +--- +layout: page +title: "Pointset generator" +meta_title: "pointsetgenerator" +subheadline: "" +teaser: "" +permalink: "/pointsetgenerator/" +--- +{::comment} +These flags above are here for web site generation, please let them. +cf. https://gitlab.inria.fr/GUDHI/website +Must be in conformity with _data/navigation.yml +{:/comment} -## `off_file_from_shape_generator` ## +## off_file_from_shape_generator ## Generates a pointset and save it in an OFF file. Command-line is: -`off_file_from_shape_generator on|in sphere|cube|curve|torus|klein ...` + +``` +off_file_from_shape_generator on|in sphere|cube|curve|torus|klein ... +``` Warning: "on cube" generator is not available! -Examples: +**Examples** + +``` +off_file_from_shape_generator on sphere onSphere.off 1000 3 15.2 +``` + +* Generates an onSphere.off file with 1000 points randomized on a sphere of dimension 3 and radius 15.2. + +``` +off_file_from_shape_generator in sphere inSphere.off 100 2 +``` + +* Generates an inSphere.off file with 100 points randomized in a sphere of dimension 2 (circle) and radius 1.0 (default). -* Generate an onSphere.off file with 1000 points randomized on a sphere of dimension 3 and radius 15.2: -`off_file_from_shape_generator on sphere onSphere.off 1000 3 15.2` - -* Generate an inSphere.off file with 100 points randomized in a sphere of dimension 2 (circle) and radius 1.0 (default): -`off_file_from_shape_generator in sphere inSphere.off 100 2` +``` +off_file_from_shape_generator in cube inCube.off 10000 3 5.8 +``` -* Generates a inCube.off file with 10000 points randomized in a cube of dimension 3 and side 5.8: -`off_file_from_shape_generator in cube inCube.off 10000 3 5.8` +* Generates a inCube.off file with 10000 points randomized in a cube of dimension 3 and side 5.8. -- cgit v1.2.3 From c50ac9a8e5d1f506cc79b9c1e623228fffd545bf Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Mon, 29 Jan 2018 16:34:16 +0000 Subject: Rename README files for web site generation conformity git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@3177 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 632b264790c30accb42e731c4a4f6744a2f7ba11 --- src/Alpha_complex/utilities/README | 169 --------------------- src/Alpha_complex/utilities/alphacomplex.md | 169 +++++++++++++++++++++ src/Bitmap_cubical_complex/utilities/README | 40 ----- .../utilities/cubicalcomplex.md | 40 +++++ src/Bottleneck_distance/utilities/README | 30 ---- .../utilities/bottleneckdistance.md | 30 ++++ src/Rips_complex/utilities/README | 61 -------- src/Rips_complex/utilities/ripscomplex.md | 61 ++++++++ src/Witness_complex/utilities/README | 76 --------- src/Witness_complex/utilities/witnesscomplex.md | 76 +++++++++ src/common/utilities/README | 43 ------ src/common/utilities/pointsetgenerator.md | 43 ++++++ 12 files changed, 419 insertions(+), 419 deletions(-) delete mode 100644 src/Alpha_complex/utilities/README create mode 100644 src/Alpha_complex/utilities/alphacomplex.md delete mode 100644 src/Bitmap_cubical_complex/utilities/README create mode 100644 src/Bitmap_cubical_complex/utilities/cubicalcomplex.md delete mode 100644 src/Bottleneck_distance/utilities/README create mode 100644 src/Bottleneck_distance/utilities/bottleneckdistance.md delete mode 100644 src/Rips_complex/utilities/README create mode 100644 src/Rips_complex/utilities/ripscomplex.md delete mode 100644 src/Witness_complex/utilities/README create mode 100644 src/Witness_complex/utilities/witnesscomplex.md delete mode 100644 src/common/utilities/README create mode 100644 src/common/utilities/pointsetgenerator.md (limited to 'src/Rips_complex') diff --git a/src/Alpha_complex/utilities/README b/src/Alpha_complex/utilities/README deleted file mode 100644 index 56bce602..00000000 --- a/src/Alpha_complex/utilities/README +++ /dev/null @@ -1,169 +0,0 @@ ---- -layout: page -title: "Alpha complex" -meta_title: "alphacomplex" -subheadline: "" -teaser: "" -permalink: "/alphacomplex/" ---- -{::comment} -These flags above are here for web site generation, please let them. -cf. https://gitlab.inria.fr/GUDHI/website -Must be in conformity with _data/navigation.yml -{:/comment} - - - -## alpha_complex_3d_persistence ## -This program computes the persistent homology with coefficient field Z/pZ of the 3D alpha complex built from a 3D point cloud. The output diagram contains one bar per line, written with the convention: - -``` -p dim birth death -``` - -where `dim` is the dimension of the homological feature, `birth` and `death` are respectively the birth and death of the feature, and `p` is the characteristic of the field *Z/pZ* used for homology coefficients (`p` must be a prime number). - -**Usage** - -``` - alpha_complex_3d_persistence [options] -``` - -where `` is the path to the input point cloud in [nOFF ASCII format](http://www.geomview.org/docs/html/OFF.html). - -**Allowed options** - -* `-h [ --help ]` Produce help message -* `-o [ --output-file ]` Name of file in which the persistence diagram is written. Default print in standard output. -* `-p [ --field-charac ]` (default=11) Characteristic p of the coefficient field Z/pZ for computing homology. -* `-m [ --min-persistence ]` (default = 0) Minimal lifetime of homology feature to be recorded. Enter a negative value to see zero length intervals. - -**Example** - -``` -alpha_complex_3d_persistence ../../data/points/tore3D_300.off -p 2 -m 0.45 -``` - -N.B.: - -* `alpha_complex_3d_persistence` only accepts OFF files in dimension 3. -* Filtration values are alpha square values. - - -## exact_alpha_complex_3d_persistence ## - -Same as `alpha_complex_3d_persistence`, but using exact computation. -It is slower, but it is necessary when points are on a grid for instance. - - - -## weighted_alpha_complex_3d_persistence ## - -Same as `alpha_complex_3d_persistence`, but using weighted points. - -**Usage** - -``` - weighted_alpha_complex_3d_persistence [options] -``` - -where - -* `` is the path to the input point cloud in [nOFF ASCII format](http://www.geomview.org/docs/html/OFF.html). -* `` is the path to the file containing the weights of the points (one value per line). - -**Allowed options** - -* `-h [ --help ]` Produce help message -* `-o [ --output-file ]` Name of file in which the persistence diagram is written. Default print in standard output. -* `-p [ --field-charac ]` (default=11) Characteristic p of the coefficient field Z/pZ for computing homology. -* `-m [ --min-persistence ]` (default = 0) Minimal lifetime of homology feature to be recorded. Enter a negative value to see zero length intervals. - -**Example** - -``` - weighted_alpha_complex_3d_persistence ../../data/points/tore3D_300.off ../../data/points/tore3D_300.weights -p 2 -m 0.45 -``` - - -N.B.: - -* Weights values are explained on CGAL [Alpha shape](https://doc.cgal.org/latest/Alpha_shapes_3/index.html#title0) -and [Regular triangulation](https://doc.cgal.org/latest/Triangulation_3/index.html#Triangulation3secclassRegulartriangulation) documentation. -* Filtration values are alpha square values. - - -## periodic_alpha_complex_3d_persistence ## -Same as `alpha_complex_3d_persistence`, but using periodic alpha shape 3d. -Refer to the [CGAL's 3D Periodic Triangulations User Manual](https://doc.cgal.org/latest/Periodic_3_triangulation_3/index.html) for more details. - -**Usage** - -``` - periodic_alpha_complex_3d_persistence [options] -``` - -where - -* `` is the path to the input point cloud in [nOFF ASCII format](http://www.geomview.org/docs/html/OFF.html). -* `` is the path to the file describing the periodic domain. It must be in the format described [here](http://gudhi.gforge.inria.fr/doc/latest/fileformats.html#FileFormatsIsoCuboid). - -**Allowed options** - -* `-h [ --help ]` Produce help message -* `-o [ --output-file ]` Name of file in which the persistence diagram is written. Default print in standard output. -* `-p [ --field-charac ]` (default=11) Characteristic p of the coefficient field Z/pZ for computing homology. -* `-m [ --min-persistence ]` (default = 0) Minimal lifetime of homology feature to be recorded. Enter a negative value to see zero length intervals - - -**Example** - -``` -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 -``` - -N.B.: - -* Cuboid file must be in the format described [here](http://gudhi.gforge.inria.fr/doc/latest/fileformats.html#FileFormatsIsoCuboid). -* Filtration values are alpha square values. - - - -## alpha_complex_persistence ## - -This program computes the persistent homology with coefficient field Z/pZ of the dD alpha complex built from a dD point cloud. -The output diagram contains one bar per line, written with the convention: - -``` - p dim birth death -``` - -where `dim` is the dimension of the homological feature, `birth` and `death` are respectively the birth and death of the feature, -and `p` is the characteristic of the field *Z/pZ* used for homology coefficients (`p` must be a prime number). - -**Usage** - -``` - alpha_complex_persistence [options] -``` - -where -`` is the path to the input point cloud in [nOFF ASCII format](http://www.geomview.org/docs/html/OFF.html). - -**Allowed options** - -* `-h [ --help ]` Produce help message -* `-o [ --output-file ]` Name of file in which the persistence diagram is written. Default print in standard output. -* `-r [ --max-alpha-square-value ]` (default = inf) Maximal alpha square value for the Alpha complex construction. -* `-p [ --field-charac ]` (default = 11) Characteristic p of the coefficient field Z/pZ for computing homology. -* `-m [ --min-persistence ]` (default = 0) Minimal lifetime of homology feature to be recorded. Enter a negative value to see zero length intervals. - -**Example** - -``` - alpha_complex_persistence -r 32 -p 2 -m 0.45 ../../data/points/tore3D_300.off -``` - -N.B.: - -* Filtration values are alpha square values. diff --git a/src/Alpha_complex/utilities/alphacomplex.md b/src/Alpha_complex/utilities/alphacomplex.md new file mode 100644 index 00000000..56bce602 --- /dev/null +++ b/src/Alpha_complex/utilities/alphacomplex.md @@ -0,0 +1,169 @@ +--- +layout: page +title: "Alpha complex" +meta_title: "alphacomplex" +subheadline: "" +teaser: "" +permalink: "/alphacomplex/" +--- +{::comment} +These flags above are here for web site generation, please let them. +cf. https://gitlab.inria.fr/GUDHI/website +Must be in conformity with _data/navigation.yml +{:/comment} + + + +## alpha_complex_3d_persistence ## +This program computes the persistent homology with coefficient field Z/pZ of the 3D alpha complex built from a 3D point cloud. The output diagram contains one bar per line, written with the convention: + +``` +p dim birth death +``` + +where `dim` is the dimension of the homological feature, `birth` and `death` are respectively the birth and death of the feature, and `p` is the characteristic of the field *Z/pZ* used for homology coefficients (`p` must be a prime number). + +**Usage** + +``` + alpha_complex_3d_persistence [options] +``` + +where `` is the path to the input point cloud in [nOFF ASCII format](http://www.geomview.org/docs/html/OFF.html). + +**Allowed options** + +* `-h [ --help ]` Produce help message +* `-o [ --output-file ]` Name of file in which the persistence diagram is written. Default print in standard output. +* `-p [ --field-charac ]` (default=11) Characteristic p of the coefficient field Z/pZ for computing homology. +* `-m [ --min-persistence ]` (default = 0) Minimal lifetime of homology feature to be recorded. Enter a negative value to see zero length intervals. + +**Example** + +``` +alpha_complex_3d_persistence ../../data/points/tore3D_300.off -p 2 -m 0.45 +``` + +N.B.: + +* `alpha_complex_3d_persistence` only accepts OFF files in dimension 3. +* Filtration values are alpha square values. + + +## exact_alpha_complex_3d_persistence ## + +Same as `alpha_complex_3d_persistence`, but using exact computation. +It is slower, but it is necessary when points are on a grid for instance. + + + +## weighted_alpha_complex_3d_persistence ## + +Same as `alpha_complex_3d_persistence`, but using weighted points. + +**Usage** + +``` + weighted_alpha_complex_3d_persistence [options] +``` + +where + +* `` is the path to the input point cloud in [nOFF ASCII format](http://www.geomview.org/docs/html/OFF.html). +* `` is the path to the file containing the weights of the points (one value per line). + +**Allowed options** + +* `-h [ --help ]` Produce help message +* `-o [ --output-file ]` Name of file in which the persistence diagram is written. Default print in standard output. +* `-p [ --field-charac ]` (default=11) Characteristic p of the coefficient field Z/pZ for computing homology. +* `-m [ --min-persistence ]` (default = 0) Minimal lifetime of homology feature to be recorded. Enter a negative value to see zero length intervals. + +**Example** + +``` + weighted_alpha_complex_3d_persistence ../../data/points/tore3D_300.off ../../data/points/tore3D_300.weights -p 2 -m 0.45 +``` + + +N.B.: + +* Weights values are explained on CGAL [Alpha shape](https://doc.cgal.org/latest/Alpha_shapes_3/index.html#title0) +and [Regular triangulation](https://doc.cgal.org/latest/Triangulation_3/index.html#Triangulation3secclassRegulartriangulation) documentation. +* Filtration values are alpha square values. + + +## periodic_alpha_complex_3d_persistence ## +Same as `alpha_complex_3d_persistence`, but using periodic alpha shape 3d. +Refer to the [CGAL's 3D Periodic Triangulations User Manual](https://doc.cgal.org/latest/Periodic_3_triangulation_3/index.html) for more details. + +**Usage** + +``` + periodic_alpha_complex_3d_persistence [options] +``` + +where + +* `` is the path to the input point cloud in [nOFF ASCII format](http://www.geomview.org/docs/html/OFF.html). +* `` is the path to the file describing the periodic domain. It must be in the format described [here](http://gudhi.gforge.inria.fr/doc/latest/fileformats.html#FileFormatsIsoCuboid). + +**Allowed options** + +* `-h [ --help ]` Produce help message +* `-o [ --output-file ]` Name of file in which the persistence diagram is written. Default print in standard output. +* `-p [ --field-charac ]` (default=11) Characteristic p of the coefficient field Z/pZ for computing homology. +* `-m [ --min-persistence ]` (default = 0) Minimal lifetime of homology feature to be recorded. Enter a negative value to see zero length intervals + + +**Example** + +``` +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 +``` + +N.B.: + +* Cuboid file must be in the format described [here](http://gudhi.gforge.inria.fr/doc/latest/fileformats.html#FileFormatsIsoCuboid). +* Filtration values are alpha square values. + + + +## alpha_complex_persistence ## + +This program computes the persistent homology with coefficient field Z/pZ of the dD alpha complex built from a dD point cloud. +The output diagram contains one bar per line, written with the convention: + +``` + p dim birth death +``` + +where `dim` is the dimension of the homological feature, `birth` and `death` are respectively the birth and death of the feature, +and `p` is the characteristic of the field *Z/pZ* used for homology coefficients (`p` must be a prime number). + +**Usage** + +``` + alpha_complex_persistence [options] +``` + +where +`` is the path to the input point cloud in [nOFF ASCII format](http://www.geomview.org/docs/html/OFF.html). + +**Allowed options** + +* `-h [ --help ]` Produce help message +* `-o [ --output-file ]` Name of file in which the persistence diagram is written. Default print in standard output. +* `-r [ --max-alpha-square-value ]` (default = inf) Maximal alpha square value for the Alpha complex construction. +* `-p [ --field-charac ]` (default = 11) Characteristic p of the coefficient field Z/pZ for computing homology. +* `-m [ --min-persistence ]` (default = 0) Minimal lifetime of homology feature to be recorded. Enter a negative value to see zero length intervals. + +**Example** + +``` + alpha_complex_persistence -r 32 -p 2 -m 0.45 ../../data/points/tore3D_300.off +``` + +N.B.: + +* Filtration values are alpha square values. diff --git a/src/Bitmap_cubical_complex/utilities/README b/src/Bitmap_cubical_complex/utilities/README deleted file mode 100644 index 393b2654..00000000 --- a/src/Bitmap_cubical_complex/utilities/README +++ /dev/null @@ -1,40 +0,0 @@ ---- -layout: page -title: "Bitmap cubical complex" -meta_title: "cubicalcomplex" -subheadline: "" -teaser: "" -permalink: "/cubicalcomplex/" ---- -{::comment} -These flags above are here for web site generation, please let them. -cf. https://gitlab.inria.fr/GUDHI/website -Must be in conformity with _data/navigation.yml -{:/comment} - - -## cubical_complex_persistence ## -This program computes persistent homology, by using the Bitmap_cubical_complex class, of cubical complexes provided in text files in Perseus style. -See [here](http://gudhi.gforge.inria.fr/doc/latest/fileformats.html#FileFormatsPerseus) for a description of the file format. - -**Example** - -``` - cubical_complex_persistence data/bitmap/CubicalTwoSphere.txt -``` - -* Creates a Cubical Complex from the Perseus style file `CubicalTwoSphere.txt`, -computes Persistence cohomology from it and writes the results in a persistence file `CubicalTwoSphere.txt_persistence`. - -## periodic_cubical_complex_persistence ## - -Same as above, but with periodic boundary conditions. - -**Example** - -``` - periodic_cubical_complex_persistence data/bitmap/3d_torus.txt -``` - -* Creates a Periodical Cubical Complex from the Perseus style file `3d_torus.txt`, -computes Persistence cohomology from it and writes the results in a persistence file `3d_torus.txt_persistence`. diff --git a/src/Bitmap_cubical_complex/utilities/cubicalcomplex.md b/src/Bitmap_cubical_complex/utilities/cubicalcomplex.md new file mode 100644 index 00000000..393b2654 --- /dev/null +++ b/src/Bitmap_cubical_complex/utilities/cubicalcomplex.md @@ -0,0 +1,40 @@ +--- +layout: page +title: "Bitmap cubical complex" +meta_title: "cubicalcomplex" +subheadline: "" +teaser: "" +permalink: "/cubicalcomplex/" +--- +{::comment} +These flags above are here for web site generation, please let them. +cf. https://gitlab.inria.fr/GUDHI/website +Must be in conformity with _data/navigation.yml +{:/comment} + + +## cubical_complex_persistence ## +This program computes persistent homology, by using the Bitmap_cubical_complex class, of cubical complexes provided in text files in Perseus style. +See [here](http://gudhi.gforge.inria.fr/doc/latest/fileformats.html#FileFormatsPerseus) for a description of the file format. + +**Example** + +``` + cubical_complex_persistence data/bitmap/CubicalTwoSphere.txt +``` + +* Creates a Cubical Complex from the Perseus style file `CubicalTwoSphere.txt`, +computes Persistence cohomology from it and writes the results in a persistence file `CubicalTwoSphere.txt_persistence`. + +## periodic_cubical_complex_persistence ## + +Same as above, but with periodic boundary conditions. + +**Example** + +``` + periodic_cubical_complex_persistence data/bitmap/3d_torus.txt +``` + +* Creates a Periodical Cubical Complex from the Perseus style file `3d_torus.txt`, +computes Persistence cohomology from it and writes the results in a persistence file `3d_torus.txt_persistence`. diff --git a/src/Bottleneck_distance/utilities/README b/src/Bottleneck_distance/utilities/README deleted file mode 100644 index 04e1c4bd..00000000 --- a/src/Bottleneck_distance/utilities/README +++ /dev/null @@ -1,30 +0,0 @@ ---- -layout: page -title: "Bottleneck distance" -meta_title: "bottleneckdistance" -subheadline: "" -teaser: "" -permalink: "/bottleneckdistance/" ---- -{::comment} -These flags above are here for web site generation, please let them. -cf. https://gitlab.inria.fr/GUDHI/website -Must be in conformity with _data/navigation.yml -{:/comment} - - - -## bottleneck_read_file_example ## - -This program computes the Bottleneck distance between two persistence diagram files. - -**Usage** - -``` - bottleneck_read_file_example [] -``` - -where - -* `` and `` must be in the format described [here](http://gudhi.gforge.inria.fr/doc/latest/fileformats.html#FileFormatsPers). -* `` is an error bound on the bottleneck distance (set by default to the smallest positive double value). diff --git a/src/Bottleneck_distance/utilities/bottleneckdistance.md b/src/Bottleneck_distance/utilities/bottleneckdistance.md new file mode 100644 index 00000000..04e1c4bd --- /dev/null +++ b/src/Bottleneck_distance/utilities/bottleneckdistance.md @@ -0,0 +1,30 @@ +--- +layout: page +title: "Bottleneck distance" +meta_title: "bottleneckdistance" +subheadline: "" +teaser: "" +permalink: "/bottleneckdistance/" +--- +{::comment} +These flags above are here for web site generation, please let them. +cf. https://gitlab.inria.fr/GUDHI/website +Must be in conformity with _data/navigation.yml +{:/comment} + + + +## bottleneck_read_file_example ## + +This program computes the Bottleneck distance between two persistence diagram files. + +**Usage** + +``` + bottleneck_read_file_example [] +``` + +where + +* `` and `` must be in the format described [here](http://gudhi.gforge.inria.fr/doc/latest/fileformats.html#FileFormatsPers). +* `` is an error bound on the bottleneck distance (set by default to the smallest positive double value). diff --git a/src/Rips_complex/utilities/README b/src/Rips_complex/utilities/README deleted file mode 100644 index 44a37543..00000000 --- a/src/Rips_complex/utilities/README +++ /dev/null @@ -1,61 +0,0 @@ ---- -layout: page -title: "Rips complex" -meta_title: "ripscomplex" -subheadline: "" -teaser: "" -permalink: "/ripscomplex/" ---- -{::comment} -These flags above are here for web site generation, please let them. -cf. https://gitlab.inria.fr/GUDHI/website -Must be in conformity with _data/navigation.yml -{:/comment} - - - -## rips_persistence ## -This program computes the persistent homology with coefficient field *Z/pZ* of a Rips complex defined on a set of input points. The output diagram contains one bar per line, written with the convention: - -`p dim birth death` - -where `dim` is the dimension of the homological feature, `birth` and `death` are respectively the birth and death of the feature, and `p` is the characteristic of the field *Z/pZ* used for homology coefficients (`p` must be a prime number). - -**Usage** - -`rips_persistence [options] ` - -**Allowed options** - -* `-h [ --help ]` Produce help message -* `-o [ --output-file ]` Name of file in which the persistence diagram is written. Default print in standard output. -* `-r [ --max-edge-length ]` (default = inf) Maximal length of an edge for the Rips complex construction. -* `-d [ --cpx-dimension ]` (default = 1) Maximal dimension of the Rips complex we want to compute. -* `-p [ --field-charac ]` (default = 11) Characteristic p of the coefficient field Z/pZ for computing homology. -* `-m [ --min-persistence ]` (default = 0) Minimal lifetime of homology feature to be recorded. Enter a negative value to see zero length intervals. - -Beware: this program may use a lot of RAM and take a lot of time if `max-edge-length` is set to a large value. - -**Example 1 with Z/2Z coefficients** - -`rips_persistence ../../data/points/tore3D_1307.off -r 0.25 -m 0.5 -d 3 -p 2` - -**Example 2 with Z/3Z coefficients** - -`rips_persistence ../../data/points/tore3D_1307.off -r 0.25 -m 0.5 -d 3 -p 3` - - -## rips_distance_matrix_persistence ## - -Same as `rips_persistence` but taking a distance matrix as input. - -**Usage** - -`rips_persistence [options] ` - -where -`` is the path to the file containing a distance matrix. Can be square or lower triangular matrix. Separator is ';'. - -**Example** - -`rips_distance_matrix_persistence data/distance_matrix/full_square_distance_matrix.csv -r 15 -d 3 -p 3 -m 0` diff --git a/src/Rips_complex/utilities/ripscomplex.md b/src/Rips_complex/utilities/ripscomplex.md new file mode 100644 index 00000000..44a37543 --- /dev/null +++ b/src/Rips_complex/utilities/ripscomplex.md @@ -0,0 +1,61 @@ +--- +layout: page +title: "Rips complex" +meta_title: "ripscomplex" +subheadline: "" +teaser: "" +permalink: "/ripscomplex/" +--- +{::comment} +These flags above are here for web site generation, please let them. +cf. https://gitlab.inria.fr/GUDHI/website +Must be in conformity with _data/navigation.yml +{:/comment} + + + +## rips_persistence ## +This program computes the persistent homology with coefficient field *Z/pZ* of a Rips complex defined on a set of input points. The output diagram contains one bar per line, written with the convention: + +`p dim birth death` + +where `dim` is the dimension of the homological feature, `birth` and `death` are respectively the birth and death of the feature, and `p` is the characteristic of the field *Z/pZ* used for homology coefficients (`p` must be a prime number). + +**Usage** + +`rips_persistence [options] ` + +**Allowed options** + +* `-h [ --help ]` Produce help message +* `-o [ --output-file ]` Name of file in which the persistence diagram is written. Default print in standard output. +* `-r [ --max-edge-length ]` (default = inf) Maximal length of an edge for the Rips complex construction. +* `-d [ --cpx-dimension ]` (default = 1) Maximal dimension of the Rips complex we want to compute. +* `-p [ --field-charac ]` (default = 11) Characteristic p of the coefficient field Z/pZ for computing homology. +* `-m [ --min-persistence ]` (default = 0) Minimal lifetime of homology feature to be recorded. Enter a negative value to see zero length intervals. + +Beware: this program may use a lot of RAM and take a lot of time if `max-edge-length` is set to a large value. + +**Example 1 with Z/2Z coefficients** + +`rips_persistence ../../data/points/tore3D_1307.off -r 0.25 -m 0.5 -d 3 -p 2` + +**Example 2 with Z/3Z coefficients** + +`rips_persistence ../../data/points/tore3D_1307.off -r 0.25 -m 0.5 -d 3 -p 3` + + +## rips_distance_matrix_persistence ## + +Same as `rips_persistence` but taking a distance matrix as input. + +**Usage** + +`rips_persistence [options] ` + +where +`` is the path to the file containing a distance matrix. Can be square or lower triangular matrix. Separator is ';'. + +**Example** + +`rips_distance_matrix_persistence data/distance_matrix/full_square_distance_matrix.csv -r 15 -d 3 -p 3 -m 0` diff --git a/src/Witness_complex/utilities/README b/src/Witness_complex/utilities/README deleted file mode 100644 index 5cdb1f88..00000000 --- a/src/Witness_complex/utilities/README +++ /dev/null @@ -1,76 +0,0 @@ ---- -layout: page -title: "Witness complex" -meta_title: "witnesscomplex" -subheadline: "" -teaser: "" -permalink: "/witnesscomplex/" ---- -{::comment} -These flags above are here for web site generation, please let them. -cf. https://gitlab.inria.fr/GUDHI/website -Must be in conformity with _data/navigation.yml -{:/comment} - - -For more details about the witness complex, please read the [user manual of the package](http://gudhi.gforge.inria.fr/doc/latest/group__witness__complex.html). - -## weak_witness_persistence ## -This program computes the persistent homology with coefficient field *Z/pZ* of a Weak witness complex defined on a set of input points. -The output diagram contains one bar per line, written with the convention: - -`p dim birth death` - -where `dim` is the dimension of the homological feature, `birth` and `death` are respectively the birth and death of the feature, -and `p` is the characteristic of the field *Z/pZ* used for homology coefficients. - -**Usage** - -`weak_witness_persistence [options] ` - -**Allowed options** - -* `-h [ --help ]` Produce help message -* `-l [ --landmarks ]` Number of landmarks to choose from the point cloud. -* `-o [ --output-file ]` Name of file in which the persistence diagram is written. By default, print in std::cout. -* `-a [ --max-sq-alpha ]` (default = inf) Maximal squared relaxation parameter. -* `-p [ --field-charac ]` (default = 11) Characteristic p of the coefficient field Z/pZ for computing homology. -* `-m [ --min-persistence ]` (default = 0) Minimal lifetime of homology feature to be recorded. Enter a negative value to see zero length intervals. -* `-d [ --cpx-dimension ]` (default = 2147483647) Maximal dimension of the weak witness complex we want to compute. - -**Example** - -`weak_witness_persistence data/points/tore3D_1307.off -l 20 -a 0.5 -m 0.006` - -N.B.: output is random as the 20 landmarks are chosen randomly. - - -## strong_witness_persistence ## - -This program computes the persistent homology with coefficient field *Z/pZ* of a Strong witness complex defined on a set of input points. -The output diagram contains one bar per line, written with the convention: - -`p dim birth death` - -where `dim` is the dimension of the homological feature, `birth` and `death` are respectively the birth and death of the feature, -and `p` is the characteristic of the field *Z/pZ* used for homology coefficients. - -**Usage** - -`strong_witness_persistence [options] ` - -**Allowed options** - -* `-h [ --help ]` Produce help message -* `-l [ --landmarks ]` Number of landmarks to choose from the point cloud. -* `-o [ --output-file ]` Name of file in which the persistence diagram is written. By default, print in std::cout. -* `-a [ --max-sq-alpha ]` (default = inf) Maximal squared relaxation parameter. -* `-p [ --field-charac ]` (default = 11) Characteristic p of the coefficient field Z/pZ for computing homology. -* `-m [ --min-persistence ]` (default = 0) Minimal lifetime of homology feature to be recorded. Enter a negative value to see zero length intervals. -* `-d [ --cpx-dimension ]` (default = 2147483647) Maximal dimension of the weak witness complex we want to compute. - -**Example** - -`strong_witness_persistence data/points/tore3D_1307.off -l 20 -a 0.5 -m 0.06` - -N.B.: output is random as the 20 landmarks are chosen randomly. diff --git a/src/Witness_complex/utilities/witnesscomplex.md b/src/Witness_complex/utilities/witnesscomplex.md new file mode 100644 index 00000000..5cdb1f88 --- /dev/null +++ b/src/Witness_complex/utilities/witnesscomplex.md @@ -0,0 +1,76 @@ +--- +layout: page +title: "Witness complex" +meta_title: "witnesscomplex" +subheadline: "" +teaser: "" +permalink: "/witnesscomplex/" +--- +{::comment} +These flags above are here for web site generation, please let them. +cf. https://gitlab.inria.fr/GUDHI/website +Must be in conformity with _data/navigation.yml +{:/comment} + + +For more details about the witness complex, please read the [user manual of the package](http://gudhi.gforge.inria.fr/doc/latest/group__witness__complex.html). + +## weak_witness_persistence ## +This program computes the persistent homology with coefficient field *Z/pZ* of a Weak witness complex defined on a set of input points. +The output diagram contains one bar per line, written with the convention: + +`p dim birth death` + +where `dim` is the dimension of the homological feature, `birth` and `death` are respectively the birth and death of the feature, +and `p` is the characteristic of the field *Z/pZ* used for homology coefficients. + +**Usage** + +`weak_witness_persistence [options] ` + +**Allowed options** + +* `-h [ --help ]` Produce help message +* `-l [ --landmarks ]` Number of landmarks to choose from the point cloud. +* `-o [ --output-file ]` Name of file in which the persistence diagram is written. By default, print in std::cout. +* `-a [ --max-sq-alpha ]` (default = inf) Maximal squared relaxation parameter. +* `-p [ --field-charac ]` (default = 11) Characteristic p of the coefficient field Z/pZ for computing homology. +* `-m [ --min-persistence ]` (default = 0) Minimal lifetime of homology feature to be recorded. Enter a negative value to see zero length intervals. +* `-d [ --cpx-dimension ]` (default = 2147483647) Maximal dimension of the weak witness complex we want to compute. + +**Example** + +`weak_witness_persistence data/points/tore3D_1307.off -l 20 -a 0.5 -m 0.006` + +N.B.: output is random as the 20 landmarks are chosen randomly. + + +## strong_witness_persistence ## + +This program computes the persistent homology with coefficient field *Z/pZ* of a Strong witness complex defined on a set of input points. +The output diagram contains one bar per line, written with the convention: + +`p dim birth death` + +where `dim` is the dimension of the homological feature, `birth` and `death` are respectively the birth and death of the feature, +and `p` is the characteristic of the field *Z/pZ* used for homology coefficients. + +**Usage** + +`strong_witness_persistence [options] ` + +**Allowed options** + +* `-h [ --help ]` Produce help message +* `-l [ --landmarks ]` Number of landmarks to choose from the point cloud. +* `-o [ --output-file ]` Name of file in which the persistence diagram is written. By default, print in std::cout. +* `-a [ --max-sq-alpha ]` (default = inf) Maximal squared relaxation parameter. +* `-p [ --field-charac ]` (default = 11) Characteristic p of the coefficient field Z/pZ for computing homology. +* `-m [ --min-persistence ]` (default = 0) Minimal lifetime of homology feature to be recorded. Enter a negative value to see zero length intervals. +* `-d [ --cpx-dimension ]` (default = 2147483647) Maximal dimension of the weak witness complex we want to compute. + +**Example** + +`strong_witness_persistence data/points/tore3D_1307.off -l 20 -a 0.5 -m 0.06` + +N.B.: output is random as the 20 landmarks are chosen randomly. diff --git a/src/common/utilities/README b/src/common/utilities/README deleted file mode 100644 index f39c63b8..00000000 --- a/src/common/utilities/README +++ /dev/null @@ -1,43 +0,0 @@ ---- -layout: page -title: "Pointset generator" -meta_title: "pointsetgenerator" -subheadline: "" -teaser: "" -permalink: "/pointsetgenerator/" ---- -{::comment} -These flags above are here for web site generation, please let them. -cf. https://gitlab.inria.fr/GUDHI/website -Must be in conformity with _data/navigation.yml -{:/comment} - -## off_file_from_shape_generator ## - -Generates a pointset and save it in an OFF file. Command-line is: - -``` -off_file_from_shape_generator on|in sphere|cube|curve|torus|klein ... -``` - -Warning: "on cube" generator is not available! - -**Examples** - -``` -off_file_from_shape_generator on sphere onSphere.off 1000 3 15.2 -``` - -* Generates an onSphere.off file with 1000 points randomized on a sphere of dimension 3 and radius 15.2. - -``` -off_file_from_shape_generator in sphere inSphere.off 100 2 -``` - -* Generates an inSphere.off file with 100 points randomized in a sphere of dimension 2 (circle) and radius 1.0 (default). - -``` -off_file_from_shape_generator in cube inCube.off 10000 3 5.8 -``` - -* Generates a inCube.off file with 10000 points randomized in a cube of dimension 3 and side 5.8. diff --git a/src/common/utilities/pointsetgenerator.md b/src/common/utilities/pointsetgenerator.md new file mode 100644 index 00000000..f39c63b8 --- /dev/null +++ b/src/common/utilities/pointsetgenerator.md @@ -0,0 +1,43 @@ +--- +layout: page +title: "Pointset generator" +meta_title: "pointsetgenerator" +subheadline: "" +teaser: "" +permalink: "/pointsetgenerator/" +--- +{::comment} +These flags above are here for web site generation, please let them. +cf. https://gitlab.inria.fr/GUDHI/website +Must be in conformity with _data/navigation.yml +{:/comment} + +## off_file_from_shape_generator ## + +Generates a pointset and save it in an OFF file. Command-line is: + +``` +off_file_from_shape_generator on|in sphere|cube|curve|torus|klein ... +``` + +Warning: "on cube" generator is not available! + +**Examples** + +``` +off_file_from_shape_generator on sphere onSphere.off 1000 3 15.2 +``` + +* Generates an onSphere.off file with 1000 points randomized on a sphere of dimension 3 and radius 15.2. + +``` +off_file_from_shape_generator in sphere inSphere.off 100 2 +``` + +* Generates an inSphere.off file with 100 points randomized in a sphere of dimension 2 (circle) and radius 1.0 (default). + +``` +off_file_from_shape_generator in cube inCube.off 10000 3 5.8 +``` + +* Generates a inCube.off file with 10000 points randomized in a cube of dimension 3 and side 5.8. -- cgit v1.2.3 From 37ded65d83935d417fc3bc484594a83b36f63514 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Tue, 30 Jan 2018 17:05:03 +0000 Subject: Fix after web review git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@3189 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: fd42bab9b27a3c086adeaf75068c83a911ede000 --- src/Alpha_complex/utilities/alphacomplex.md | 100 +++++++++------------ .../utilities/cubicalcomplex.md | 17 +--- .../utilities/bottleneckdistance.md | 16 +--- src/Nerve_GIC/utilities/covercomplex.md | 15 +--- src/Rips_complex/utilities/ripscomplex.md | 16 +--- src/Witness_complex/utilities/witnesscomplex.md | 22 ++--- src/common/utilities/pointsetgenerator.md | 16 +--- 7 files changed, 62 insertions(+), 140 deletions(-) (limited to 'src/Rips_complex') diff --git a/src/Alpha_complex/utilities/alphacomplex.md b/src/Alpha_complex/utilities/alphacomplex.md index 0e500e53..aace85d3 100644 --- a/src/Alpha_complex/utilities/alphacomplex.md +++ b/src/Alpha_complex/utilities/alphacomplex.md @@ -1,18 +1,47 @@ ---- -layout: page -title: "Alpha complex" -meta_title: "alphacomplex" -subheadline: "" -teaser: "" -permalink: "/alphacomplex/" ---- -{::comment} -These flags above are here for web site generation, please let them. -cf. https://gitlab.inria.fr/GUDHI/website -Must be in conformity with _data/navigation.yml -{:/comment} +# Alpha complex # + + +## alpha_complex_persistence ## + +This program computes the persistent homology with coefficient field Z/pZ of the dD alpha complex built from a dD point cloud. +The output diagram contains one bar per line, written with the convention: + +``` + p dim birth death +``` + +where `dim` is the dimension of the homological feature, `birth` and `death` are respectively the birth and death of the feature, +and `p` is the characteristic of the field *Z/pZ* used for homology coefficients (`p` must be a prime number). + +**Usage** + +``` + alpha_complex_persistence [options] +``` + +where +`` is the path to the input point cloud in [nOFF ASCII format](http://www.geomview.org/docs/html/OFF.html). + +**Allowed options** + +* `-h [ --help ]` Produce help message +* `-o [ --output-file ]` Name of file in which the persistence diagram is written. Default print in standard output. +* `-r [ --max-alpha-square-value ]` (default = inf) Maximal alpha square value for the Alpha complex construction. +* `-p [ --field-charac ]` (default = 11) Characteristic p of the coefficient field Z/pZ for computing homology. +* `-m [ --min-persistence ]` (default = 0) Minimal lifetime of homology feature to be recorded. Enter a negative value to see zero length intervals. + +**Example** + +``` + alpha_complex_persistence -r 32 -p 2 -m 0.45 ../../data/points/tore3D_300.off +``` + +N.B.: + +* Filtration values are alpha square values. + ## alpha_complex_3d_persistence ## This program computes the persistent homology with coefficient field Z/pZ of the 3D alpha complex built from a 3D point cloud. The output diagram contains one bar per line, written with the convention: @@ -107,7 +136,7 @@ where * `` is the path to the input point cloud in [nOFF ASCII format](http://www.geomview.org/docs/html/OFF.html). * `` is the path to the file describing the periodic domain. It must be in the format described -[here](../doc/latest/fileformats.html#FileFormatsIsoCuboid). +[here](/doc/latest/fileformats.html#FileFormatsIsoCuboid). **Allowed options** @@ -125,46 +154,5 @@ periodic_alpha_complex_3d_persistence ../../data/points/grid_10_10_10_in_0_1.off N.B.: -* Cuboid file must be in the format described [here](../doc/latest/fileformats.html#FileFormatsIsoCuboid). -* Filtration values are alpha square values. - - - -## alpha_complex_persistence ## - -This program computes the persistent homology with coefficient field Z/pZ of the dD alpha complex built from a dD point cloud. -The output diagram contains one bar per line, written with the convention: - -``` - p dim birth death -``` - -where `dim` is the dimension of the homological feature, `birth` and `death` are respectively the birth and death of the feature, -and `p` is the characteristic of the field *Z/pZ* used for homology coefficients (`p` must be a prime number). - -**Usage** - -``` - alpha_complex_persistence [options] -``` - -where -`` is the path to the input point cloud in [nOFF ASCII format](http://www.geomview.org/docs/html/OFF.html). - -**Allowed options** - -* `-h [ --help ]` Produce help message -* `-o [ --output-file ]` Name of file in which the persistence diagram is written. Default print in standard output. -* `-r [ --max-alpha-square-value ]` (default = inf) Maximal alpha square value for the Alpha complex construction. -* `-p [ --field-charac ]` (default = 11) Characteristic p of the coefficient field Z/pZ for computing homology. -* `-m [ --min-persistence ]` (default = 0) Minimal lifetime of homology feature to be recorded. Enter a negative value to see zero length intervals. - -**Example** - -``` - alpha_complex_persistence -r 32 -p 2 -m 0.45 ../../data/points/tore3D_300.off -``` - -N.B.: - +* Cuboid file must be in the format described [here](/doc/latest/fileformats.html#FileFormatsIsoCuboid). * Filtration values are alpha square values. diff --git a/src/Bitmap_cubical_complex/utilities/cubicalcomplex.md b/src/Bitmap_cubical_complex/utilities/cubicalcomplex.md index 3a9e6aac..6e1b2578 100644 --- a/src/Bitmap_cubical_complex/utilities/cubicalcomplex.md +++ b/src/Bitmap_cubical_complex/utilities/cubicalcomplex.md @@ -1,21 +1,10 @@ ---- -layout: page -title: "Bitmap cubical complex" -meta_title: "cubicalcomplex" -subheadline: "" -teaser: "" -permalink: "/cubicalcomplex/" ---- -{::comment} -These flags above are here for web site generation, please let them. -cf. https://gitlab.inria.fr/GUDHI/website -Must be in conformity with _data/navigation.yml -{:/comment} +# Cubical complex# + ## cubical_complex_persistence ## This program computes persistent homology, by using the Bitmap_cubical_complex class, of cubical complexes provided in text files in Perseus style. -See [here](../doc/latest/fileformats.html#FileFormatsPerseus) for a description of the file format. +See [here](/doc/latest/fileformats.html#FileFormatsPerseus) for a description of the file format. **Example** diff --git a/src/Bottleneck_distance/utilities/bottleneckdistance.md b/src/Bottleneck_distance/utilities/bottleneckdistance.md index e9079058..526f5822 100644 --- a/src/Bottleneck_distance/utilities/bottleneckdistance.md +++ b/src/Bottleneck_distance/utilities/bottleneckdistance.md @@ -1,18 +1,6 @@ ---- -layout: page -title: "Bottleneck distance" -meta_title: "bottleneckdistance" -subheadline: "" -teaser: "" -permalink: "/bottleneckdistance/" ---- -{::comment} -These flags above are here for web site generation, please let them. -cf. https://gitlab.inria.fr/GUDHI/website -Must be in conformity with _data/navigation.yml -{:/comment} +# Bottleneck distance # ## bottleneck_read_file_example ## @@ -26,5 +14,5 @@ This program computes the Bottleneck distance between two persistence diagram fi where -* `` and `` must be in the format described [here](../doc/latest/fileformats.html#FileFormatsPers). +* `` and `` must be in the format described [here](/doc/latest/fileformats.html#FileFormatsPers). * `` is an error bound on the bottleneck distance (set by default to the smallest positive double value). diff --git a/src/Nerve_GIC/utilities/covercomplex.md b/src/Nerve_GIC/utilities/covercomplex.md index 41489b66..f33cb2e0 100644 --- a/src/Nerve_GIC/utilities/covercomplex.md +++ b/src/Nerve_GIC/utilities/covercomplex.md @@ -1,18 +1,7 @@ ---- -layout: page -title: "Cover complex" -meta_title: "covercomplex" -subheadline: "" -teaser: "" -permalink: "/covercomplex/" ---- -{::comment} -These flags above are here for web site generation, please let them. -cf. https://gitlab.inria.fr/GUDHI/website -Must be in conformity with _data/navigation.yml -{:/comment} +# Cover complex # + ## Nerve ## This program builds the Nerve of a point cloud sampled on an OFF file. diff --git a/src/Rips_complex/utilities/ripscomplex.md b/src/Rips_complex/utilities/ripscomplex.md index 44a37543..4291fae7 100644 --- a/src/Rips_complex/utilities/ripscomplex.md +++ b/src/Rips_complex/utilities/ripscomplex.md @@ -1,21 +1,9 @@ ---- -layout: page -title: "Rips complex" -meta_title: "ripscomplex" -subheadline: "" -teaser: "" -permalink: "/ripscomplex/" ---- -{::comment} -These flags above are here for web site generation, please let them. -cf. https://gitlab.inria.fr/GUDHI/website -Must be in conformity with _data/navigation.yml -{:/comment} +# Rips complex # ## rips_persistence ## -This program computes the persistent homology with coefficient field *Z/pZ* of a Rips complex defined on a set of input points. The output diagram contains one bar per line, written with the convention: +This program computes the persistent homology with coefficient field *Z/pZ* of a Rips complex defined on a set of input points, using Euclidean distance. The output diagram contains one bar per line, written with the convention: `p dim birth death` diff --git a/src/Witness_complex/utilities/witnesscomplex.md b/src/Witness_complex/utilities/witnesscomplex.md index 40864871..2341759b 100644 --- a/src/Witness_complex/utilities/witnesscomplex.md +++ b/src/Witness_complex/utilities/witnesscomplex.md @@ -1,19 +1,9 @@ ---- -layout: page -title: "Witness complex" -meta_title: "witnesscomplex" -subheadline: "" -teaser: "" -permalink: "/witnesscomplex/" ---- -{::comment} -These flags above are here for web site generation, please let them. -cf. https://gitlab.inria.fr/GUDHI/website -Must be in conformity with _data/navigation.yml -{:/comment} - - -For more details about the witness complex, please read the [user manual of the package](../doc/latest/group__witness__complex.html). + + +# Witness complex # + + +For more details about the witness complex, please read the [user manual of the package](/doc/latest/group__witness__complex.html). ## weak_witness_persistence ## This program computes the persistent homology with coefficient field *Z/pZ* of a Weak witness complex defined on a set of input points. diff --git a/src/common/utilities/pointsetgenerator.md b/src/common/utilities/pointsetgenerator.md index f39c63b8..284715d4 100644 --- a/src/common/utilities/pointsetgenerator.md +++ b/src/common/utilities/pointsetgenerator.md @@ -1,16 +1,6 @@ ---- -layout: page -title: "Pointset generator" -meta_title: "pointsetgenerator" -subheadline: "" -teaser: "" -permalink: "/pointsetgenerator/" ---- -{::comment} -These flags above are here for web site generation, please let them. -cf. https://gitlab.inria.fr/GUDHI/website -Must be in conformity with _data/navigation.yml -{:/comment} + + +# common # ## off_file_from_shape_generator ## -- cgit v1.2.3