summaryrefslogtreecommitdiff
path: root/example/Persistent_cohomology
diff options
context:
space:
mode:
Diffstat (limited to 'example/Persistent_cohomology')
-rw-r--r--example/Persistent_cohomology/CMakeLists.txt50
-rw-r--r--example/Persistent_cohomology/README2
-rw-r--r--example/Persistent_cohomology/alpha_complex_3d_persistence.cpp7
-rw-r--r--example/Persistent_cohomology/exact_alpha_complex_3d_persistence.cpp7
-rw-r--r--example/Persistent_cohomology/periodic_alpha_complex_3d_persistence.cpp14
-rw-r--r--example/Persistent_cohomology/persistence_from_file.cpp3
-rw-r--r--example/Persistent_cohomology/persistence_from_simple_simplex_tree.cpp3
-rw-r--r--example/Persistent_cohomology/rips_distance_matrix_persistence.cpp2
-rw-r--r--example/Persistent_cohomology/weighted_alpha_complex_3d_persistence.cpp14
9 files changed, 62 insertions, 40 deletions
diff --git a/example/Persistent_cohomology/CMakeLists.txt b/example/Persistent_cohomology/CMakeLists.txt
index 3c45e79b..f47de4c3 100644
--- a/example/Persistent_cohomology/CMakeLists.txt
+++ b/example/Persistent_cohomology/CMakeLists.txt
@@ -2,25 +2,23 @@ cmake_minimum_required(VERSION 2.6)
project(Persistent_cohomology_examples)
add_executable(plain_homology plain_homology.cpp)
-target_link_libraries(plain_homology ${Boost_SYSTEM_LIBRARY})
add_executable(persistence_from_simple_simplex_tree persistence_from_simple_simplex_tree.cpp)
-target_link_libraries(persistence_from_simple_simplex_tree ${Boost_SYSTEM_LIBRARY})
add_executable(rips_distance_matrix_persistence rips_distance_matrix_persistence.cpp)
-target_link_libraries(rips_distance_matrix_persistence ${Boost_SYSTEM_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY})
+target_link_libraries(rips_distance_matrix_persistence ${Boost_PROGRAM_OPTIONS_LIBRARY})
add_executable(rips_persistence rips_persistence.cpp)
-target_link_libraries(rips_persistence ${Boost_SYSTEM_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY})
+target_link_libraries(rips_persistence ${Boost_PROGRAM_OPTIONS_LIBRARY})
add_executable(rips_persistence_step_by_step rips_persistence_step_by_step.cpp)
-target_link_libraries(rips_persistence_step_by_step ${Boost_SYSTEM_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY})
+target_link_libraries(rips_persistence_step_by_step ${Boost_PROGRAM_OPTIONS_LIBRARY})
add_executable(rips_persistence_via_boundary_matrix rips_persistence_via_boundary_matrix.cpp)
-target_link_libraries(rips_persistence_via_boundary_matrix ${Boost_SYSTEM_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY})
+target_link_libraries(rips_persistence_via_boundary_matrix ${Boost_PROGRAM_OPTIONS_LIBRARY})
add_executable(persistence_from_file persistence_from_file.cpp)
-target_link_libraries(persistence_from_file ${Boost_SYSTEM_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY})
+target_link_libraries(persistence_from_file ${Boost_PROGRAM_OPTIONS_LIBRARY})
if (TBB_FOUND)
target_link_libraries(plain_homology ${TBB_LIBRARIES})
@@ -47,27 +45,36 @@ add_test(NAME Persistent_cohomology_example_from_file_3_2_0 COMMAND $<TARGET_FIL
"${CMAKE_SOURCE_DIR}/data/filtered_simplicial_complex/bunny_5000_complex.fsc" "-p" "2" "-m" "0")
add_test(NAME Persistent_cohomology_example_from_file_3_3_100 COMMAND $<TARGET_FILE:persistence_from_file>
"${CMAKE_SOURCE_DIR}/data/filtered_simplicial_complex/bunny_5000_complex.fsc" "-p" "3" "-m" "100")
-
+
+install(TARGETS plain_homology DESTINATION bin)
+install(TARGETS persistence_from_simple_simplex_tree DESTINATION bin)
+install(TARGETS rips_distance_matrix_persistence DESTINATION bin)
+install(TARGETS rips_persistence DESTINATION bin)
+install(TARGETS rips_persistence_step_by_step DESTINATION bin)
+install(TARGETS rips_persistence_via_boundary_matrix DESTINATION bin)
+install(TARGETS persistence_from_file DESTINATION bin)
+
if(GMP_FOUND)
if(GMPXX_FOUND)
add_executable(rips_multifield_persistence rips_multifield_persistence.cpp )
target_link_libraries(rips_multifield_persistence
- ${Boost_SYSTEM_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY} ${GMPXX_LIBRARIES} ${GMP_LIBRARIES})
+ ${Boost_PROGRAM_OPTIONS_LIBRARY} ${GMPXX_LIBRARIES} ${GMP_LIBRARIES})
if (TBB_FOUND)
target_link_libraries(rips_multifield_persistence ${TBB_LIBRARIES})
endif(TBB_FOUND)
- add_test(NAME Persistent_cohomology_example_multifield_2_71 COMMAND $<TARGET_FILE:rips_multifield_persistence>
- "${CMAKE_SOURCE_DIR}/data/points/tore3D_1307.off" "-r" "0.25" "-m" "0.5" "-d" "3" "-p" "2" "-q" "71")
+ add_test(NAME Persistent_cohomology_example_multifield_2_71 COMMAND $<TARGET_FILE:rips_multifield_persistence>
+ "${CMAKE_SOURCE_DIR}/data/points/tore3D_1307.off" "-r" "0.25" "-m" "0.5" "-d" "3" "-p" "2" "-q" "71")
+ install(TARGETS rips_multifield_persistence DESTINATION bin)
endif(GMPXX_FOUND)
endif(GMP_FOUND)
if(CGAL_FOUND)
add_executable(alpha_complex_3d_persistence alpha_complex_3d_persistence.cpp)
- target_link_libraries(alpha_complex_3d_persistence ${Boost_SYSTEM_LIBRARY} ${CGAL_LIBRARY})
+ target_link_libraries(alpha_complex_3d_persistence ${CGAL_LIBRARY})
add_executable(exact_alpha_complex_3d_persistence exact_alpha_complex_3d_persistence.cpp)
- target_link_libraries(exact_alpha_complex_3d_persistence ${Boost_SYSTEM_LIBRARY} ${CGAL_LIBRARY})
+ target_link_libraries(exact_alpha_complex_3d_persistence ${CGAL_LIBRARY})
add_executable(weighted_alpha_complex_3d_persistence weighted_alpha_complex_3d_persistence.cpp)
- target_link_libraries(weighted_alpha_complex_3d_persistence ${Boost_SYSTEM_LIBRARY} ${CGAL_LIBRARY})
+ target_link_libraries(weighted_alpha_complex_3d_persistence ${CGAL_LIBRARY})
if (TBB_FOUND)
target_link_libraries(alpha_complex_3d_persistence ${TBB_LIBRARIES})
@@ -81,16 +88,20 @@ if(CGAL_FOUND)
add_test(NAME Persistent_cohomology_example_weighted_alpha_complex_3d COMMAND $<TARGET_FILE:weighted_alpha_complex_3d_persistence>
"${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off" "${CMAKE_SOURCE_DIR}/data/points/tore3D_300.weights" "2" "0.45")
+ install(TARGETS alpha_complex_3d_persistence DESTINATION bin)
+ install(TARGETS exact_alpha_complex_3d_persistence DESTINATION bin)
+ install(TARGETS weighted_alpha_complex_3d_persistence DESTINATION bin)
+
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
- ${Boost_SYSTEM_LIBRARY} ${CGAL_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY})
+ ${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 ${Boost_SYSTEM_LIBRARY} ${CGAL_LIBRARY})
+ target_link_libraries(periodic_alpha_complex_3d_persistence ${CGAL_LIBRARY})
add_executable(custom_persistence_sort custom_persistence_sort.cpp)
- target_link_libraries(custom_persistence_sort ${Boost_SYSTEM_LIBRARY} ${CGAL_LIBRARY})
+ target_link_libraries(custom_persistence_sort ${CGAL_LIBRARY})
if (TBB_FOUND)
target_link_libraries(alpha_complex_persistence ${TBB_LIBRARIES})
@@ -102,5 +113,10 @@ if(CGAL_FOUND)
add_test(NAME Persistent_cohomology_example_periodic_alpha_complex_3d COMMAND $<TARGET_FILE:periodic_alpha_complex_3d_persistence>
"${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")
add_test(NAME Persistent_cohomology_example_custom_persistence_sort COMMAND $<TARGET_FILE:custom_persistence_sort>)
+
+ install(TARGETS alpha_complex_persistence DESTINATION bin)
+ install(TARGETS periodic_alpha_complex_3d_persistence DESTINATION bin)
+ install(TARGETS custom_persistence_sort DESTINATION bin)
+
endif (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.7.0)
endif(CGAL_FOUND)
diff --git a/example/Persistent_cohomology/README b/example/Persistent_cohomology/README
index 2ac79398..794b94ae 100644
--- a/example/Persistent_cohomology/README
+++ b/example/Persistent_cohomology/README
@@ -121,7 +121,7 @@ N.B.: - alpha_complex_persistence accepts OFF files in d-Dimension.
3) 3D periodic special case
---------------------------
-./periodic_alpha_complex_3d_persistence ../../data/points/grid_10_10_10_in_0_1.off 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 3 1.0
output:
Periodic Delaunay computed.
diff --git a/example/Persistent_cohomology/alpha_complex_3d_persistence.cpp b/example/Persistent_cohomology/alpha_complex_3d_persistence.cpp
index fd227b82..f63ff0f6 100644
--- a/example/Persistent_cohomology/alpha_complex_3d_persistence.cpp
+++ b/example/Persistent_cohomology/alpha_complex_3d_persistence.cpp
@@ -76,8 +76,9 @@ 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: " << progName <<
- " path_to_file_graph coeff_field_characteristic[integer > 0] min_persistence[float >= -1.0]\n";
+ 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);
}
@@ -202,7 +203,6 @@ int main(int argc, char * const argv[]) {
else
std::cout << "This shall not happen" << std::endl;
}
- simplex_tree.set_filtration(filtration_max);
simplex_tree.set_dimension(dim_max);
#ifdef DEBUG_TRACES
@@ -216,7 +216,6 @@ int main(int argc, char * const argv[]) {
std::cout << " Number of vertices = " << simplex_tree.num_vertices() << " ";
std::cout << " Number of simplices = " << simplex_tree.num_simplices() << std::endl << std::endl;
std::cout << " Dimension = " << simplex_tree.dimension() << " ";
- std::cout << " filtration = " << simplex_tree.filtration() << std::endl << std::endl;
#endif // DEBUG_TRACES
#ifdef DEBUG_TRACES
diff --git a/example/Persistent_cohomology/exact_alpha_complex_3d_persistence.cpp b/example/Persistent_cohomology/exact_alpha_complex_3d_persistence.cpp
index 8a335075..09561d03 100644
--- a/example/Persistent_cohomology/exact_alpha_complex_3d_persistence.cpp
+++ b/example/Persistent_cohomology/exact_alpha_complex_3d_persistence.cpp
@@ -77,8 +77,9 @@ 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: " << progName <<
- " path_to_file_graph coeff_field_characteristic[integer > 0] min_persistence[float >= -1.0]\n";
+ 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);
}
@@ -204,7 +205,6 @@ int main(int argc, char * const argv[]) {
else
std::cout << "This shall not happen" << std::endl;
}
- simplex_tree.set_filtration(filtration_max);
simplex_tree.set_dimension(dim_max);
#ifdef DEBUG_TRACES
@@ -218,7 +218,6 @@ int main(int argc, char * const argv[]) {
std::cout << " Number of vertices = " << simplex_tree.num_vertices() << " ";
std::cout << " Number of simplices = " << simplex_tree.num_simplices() << std::endl << std::endl;
std::cout << " Dimension = " << simplex_tree.dimension() << " ";
- std::cout << " filtration = " << simplex_tree.filtration() << std::endl << std::endl;
#endif // DEBUG_TRACES
#ifdef DEBUG_TRACES
diff --git a/example/Persistent_cohomology/periodic_alpha_complex_3d_persistence.cpp b/example/Persistent_cohomology/periodic_alpha_complex_3d_persistence.cpp
index 8928cfc2..8140a3c5 100644
--- a/example/Persistent_cohomology/periodic_alpha_complex_3d_persistence.cpp
+++ b/example/Persistent_cohomology/periodic_alpha_complex_3d_persistence.cpp
@@ -84,8 +84,16 @@ using Persistent_cohomology = Gudhi::persistent_cohomology::Persistent_cohomolog
ST, Gudhi::persistent_cohomology::Field_Zp >;
void usage(char * const progName) {
- std::cerr << "Usage: " << progName <<
- " path_to_file_graph path_to_iso_cuboid_3_file coeff_field_characteristic[integer > 0] min_persistence[float >= -1.0]\n";
+ 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);
}
@@ -221,7 +229,6 @@ int main(int argc, char * const argv[]) {
else
std::cout << "This shall not happen" << std::endl;
}
- simplex_tree.set_filtration(filtration_max);
simplex_tree.set_dimension(dim_max);
#ifdef DEBUG_TRACES
@@ -235,7 +242,6 @@ int main(int argc, char * const argv[]) {
std::cout << " Number of vertices = " << simplex_tree.num_vertices() << " ";
std::cout << " Number of simplices = " << simplex_tree.num_simplices() << std::endl << std::endl;
std::cout << " Dimension = " << simplex_tree.dimension() << " ";
- std::cout << " filtration = " << simplex_tree.filtration() << std::endl << std::endl;
#endif // DEBUG_TRACES
#ifdef DEBUG_TRACES
diff --git a/example/Persistent_cohomology/persistence_from_file.cpp b/example/Persistent_cohomology/persistence_from_file.cpp
index 67235467..eafa3fd5 100644
--- a/example/Persistent_cohomology/persistence_from_file.cpp
+++ b/example/Persistent_cohomology/persistence_from_file.cpp
@@ -61,8 +61,7 @@ int main(int argc, char * argv[]) {
simplex_tree_stream >> simplex_tree;
std::cout << "The complex contains " << simplex_tree.num_simplices() << " simplices" << std::endl;
- std::cout << " - dimension " << simplex_tree.dimension() << " - filtration " << simplex_tree.filtration()
- << std::endl;
+ std::cout << " - dimension " << simplex_tree.dimension() << std::endl;
/*
std::cout << std::endl << std::endl << "Iterator on Simplices in the filtration, with [filtration value]:" << std::endl;
diff --git a/example/Persistent_cohomology/persistence_from_simple_simplex_tree.cpp b/example/Persistent_cohomology/persistence_from_simple_simplex_tree.cpp
index 7ca9410a..8214d66a 100644
--- a/example/Persistent_cohomology/persistence_from_simple_simplex_tree.cpp
+++ b/example/Persistent_cohomology/persistence_from_simple_simplex_tree.cpp
@@ -143,11 +143,10 @@ int main(int argc, char * const argv[]) {
/* An edge [10,12,2] */
st.set_dimension(2);
- st.set_filtration(0.4);
std::cout << "The complex contains " << st.num_simplices() << " simplices - " << st.num_vertices() << " vertices "
<< std::endl;
- std::cout << " - dimension " << st.dimension() << " - filtration " << st.filtration() << std::endl;
+ std::cout << " - dimension " << st.dimension() << std::endl;
std::cout << std::endl << std::endl << "Iterator on Simplices in the filtration, with [filtration value]:"
<< std::endl;
std::cout << "**************************************************************" << std::endl;
diff --git a/example/Persistent_cohomology/rips_distance_matrix_persistence.cpp b/example/Persistent_cohomology/rips_distance_matrix_persistence.cpp
index 8517e7f6..d38808c7 100644
--- a/example/Persistent_cohomology/rips_distance_matrix_persistence.cpp
+++ b/example/Persistent_cohomology/rips_distance_matrix_persistence.cpp
@@ -57,7 +57,7 @@ int main(int argc, char * argv[]) {
program_options(argc, argv, csv_matrix_file, filediag, threshold, dim_max, p, min_persistence);
- Distance_matrix distances = read_lower_triangular_matrix_from_csv_file<Filtration_value>(csv_matrix_file);
+ Distance_matrix distances = Gudhi::read_lower_triangular_matrix_from_csv_file<Filtration_value>(csv_matrix_file);
Rips_complex rips_complex_from_file(distances, threshold);
// Construct the Rips complex in a Simplex Tree
diff --git a/example/Persistent_cohomology/weighted_alpha_complex_3d_persistence.cpp b/example/Persistent_cohomology/weighted_alpha_complex_3d_persistence.cpp
index 34b90933..72268511 100644
--- a/example/Persistent_cohomology/weighted_alpha_complex_3d_persistence.cpp
+++ b/example/Persistent_cohomology/weighted_alpha_complex_3d_persistence.cpp
@@ -81,8 +81,13 @@ using Persistent_cohomology = Gudhi::persistent_cohomology::Persistent_cohomolog
ST, Gudhi::persistent_cohomology::Field_Zp >;
void usage(char * const progName) {
- std::cerr << "Usage: " << progName <<
- " path_to_file_graph path_to_weight_file coeff_field_characteristic[integer > 0] min_persistence[float >= -1.0]\n";
+ 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);
}
@@ -115,6 +120,7 @@ int main(int argc, char * const argv[]) {
if (weights_ifstr.good()) {
double weight = 0.0;
std::size_t index = 0;
+ wp.reserve(lp.size());
// Attempt read the weight in a double format, return false if it fails
while ((weights_ifstr >> weight) && (index < lp.size())) {
wp.push_back(Weighted_point_3(lp[index], weight));
@@ -130,7 +136,7 @@ int main(int argc, char * const argv[]) {
}
// alpha shape construction from points. CGAL has a strange behavior in REGULARIZED mode.
- Alpha_shape_3 as(lp.begin(), lp.end(), 0, Alpha_shape_3::GENERAL);
+ Alpha_shape_3 as(wp.begin(), wp.end(), 0, Alpha_shape_3::GENERAL);
#ifdef DEBUG_TRACES
std::cout << "Alpha shape computed in GENERAL mode" << std::endl;
#endif // DEBUG_TRACES
@@ -222,7 +228,6 @@ int main(int argc, char * const argv[]) {
else
std::cout << "This shall not happen" << std::endl;
}
- simplex_tree.set_filtration(filtration_max);
simplex_tree.set_dimension(dim_max);
#ifdef DEBUG_TRACES
@@ -236,7 +241,6 @@ int main(int argc, char * const argv[]) {
std::cout << " Number of vertices = " << simplex_tree.num_vertices() << " ";
std::cout << " Number of simplices = " << simplex_tree.num_simplices() << std::endl << std::endl;
std::cout << " Dimension = " << simplex_tree.dimension() << " ";
- std::cout << " filtration = " << simplex_tree.filtration() << std::endl << std::endl;
#endif // DEBUG_TRACES
#ifdef DEBUG_TRACES