From ca8474aa59374fc5f4266aa56196587685b86637 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Sat, 9 Dec 2017 12:47:11 +0000 Subject: CMake modification strategy as it was quite painful to maintain all these utilities git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/persistence_representation_integration_cmake_improvement@3062 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: c0eae764abe5c7076ae59027eeab2a7ad451463c --- .../include/gudhi/Persistence_heat_maps.h | 10 +-- .../include/gudhi/Persistence_landscape.h | 11 ++-- .../include/gudhi/Persistence_landscape_on_grid.h | 12 ++-- .../include/gudhi/Persistence_vectors.h | 3 +- .../utilities/CMakeLists.txt | 48 +++++++++++++++ .../utilities/persistence_heat_maps/CMakeLists.txt | 72 ++++------------------ .../average_persistence_heat_maps.cpp | 16 +++-- .../compute_distance_of_persistence_heat_maps.cpp | 13 ++-- ...ute_scalar_product_of_persistence_heat_maps.cpp | 14 +++-- ...h_m_weighted_by_arctan_of_their_persistence.cpp | 33 +++++----- ...te_p_h_m_weighted_by_distance_from_diagonal.cpp | 34 +++++----- ...ate_p_h_m_weighted_by_squared_diag_distance.cpp | 34 +++++----- .../create_persistence_heat_maps.cpp | 34 +++++----- .../persistence_heat_maps/create_pssk.cpp | 34 +++++----- .../plot_persistence_heat_map.cpp | 8 ++- .../utilities/persistence_intervals/CMakeLists.txt | 6 -- .../persistence_landscapes/CMakeLists.txt | 40 ++---------- .../persistence_landscapes/average_landscapes.cpp | 15 ++--- .../compute_distance_of_landscapes.cpp | 14 ++--- .../compute_scalar_product_of_landscapes.cpp | 15 +++-- .../persistence_landscapes/create_landscapes.cpp | 24 +++++--- .../persistence_landscapes/plot_landscapes.cpp | 16 ++--- .../persistence_landscapes_on_grid/CMakeLists.txt | 39 ++---------- .../average_landscapes_on_grid.cpp | 16 +++-- .../compute_distance_of_landscapes_on_grid.cpp | 13 ++-- ...ompute_scalar_product_of_landscapes_on_grid.cpp | 14 +++-- .../create_landscapes_on_grid.cpp | 27 ++++---- .../plot_landscapes_on_grid.cpp | 17 +++-- .../utilities/persistence_vectors/CMakeLists.txt | 38 ++---------- .../average_persistence_vectors.cpp | 13 ++-- .../compute_distance_of_persistence_vectors.cpp | 3 +- ...mpute_scalar_product_of_persistence_vectors.cpp | 15 +++-- .../create_persistence_vectors.cpp | 23 ++++--- 33 files changed, 328 insertions(+), 396 deletions(-) (limited to 'src/Persistence_representations') diff --git a/src/Persistence_representations/include/gudhi/Persistence_heat_maps.h b/src/Persistence_representations/include/gudhi/Persistence_heat_maps.h index 04dd78ad..ae1740a7 100644 --- a/src/Persistence_representations/include/gudhi/Persistence_heat_maps.h +++ b/src/Persistence_representations/include/gudhi/Persistence_heat_maps.h @@ -743,10 +743,10 @@ void Persistence_heat_maps::compute_percentage_of_active( template void Persistence_heat_maps::plot(const char* filename) const { std::ofstream out; - std::stringstream ss; - ss << filename << "_GnuplotScript"; + std::stringstream gnuplot_script; + gnuplot_script << filename << "_GnuplotScript"; - out.open(ss.str().c_str()); + out.open(gnuplot_script.str().c_str()); out << "plot '-' matrix with image" << std::endl; for (size_t i = 0; i != this->heat_map.size(); ++i) { for (size_t j = 0; j != this->heat_map[i].size(); ++j) { @@ -755,8 +755,8 @@ void Persistence_heat_maps::plot(const char* filename) cons out << std::endl; } out.close(); - std::cout << "Gnuplot script have been created. Open gnuplot and type load \'" << ss.str().c_str() - << "\' to see the picture." << std::endl; + std::cout << "To visualize, install gnuplot and type the command: gnuplot -persist -e \"load \'" + << gnuplot_script.str().c_str() << "\'\"" << std::endl; } template diff --git a/src/Persistence_representations/include/gudhi/Persistence_landscape.h b/src/Persistence_representations/include/gudhi/Persistence_landscape.h index 5c300112..72498edf 100644 --- a/src/Persistence_representations/include/gudhi/Persistence_landscape.h +++ b/src/Persistence_representations/include/gudhi/Persistence_landscape.h @@ -1340,10 +1340,9 @@ void Persistence_landscape::plot(const char* filename, double xRangeBegin, doubl // this program create a gnuplot script file that allows to plot persistence diagram. std::ofstream out; - std::ostringstream nameSS; - nameSS << filename << "_GnuplotScript"; - std::string nameStr = nameSS.str(); - out.open(nameStr); + std::ostringstream gnuplot_script; + gnuplot_script << filename << "_GnuplotScript"; + out.open(gnuplot_script.str().c_str()); if ((xRangeBegin != std::numeric_limits::max()) || (xRangeEnd != std::numeric_limits::max()) || (yRangeBegin != std::numeric_limits::max()) || (yRangeEnd != std::numeric_limits::max())) { @@ -1376,8 +1375,8 @@ void Persistence_landscape::plot(const char* filename, double xRangeBegin, doubl } out << "EOF" << std::endl; } - std::cout << "Gnuplot script to visualize persistence diagram written to the file: " << nameStr << ". Type load '" - << nameStr << "' in gnuplot to visualize." << std::endl; + std::cout << "To visualize, install gnuplot and type the command: gnuplot -persist -e \"load \'" + << gnuplot_script.str().c_str() << "\'\"" << std::endl; } } // namespace Persistence_representations diff --git a/src/Persistence_representations/include/gudhi/Persistence_landscape_on_grid.h b/src/Persistence_representations/include/gudhi/Persistence_landscape_on_grid.h index 4ceb9bf6..84fd22ed 100644 --- a/src/Persistence_representations/include/gudhi/Persistence_landscape_on_grid.h +++ b/src/Persistence_representations/include/gudhi/Persistence_landscape_on_grid.h @@ -1207,10 +1207,9 @@ void Persistence_landscape_on_grid::plot(const char* filename, double min_x, dou // this program create a gnuplot script file that allows to plot persistence diagram. std::ofstream out; - std::ostringstream nameSS; - nameSS << filename << "_GnuplotScript"; - std::string nameStr = nameSS.str(); - out.open(nameStr); + std::ostringstream gnuplot_script; + gnuplot_script << filename << "_GnuplotScript"; + out.open(gnuplot_script.str().c_str()); if (min_x == max_x) { std::pair min_max = compute_minimum_maximum(); @@ -1241,7 +1240,6 @@ void Persistence_landscape_on_grid::plot(const char* filename, double min_x, dou out << "plot "; for (size_t lambda = from; lambda != to; ++lambda) { - // out << " '-' using 1:2 title 'l" << lambda << "' with lp"; out << " '-' using 1:2 notitle with lp"; if (lambda + 1 != to) { out << ", \\"; @@ -1261,8 +1259,8 @@ void Persistence_landscape_on_grid::plot(const char* filename, double min_x, dou } out << "EOF" << std::endl; } - std::cout << "Gnuplot script to visualize persistence diagram written to the file: " << nameStr << ". Type load '" - << nameStr << "' in gnuplot to visualize." << std::endl; + std::cout << "To visualize, install gnuplot and type the command: gnuplot -persist -e \"load \'" + << gnuplot_script.str().c_str() << "\'\"" << std::endl; } template diff --git a/src/Persistence_representations/include/gudhi/Persistence_vectors.h b/src/Persistence_representations/include/gudhi/Persistence_vectors.h index 0fb49eee..39df37e0 100644 --- a/src/Persistence_representations/include/gudhi/Persistence_vectors.h +++ b/src/Persistence_representations/include/gudhi/Persistence_vectors.h @@ -201,7 +201,8 @@ class Vector_distances_in_diagram { } out << std::endl; out.close(); - std::cout << "To visualize, open gnuplot and type: load \'" << gnuplot_script.str().c_str() << "\'" << std::endl; + std::cout << "To visualize, install gnuplot and type the command: gnuplot -persist -e \"load \'" + << gnuplot_script.str().c_str() << "\'\"" << std::endl; } /** diff --git a/src/Persistence_representations/utilities/CMakeLists.txt b/src/Persistence_representations/utilities/CMakeLists.txt index 66524666..d0d93f9d 100644 --- a/src/Persistence_representations/utilities/CMakeLists.txt +++ b/src/Persistence_representations/utilities/CMakeLists.txt @@ -1,3 +1,51 @@ +# Copy files, otherwise result files are created in sources +file(COPY "${CMAKE_SOURCE_DIR}/data/persistence_diagram/first.pers" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/") +file(COPY "${CMAKE_SOURCE_DIR}/data/persistence_diagram/second.pers" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/") + +function(add_persistence_representation_creation_utility creation_utility) + add_executable ( ${creation_utility} ${creation_utility}.cpp ) + + # as the function is called in a subdirectory level, need to '../' to find persistence files + # ARGN will add all the other arguments (except creation_utility) sent to the CMake functions + add_test(NAME Persistence_representation_utilities_${creation_utility} COMMAND $ + ${ARGN} "${CMAKE_CURRENT_BINARY_DIR}/../first.pers" + "${CMAKE_CURRENT_BINARY_DIR}/../second.pers") +endfunction(add_persistence_representation_creation_utility) + +function(add_persistence_representation_plot_utility plot_utility tool_extension) + add_executable ( ${plot_utility} ${plot_utility}.cpp ) + + # as the function is called in a subdirectory level, need to '../' to find persistence heat maps files + add_test(NAME Persistence_representation_utilities_${plot_utility}_first COMMAND $ + "${CMAKE_CURRENT_BINARY_DIR}/../first.pers${tool_extension}") + add_test(NAME Persistence_representation_utilities_${plot_utility}_second COMMAND $ + "${CMAKE_CURRENT_BINARY_DIR}/../second.pers${tool_extension}") + if(GNUPLOT_PATH) + add_test(NAME Persistence_representation_utilities_${plot_utility}_first_gnuplot COMMAND ${GNUPLOT_PATH} + "-e" "load '${CMAKE_CURRENT_BINARY_DIR}/../first.pers${tool_extension}_GnuplotScript'") + add_test(NAME Persistence_representation_utilities_${plot_utility}_second_gnuplot COMMAND ${GNUPLOT_PATH} + "-e" "load '${CMAKE_CURRENT_BINARY_DIR}/../second.pers${tool_extension}_GnuplotScript'") + endif() +endfunction(add_persistence_representation_plot_utility) + +function(add_persistence_representation_function_utility function_utility tool_extension) + add_executable ( ${function_utility} ${function_utility}.cpp ) + + # ARGV2 is an optional argument + if (${ARGV2}) + # as the function is called in a subdirectory level, need to '../' to find persistence heat maps files + add_test(NAME Persistence_representation_utilities_${function_utility} COMMAND $ + "${ARGV2}" + "${CMAKE_CURRENT_BINARY_DIR}/../first.pers${tool_extension}" + "${CMAKE_CURRENT_BINARY_DIR}/../second.pers${tool_extension}") + else() + # as the function is called in a subdirectory level, need to '../' to find persistence heat maps files + add_test(NAME Persistence_representation_utilities_${function_utility} COMMAND $ + "${CMAKE_CURRENT_BINARY_DIR}/../first.pers${tool_extension}" + "${CMAKE_CURRENT_BINARY_DIR}/../second.pers${tool_extension}") + endif() +endfunction(add_persistence_representation_function_utility) + add_subdirectory(persistence_heat_maps) add_subdirectory(persistence_intervals) add_subdirectory(persistence_landscapes) diff --git a/src/Persistence_representations/utilities/persistence_heat_maps/CMakeLists.txt b/src/Persistence_representations/utilities/persistence_heat_maps/CMakeLists.txt index 0dd63852..386e9fa5 100644 --- a/src/Persistence_representations/utilities/persistence_heat_maps/CMakeLists.txt +++ b/src/Persistence_representations/utilities/persistence_heat_maps/CMakeLists.txt @@ -1,63 +1,15 @@ cmake_minimum_required(VERSION 2.6) project(Persistence_representations_heat_maps_utilities) -file(COPY "${CMAKE_SOURCE_DIR}/data/persistence_diagram/simple_diagram.txt" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/") - -add_executable ( create_persistence_heat_maps create_persistence_heat_maps.cpp ) -target_link_libraries(create_persistence_heat_maps ${Boost_SYSTEM_LIBRARY}) - -add_test(NAME create_persistence_heat_maps COMMAND $ - "10" "-1" "-1" "4" "-1" "${CMAKE_CURRENT_BINARY_DIR}/simple_diagram.txt") - - -add_executable ( create_pssk create_pssk.cpp ) -target_link_libraries(create_pssk ${Boost_SYSTEM_LIBRARY}) - -add_test(NAME create_pssk COMMAND $ - "10" "-1" "-1" "4" "-1" "${CMAKE_CURRENT_BINARY_DIR}/simple_diagram.txt") - -add_executable ( create_p_h_m_weighted_by_distance_from_diagonal create_p_h_m_weighted_by_distance_from_diagonal.cpp ) -target_link_libraries(create_p_h_m_weighted_by_distance_from_diagonal ${Boost_SYSTEM_LIBRARY}) - -add_test(NAME create_p_h_m_weighted_by_distance_from_diagonal COMMAND $ - "10" "-1" "-1" "4" "-1" "${CMAKE_CURRENT_BINARY_DIR}/simple_diagram.txt") - -add_executable ( create_p_h_m_weighted_by_squared_diag_distance create_p_h_m_weighted_by_squared_diag_distance.cpp ) -target_link_libraries(create_p_h_m_weighted_by_squared_diag_distance ${Boost_SYSTEM_LIBRARY}) - -add_test(NAME create_p_h_m_weighted_by_squared_diag_distance COMMAND $ - "10" "-1" "-1" "4" "-1" "${CMAKE_CURRENT_BINARY_DIR}/simple_diagram.txt") - -add_executable ( create_p_h_m_weighted_by_arctan_of_their_persistence create_p_h_m_weighted_by_arctan_of_their_persistence.cpp ) -target_link_libraries(create_p_h_m_weighted_by_arctan_of_their_persistence ${Boost_SYSTEM_LIBRARY}) - -add_test(NAME create_p_h_m_weighted_by_arctan_of_their_persistence COMMAND $ - "10" "-1" "-1" "4" "-1" "${CMAKE_CURRENT_BINARY_DIR}/simple_diagram.txt") - -add_executable ( average_persistence_heat_maps average_persistence_heat_maps.cpp ) -target_link_libraries(average_persistence_heat_maps ${Boost_SYSTEM_LIBRARY}) - -add_test(NAME average_persistence_heat_maps COMMAND $ - "${CMAKE_CURRENT_BINARY_DIR}/simple_diagram.txt" - "${CMAKE_CURRENT_BINARY_DIR}/simple_diagram.txt") - -add_executable ( plot_persistence_heat_map plot_persistence_heat_map.cpp ) -target_link_libraries(plot_persistence_heat_map ${Boost_SYSTEM_LIBRARY}) - -add_test(NAME plot_persistence_heat_map COMMAND $ - "${CMAKE_CURRENT_BINARY_DIR}/simple_diagram.txt") - -add_executable ( compute_distance_of_persistence_heat_maps compute_distance_of_persistence_heat_maps.cpp ) -target_link_libraries(compute_distance_of_persistence_heat_maps ${Boost_SYSTEM_LIBRARY}) - -add_test(NAME compute_distance_of_persistence_heat_maps COMMAND $ - "1" - "${CMAKE_CURRENT_BINARY_DIR}/simple_diagram.txt" - "${CMAKE_CURRENT_BINARY_DIR}/simple_diagram.txt") - -add_executable ( compute_scalar_product_of_persistence_heat_maps compute_scalar_product_of_persistence_heat_maps.cpp ) -target_link_libraries(compute_scalar_product_of_persistence_heat_maps ${Boost_SYSTEM_LIBRARY}) - -add_test(NAME compute_scalar_product_of_persistence_heat_maps COMMAND $ - "${CMAKE_CURRENT_BINARY_DIR}/simple_diagram.txt" - "${CMAKE_CURRENT_BINARY_DIR}/simple_diagram.txt") +add_persistence_representation_creation_utility(create_pssk "10" "-1" "-1" "4" "-1") +add_persistence_representation_creation_utility(create_p_h_m_weighted_by_arctan_of_their_persistence "10" "-1" "-1" "4" "-1") +add_persistence_representation_creation_utility(create_p_h_m_weighted_by_distance_from_diagonal "10" "-1" "-1" "4" "-1") +add_persistence_representation_creation_utility(create_p_h_m_weighted_by_squared_diag_distance "10" "-1" "-1" "4" "-1") +# Need to set grid min and max for further average, distance and scalar_product +add_persistence_representation_creation_utility(create_persistence_heat_maps "10" "0" "35" "10" "-1") + +add_persistence_representation_plot_utility(plot_persistence_heat_map ".mps") + +add_persistence_representation_function_utility(average_persistence_heat_maps ".mps") +add_persistence_representation_function_utility(compute_distance_of_persistence_heat_maps ".mps" "1") +add_persistence_representation_function_utility(compute_scalar_product_of_persistence_heat_maps ".mps") diff --git a/src/Persistence_representations/utilities/persistence_heat_maps/average_persistence_heat_maps.cpp b/src/Persistence_representations/utilities/persistence_heat_maps/average_persistence_heat_maps.cpp index 4e81375a..6739e0b6 100644 --- a/src/Persistence_representations/utilities/persistence_heat_maps/average_persistence_heat_maps.cpp +++ b/src/Persistence_representations/utilities/persistence_heat_maps/average_persistence_heat_maps.cpp @@ -29,21 +29,20 @@ using constant_scaling_function = Gudhi::Persistence_representations::constant_s using Persistence_heat_maps = Gudhi::Persistence_representations::Persistence_heat_maps; int main(int argc, char** argv) { - std::cout << "This program computes average persistence landscape of persistence landscapes created based on " - "persistence diagrams provided as an input. Please call this program with the names of files with " - "persistence diagrams \n"; - std::vector filenames; + std::cout << "This program computes average of persistence heat maps stored in files (the files needs to be " + << "created beforehand).\n" + << "The parameters of this programs are names of files with persistence heat maps.\n"; - if (argc == 1) { - std::cout << "No input files given, the program will now terminate \n"; + if (argc < 3) { + std::cout << "Wrong number of parameters, the program will now terminate \n"; return 1; } + std::vector filenames; for (int i = 1; i < argc; ++i) { filenames.push_back(argv[i]); } - std::cout << "Creating persistence landscapes...\n"; std::vector maps; for (size_t i = 0; i != filenames.size(); ++i) { Persistence_heat_maps* l = new Persistence_heat_maps; @@ -53,13 +52,12 @@ int main(int argc, char** argv) { Persistence_heat_maps av; av.compute_average(maps); - av.print_to_file("average.mps"); for (size_t i = 0; i != filenames.size(); ++i) { delete maps[i]; } - std::cout << "Done \n"; + std::cout << "Average can be found in 'average.mps' file\n"; return 0; } diff --git a/src/Persistence_representations/utilities/persistence_heat_maps/compute_distance_of_persistence_heat_maps.cpp b/src/Persistence_representations/utilities/persistence_heat_maps/compute_distance_of_persistence_heat_maps.cpp index befb0837..ed8278a2 100644 --- a/src/Persistence_representations/utilities/persistence_heat_maps/compute_distance_of_persistence_heat_maps.cpp +++ b/src/Persistence_representations/utilities/persistence_heat_maps/compute_distance_of_persistence_heat_maps.cpp @@ -31,11 +31,11 @@ using constant_scaling_function = Gudhi::Persistence_representations::constant_s using Persistence_heat_maps = Gudhi::Persistence_representations::Persistence_heat_maps; int main(int argc, char** argv) { - std::cout << "This program computes distance of persistence heat maps stored in a file (the file needs to be created " - "beforehand). \n"; - std::cout << "The first parameter of a program is an integer p. The program compute L^p distance of the two heat " - "maps. For L^infty distance choose p = -1. \n"; - std::cout << "The remaining parameters of this program are names of files with persistence heat maps.\n"; + std::cout << "This program computes distance of persistence heat maps stored in files (the files needs to be " + << "created beforehand).\n" + << "The first parameter of a program is an integer p. The program compute L^p distance of the two heat " + << "maps. For L^infty distance choose p = -1. \n" + << "The remaining parameters of this program are names of files with persistence heat maps.\n"; if (argc < 3) { std::cout << "Wrong number of parameters, the program will now terminate \n"; @@ -78,7 +78,7 @@ int main(int argc, char** argv) { // and now output the result to the screen and a file: std::ofstream out; - out.open("distance"); + out.open("distance.mps"); for (size_t i = 0; i != distance.size(); ++i) { for (size_t j = 0; j != distance.size(); ++j) { std::cout << distance[i][j] << " "; @@ -89,5 +89,6 @@ int main(int argc, char** argv) { } out.close(); + std::cout << "Distance can be found in 'distance.mps' file\n"; return 0; } diff --git a/src/Persistence_representations/utilities/persistence_heat_maps/compute_scalar_product_of_persistence_heat_maps.cpp b/src/Persistence_representations/utilities/persistence_heat_maps/compute_scalar_product_of_persistence_heat_maps.cpp index c684a336..63626853 100644 --- a/src/Persistence_representations/utilities/persistence_heat_maps/compute_scalar_product_of_persistence_heat_maps.cpp +++ b/src/Persistence_representations/utilities/persistence_heat_maps/compute_scalar_product_of_persistence_heat_maps.cpp @@ -30,9 +30,14 @@ using constant_scaling_function = Gudhi::Persistence_representations::constant_s using Persistence_heat_maps = Gudhi::Persistence_representations::Persistence_heat_maps; int main(int argc, char** argv) { - std::cout << "This program computes scalar product of persistence landscapes stored in a file (the file needs to be " - "created beforehand). \n"; - std::cout << "The parameters of this programs are names of files with persistence landscapes.\n"; + std::cout << "This program computes scalar product of persistence heat maps stored in a file (the file needs to be " + << "created beforehand). \n" + << "The parameters of this programs are names of files with persistence heat maps.\n"; + + if (argc < 3) { + std::cout << "Wrong number of parameters, the program will now terminate \n"; + return 1; + } std::vector filenames; for (int i = 1; i < argc; ++i) { @@ -64,7 +69,7 @@ int main(int argc, char** argv) { // and now output the result to the screen and a file: std::ofstream out; - out.open("scalar_product"); + out.open("scalar_product.mps"); for (size_t i = 0; i != scalar_product.size(); ++i) { for (size_t j = 0; j != scalar_product.size(); ++j) { std::cout << scalar_product[i][j] << " "; @@ -75,5 +80,6 @@ int main(int argc, char** argv) { } out.close(); + std::cout << "Distance can be found in 'scalar_product.mps' file\n"; return 0; } diff --git a/src/Persistence_representations/utilities/persistence_heat_maps/create_p_h_m_weighted_by_arctan_of_their_persistence.cpp b/src/Persistence_representations/utilities/persistence_heat_maps/create_p_h_m_weighted_by_arctan_of_their_persistence.cpp index 2bf185a3..47c70484 100644 --- a/src/Persistence_representations/utilities/persistence_heat_maps/create_p_h_m_weighted_by_arctan_of_their_persistence.cpp +++ b/src/Persistence_representations/utilities/persistence_heat_maps/create_p_h_m_weighted_by_arctan_of_their_persistence.cpp @@ -32,22 +32,22 @@ using Persistence_heat_maps = Gudhi::Persistence_representations::Persistence_heat_maps; int main(int argc, char** argv) { - std::cout << "This program creates persistence heat map of diagrams provided as an input. The Gaussian kernels are " - "weighted by the arc tangential of their persistence.\n"; - std::cout << "The first parameter of a program is an integer, a size of a grid.\n"; - std::cout << "The second and third parameters are min and max of the grid. If you want those numbers to be computed " - "based on the data, set them both to -1 \n"; - std::cerr << "The fourth parameter is an integer, the standard deviation of a Gaussian kernel expressed in a number " - "of pixels \n"; - std::cout << "The fifth parameter of this program is a dimension of persistence that will be used in creation of the " - "persistence heat maps."; - std::cout << "If our input files contain persistence pairs of various dimension, as a fifth parameter of the " - "procedure please provide the dimension of persistence you want to use."; - std::cout << "If in your file there are only birth-death pairs of the same dimension, set the first parameter to -1." - << std::endl; - std::cout << "The remaining parameters are the names of files with persistence diagrams. \n"; + std::cout << "This program creates persistence heat map files (*.mps) of persistence diagrams files (*.pers) " + << "provided as an input.The Gaussian kernels are weighted by the arc tangential of their persistence.\n" + << "The first parameter of a program is an integer, a size of a grid.\n" + << "The second and third parameters are min and max of the grid. If you want those numbers to be computed " + << "based on the data, set them both to -1 \n" + << "The fourth parameter is an integer, the standard deviation of a Gaussian kernel expressed in a number " + << "of pixels.\n" + << "The fifth parameter of this program is a dimension of persistence that will be used in creation of " + << "the persistence heat maps." + << "If your input files contains persistence pairs of various dimension, as a fifth parameter of the " + << "procedure please provide the dimension of persistence you want to use." + << "If in your files there are only birth-death pairs of the same dimension, set the fifth parameter to " + << "-1.\n" + << "The remaining parameters are the names of files with persistence diagrams. \n"; - if (argc < 5) { + if (argc < 7) { std::cout << "Wrong parameter list, the program will now terminate \n"; return 1; } @@ -68,9 +68,7 @@ int main(int argc, char** argv) { filenames.push_back(argv[i]); } - std::cout << "Creating persistence heat maps...\n"; std::vector > filter = Gudhi::Persistence_representations::create_Gaussian_filter(stdiv, 1); - for (size_t i = 0; i != filenames.size(); ++i) { std::cout << "Creating a heat map based on a file : " << filenames[i] << std::endl; Persistence_heat_maps l(filenames[i], filter, false, size_of_grid, min_, max_, dimension); @@ -79,6 +77,5 @@ int main(int argc, char** argv) { ss << filenames[i] << ".mps"; l.print_to_file(ss.str().c_str()); } - std::cout << "Done \n"; return 0; } diff --git a/src/Persistence_representations/utilities/persistence_heat_maps/create_p_h_m_weighted_by_distance_from_diagonal.cpp b/src/Persistence_representations/utilities/persistence_heat_maps/create_p_h_m_weighted_by_distance_from_diagonal.cpp index ec9477f1..659a5105 100644 --- a/src/Persistence_representations/utilities/persistence_heat_maps/create_p_h_m_weighted_by_distance_from_diagonal.cpp +++ b/src/Persistence_representations/utilities/persistence_heat_maps/create_p_h_m_weighted_by_distance_from_diagonal.cpp @@ -32,22 +32,23 @@ using Persistence_heat_maps = Gudhi::Persistence_representations::Persistence_heat_maps; int main(int argc, char** argv) { - std::cout << "This program creates persistence heat map of diagrams provided as an input. The Gaussian kernels are " - "weighted by the distance of a center from the diagonal.\n"; - std::cout << "The first parameter of a program is an integer, a size of a grid.\n"; - std::cout << "The second and third parameters are min and max of the grid. If you want those numbers to be computed " - "based on the data, set them both to -1 \n"; - std::cerr << "The fourth parameter is an integer, the standard deviation of a Gaussian kernel expressed in a number " - "of pixels \n"; - std::cout << "The fifth parameter of this program is a dimension of persistence that will be used in creation of the " - "persistence heat maps."; - std::cout << "If our input files contain persistence pairs of various dimension, as a fifth parameter of the " - "procedure please provide the dimension of persistence you want to use."; - std::cout << "If in your file there are only birth-death pairs of the same dimension, set the first parameter to -1." - << std::endl; - std::cout << "The remaining parameters are the names of files with persistence diagrams. \n"; + std::cout << "This program creates persistence heat map files (*.mps) of persistence diagrams files (*.pers) " + << "provided as an input.The Gaussian kernels are weighted by the distance of a center from the " + << "diagonal.\n" + << "The first parameter of a program is an integer, a size of a grid.\n" + << "The second and third parameters are min and max of the grid. If you want those numbers to be computed " + << "based on the data, set them both to -1 \n" + << "The fourth parameter is an integer, the standard deviation of a Gaussian kernel expressed in a number " + << "of pixels.\n" + << "The fifth parameter of this program is a dimension of persistence that will be used in creation of " + << "the persistence heat maps." + << "If your input files contains persistence pairs of various dimension, as a fifth parameter of the " + << "procedure please provide the dimension of persistence you want to use." + << "If in your files there are only birth-death pairs of the same dimension, set the fifth parameter to " + << "-1.\n" + << "The remaining parameters are the names of files with persistence diagrams. \n"; - if (argc < 5) { + if (argc < 7) { std::cout << "Wrong parameter list, the program will now terminate \n"; return 1; } @@ -68,9 +69,7 @@ int main(int argc, char** argv) { filenames.push_back(argv[i]); } - std::cout << "Creating persistence heat maps...\n"; std::vector > filter = Gudhi::Persistence_representations::create_Gaussian_filter(stdiv, 1); - for (size_t i = 0; i != filenames.size(); ++i) { std::cout << "Creating a heat map based on a file : " << filenames[i] << std::endl; Persistence_heat_maps l(filenames[i], filter, false, size_of_grid, min_, max_, dimension); @@ -79,6 +78,5 @@ int main(int argc, char** argv) { ss << filenames[i] << ".mps"; l.print_to_file(ss.str().c_str()); } - std::cout << "Done \n"; return 0; } diff --git a/src/Persistence_representations/utilities/persistence_heat_maps/create_p_h_m_weighted_by_squared_diag_distance.cpp b/src/Persistence_representations/utilities/persistence_heat_maps/create_p_h_m_weighted_by_squared_diag_distance.cpp index ffec8b3d..9497b188 100644 --- a/src/Persistence_representations/utilities/persistence_heat_maps/create_p_h_m_weighted_by_squared_diag_distance.cpp +++ b/src/Persistence_representations/utilities/persistence_heat_maps/create_p_h_m_weighted_by_squared_diag_distance.cpp @@ -33,22 +33,23 @@ using Persistence_heat_maps = Gudhi::Persistence_representations::Persistence_heat_maps; int main(int argc, char** argv) { - std::cout << "This program creates persistence heat map of diagrams provided as an input. The Gaussian kernels are " - "weighted by the square of distance of a center from the diagonal.\n"; - std::cout << "The first parameter of a program is an integer, a size of a grid.\n"; - std::cout << "The second and third parameters are min and max of the grid. If you want those numbers to be computed " - "based on the data, set them both to -1 \n"; - std::cerr << "The fourth parameter is an integer, the standard deviation of a Gaussian kernel expressed in a number " - "of pixels \n"; - std::cout << "The fifth parameter of this program is a dimension of persistence that will be used in creation of the " - "persistence heat maps."; - std::cout << "If our input files contain persistence pairs of various dimension, as a fifth parameter of the " - "procedure please provide the dimension of persistence you want to use."; - std::cout << "If in your file there are only birth-death pairs of the same dimension, set the first parameter to -1." - << std::endl; - std::cout << "The remaining parameters are the names of files with persistence diagrams. \n"; + std::cout << "This program creates persistence heat map files (*.mps) of persistence diagrams files (*.pers) " + << "provided as an input.The Gaussian kernels are weighted by the square of distance of a center from the " + << "diagonal.\n" + << "The first parameter of a program is an integer, a size of a grid.\n" + << "The second and third parameters are min and max of the grid. If you want those numbers to be computed " + << "based on the data, set them both to -1 \n" + << "The fourth parameter is an integer, the standard deviation of a Gaussian kernel expressed in a number " + << "of pixels.\n" + << "The fifth parameter of this program is a dimension of persistence that will be used in creation of " + << "the persistence heat maps." + << "If your input files contains persistence pairs of various dimension, as a fifth parameter of the " + << "procedure please provide the dimension of persistence you want to use." + << "If in your files there are only birth-death pairs of the same dimension, set the fifth parameter to " + << "-1.\n" + << "The remaining parameters are the names of files with persistence diagrams. \n"; - if (argc < 5) { + if (argc < 7) { std::cout << "Wrong parameter list, the program will now terminate \n"; return 1; } @@ -69,9 +70,7 @@ int main(int argc, char** argv) { filenames.push_back(argv[i]); } - std::cout << "Creating persistence heat maps...\n"; std::vector > filter = Gudhi::Persistence_representations::create_Gaussian_filter(stdiv, 1); - for (size_t i = 0; i != filenames.size(); ++i) { std::cout << "Creating a heat map based on a file : " << filenames[i] << std::endl; Persistence_heat_maps l(filenames[i], filter, false, size_of_grid, min_, max_, dimension); @@ -80,6 +79,5 @@ int main(int argc, char** argv) { ss << filenames[i] << ".mps"; l.print_to_file(ss.str().c_str()); } - std::cout << "Done \n"; return 0; } diff --git a/src/Persistence_representations/utilities/persistence_heat_maps/create_persistence_heat_maps.cpp b/src/Persistence_representations/utilities/persistence_heat_maps/create_persistence_heat_maps.cpp index db2f0008..25cd1067 100644 --- a/src/Persistence_representations/utilities/persistence_heat_maps/create_persistence_heat_maps.cpp +++ b/src/Persistence_representations/utilities/persistence_heat_maps/create_persistence_heat_maps.cpp @@ -31,21 +31,22 @@ using constant_scaling_function = Gudhi::Persistence_representations::constant_s using Persistence_heat_maps = Gudhi::Persistence_representations::Persistence_heat_maps; int main(int argc, char** argv) { - std::cout << "This program creates persistence heat map of diagrams provided as an input.\n"; - std::cout << "The first parameter of a program is an integer, a size of a grid.\n"; - std::cout << "The second and third parameters are min and max of the grid. If you want those numbers to be computed " - "based on the data, set them both to -1 \n"; - std::cerr << "The fourth parameter is an integer, the standard deviation of a Gaussian kernel expressed in a number " - "of pixels \n"; + std::cout << "This program creates persistence heat map files (*.mps) of persistence diagrams files (*.pers) " + << "provided as an input.\n" + << "The first parameter of a program is an integer, a size of a grid.\n" + << "The second and third parameters are min and max of the grid. If you want those numbers to be computed " + << "based on the data, set them both to -1 \n" + << "The fourth parameter is an integer, the standard deviation of a Gaussian kernel expressed in a number " + << "of pixels.\n" + << "The fifth parameter of this program is a dimension of persistence that will be used in creation of " + << "the persistence heat maps." + << "If your input files contains persistence pairs of various dimension, as a fifth parameter of the " + << "procedure please provide the dimension of persistence you want to use." + << "If in your files there are only birth-death pairs of the same dimension, set the fifth parameter to " + << "-1.\n" + << "The remaining parameters are the names of files with persistence diagrams. \n"; - std::cout << "The fifth parameter of this program is a dimension of persistence that will be used in creation of the " - "persistence heat maps."; - std::cout << "If your input file contains persistence pairs of various dimension, as a fifth parameter of the " - "procedure please provide the dimension of persistence you want to use."; - std::cout << "If in your file there are only birth-death pairs of the same dimension, set the first parameter to -1." - << std::endl; - std::cout << "The remaining parameters are the names of files with persistence diagrams. \n"; - if (argc < 5) { + if (argc < 7) { std::cout << "Wrong parameter list, the program will now terminate \n"; return 1; } @@ -64,17 +65,14 @@ int main(int argc, char** argv) { filenames.push_back(argv[i]); } - std::cout << "Creating persistence heat maps...\n"; std::vector > filter = Gudhi::Persistence_representations::create_Gaussian_filter(stdiv, 1); - for (size_t i = 0; i != filenames.size(); ++i) { - std::cout << "Creating a heat map based on a file : " << filenames[i] << std::endl; + std::cout << "Creating a heat map based on file : " << filenames[i] << std::endl; Persistence_heat_maps l(filenames[i], filter, false, size_of_grid, min_, max_, dimension); std::stringstream ss; ss << filenames[i] << ".mps"; l.print_to_file(ss.str().c_str()); } - std::cout << "Done \n"; return 0; } diff --git a/src/Persistence_representations/utilities/persistence_heat_maps/create_pssk.cpp b/src/Persistence_representations/utilities/persistence_heat_maps/create_pssk.cpp index 6aefbb00..97ddb8f0 100644 --- a/src/Persistence_representations/utilities/persistence_heat_maps/create_pssk.cpp +++ b/src/Persistence_representations/utilities/persistence_heat_maps/create_pssk.cpp @@ -30,21 +30,22 @@ using PSSK = Gudhi::Persistence_representations::PSSK; int main(int argc, char** argv) { - std::cout << "This program creates PSSK of diagrams provided as an input.\n"; - std::cout << "The first parameter of a program is an integer, a size of a grid.\n"; - std::cout << "The second and third parameters are min and max of the grid. If you want those numbers to be computed " - "based on the data, set them both to -1 \n"; - std::cerr << "The fourth parameter is an integer, the standard deviation of a Gaussian kernel expressed in a number " - "of pixels \n"; - std::cout << "The fifth parameter of this program is a dimension of persistence that will be used in creation of the " - "persistence heat maps."; - std::cout << "If our input files contain persistence pairs of various dimension, as a fifth parameter of the " - "procedure please provide the dimension of persistence you want to use."; - std::cout << "If in your file there are only birth-death pairs of the same dimension, set the first parameter to -1." - << std::endl; - std::cout << "The remaining parameters are the names of files with persistence diagrams. \n"; + std::cout << "This program creates PSSK files (*.pssk) of persistence diagrams files (*.pers) " + << "provided as an input.\n" + << "The first parameter of a program is an integer, a size of a grid.\n" + << "The second and third parameters are min and max of the grid. If you want those numbers to be computed " + << "based on the data, set them both to -1 \n" + << "The fourth parameter is an integer, the standard deviation of a Gaussian kernel expressed in a number " + << "of pixels.\n" + << "The fifth parameter of this program is a dimension of persistence that will be used in creation of " + << "the PSSK." + << "If your input files contains persistence pairs of various dimension, as a fifth parameter of the " + << "procedure please provide the dimension of persistence you want to use." + << "If in your files there are only birth-death pairs of the same dimension, set the first parameter to " + << "-1.\n" + << "The remaining parameters are the names of files with persistence diagrams. \n"; - if (argc < 5) { + if (argc < 7) { std::cout << "Wrong parameter list, the program will now terminate \n"; return 1; } @@ -65,17 +66,14 @@ int main(int argc, char** argv) { filenames.push_back(argv[i]); } - std::cout << "Creating persistence heat maps...\n"; std::vector > filter = Gudhi::Persistence_representations::create_Gaussian_filter(stdiv, 1); - for (size_t i = 0; i != filenames.size(); ++i) { - std::cout << "Creating a heat map based on a file : " << filenames[i] << std::endl; + std::cout << "Creating a PSSK based on a file : " << filenames[i] << std::endl; PSSK l(filenames[i], filter, size_of_grid, min_, max_, dimension); std::stringstream ss; ss << filenames[i] << ".pssk"; l.print_to_file(ss.str().c_str()); } - std::cout << "Done \n"; return 0; } diff --git a/src/Persistence_representations/utilities/persistence_heat_maps/plot_persistence_heat_map.cpp b/src/Persistence_representations/utilities/persistence_heat_maps/plot_persistence_heat_map.cpp index a7c9f2d8..63711d83 100644 --- a/src/Persistence_representations/utilities/persistence_heat_maps/plot_persistence_heat_map.cpp +++ b/src/Persistence_representations/utilities/persistence_heat_maps/plot_persistence_heat_map.cpp @@ -29,8 +29,12 @@ using constant_scaling_function = Gudhi::Persistence_representations::constant_s using Persistence_heat_maps = Gudhi::Persistence_representations::Persistence_heat_maps; int main(int argc, char** argv) { - std::cout << "This program plot persistence landscape stored in a file (the file needs to be created beforehand). " - "Please call the code with the name of a landscape file \n"; + std::cout << "This program creates a gnuplot script from a persistence heat maps stored in a file (the file needs " + << "to be created beforehand). Please call the code with the name of a single heat maps file \n"; + if (argc != 2) { + std::cout << "Wrong parameter list, the program will now terminate \n"; + return 1; + } Persistence_heat_maps l; l.load_from_file(argv[1]); l.plot(argv[1]); diff --git a/src/Persistence_representations/utilities/persistence_intervals/CMakeLists.txt b/src/Persistence_representations/utilities/persistence_intervals/CMakeLists.txt index 105b7efb..2ba6efe5 100644 --- a/src/Persistence_representations/utilities/persistence_intervals/CMakeLists.txt +++ b/src/Persistence_representations/utilities/persistence_intervals/CMakeLists.txt @@ -4,38 +4,32 @@ project(Persistence_representations_intervals_utilities) file(COPY "${CMAKE_SOURCE_DIR}/data/persistence_diagram/simple_diagram.txt" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/") add_executable ( plot_persistence_intervals plot_persistence_intervals.cpp ) -target_link_libraries( plot_persistence_intervals ${Boost_SYSTEM_LIBRARY}) add_test(NAME plot_persistence_intervals COMMAND $ "${CMAKE_CURRENT_BINARY_DIR}/simple_diagram.txt") add_executable ( compute_birth_death_range_in_persistence_diagram compute_birth_death_range_in_persistence_diagram.cpp ) -target_link_libraries( compute_birth_death_range_in_persistence_diagram ${Boost_SYSTEM_LIBRARY}) add_test(NAME compute_birth_death_range_in_persistence_diagram COMMAND $ "-1" "${CMAKE_CURRENT_BINARY_DIR}/simple_diagram.txt") add_executable ( compute_number_of_dominant_intervals compute_number_of_dominant_intervals.cpp ) -target_link_libraries( compute_number_of_dominant_intervals ${Boost_SYSTEM_LIBRARY}) add_test(NAME compute_number_of_dominant_intervals COMMAND $ "${CMAKE_CURRENT_BINARY_DIR}/simple_diagram.txt" "-1" "2") add_executable ( plot_histogram_of_intervals_lengths plot_histogram_of_intervals_lengths.cpp ) -target_link_libraries( plot_histogram_of_intervals_lengths ${Boost_SYSTEM_LIBRARY}) add_test(NAME plot_histogram_of_intervals_lengths COMMAND $ "${CMAKE_CURRENT_BINARY_DIR}/simple_diagram.txt" "2") add_executable ( plot_persistence_Betti_numbers plot_persistence_Betti_numbers.cpp ) -target_link_libraries( plot_persistence_Betti_numbers ${Boost_SYSTEM_LIBRARY}) add_test(NAME plot_persistence_Betti_numbers COMMAND $ "${CMAKE_CURRENT_BINARY_DIR}/simple_diagram.txt") if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1) add_executable ( compute_bottleneck_distance compute_bottleneck_distance.cpp ) - target_link_libraries( compute_bottleneck_distance ${Boost_SYSTEM_LIBRARY}) if (TBB_FOUND) target_link_libraries(compute_bottleneck_distance ${TBB_LIBRARIES}) endif(TBB_FOUND) diff --git a/src/Persistence_representations/utilities/persistence_landscapes/CMakeLists.txt b/src/Persistence_representations/utilities/persistence_landscapes/CMakeLists.txt index baf8de3c..d7087ed8 100644 --- a/src/Persistence_representations/utilities/persistence_landscapes/CMakeLists.txt +++ b/src/Persistence_representations/utilities/persistence_landscapes/CMakeLists.txt @@ -1,38 +1,10 @@ cmake_minimum_required(VERSION 2.6) -project(Persistence_representations_lanscapes_utilities) +project(Persistence_representations_landscapes_utilities) -file(COPY "${CMAKE_SOURCE_DIR}/data/persistence_diagram/simple_diagram.txt" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/") +add_persistence_representation_creation_utility(create_landscapes "-1") -add_executable ( create_landscapes create_landscapes.cpp ) -target_link_libraries(create_landscapes ${Boost_SYSTEM_LIBRARY}) +add_persistence_representation_plot_utility(plot_landscapes ".land") -# Will create simple_diagram.txt.land -add_test(NAME create_landscapes COMMAND $ - "-1" "${CMAKE_CURRENT_BINARY_DIR}/simple_diagram.txt") - -add_executable ( average_landscapes average_landscapes.cpp ) -target_link_libraries(average_landscapes ${Boost_SYSTEM_LIBRARY}) - -add_test(NAME average_landscapes COMMAND $ - "${CMAKE_CURRENT_BINARY_DIR}/simple_diagram.txt" - "${CMAKE_CURRENT_BINARY_DIR}/simple_diagram.txt") - -add_executable ( plot_landscapes plot_landscapes.cpp ) -target_link_libraries(plot_landscapes ${Boost_SYSTEM_LIBRARY}) - -add_test(NAME plot_landscapes COMMAND $ - "${CMAKE_CURRENT_BINARY_DIR}/simple_diagram.txt") - -add_executable ( compute_distance_of_landscapes compute_distance_of_landscapes.cpp ) -target_link_libraries(compute_distance_of_landscapes ${Boost_SYSTEM_LIBRARY}) - -add_test(NAME compute_distance_of_landscapes COMMAND $ - "1" "${CMAKE_CURRENT_BINARY_DIR}/simple_diagram.txt.land" - "${CMAKE_CURRENT_BINARY_DIR}/simple_diagram.txt.land") - -add_executable ( compute_scalar_product_of_landscapes compute_scalar_product_of_landscapes.cpp ) -target_link_libraries(compute_scalar_product_of_landscapes ${Boost_SYSTEM_LIBRARY}) - -add_test(NAME compute_scalar_product_of_landscapes COMMAND $ - "${CMAKE_CURRENT_BINARY_DIR}/simple_diagram.txt.land" - "${CMAKE_CURRENT_BINARY_DIR}/simple_diagram.txt.land") +add_persistence_representation_function_utility(average_landscapes ".land") +add_persistence_representation_function_utility(compute_distance_of_landscapes ".land" "1") +add_persistence_representation_function_utility(compute_scalar_product_of_landscapes ".land") diff --git a/src/Persistence_representations/utilities/persistence_landscapes/average_landscapes.cpp b/src/Persistence_representations/utilities/persistence_landscapes/average_landscapes.cpp index 526130e9..1a59be8c 100644 --- a/src/Persistence_representations/utilities/persistence_landscapes/average_landscapes.cpp +++ b/src/Persistence_representations/utilities/persistence_landscapes/average_landscapes.cpp @@ -28,14 +28,13 @@ using Persistence_landscape = Gudhi::Persistence_representations::Persistence_landscape; int main(int argc, char** argv) { - std::cout << "This program computes average persistence landscape of persistence landscapes created based on " - "persistence diagrams provided as an input (you must create them first).\n"; - std::cout << "Please call this program with the names of files with persistence landscapes. The program will create " - "a persistence landscape which will be their average \n"; + std::cout << "This program computes average of persistence landscapes stored in files (the files needs to be " + << "created beforehand).\n" + << "The parameters of this programs are names of files with persistence landscapes.\n"; std::vector filenames; - if (argc == 1) { - std::cout << "No input files given, the program will now terminate \n"; + if (argc < 3) { + std::cout << "Wrong number of parameters, the program will now terminate \n"; return 1; } @@ -43,7 +42,6 @@ int main(int argc, char** argv) { filenames.push_back(argv[i]); } - std::cout << "Creating persistence landscapes...\n"; std::vector lands; for (size_t i = 0; i != filenames.size(); ++i) { Persistence_landscape* l = new Persistence_landscape; @@ -60,7 +58,6 @@ int main(int argc, char** argv) { delete lands[i]; } - std::cout << "Done \n"; - + std::cout << "Average can be found in 'average.land' file\n"; return 0; } diff --git a/src/Persistence_representations/utilities/persistence_landscapes/compute_distance_of_landscapes.cpp b/src/Persistence_representations/utilities/persistence_landscapes/compute_distance_of_landscapes.cpp index b3881d6a..5062f521 100644 --- a/src/Persistence_representations/utilities/persistence_landscapes/compute_distance_of_landscapes.cpp +++ b/src/Persistence_representations/utilities/persistence_landscapes/compute_distance_of_landscapes.cpp @@ -30,11 +30,11 @@ using Persistence_landscape = Gudhi::Persistence_representations::Persistence_landscape; int main(int argc, char** argv) { - std::cout << "This program compute distance of persistence landscapes stored in a file (the file needs to be created " - "beforehand). \n"; - std::cout << "The first parameter of a program is an integer p. The program compute L^p distance of the given " - "landscapes. For L^infty distance choose p = -1. \n"; - std::cout << "The remaining parameters of this programs are names of files with persistence landscapes."; + std::cout << "This program computes distance of persistence landscapes stored in files (the files needs to be " + << "created beforehand).\n" + << "The first parameter of a program is an integer p. The program compute L^p distance of the two heat " + << "maps. For L^infty distance choose p = -1. \n" + << "The remaining parameters of this program are names of files with persistence landscapes.\n"; if (argc < 3) { std::cout << "Wrong number of parameters, the program will now terminate \n"; @@ -54,7 +54,6 @@ int main(int argc, char** argv) { std::vector landscaspes; landscaspes.reserve(filenames.size()); for (size_t file_no = 0; file_no != filenames.size(); ++file_no) { - std::cout << "Loading persistence landscape from a file : " << filenames[file_no] << std::endl; Persistence_landscape l; l.load_landscape_from_file(filenames[file_no]); landscaspes.push_back(l); @@ -78,7 +77,7 @@ int main(int argc, char** argv) { // and now output the result to the screen and a file: std::ofstream out; - out.open("distance"); + out.open("distance.land"); for (size_t i = 0; i != distance.size(); ++i) { for (size_t j = 0; j != distance.size(); ++j) { std::cout << distance[i][j] << " "; @@ -89,5 +88,6 @@ int main(int argc, char** argv) { } out.close(); + std::cout << "Distance can be found in 'distance.land' file\n"; return 0; } diff --git a/src/Persistence_representations/utilities/persistence_landscapes/compute_scalar_product_of_landscapes.cpp b/src/Persistence_representations/utilities/persistence_landscapes/compute_scalar_product_of_landscapes.cpp index 8dad7b4d..5b5e9fa3 100644 --- a/src/Persistence_representations/utilities/persistence_landscapes/compute_scalar_product_of_landscapes.cpp +++ b/src/Persistence_representations/utilities/persistence_landscapes/compute_scalar_product_of_landscapes.cpp @@ -29,9 +29,14 @@ using Persistence_landscape = Gudhi::Persistence_representations::Persistence_landscape; int main(int argc, char** argv) { - std::cout << "This program compute scalar product of persistence landscapes stored in a file (the file needs to be " - "created beforehand). \n"; - std::cout << "The parameters of this programs are names of files with persistence landscapes.\n"; + std::cout << "This program computes scalar product of persistence landscapes stored in a file (the file needs to be " + << "created beforehand). \n" + << "The parameters of this programs are names of files with persistence landscapes.\n"; + + if (argc < 3) { + std::cout << "Wrong number of parameters, the program will now terminate \n"; + return 1; + } std::vector filenames; for (int i = 1; i < argc; ++i) { @@ -40,7 +45,6 @@ int main(int argc, char** argv) { std::vector landscaspes; landscaspes.reserve(filenames.size()); for (size_t file_no = 0; file_no != filenames.size(); ++file_no) { - std::cout << "Reading persistence landscape from a file : " << filenames[file_no] << std::endl; Persistence_landscape l; l.load_landscape_from_file(filenames[file_no]); landscaspes.push_back(l); @@ -64,7 +68,7 @@ int main(int argc, char** argv) { // and now output the result to the screen and a file: std::ofstream out; - out.open("scalar_product"); + out.open("scalar_product.land"); for (size_t i = 0; i != scalar_product.size(); ++i) { for (size_t j = 0; j != scalar_product.size(); ++j) { std::cout << scalar_product[i][j] << " "; @@ -75,5 +79,6 @@ int main(int argc, char** argv) { } out.close(); + std::cout << "Distance can be found in 'scalar_product.land' file\n"; return 0; } diff --git a/src/Persistence_representations/utilities/persistence_landscapes/create_landscapes.cpp b/src/Persistence_representations/utilities/persistence_landscapes/create_landscapes.cpp index 325081d1..6030e994 100644 --- a/src/Persistence_representations/utilities/persistence_landscapes/create_landscapes.cpp +++ b/src/Persistence_representations/utilities/persistence_landscapes/create_landscapes.cpp @@ -30,13 +30,20 @@ using Persistence_landscape = Gudhi::Persistence_representations::Persistence_landscape; int main(int argc, char** argv) { - std::cout << "This program creates persistence landscapes of diagrams provided as an input. \n"; - std::cout << "The first parameter of the program is the dimension of persistence to be used to construct persistence " - "landscapes. If your file contains "; - std::cout << "the information about dimension of persistence pairs, please provide here the dimension of persistence " - "pairs you want to use. If your input files consist only "; - std::cout << "of birth-death pairs, please set this first parameter to -1 \n"; - std::cout << "The remaining parameters of the program are the names of files with persistence diagrams. \n"; + std::cout << "This program creates persistence landscapes files (*.land) of persistence diagrams files (*.pers) " + << "provided as an input.\n" + << "The first parameter of this program is a dimension of persistence that will be used in creation of " + << "the persistence heat maps." + << "If your input files contains persistence pairs of various dimension, as a first parameter of the " + << "procedure please provide the dimension of persistence you want to use." + << "If in your files there are only birth-death pairs of the same dimension, set the first parameter to " + << "-1.\n" + << "The remaining parameters are the names of files with persistence diagrams. \n"; + + if (argc < 3) { + std::cout << "Wrong parameter list, the program will now terminate \n"; + return 1; + } std::vector filenames; int dim = atoi(argv[1]); unsigned dimension = std::numeric_limits::max(); @@ -47,13 +54,12 @@ int main(int argc, char** argv) { filenames.push_back(argv[i]); } - std::cout << "Creating persistence landscapes...\n"; for (size_t i = 0; i != filenames.size(); ++i) { + std::cout << "Creating a landscape based on file : " << filenames[i] << std::endl; Persistence_landscape l(filenames[i], dimension); std::stringstream ss; ss << filenames[i] << ".land"; l.print_to_file(ss.str().c_str()); } - std::cout << "Done \n"; return 0; } diff --git a/src/Persistence_representations/utilities/persistence_landscapes/plot_landscapes.cpp b/src/Persistence_representations/utilities/persistence_landscapes/plot_landscapes.cpp index ebdb20a1..c797a7a8 100644 --- a/src/Persistence_representations/utilities/persistence_landscapes/plot_landscapes.cpp +++ b/src/Persistence_representations/utilities/persistence_landscapes/plot_landscapes.cpp @@ -28,16 +28,16 @@ using Persistence_landscape = Gudhi::Persistence_representations::Persistence_landscape; int main(int argc, char** argv) { - std::cout << "This program plot persistence landscape stored in a file (the file needs to be created beforehand). " - "Please call the code with the name of a landscape file \n"; + std::cout << "This program creates a gnuplot script from a persistence landscape stored in a file (the file needs " + << "to be created beforehand). Please call the code with the name of a single landscape file.\n"; + if (argc != 2) { + std::cout << "Wrong parameter list, the program will now terminate \n"; + return 1; + } + Persistence_landscape l; l.load_landscape_from_file(argv[1]); - - std::stringstream ss; - ss << argv[1] << "_gnuplot_script"; - l.plot(ss.str().c_str()); - - std::cout << "Done \n"; + l.plot(argv[1]); return 0; } diff --git a/src/Persistence_representations/utilities/persistence_landscapes_on_grid/CMakeLists.txt b/src/Persistence_representations/utilities/persistence_landscapes_on_grid/CMakeLists.txt index 55a4fd50..c5ea4bbf 100644 --- a/src/Persistence_representations/utilities/persistence_landscapes_on_grid/CMakeLists.txt +++ b/src/Persistence_representations/utilities/persistence_landscapes_on_grid/CMakeLists.txt @@ -1,38 +1,11 @@ cmake_minimum_required(VERSION 2.6) project(Persistence_representations_lanscapes_on_grid_utilities) -file(COPY "${CMAKE_SOURCE_DIR}/data/persistence_diagram/simple_diagram.txt" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/") +# Need to set grid min and max for further average, distance and scalar_product +add_persistence_representation_creation_utility(create_landscapes_on_grid "100" "0" "35" "-1") -add_executable ( create_landscapes_on_grid create_landscapes_on_grid.cpp ) -target_link_libraries(create_landscapes_on_grid ${Boost_SYSTEM_LIBRARY}) +add_persistence_representation_plot_utility(plot_landscapes_on_grid ".g_land") -# Will create simple_diagram.txt.land -add_test(NAME create_landscapes_on_grid COMMAND $ - "100" "-1" "-1" "-1" "${CMAKE_CURRENT_BINARY_DIR}/simple_diagram.txt") - -add_executable ( average_landscapes_on_grid average_landscapes_on_grid.cpp ) -target_link_libraries(average_landscapes_on_grid ${Boost_SYSTEM_LIBRARY}) - -add_test(NAME average_landscapes_on_grid COMMAND $ - "${CMAKE_CURRENT_BINARY_DIR}/simple_diagram.txt.g_land" - "${CMAKE_CURRENT_BINARY_DIR}/simple_diagram.txt.g_land") - -add_executable ( plot_landscapes_on_grid plot_landscapes_on_grid.cpp ) -target_link_libraries(plot_landscapes_on_grid ${Boost_SYSTEM_LIBRARY}) - -add_test(NAME plot_landscapes_on_grid COMMAND $ - "${CMAKE_CURRENT_BINARY_DIR}/simple_diagram.txt.g_land") - -add_executable ( compute_distance_of_landscapes_on_grid compute_distance_of_landscapes_on_grid.cpp ) -target_link_libraries(compute_distance_of_landscapes_on_grid ${Boost_SYSTEM_LIBRARY}) - -add_test(NAME compute_distance_of_landscapes_on_grid COMMAND $ - "${CMAKE_CURRENT_BINARY_DIR}/simple_diagram.txt.g_land" - "${CMAKE_CURRENT_BINARY_DIR}/simple_diagram.txt.g_land") - -add_executable ( compute_scalar_product_of_landscapes_on_grid compute_scalar_product_of_landscapes_on_grid.cpp ) -target_link_libraries(compute_scalar_product_of_landscapes_on_grid ${Boost_SYSTEM_LIBRARY}) - -add_test(NAME compute_scalar_product_of_landscapes_on_grid COMMAND $ - "${CMAKE_CURRENT_BINARY_DIR}/simple_diagram.txt.g_land" - "${CMAKE_CURRENT_BINARY_DIR}/simple_diagram.txt.g_land") +add_persistence_representation_function_utility(average_landscapes_on_grid ".g_land") +add_persistence_representation_function_utility(compute_distance_of_landscapes_on_grid ".g_land" "1") +add_persistence_representation_function_utility(compute_scalar_product_of_landscapes_on_grid ".g_land") diff --git a/src/Persistence_representations/utilities/persistence_landscapes_on_grid/average_landscapes_on_grid.cpp b/src/Persistence_representations/utilities/persistence_landscapes_on_grid/average_landscapes_on_grid.cpp index d50118a0..0b098d1a 100644 --- a/src/Persistence_representations/utilities/persistence_landscapes_on_grid/average_landscapes_on_grid.cpp +++ b/src/Persistence_representations/utilities/persistence_landscapes_on_grid/average_landscapes_on_grid.cpp @@ -28,21 +28,20 @@ using Persistence_landscape_on_grid = Gudhi::Persistence_representations::Persistence_landscape_on_grid; int main(int argc, char** argv) { - std::cout << "This program computes average persistence landscape on grid of persistence landscapes on grid created " - "based on persistence diagrams provided as an input. Please call this program with the names of files " - "with persistence diagrams \n"; - std::vector filenames; + std::cout << "This program computes average of persistence landscapes on grid stored in files (the files needs to " + << "be created beforehand).\n" + << "The parameters of this programs are names of files with persistence landscapes on grid.\n"; - if (argc == 1) { - std::cout << "No input files given, the program will now terminate \n"; + if (argc < 3) { + std::cout << "Wrong number of parameters, the program will now terminate \n"; return 1; } + std::vector filenames; for (int i = 1; i < argc; ++i) { filenames.push_back(argv[i]); } - std::cout << "Creating persistence landscapes...\n"; std::vector lands; for (size_t i = 0; i != filenames.size(); ++i) { Persistence_landscape_on_grid* l = new Persistence_landscape_on_grid; @@ -59,7 +58,6 @@ int main(int argc, char** argv) { delete lands[i]; } - std::cout << "Done \n"; - + std::cout << "Average can be found in 'average.g_land' file\n"; return 0; } diff --git a/src/Persistence_representations/utilities/persistence_landscapes_on_grid/compute_distance_of_landscapes_on_grid.cpp b/src/Persistence_representations/utilities/persistence_landscapes_on_grid/compute_distance_of_landscapes_on_grid.cpp index 859c6991..fd0fcd15 100644 --- a/src/Persistence_representations/utilities/persistence_landscapes_on_grid/compute_distance_of_landscapes_on_grid.cpp +++ b/src/Persistence_representations/utilities/persistence_landscapes_on_grid/compute_distance_of_landscapes_on_grid.cpp @@ -30,11 +30,11 @@ using Persistence_landscape_on_grid = Gudhi::Persistence_representations::Persistence_landscape_on_grid; int main(int argc, char** argv) { - std::cout << "This program compute distance of persistence landscapes on grid stored in a file (the file needs to be " - "created beforehand). \n"; - std::cout << "The first parameter of a program is an integer p. The program compute L^p distance of the landscapes " - "on grid. For L^infty distance choose p = -1. \n"; - std::cout << "The remaining parameters of this programs are names of files with persistence landscapes on grid.\n"; + std::cout << "This program computes distance of persistence landscapes on grid stored in files (the files needs to " + << "be created beforehand).\n" + << "The first parameter of a program is an integer p. The program compute L^p distance of the two heat " + << "maps. For L^infty distance choose p = -1. \n" + << "The remaining parameters of this program are names of files with persistence landscapes on grid.\n"; if (argc < 3) { std::cout << "Wrong number of parameters, the program will now terminate \n"; @@ -77,7 +77,7 @@ int main(int argc, char** argv) { // and now output the result to the screen and a file: std::ofstream out; - out.open("distance"); + out.open("distance.g_land"); for (size_t i = 0; i != distance.size(); ++i) { for (size_t j = 0; j != distance.size(); ++j) { std::cout << distance[i][j] << " "; @@ -88,5 +88,6 @@ int main(int argc, char** argv) { } out.close(); + std::cout << "Distance can be found in 'distance.g_land' file\n"; return 0; } diff --git a/src/Persistence_representations/utilities/persistence_landscapes_on_grid/compute_scalar_product_of_landscapes_on_grid.cpp b/src/Persistence_representations/utilities/persistence_landscapes_on_grid/compute_scalar_product_of_landscapes_on_grid.cpp index e95bf8ad..e2222487 100644 --- a/src/Persistence_representations/utilities/persistence_landscapes_on_grid/compute_scalar_product_of_landscapes_on_grid.cpp +++ b/src/Persistence_representations/utilities/persistence_landscapes_on_grid/compute_scalar_product_of_landscapes_on_grid.cpp @@ -29,9 +29,14 @@ using Persistence_landscape_on_grid = Gudhi::Persistence_representations::Persistence_landscape_on_grid; int main(int argc, char** argv) { - std::cout << "This program compute scalar product of persistence landscapes on grid stored in a file (the file needs " - "to be created beforehand). \n"; - std::cout << "The parameters of this programs are names of files with persistence landscapes on grid.\n"; + std::cout << "This program computes scalar product of persistence landscapes on grid stored in a file (the file needs to " + << "be created beforehand). \n" + << "The parameters of this programs are names of files with persistence landscapes on grid.\n"; + + if (argc < 3) { + std::cout << "Wrong number of parameters, the program will now terminate \n"; + return 1; + } std::vector filenames; for (int i = 1; i < argc; ++i) { @@ -63,7 +68,7 @@ int main(int argc, char** argv) { // and now output the result to the screen and a file: std::ofstream out; - out.open("scalar_product"); + out.open("scalar_product.g_land"); for (size_t i = 0; i != scalar_product.size(); ++i) { for (size_t j = 0; j != scalar_product.size(); ++j) { std::cout << scalar_product[i][j] << " "; @@ -74,5 +79,6 @@ int main(int argc, char** argv) { } out.close(); + std::cout << "Distance can be found in 'scalar_product.g_land' file\n"; return 0; } diff --git a/src/Persistence_representations/utilities/persistence_landscapes_on_grid/create_landscapes_on_grid.cpp b/src/Persistence_representations/utilities/persistence_landscapes_on_grid/create_landscapes_on_grid.cpp index 8d747c14..2827f982 100644 --- a/src/Persistence_representations/utilities/persistence_landscapes_on_grid/create_landscapes_on_grid.cpp +++ b/src/Persistence_representations/utilities/persistence_landscapes_on_grid/create_landscapes_on_grid.cpp @@ -30,22 +30,25 @@ using Persistence_landscape_on_grid = Gudhi::Persistence_representations::Persistence_landscape_on_grid; int main(int argc, char** argv) { - std::cout << "This program creates persistence landscape on grid of diagrams provided as an input.\n"; - std::cout << "The first parameter of a program is an integer, a size of a grid.\n"; - std::cout << "The second and third parameters are min and max of the grid. If you want those numbers to be computed " - "based on the data, set them both to -1 \n"; - std::cout << "The fourth parameter of the program is the dimension of persistence to be used to construct " - "persistence landscape on a grid. If your file contains "; - std::cout << "the information about dimension of birth-death pairs, please provide here the dimension of intervals " - "you want to use. If your input files consist only "; - std::cout << "of birth-death pairs, please set the fourth parameter to -1 \n"; - std::cout << "The remaining parameters are the names of files with persistence diagrams. \n"; + std::cout << "This program creates persistence landscapes on grid files (*.g_land) of persistence diagrams files " + << "(*.pers) provided as an input.\n" + << "The first parameter of a program is an integer, a size of a grid.\n" + << "The second and third parameters are min and max of the grid. If you want those numbers to be computed " + << "based on the data, set them both to -1 \n" + << "The fourth parameter of this program is a dimension of persistence that will be used in creation of " + << "the persistence heat maps." + << "If your input files contains persistence pairs of various dimension, as a fourth parameter of the " + << "procedure please provide the dimension of persistence you want to use." + << "If in your files there are only birth-death pairs of the same dimension, set the fourth parameter to " + << "-1.\n" + << "The remaining parameters are the names of files with persistence diagrams. \n"; - if (argc < 5) { + if (argc < 6) { std::cout << "Wrong parameter list, the program will now terminate \n"; return 1; } + size_t size_of_grid = (size_t)atoi(argv[1]); double min_ = atof(argv[2]); double max_ = atof(argv[3]); @@ -60,7 +63,6 @@ int main(int argc, char** argv) { filenames.push_back(argv[i]); } - std::cout << "Creating persistence landscapes...\n"; for (size_t i = 0; i != filenames.size(); ++i) { std::cout << "Creating persistence landscape on a grid based on a file : " << filenames[i] << std::endl; Persistence_landscape_on_grid l; @@ -74,6 +76,5 @@ int main(int argc, char** argv) { ss << filenames[i] << ".g_land"; l.print_to_file(ss.str().c_str()); } - std::cout << "Done \n"; return 0; } diff --git a/src/Persistence_representations/utilities/persistence_landscapes_on_grid/plot_landscapes_on_grid.cpp b/src/Persistence_representations/utilities/persistence_landscapes_on_grid/plot_landscapes_on_grid.cpp index 42822a01..dddb3615 100644 --- a/src/Persistence_representations/utilities/persistence_landscapes_on_grid/plot_landscapes_on_grid.cpp +++ b/src/Persistence_representations/utilities/persistence_landscapes_on_grid/plot_landscapes_on_grid.cpp @@ -28,20 +28,17 @@ using Persistence_landscape_on_grid = Gudhi::Persistence_representations::Persistence_landscape_on_grid; int main(int argc, char** argv) { - std::cout << "This program plot persistence landscape on grid stored in a file (the file needs to be created " - "beforehand). Please call the code with the name of a landscape on grid file \n"; - if (argc == 1) { - std::cout << "Wrong parameters of a program call, the program will now terminate \n"; + std::cout << "This program creates a gnuplot script from a persistence landscape on grid stored in a file (the file " + << "needs to be created beforehand). Please call the code with the name of a single landscape on grid file" + << ".\n"; + if (argc != 2) { + std::cout << "Wrong parameter list, the program will now terminate \n"; return 1; } + Persistence_landscape_on_grid l; l.load_landscape_from_file(argv[1]); - - std::stringstream ss; - ss << argv[1] << "_gnuplot_script"; - l.plot(ss.str().c_str()); - - std::cout << "Done \n"; + l.plot(argv[1]); return 0; } diff --git a/src/Persistence_representations/utilities/persistence_vectors/CMakeLists.txt b/src/Persistence_representations/utilities/persistence_vectors/CMakeLists.txt index e3d1013b..a401c955 100644 --- a/src/Persistence_representations/utilities/persistence_vectors/CMakeLists.txt +++ b/src/Persistence_representations/utilities/persistence_vectors/CMakeLists.txt @@ -1,38 +1,10 @@ cmake_minimum_required(VERSION 2.6) project(Persistence_vectors_utilities) -file(COPY "${CMAKE_SOURCE_DIR}/data/persistence_diagram/simple_diagram.txt" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/") +add_persistence_representation_creation_utility(create_persistence_vectors "-1") -add_executable ( create_persistence_vectors create_persistence_vectors.cpp ) -target_link_libraries(create_persistence_vectors ${Boost_SYSTEM_LIBRARY}) +add_persistence_representation_plot_utility(plot_persistence_vectors ".vect") -# Will create simple_diagram.txt.vect -add_test(NAME create_persistence_vectors COMMAND $ - "-1" "${CMAKE_CURRENT_BINARY_DIR}/simple_diagram.txt") - -add_executable ( average_persistence_vectors average_persistence_vectors.cpp ) -target_link_libraries(average_persistence_vectors ${Boost_SYSTEM_LIBRARY}) - -add_test(NAME average_persistence_vectors COMMAND $ - "${CMAKE_CURRENT_BINARY_DIR}/simple_diagram.txt.vect" - "${CMAKE_CURRENT_BINARY_DIR}/simple_diagram.txt.vect") - -add_executable ( compute_distance_of_persistence_vectors compute_distance_of_persistence_vectors.cpp ) -target_link_libraries(compute_distance_of_persistence_vectors ${Boost_SYSTEM_LIBRARY}) - -add_test(NAME compute_distance_of_persistence_vectors COMMAND $ - "-1" "${CMAKE_CURRENT_BINARY_DIR}/simple_diagram.txt.vect" - "${CMAKE_CURRENT_BINARY_DIR}/simple_diagram.txt.vect") - -add_executable ( compute_scalar_product_of_persistence_vectors compute_scalar_product_of_persistence_vectors.cpp ) -target_link_libraries(compute_scalar_product_of_persistence_vectors ${Boost_SYSTEM_LIBRARY}) - -add_test(NAME compute_scalar_product_of_persistence_vectors COMMAND $ - "${CMAKE_CURRENT_BINARY_DIR}/simple_diagram.txt.vect" - "${CMAKE_CURRENT_BINARY_DIR}/simple_diagram.txt.vect") - -add_executable ( plot_persistence_vectors plot_persistence_vectors.cpp ) -target_link_libraries(plot_persistence_vectors ${Boost_SYSTEM_LIBRARY}) - -add_test(NAME plot_persistence_vectors COMMAND $ - "${CMAKE_CURRENT_BINARY_DIR}/simple_diagram.txt.vect") +add_persistence_representation_function_utility(average_persistence_vectors ".vect") +add_persistence_representation_function_utility(compute_distance_of_persistence_vectors ".vect" "1") +add_persistence_representation_function_utility(compute_scalar_product_of_persistence_vectors ".vect") diff --git a/src/Persistence_representations/utilities/persistence_vectors/average_persistence_vectors.cpp b/src/Persistence_representations/utilities/persistence_vectors/average_persistence_vectors.cpp index 366ee2bc..8de7725c 100644 --- a/src/Persistence_representations/utilities/persistence_vectors/average_persistence_vectors.cpp +++ b/src/Persistence_representations/utilities/persistence_vectors/average_persistence_vectors.cpp @@ -30,21 +30,20 @@ using Vector_distances_in_diagram = Gudhi::Persistence_representations::Vector_distances_in_diagram; int main(int argc, char** argv) { - std::cout << "This program computes average persistence vector of persistence vectors created based on persistence " - "diagrams provided as an input. \n"; - std::cout << "Please call this program with the names of files with persistence diagrams \n"; - std::vector filenames; + std::cout << "This program computes average of persistence vectors stored in files (the files needs to " + << "be created beforehand).\n" + << "The parameters of this programs are names of files with persistence vectors.\n"; - if (argc == 1) { - std::cout << "No input files given, the program will now terminate \n"; + if (argc < 3) { + std::cout << "Wrong number of parameters, the program will now terminate \n"; return 1; } + std::vector filenames; for (int i = 1; i < argc; ++i) { filenames.push_back(argv[i]); } - std::cout << "Reading persistence vectors...\n"; std::vector lands; for (size_t i = 0; i != filenames.size(); ++i) { Vector_distances_in_diagram* l = new Vector_distances_in_diagram; diff --git a/src/Persistence_representations/utilities/persistence_vectors/compute_distance_of_persistence_vectors.cpp b/src/Persistence_representations/utilities/persistence_vectors/compute_distance_of_persistence_vectors.cpp index 3aed297e..f8b71e5b 100644 --- a/src/Persistence_representations/utilities/persistence_vectors/compute_distance_of_persistence_vectors.cpp +++ b/src/Persistence_representations/utilities/persistence_vectors/compute_distance_of_persistence_vectors.cpp @@ -79,7 +79,7 @@ int main(int argc, char** argv) { // and now output the result to the screen and a file: std::ofstream out; - out.open("distance"); + out.open("distance.vect"); for (size_t i = 0; i != distance.size(); ++i) { for (size_t j = 0; j != distance.size(); ++j) { std::cout << distance[i][j] << " "; @@ -90,5 +90,6 @@ int main(int argc, char** argv) { } out.close(); + std::cout << "Distance can be found in 'distance.vect' file\n"; return 0; } diff --git a/src/Persistence_representations/utilities/persistence_vectors/compute_scalar_product_of_persistence_vectors.cpp b/src/Persistence_representations/utilities/persistence_vectors/compute_scalar_product_of_persistence_vectors.cpp index d9ad4360..bda0b61b 100644 --- a/src/Persistence_representations/utilities/persistence_vectors/compute_scalar_product_of_persistence_vectors.cpp +++ b/src/Persistence_representations/utilities/persistence_vectors/compute_scalar_product_of_persistence_vectors.cpp @@ -32,9 +32,14 @@ using Vector_distances_in_diagram = Gudhi::Persistence_representations::Vector_distances_in_diagram; int main(int argc, char** argv) { - std::cout << "This program compute scalar product of persistence vectors stored in a file (the file needs to be " - "created beforehand). \n"; - std::cout << "The parameters of this programs are names of files with persistence vectors.\n"; + std::cout << "This program computes scalar product of persistence vectors stored in a file (the file needs to " + << "be created beforehand). \n" + << "The parameters of this programs are names of files with persistence vectors.\n"; + + if (argc < 3) { + std::cout << "Wrong number of parameters, the program will now terminate \n"; + return 1; + } std::vector filenames; for (int i = 1; i < argc; ++i) { @@ -66,7 +71,7 @@ int main(int argc, char** argv) { // and now output the result to the screen and a file: std::ofstream out; - out.open("scalar_product"); + out.open("scalar_product.vect"); for (size_t i = 0; i != scalar_product.size(); ++i) { for (size_t j = 0; j != scalar_product.size(); ++j) { std::cout << scalar_product[i][j] << " "; @@ -76,5 +81,7 @@ int main(int argc, char** argv) { out << std::endl; } out.close(); + + std::cout << "Distance can be found in 'scalar_product.vect' file\n"; return 0; } diff --git a/src/Persistence_representations/utilities/persistence_vectors/create_persistence_vectors.cpp b/src/Persistence_representations/utilities/persistence_vectors/create_persistence_vectors.cpp index b618ca67..753675cb 100644 --- a/src/Persistence_representations/utilities/persistence_vectors/create_persistence_vectors.cpp +++ b/src/Persistence_representations/utilities/persistence_vectors/create_persistence_vectors.cpp @@ -32,13 +32,21 @@ using Vector_distances_in_diagram = Gudhi::Persistence_representations::Vector_distances_in_diagram; int main(int argc, char** argv) { - std::cout << "This program creates persistence vectors of diagrams provided as an input. The first parameter of this " - "program is a dimension of persistence "; - std::cout << " that will be used in creation of the persistence vectors. If our input files contain persistence " - "pairs of various dimension, as a second parameter of the "; - std::cout << " procedure please provide the dimension of persistence you want to use. If in your file there are only " - "birth-death pairs of the same dimension, set the first parameter to -1." - << std::endl; + std::cout << "This program creates persistence vectors files (*.vect) of persistence diagrams files (*.pers) " + << "provided as an input.\n" + << "The first parameter of this program is a dimension of persistence that will be used in creation of " + << "the persistence heat maps." + << "If your input files contains persistence pairs of various dimension, as a first parameter of the " + << "procedure please provide the dimension of persistence you want to use." + << "If in your files there are only birth-death pairs of the same dimension, set the first parameter to " + << "-1.\n" + << "The remaining parameters are the names of files with persistence diagrams. \n"; + + if (argc < 3) { + std::cout << "Wrong parameter list, the program will now terminate \n"; + return 1; + } + std::cout << "The remaining parameters are the names of files with persistence diagrams. \n"; int dim = atoi(argv[1]); unsigned dimension = std::numeric_limits::max(); @@ -58,6 +66,5 @@ int main(int argc, char** argv) { ss << filenames[i] << ".vect"; l.print_to_file(ss.str().c_str()); } - std::cout << "Done \n"; return 0; } -- cgit v1.2.3 From 1ae99c5f04b6d14a730bdc8fea2e77d33665cd26 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Thu, 14 Dec 2017 12:31:48 +0000 Subject: Add cmake improvement for Persistence representation module. Was bad tested and too hard to maintain git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/persistence_representation_integration_cmake_improvement@3071 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: fa4684701edbe6d172e75f119afa912eb3b5dad7 --- data/persistence_diagram/simple_diagram.txt | 4 - .../example/CMakeLists.txt | 4 +- .../include/gudhi/Persistence_intervals.h | 12 +-- .../gudhi/Persistence_intervals_with_distances.h | 2 +- .../utilities/CMakeLists.txt | 9 +- .../persistence_heat_maps/simple_diagram.txt.mps | 11 --- .../utilities/persistence_intervals/CMakeLists.txt | 38 +++----- ...te_birth_death_range_in_persistence_diagram.cpp | 22 +++-- .../compute_bottleneck_distance.cpp | 20 ++-- .../compute_number_of_dominant_intervals.cpp | 1 - .../plot_histogram_of_intervals_lengths.cpp | 39 ++++---- .../plot_persistence_Betti_numbers.cpp | 30 +++--- .../plot_persistence_intervals.cpp | 13 ++- .../persistence_landscapes/simple_diagram.txt.land | 13 --- .../simple_diagram.txt.g_land | 104 --------------------- .../persistence_vectors/simple_diagram.txt.vect | 1 - 16 files changed, 94 insertions(+), 229 deletions(-) delete mode 100644 data/persistence_diagram/simple_diagram.txt delete mode 100644 src/Persistence_representations/utilities/persistence_heat_maps/simple_diagram.txt.mps delete mode 100644 src/Persistence_representations/utilities/persistence_landscapes/simple_diagram.txt.land delete mode 100644 src/Persistence_representations/utilities/persistence_landscapes_on_grid/simple_diagram.txt.g_land delete mode 100644 src/Persistence_representations/utilities/persistence_vectors/simple_diagram.txt.vect (limited to 'src/Persistence_representations') diff --git a/data/persistence_diagram/simple_diagram.txt b/data/persistence_diagram/simple_diagram.txt deleted file mode 100644 index 2f199fd4..00000000 --- a/data/persistence_diagram/simple_diagram.txt +++ /dev/null @@ -1,4 +0,0 @@ -1 2 -3 4 -5 6 -7 8 \ No newline at end of file diff --git a/src/Persistence_representations/example/CMakeLists.txt b/src/Persistence_representations/example/CMakeLists.txt index 7788b603..3a6696b7 100644 --- a/src/Persistence_representations/example/CMakeLists.txt +++ b/src/Persistence_representations/example/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 2.6) project(Persistence_representations_example) -file(COPY "${CMAKE_SOURCE_DIR}/data/persistence_diagram/simple_diagram.txt" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/") +#file(COPY "${CMAKE_SOURCE_DIR}/data/persistence_diagram/simple_diagram.txt" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/") add_executable ( Persistence_representations_example_landscape_on_grid persistence_landscape_on_grid.cpp ) target_link_libraries(Persistence_representations_example_landscape_on_grid ${Boost_SYSTEM_LIBRARY}) @@ -17,7 +17,7 @@ add_executable ( Persistence_representations_example_intervals persistence_inter target_link_libraries(Persistence_representations_example_intervals ${Boost_SYSTEM_LIBRARY}) add_test(NAME Persistence_representations_example_intervals COMMAND $ - "${CMAKE_CURRENT_BINARY_DIR}/simple_diagram.txt") + "${CMAKE_SOURCE_DIR}/data/persistence_diagram/first.pers") add_executable ( Persistence_representations_example_vectors persistence_vectors.cpp ) target_link_libraries(Persistence_representations_example_vectors ${Boost_SYSTEM_LIBRARY}) diff --git a/src/Persistence_representations/include/gudhi/Persistence_intervals.h b/src/Persistence_representations/include/gudhi/Persistence_intervals.h index 525d58a3..1ed97882 100644 --- a/src/Persistence_representations/include/gudhi/Persistence_intervals.h +++ b/src/Persistence_representations/include/gudhi/Persistence_intervals.h @@ -167,10 +167,10 @@ class Persistence_intervals { // this program create a gnuplot script file that allows to plot persistence diagram. std::ofstream out; - std::ostringstream nameSS; - nameSS << filename << "_GnuplotScript"; - std::string nameStr = nameSS.str(); - out.open(nameStr); + std::stringstream gnuplot_script; + gnuplot_script << filename << "_GnuplotScript"; + + out.open(gnuplot_script.str().c_str()); std::pair min_max_values = this->get_x_range(); if (min_x == max_x) { @@ -195,8 +195,8 @@ class Persistence_intervals { out.close(); - std::cout << "Gnuplot script to visualize persistence diagram written to the file: " << nameStr << ". Type load '" - << nameStr << "' in gnuplot to visualize." << std::endl; + std::cout << "To visualize, install gnuplot and type the command: gnuplot -persist -e \"load \'" + << gnuplot_script.str().c_str() << "\'\"" << std::endl; } /** diff --git a/src/Persistence_representations/include/gudhi/Persistence_intervals_with_distances.h b/src/Persistence_representations/include/gudhi/Persistence_intervals_with_distances.h index d5ab04b4..2a3858bf 100644 --- a/src/Persistence_representations/include/gudhi/Persistence_intervals_with_distances.h +++ b/src/Persistence_representations/include/gudhi/Persistence_intervals_with_distances.h @@ -47,7 +47,7 @@ class Persistence_intervals_with_distances : public Persistence_intervals { * The last parameter, tolerance, it is an additiv error of the approimation, set by default to zero. **/ double distance(const Persistence_intervals_with_distances& second, double power = std::numeric_limits::max(), - double tolerance = 0) const { + double tolerance = (std::numeric_limits::min)()) const { if (power >= std::numeric_limits::max()) { return Gudhi::persistence_diagram::bottleneck_distance(this->intervals, second.intervals, tolerance); } else { diff --git a/src/Persistence_representations/utilities/CMakeLists.txt b/src/Persistence_representations/utilities/CMakeLists.txt index d0d93f9d..137eb0c1 100644 --- a/src/Persistence_representations/utilities/CMakeLists.txt +++ b/src/Persistence_representations/utilities/CMakeLists.txt @@ -18,13 +18,13 @@ function(add_persistence_representation_plot_utility plot_utility tool_extension # as the function is called in a subdirectory level, need to '../' to find persistence heat maps files add_test(NAME Persistence_representation_utilities_${plot_utility}_first COMMAND $ "${CMAKE_CURRENT_BINARY_DIR}/../first.pers${tool_extension}") - add_test(NAME Persistence_representation_utilities_${plot_utility}_second COMMAND $ - "${CMAKE_CURRENT_BINARY_DIR}/../second.pers${tool_extension}") + #add_test(NAME Persistence_representation_utilities_${plot_utility}_second COMMAND $ + # "${CMAKE_CURRENT_BINARY_DIR}/../second.pers${tool_extension}") if(GNUPLOT_PATH) add_test(NAME Persistence_representation_utilities_${plot_utility}_first_gnuplot COMMAND ${GNUPLOT_PATH} "-e" "load '${CMAKE_CURRENT_BINARY_DIR}/../first.pers${tool_extension}_GnuplotScript'") - add_test(NAME Persistence_representation_utilities_${plot_utility}_second_gnuplot COMMAND ${GNUPLOT_PATH} - "-e" "load '${CMAKE_CURRENT_BINARY_DIR}/../second.pers${tool_extension}_GnuplotScript'") + #add_test(NAME Persistence_representation_utilities_${plot_utility}_second_gnuplot COMMAND ${GNUPLOT_PATH} + # "-e" "load '${CMAKE_CURRENT_BINARY_DIR}/../second.pers${tool_extension}_GnuplotScript'") endif() endfunction(add_persistence_representation_plot_utility) @@ -51,4 +51,3 @@ add_subdirectory(persistence_intervals) add_subdirectory(persistence_landscapes) add_subdirectory(persistence_landscapes_on_grid) add_subdirectory(persistence_vectors) - diff --git a/src/Persistence_representations/utilities/persistence_heat_maps/simple_diagram.txt.mps b/src/Persistence_representations/utilities/persistence_heat_maps/simple_diagram.txt.mps deleted file mode 100644 index b7643887..00000000 --- a/src/Persistence_representations/utilities/persistence_heat_maps/simple_diagram.txt.mps +++ /dev/null @@ -1,11 +0,0 @@ -0.93 8.0707 -0.0492104 0.03889 0.0190956 0.00603584 0.00131569 0.000120934 2.10152e-05 0 0 0 -0.0650745 0.0539306 0.0296488 0.011745 0.00357642 0.000695928 0.000120934 0 0 0 -0.0572665 0.0559446 0.0409942 0.0230905 0.00937173 0.00242903 0.000422102 0 0 0 -0.0409942 0.0559656 0.0573874 0.0408475 0.0192639 0.00628964 0.00178718 0.000422102 0.000120934 2.10152e-05 -0.0296488 0.0540515 0.0657704 0.0519133 0.0283092 0.0132056 0.00628964 0.00242903 0.000695928 0.000120934 -0.0190956 0.0393121 0.0516395 0.0465955 0.0359385 0.0283092 0.0192639 0.00937173 0.00357642 0.00131569 -0.00847814 0.0188418 0.0281882 0.0358964 0.0465955 0.0519133 0.0408475 0.0230905 0.011745 0.00603584 -0.00242903 0.00628964 0.0132056 0.0281882 0.0516395 0.0657704 0.0573874 0.0409942 0.0296488 0.0190956 -0.000422102 0.00178718 0.00628964 0.0188418 0.0393121 0.0540515 0.0559656 0.0559446 0.0539306 0.03889 -0 0.000422102 0.00242903 0.00847814 0.0190956 0.0296488 0.0409942 0.0572665 0.0650745 0.0492104 diff --git a/src/Persistence_representations/utilities/persistence_intervals/CMakeLists.txt b/src/Persistence_representations/utilities/persistence_intervals/CMakeLists.txt index 2ba6efe5..897e12a3 100644 --- a/src/Persistence_representations/utilities/persistence_intervals/CMakeLists.txt +++ b/src/Persistence_representations/utilities/persistence_intervals/CMakeLists.txt @@ -1,40 +1,32 @@ cmake_minimum_required(VERSION 2.6) project(Persistence_representations_intervals_utilities) -file(COPY "${CMAKE_SOURCE_DIR}/data/persistence_diagram/simple_diagram.txt" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/") -add_executable ( plot_persistence_intervals plot_persistence_intervals.cpp ) - -add_test(NAME plot_persistence_intervals COMMAND $ - "${CMAKE_CURRENT_BINARY_DIR}/simple_diagram.txt") - -add_executable ( compute_birth_death_range_in_persistence_diagram compute_birth_death_range_in_persistence_diagram.cpp ) - -add_test(NAME compute_birth_death_range_in_persistence_diagram COMMAND $ - "-1" "${CMAKE_CURRENT_BINARY_DIR}/simple_diagram.txt") +add_executable ( plot_histogram_of_intervals_lengths plot_histogram_of_intervals_lengths.cpp ) -add_executable ( compute_number_of_dominant_intervals compute_number_of_dominant_intervals.cpp ) +add_test(NAME plot_histogram_of_intervals_lengths COMMAND $ + "${CMAKE_CURRENT_BINARY_DIR}/../first.pers" "-1") -add_test(NAME compute_number_of_dominant_intervals COMMAND $ - "${CMAKE_CURRENT_BINARY_DIR}/simple_diagram.txt" "-1" "2") +add_persistence_representation_plot_utility(plot_persistence_intervals "") +add_persistence_representation_plot_utility(plot_persistence_Betti_numbers "") -add_executable ( plot_histogram_of_intervals_lengths plot_histogram_of_intervals_lengths.cpp ) +add_persistence_representation_creation_utility(compute_birth_death_range_in_persistence_diagram "-1") -add_test(NAME plot_histogram_of_intervals_lengths COMMAND $ - "${CMAKE_CURRENT_BINARY_DIR}/simple_diagram.txt" "2") -add_executable ( plot_persistence_Betti_numbers plot_persistence_Betti_numbers.cpp ) +add_executable ( compute_number_of_dominant_intervals compute_number_of_dominant_intervals.cpp ) +add_test(NAME Persistence_representation_utilities_compute_number_of_dominant_intervals + COMMAND $ + "${CMAKE_CURRENT_BINARY_DIR}/../first.pers" "-1" "2") -add_test(NAME plot_persistence_Betti_numbers COMMAND $ - "${CMAKE_CURRENT_BINARY_DIR}/simple_diagram.txt") if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1) add_executable ( compute_bottleneck_distance compute_bottleneck_distance.cpp ) if (TBB_FOUND) target_link_libraries(compute_bottleneck_distance ${TBB_LIBRARIES}) endif(TBB_FOUND) - - add_test(NAME compute_bottleneck_distance COMMAND $ - "${CMAKE_CURRENT_BINARY_DIR}/simple_diagram.txt" - "${CMAKE_CURRENT_BINARY_DIR}/simple_diagram.txt") + add_test(NAME Persistence_representation_utilities_compute_bottleneck_distance + COMMAND $ + "-1" + "${CMAKE_CURRENT_BINARY_DIR}/../first.pers" + "${CMAKE_CURRENT_BINARY_DIR}/../second.pers") endif (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1) diff --git a/src/Persistence_representations/utilities/persistence_intervals/compute_birth_death_range_in_persistence_diagram.cpp b/src/Persistence_representations/utilities/persistence_intervals/compute_birth_death_range_in_persistence_diagram.cpp index 66fa31ca..9102da79 100644 --- a/src/Persistence_representations/utilities/persistence_intervals/compute_birth_death_range_in_persistence_diagram.cpp +++ b/src/Persistence_representations/utilities/persistence_intervals/compute_birth_death_range_in_persistence_diagram.cpp @@ -20,7 +20,6 @@ * along with this program. If not, see . */ -#include #include #include @@ -31,16 +30,21 @@ using Persistence_intervals = Gudhi::Persistence_representations::Persistence_intervals; int main(int argc, char** argv) { - std::cout << "This program compute the range of birth and death times of persistence pairs in diagrams provided as " - "an input. \n"; - std::cout << "The first parameter of the program is the dimension of persistence to be used. If your file contains "; - std::cout << "the information about dimension of persistence pairs, please provide here the dimension of persistence " - "pairs you want to use. If your input files consist only "; - std::cout << "of birth-death pairs, please set this first parameter to -1 \n"; - std::cout << "The remaining parameters of the program are the names of files with persistence diagrams. \n"; + std::cout << "This program computes the range of birth and death times of persistence pairs in diagrams provided as " + << "an input.\n" + << "The first parameter is the dimension of persistence to be used to create persistence intervals. " + << "If your file contains the information about dimension of persistence pairs, please provide here the " + << "dimension of persistence pairs you want to use. " + << "If your input files consist only of birth-death pairs, please set this first parameter to -1.\n" + << "The remaining parameters of the program are the names of files with persistence diagrams.\n"; + + if (argc < 3) { + std::cout << "Wrong parameter list, the program will now terminate \n"; + return 1; + } - int dim = atoi(argv[1]); unsigned dimension = std::numeric_limits::max(); + int dim = atoi(argv[1]); if (dim >= 0) { dimension = (unsigned)dim; } diff --git a/src/Persistence_representations/utilities/persistence_intervals/compute_bottleneck_distance.cpp b/src/Persistence_representations/utilities/persistence_intervals/compute_bottleneck_distance.cpp index 0b1b526d..c8290845 100644 --- a/src/Persistence_representations/utilities/persistence_intervals/compute_bottleneck_distance.cpp +++ b/src/Persistence_representations/utilities/persistence_intervals/compute_bottleneck_distance.cpp @@ -21,7 +21,6 @@ */ #include -#include #include #include @@ -31,21 +30,21 @@ using Persistence_intervals_with_distances = Gudhi::Persistence_representations::Persistence_intervals_with_distances; int main(int argc, char** argv) { - std::cout << "This program compute the bottleneck distance of persistence diagrams stored in a files. \n"; - std::cout << "The first parameter of the program is the dimension of persistence to be used to construct persistence " - "landscapes. If your file contains "; - std::cout << "the information about dimension of persistence pairs, please provide here the dimension of persistence " - "pairs you want to use. If your input files consist only "; - std::cout << "of birth-death pairs, please set this first parameter to -1 \n"; - std::cout << "The remaining parameters of this programs are names of files with persistence diagrams.\n"; + std::cout << "This program computes the bottleneck distance of persistence pairs in diagrams provided as " + << "an input.\n" + << "The first parameter is the dimension of persistence to be used to create persistence intervals. " + << "If your file contains the information about dimension of persistence pairs, please provide here the " + << "dimension of persistence pairs you want to use. " + << "If your input files consist only of birth-death pairs, please set this first parameter to -1.\n" + << "The remaining parameters of the program are the names of files with persistence diagrams.\n"; if (argc < 3) { std::cout << "Wrong number of parameters, the program will now terminate \n"; return 1; } - int dim = atoi(argv[1]); unsigned dimension = std::numeric_limits::max(); + int dim = atoi(argv[1]); if (dim >= 0) { dimension = (unsigned)dim; } @@ -80,7 +79,7 @@ int main(int argc, char** argv) { // and now output the result to the screen and a file: std::ofstream out; - out.open("distance"); + out.open("distance.itv"); for (size_t i = 0; i != distance.size(); ++i) { for (size_t j = 0; j != distance.size(); ++j) { std::cout << distance[i][j] << " "; @@ -91,5 +90,6 @@ int main(int argc, char** argv) { } out.close(); + std::cout << "Distance can be found in 'distance.itv' file\n"; return 0; } diff --git a/src/Persistence_representations/utilities/persistence_intervals/compute_number_of_dominant_intervals.cpp b/src/Persistence_representations/utilities/persistence_intervals/compute_number_of_dominant_intervals.cpp index 1286ca57..b3d126f0 100644 --- a/src/Persistence_representations/utilities/persistence_intervals/compute_number_of_dominant_intervals.cpp +++ b/src/Persistence_representations/utilities/persistence_intervals/compute_number_of_dominant_intervals.cpp @@ -20,7 +20,6 @@ * along with this program. If not, see . */ -#include #include #include diff --git a/src/Persistence_representations/utilities/persistence_intervals/plot_histogram_of_intervals_lengths.cpp b/src/Persistence_representations/utilities/persistence_intervals/plot_histogram_of_intervals_lengths.cpp index d68f4584..ccb5b645 100644 --- a/src/Persistence_representations/utilities/persistence_intervals/plot_histogram_of_intervals_lengths.cpp +++ b/src/Persistence_representations/utilities/persistence_intervals/plot_histogram_of_intervals_lengths.cpp @@ -20,7 +20,6 @@ * along with this program. If not, see . */ -#include #include #include @@ -31,30 +30,34 @@ using Persistence_intervals = Gudhi::Persistence_representations::Persistence_intervals; int main(int argc, char** argv) { - std::cout << "This program compute a histogram of barcode's length. A number of bins in the histogram is a parameter " - "of this program. \n"; - if (argc != 3) { + std::cout << "This program computes a histogram of barcode's length. A number of bins in the histogram is a " + << "parameter of this program. \n"; + if ((argc != 3) && (argc != 4)) { std::cout << "To run this program, please provide the name of a file with persistence diagram and number of " - "dominant intervals you would like to get \n"; - std::cout << "The third parameter of a program is the dimension of the persistence that is to be used. If your " - "file contains only birth-death pairs, you can skip this parameter\n"; + << "dominant intervals you would like to get. Set a negative number dominant intervals value " + << "If your file contains only birth-death pairs.\n" + << "The third parameter is the dimension of the persistence that is to be used. If your " + << "file contains only birth-death pairs, you can skip this parameter\n"; return 1; } - unsigned dimension = std::numeric_limits::max(); - int dim = -1; - if (argc > 2) { - dim = atoi(argv[2]); + + unsigned dominant_interval_number = std::numeric_limits::max(); + int nbr = atoi(argv[2]); + if (nbr >= 0) { + dominant_interval_number = static_cast(nbr); } - if (dim >= 0) { - dimension = (unsigned)dim; + + int persistence_dimension = -1; + if (argc == 4) { + persistence_dimension = atoi(argv[3]); } - Persistence_intervals p(argv[1], dimension); - std::vector > dominant_intervals = p.dominant_intervals(atoi(argv[2])); + Persistence_intervals p(argv[1], dominant_interval_number); + std::vector > dominant_intervals = p.dominant_intervals(persistence_dimension); std::vector histogram = p.histogram_of_lengths(10); std::stringstream gnuplot_script; - gnuplot_script << argv[1] << "_Gnuplot_script"; + gnuplot_script << argv[1] << "_GnuplotScript"; std::ofstream out; out.open(gnuplot_script.str().c_str()); @@ -66,7 +69,9 @@ int main(int argc, char** argv) { out << histogram[i] << std::endl; } out << std::endl; - std::cout << "To visualize, open gnuplot and type: load \'" << gnuplot_script.str().c_str() << "\'" << std::endl; out.close(); + + std::cout << "To visualize, install gnuplot and type the command: gnuplot -persist -e \"load \'" + << gnuplot_script.str().c_str() << "\'\"" << std::endl; return 0; } diff --git a/src/Persistence_representations/utilities/persistence_intervals/plot_persistence_Betti_numbers.cpp b/src/Persistence_representations/utilities/persistence_intervals/plot_persistence_Betti_numbers.cpp index da2b9319..b433c2b3 100644 --- a/src/Persistence_representations/utilities/persistence_intervals/plot_persistence_Betti_numbers.cpp +++ b/src/Persistence_representations/utilities/persistence_intervals/plot_persistence_Betti_numbers.cpp @@ -20,7 +20,6 @@ * along with this program. If not, see . */ -#include #include #include @@ -31,29 +30,24 @@ using Persistence_intervals = Gudhi::Persistence_representations::Persistence_intervals; int main(int argc, char** argv) { - std::cout << "This program compute a plot of persistence Betti numbers. The input parameter is a file with " - "persistence intervals. \n"; - std::cout << "The second optional parameter of a program is the dimension of the persistence that is to be used. If " - "your file contains only birth-death pairs, you can skip this parameter\n"; - if (argc < 2) { - std::cout << "To run this program, please provide the name of a file with persistence diagram and number of " - "dominant intervals you would like to get \n"; + if ((argc != 3) && (argc != 2)) { + std::cout << "This program creates a gnuplot script of Betti numbers from a single persistence diagram file" + << "(*.pers).\n" + << "To run this program, please provide the name of a file with persistence diagram.\n" + << "The second optional parameter of a program is the dimension of the persistence that is to be used. " + << "If your file contains only birth-death pairs, you can skip this parameter.\n"; return 1; } + unsigned dimension = std::numeric_limits::max(); int dim = -1; - if (argc > 2) { + if (argc == 3) { dim = atoi(argv[2]); } if (dim >= 0) { dimension = (unsigned)dim; } - std::stringstream gnuplot_script; - gnuplot_script << argv[1] << "_Gnuplot_script"; - std::ofstream out; - out.open(gnuplot_script.str().c_str()); - Persistence_intervals p(argv[1], dimension); std::vector > pbns = p.compute_persistent_betti_numbers(); @@ -69,6 +63,11 @@ int main(int argc, char** argv) { xRangeEnd += (xRangeEnd - xRangeBegin) / 100.0; yRangeEnd += yRangeEnd / 100; + std::stringstream gnuplot_script; + gnuplot_script << argv[1] << "_GnuplotScript"; + std::ofstream out; + out.open(gnuplot_script.str().c_str()); + out << "set xrange [" << xRangeBegin << " : " << xRangeEnd << "]" << std::endl; out << "set yrange [" << yRangeBegin << " : " << yRangeEnd << "]" << std::endl; out << "plot '-' using 1:2 notitle with lp " << std::endl; @@ -81,7 +80,8 @@ int main(int argc, char** argv) { out << std::endl; out.close(); - std::cout << "To visualize, open gnuplot and type: load \'" << gnuplot_script.str().c_str() << "\'" << std::endl; + std::cout << "To visualize, install gnuplot and type the command: gnuplot -persist -e \"load \'" + << gnuplot_script.str().c_str() << "\'\"" << std::endl; return 0; } diff --git a/src/Persistence_representations/utilities/persistence_intervals/plot_persistence_intervals.cpp b/src/Persistence_representations/utilities/persistence_intervals/plot_persistence_intervals.cpp index e7d29e84..33387802 100644 --- a/src/Persistence_representations/utilities/persistence_intervals/plot_persistence_intervals.cpp +++ b/src/Persistence_representations/utilities/persistence_intervals/plot_persistence_intervals.cpp @@ -20,9 +20,7 @@ * along with this program. If not, see . */ -#include #include -#include #include #include @@ -32,15 +30,16 @@ using Persistence_intervals = Gudhi::Persistence_representations::Persistence_intervals; int main(int argc, char** argv) { - if (argc < 2) { - std::cout << "To run this program, please provide the name of a file with persistence diagram \n"; - std::cout << "The second optional parameter of a program is the dimension of the persistence that is to be used. " - "If your file contains only birth-death pairs, you can skip this parameter\n"; + if ((argc != 3) && (argc != 2)) { + std::cout << "This program creates a gnuplot script from a single persistence diagram file (*.pers).\n" + << "To run this program, please provide the name of a file with persistence diagram.\n" + << "The second optional parameter of a program is the dimension of the persistence that is to be used. " + << "If your file contains only birth-death pairs, you can skip this parameter.\n"; return 1; } unsigned dimension = std::numeric_limits::max(); int dim = -1; - if (argc > 2) { + if (argc == 3) { dim = atoi(argv[2]); } if (dim >= 0) { diff --git a/src/Persistence_representations/utilities/persistence_landscapes/simple_diagram.txt.land b/src/Persistence_representations/utilities/persistence_landscapes/simple_diagram.txt.land deleted file mode 100644 index b99d2f62..00000000 --- a/src/Persistence_representations/utilities/persistence_landscapes/simple_diagram.txt.land +++ /dev/null @@ -1,13 +0,0 @@ -#lambda_0 -1 0 -1.5 0.5 -2 0 -3 0 -3.5 0.5 -4 0 -5 0 -5.5 0.5 -6 0 -7 0 -7.5 0.5 -8 0 diff --git a/src/Persistence_representations/utilities/persistence_landscapes_on_grid/simple_diagram.txt.g_land b/src/Persistence_representations/utilities/persistence_landscapes_on_grid/simple_diagram.txt.g_land deleted file mode 100644 index dc53b932..00000000 --- a/src/Persistence_representations/utilities/persistence_landscapes_on_grid/simple_diagram.txt.g_land +++ /dev/null @@ -1,104 +0,0 @@ -1 -8 -101 - -0.07 -0.14 -0.21 -0.28 -0.35 -0.42 -0.49 -0.42 -0.35 -0.28 -0.21 -0.14 -0.07 - - - - - - - - - - - - - - - -0.07 -0.14 -0.21 -0.28 -0.35 -0.42 -0.49 -0.42 -0.35 -0.28 -0.21 -0.14 -0.07 - - - - - - - - - - - - - - - - -0.07 -0.14 -0.21 -0.28 -0.35 -0.42 -0.49 -0.42 -0.35 -0.28 -0.21 -0.14 -0.07 - - - - - - - - - - - - - - - -0.07 -0.14 -0.21 -0.28 -0.35 -0.42 -0.49 -0.42 -0.35 -0.28 -0.21 -0.14 -0.07 - - diff --git a/src/Persistence_representations/utilities/persistence_vectors/simple_diagram.txt.vect b/src/Persistence_representations/utilities/persistence_vectors/simple_diagram.txt.vect deleted file mode 100644 index 1d4eeaaf..00000000 --- a/src/Persistence_representations/utilities/persistence_vectors/simple_diagram.txt.vect +++ /dev/null @@ -1 +0,0 @@ -0.707107 0.707107 0.707107 0.707107 0.707107 0.707107 0.707107 0.707107 0.707107 0.707107 \ No newline at end of file -- cgit v1.2.3 From 80aa35b3ad53c95607221167b72d9aa00e1f71b5 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Thu, 14 Dec 2017 12:45:10 +0000 Subject: Forgotten git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/persistence_representation_integration_cmake_improvement@3072 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 7a6ef2d5fd72f53a396464bba4035f5610552c9b --- src/Persistence_representations/example/CMakeLists.txt | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/Persistence_representations') diff --git a/src/Persistence_representations/example/CMakeLists.txt b/src/Persistence_representations/example/CMakeLists.txt index 3a6696b7..b8ce8ea6 100644 --- a/src/Persistence_representations/example/CMakeLists.txt +++ b/src/Persistence_representations/example/CMakeLists.txt @@ -1,8 +1,6 @@ cmake_minimum_required(VERSION 2.6) project(Persistence_representations_example) -#file(COPY "${CMAKE_SOURCE_DIR}/data/persistence_diagram/simple_diagram.txt" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/") - add_executable ( Persistence_representations_example_landscape_on_grid persistence_landscape_on_grid.cpp ) target_link_libraries(Persistence_representations_example_landscape_on_grid ${Boost_SYSTEM_LIBRARY}) add_test(NAME Persistence_representations_example_landscape_on_grid -- 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/Persistence_representations') 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 9fa4297c6fdf4b12cc4f0dd21942d332650cd784 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Tue, 19 Dec 2017 13:03:49 +0000 Subject: Fix tests git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/persistence_representation_integration_cmake_improvement@3084 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 4fb56062184eeb07cbc7aa0c76803bb08daa0453 --- .../test/persistence_lanscapes_test.cpp | 85 +++++++++++----------- 1 file changed, 44 insertions(+), 41 deletions(-) (limited to 'src/Persistence_representations') diff --git a/src/Persistence_representations/test/persistence_lanscapes_test.cpp b/src/Persistence_representations/test/persistence_lanscapes_test.cpp index 81adb6fa..dc8135ee 100644 --- a/src/Persistence_representations/test/persistence_lanscapes_test.cpp +++ b/src/Persistence_representations/test/persistence_lanscapes_test.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -32,7 +33,7 @@ using namespace Gudhi; using namespace Gudhi::Persistence_representations; -double epsilon = 0.0000005; +double epsilon = 0.0005; BOOST_AUTO_TEST_CASE(check_construction_of_landscape) { std::vector > diag = @@ -57,9 +58,9 @@ BOOST_AUTO_TEST_CASE(check_computations_of_integrals) { std::vector > diag = read_persistence_intervals_in_one_dimension_from_file("data/file_with_diagram"); Persistence_landscape p(diag); - double integral = p.compute_integral_of_landscape(); - // cerr << integral << " " << 2.34992 << endl; - BOOST_CHECK(fabs(integral - 2.34992) <= 0.00001); + //double integral = p.compute_integral_of_landscape(); + //BOOST_CHECK(fabs(integral - 2.34992) <= 0.00001); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.compute_integral_of_landscape(), 2.34992, epsilon); } BOOST_AUTO_TEST_CASE(check_computations_of_integrals_for_each_level_separatelly) { @@ -67,37 +68,39 @@ BOOST_AUTO_TEST_CASE(check_computations_of_integrals_for_each_level_separatelly) read_persistence_intervals_in_one_dimension_from_file("data/file_with_diagram"); Persistence_landscape p(diag); - std::vector integrals_fir_different_levels; - integrals_fir_different_levels.push_back(0.216432); - integrals_fir_different_levels.push_back(0.204763); - integrals_fir_different_levels.push_back(0.188793); - integrals_fir_different_levels.push_back(0.178856); - integrals_fir_different_levels.push_back(0.163142); - integrals_fir_different_levels.push_back(0.155015); - integrals_fir_different_levels.push_back(0.143046); - integrals_fir_different_levels.push_back(0.133765); - integrals_fir_different_levels.push_back(0.123531); - integrals_fir_different_levels.push_back(0.117393); - integrals_fir_different_levels.push_back(0.111269); - integrals_fir_different_levels.push_back(0.104283); - integrals_fir_different_levels.push_back(0.0941308); - integrals_fir_different_levels.push_back(0.0811208); - integrals_fir_different_levels.push_back(0.0679001); - integrals_fir_different_levels.push_back(0.0580801); - integrals_fir_different_levels.push_back(0.0489647); - integrals_fir_different_levels.push_back(0.0407936); - integrals_fir_different_levels.push_back(0.0342599); - integrals_fir_different_levels.push_back(0.02896); - integrals_fir_different_levels.push_back(0.0239881); - integrals_fir_different_levels.push_back(0.0171792); - integrals_fir_different_levels.push_back(0.0071511); - integrals_fir_different_levels.push_back(0.00462067); - integrals_fir_different_levels.push_back(0.00229033); - integrals_fir_different_levels.push_back(0.000195296); + std::vector integrals_for_different_levels; + integrals_for_different_levels.push_back(0.216432); + integrals_for_different_levels.push_back(0.204763); + integrals_for_different_levels.push_back(0.188793); + integrals_for_different_levels.push_back(0.178856); + integrals_for_different_levels.push_back(0.163142); + integrals_for_different_levels.push_back(0.155015); + integrals_for_different_levels.push_back(0.143046); + integrals_for_different_levels.push_back(0.133765); + integrals_for_different_levels.push_back(0.123531); + integrals_for_different_levels.push_back(0.117393); + integrals_for_different_levels.push_back(0.111269); + integrals_for_different_levels.push_back(0.104283); + integrals_for_different_levels.push_back(0.0941308); + integrals_for_different_levels.push_back(0.0811208); + integrals_for_different_levels.push_back(0.0679001); + integrals_for_different_levels.push_back(0.0580801); + integrals_for_different_levels.push_back(0.0489647); + integrals_for_different_levels.push_back(0.0407936); + integrals_for_different_levels.push_back(0.0342599); + integrals_for_different_levels.push_back(0.02896); + integrals_for_different_levels.push_back(0.0239881); + integrals_for_different_levels.push_back(0.0171792); + integrals_for_different_levels.push_back(0.0071511); + integrals_for_different_levels.push_back(0.00462067); + integrals_for_different_levels.push_back(0.00229033); + integrals_for_different_levels.push_back(0.000195296); for (size_t level = 0; level != p.size(); ++level) { - double integral = p.compute_integral_of_a_level_of_a_landscape(level); - BOOST_CHECK(fabs(integral - integrals_fir_different_levels[level]) <= 0.00001); + //double integral = p.compute_integral_of_a_level_of_a_landscape(level); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.compute_integral_of_a_level_of_a_landscape(level), + integrals_for_different_levels[level], epsilon); + //BOOST_CHECK(fabs(integral - integrals_for_different_levels[level]) <= 0.00001); } } @@ -106,16 +109,16 @@ BOOST_AUTO_TEST_CASE(check_computations_of_integrals_of_powers_of_landscape) { read_persistence_intervals_in_one_dimension_from_file("data/file_with_diagram"); Persistence_landscape p(diag); - std::vector integrals_fir_different_powers; - integrals_fir_different_powers.push_back(17.1692); - integrals_fir_different_powers.push_back(2.34992); - integrals_fir_different_powers.push_back(0.49857); - integrals_fir_different_powers.push_back(0.126405); - integrals_fir_different_powers.push_back(0.0355235); + std::vector integrals_for_different_powers; + integrals_for_different_powers.push_back(17.1692); + integrals_for_different_powers.push_back(2.34992); + integrals_for_different_powers.push_back(0.49857); + integrals_for_different_powers.push_back(0.126405); + integrals_for_different_powers.push_back(0.0355235); for (size_t power = 0; power != 5; ++power) { - double integral = p.compute_integral_of_landscape((double)power); - BOOST_CHECK(fabs(integral - integrals_fir_different_powers[power]) <= 0.00005); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.compute_integral_of_landscape((double)power), + integrals_for_different_powers[power], epsilon); } } -- cgit v1.2.3 From b6608aca85acd5a3383407f2de39bd822445fe60 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Tue, 19 Dec 2017 14:09:34 +0000 Subject: Fix test units git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/persistence_representation_integration_cmake_improvement@3086 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 2d4ea393eb3d17ee7b60efc0f6c4c0531f21d451 --- .../test/persistence_lanscapes_test.cpp | 53 ++++++++++------------ 1 file changed, 25 insertions(+), 28 deletions(-) (limited to 'src/Persistence_representations') diff --git a/src/Persistence_representations/test/persistence_lanscapes_test.cpp b/src/Persistence_representations/test/persistence_lanscapes_test.cpp index dc8135ee..47737784 100644 --- a/src/Persistence_representations/test/persistence_lanscapes_test.cpp +++ b/src/Persistence_representations/test/persistence_lanscapes_test.cpp @@ -127,18 +127,18 @@ BOOST_AUTO_TEST_CASE(check_computations_of_values_on_different_points) { read_persistence_intervals_in_one_dimension_from_file("data/file_with_diagram"); Persistence_landscape p(diag); - BOOST_CHECK(fabs(p.compute_value_at_a_given_point(1, 0.0)) <= 0.00001); - BOOST_CHECK(fabs(p.compute_value_at_a_given_point(1, 0.1) - 0.0692324) <= 0.00001); - BOOST_CHECK(fabs(p.compute_value_at_a_given_point(1, 0.2) - 0.163369) <= 0.00001); - BOOST_CHECK(fabs(p.compute_value_at_a_given_point(1, 0.3) - 0.217115) <= 0.00001); - BOOST_CHECK(fabs(p.compute_value_at_a_given_point(2, 0.0)) <= 0.00001); - BOOST_CHECK(fabs(p.compute_value_at_a_given_point(2, 0.1) - 0.0633688) <= 0.00001); - BOOST_CHECK(fabs(p.compute_value_at_a_given_point(2, 0.2) - 0.122361) <= 0.00001); - BOOST_CHECK(fabs(p.compute_value_at_a_given_point(2, 0.3) - 0.195401) <= 0.00001); - BOOST_CHECK(fabs(p.compute_value_at_a_given_point(3, 0.0)) <= 0.00001); - BOOST_CHECK(fabs(p.compute_value_at_a_given_point(3, 0.1) - 0.0455386) <= 0.00001); - BOOST_CHECK(fabs(p.compute_value_at_a_given_point(3, 0.2) - 0.0954012) <= 0.00001); - BOOST_CHECK(fabs(p.compute_value_at_a_given_point(3, 0.3) - 0.185282) <= 0.00001); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.compute_value_at_a_given_point(1, 0.0), 0. , epsilon); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.compute_value_at_a_given_point(1, 0.1), 0.0692324, epsilon); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.compute_value_at_a_given_point(1, 0.2), 0.163369 , epsilon); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.compute_value_at_a_given_point(1, 0.3), 0.217115 , epsilon); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.compute_value_at_a_given_point(2, 0.0), 0. , epsilon); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.compute_value_at_a_given_point(2, 0.1), 0.0633688, epsilon); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.compute_value_at_a_given_point(2, 0.2), 0.122361 , epsilon); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.compute_value_at_a_given_point(2, 0.3), 0.195401 , epsilon); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.compute_value_at_a_given_point(3, 0.0), 0. , epsilon); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.compute_value_at_a_given_point(3, 0.1), 0.0455386, epsilon); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.compute_value_at_a_given_point(3, 0.2), 0.0954012, epsilon); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.compute_value_at_a_given_point(3, 0.3), 0.185282 , epsilon); } BOOST_AUTO_TEST_CASE(check_computations_sum_differences_and_multiplications) { @@ -174,13 +174,14 @@ BOOST_AUTO_TEST_CASE(check_computations_of_maxima_and_norms) { second.load_landscape_from_file("data/file_with_landscape_from_file_with_diagram_1"); Persistence_landscape sum = p + second; - BOOST_CHECK(fabs(p.compute_maximum() - 0.431313) <= 0.00001); - BOOST_CHECK(fabs(p.compute_norm_of_landscape(1) - 2.34992) <= 0.00001); - BOOST_CHECK(fabs(p.compute_norm_of_landscape(2) - 0.706095) <= 0.00001); - BOOST_CHECK(fabs(p.compute_norm_of_landscape(3) - 0.501867) <= 0.00001); - BOOST_CHECK(fabs(compute_distance_of_landscapes(p, sum, 1) - 27.9323) <= 0.00005); - BOOST_CHECK(fabs(compute_distance_of_landscapes(p, sum, 2) - 2.35199) <= 0.00001); - BOOST_CHECK(fabs(compute_distance_of_landscapes(p, sum, std::numeric_limits::max()) - 0.464478) <= 0.00001); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.compute_maximum() , 0.431313, epsilon); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.compute_norm_of_landscape(1), 2.34992 , epsilon); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.compute_norm_of_landscape(2), 0.706095, epsilon); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.compute_norm_of_landscape(3), 0.501867, epsilon); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(compute_distance_of_landscapes(p, sum, 1), 27.9323, epsilon); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(compute_distance_of_landscapes(p, sum, 2), 2.35199, epsilon); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(compute_distance_of_landscapes(p, sum, std::numeric_limits::max()), + 0.464478, epsilon); } BOOST_AUTO_TEST_CASE(check_default_parameters_of_distances) { @@ -195,7 +196,7 @@ BOOST_AUTO_TEST_CASE(check_default_parameters_of_distances) { double dist_numeric_limit_max = p.distance(q, std::numeric_limits::max()); double dist_infinity = p.distance(q, std::numeric_limits::infinity()); - BOOST_CHECK(dist_numeric_limit_max == dist_infinity); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(dist_numeric_limit_max, dist_infinity); } BOOST_AUTO_TEST_CASE(check_computations_of_averages) { @@ -220,13 +221,9 @@ BOOST_AUTO_TEST_CASE(check_computations_of_distances) { std::vector > diag2 = read_persistence_intervals_in_one_dimension_from_file("data/file_with_diagram_1"); Persistence_landscape q(diag2); - std::cout << "p.distance(q) = " << p.distance(q) << std::endl; - BOOST_CHECK(fabs(p.distance(q) - 25.5824) <= 0.00005); - std::cout << "p.distance(q, 2) = " << p.distance(q, 2) << std::endl; - BOOST_CHECK(fabs(p.distance(q, 2) - 2.1264) <= 0.0001); - std::cout << "p.distance(q, std::numeric_limits::max()) = " << - p.distance(q, std::numeric_limits::max()) << std::endl; - BOOST_CHECK(fabs(p.distance(q, std::numeric_limits::max()) - 0.359068) <= 0.00001); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.distance(q), 25.5824, epsilon); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.distance(q, 2), 2.1264, epsilon); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.distance(q, std::numeric_limits::max()), 0.359068, epsilon); } BOOST_AUTO_TEST_CASE(check_computations_of_scalar_product) { @@ -236,7 +233,7 @@ BOOST_AUTO_TEST_CASE(check_computations_of_scalar_product) { std::vector > diag2 = read_persistence_intervals_in_one_dimension_from_file("data/file_with_diagram_1"); Persistence_landscape q(diag2); - BOOST_CHECK(fabs(p.compute_scalar_product(q) - 0.754498) <= 0.00001); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.compute_scalar_product(q), 0.754498, epsilon); } -- cgit v1.2.3 From 22ab936a67cdf649091599526f239bdb263100f9 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Tue, 19 Dec 2017 15:33:19 +0000 Subject: Fix unitary tests git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/persistence_representation_integration_cmake_improvement@3088 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: db6f2e909552d643597925b312b7b50743924dfa --- .../test/persistence_intervals_test.cpp | 233 ++++++++++----------- .../persistence_intervals_with_distances_test.cpp | 19 +- .../test/persistence_lanscapes_on_grid_test.cpp | 58 +++-- .../test/read_persistence_from_file_test.cpp | 2 +- .../test/vector_representation_test.cpp | 2 +- 5 files changed, 145 insertions(+), 169 deletions(-) (limited to 'src/Persistence_representations') diff --git a/src/Persistence_representations/test/persistence_intervals_test.cpp b/src/Persistence_representations/test/persistence_intervals_test.cpp index 545330c4..c8f67966 100644 --- a/src/Persistence_representations/test/persistence_intervals_test.cpp +++ b/src/Persistence_representations/test/persistence_intervals_test.cpp @@ -25,25 +25,20 @@ #include #include #include "gudhi/Persistence_intervals.h" +#include +#include #include using namespace Gudhi; using namespace Gudhi::Persistence_representations; -double epsilon = 0.0000005; - -// cout << "Left most end of the interval : " << min_max_.first << std::endl; -// cout << "Right most end of the interval : " << min_max_.second << std::endl; BOOST_AUTO_TEST_CASE(check_min_max_function) { - std::cerr << "First test \n"; Persistence_intervals p("data/file_with_diagram"); std::pair min_max_ = p.get_x_range(); - // cout << min_max_.first << " " << min_max_.second << std::endl;getchar(); - - BOOST_CHECK(fabs(min_max_.first - 0.0290362) <= epsilon); - BOOST_CHECK(fabs(min_max_.second - 0.994537) <= epsilon); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(min_max_.first, 0.0290362, Gudhi::Persistence_representations::epsi); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(min_max_.second, 0.994537, Gudhi::Persistence_representations::epsi); } BOOST_AUTO_TEST_CASE(check_length_of_dominant_intervals) { @@ -61,7 +56,8 @@ BOOST_AUTO_TEST_CASE(check_length_of_dominant_intervals) { dominant_intervals_length.push_back(0.700468); dominant_intervals_length.push_back(0.622177); for (size_t i = 0; i != dominant_ten_intervals_length.size(); ++i) { - BOOST_CHECK(fabs(dominant_ten_intervals_length[i] - dominant_intervals_length[i]) <= epsilon); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(dominant_ten_intervals_length[i], dominant_intervals_length[i], + Gudhi::Persistence_representations::epsi); } } BOOST_AUTO_TEST_CASE(check_dominant_intervals) { @@ -81,8 +77,10 @@ BOOST_AUTO_TEST_CASE(check_dominant_intervals) { templ.push_back(std::pair(0.267421, 0.889597)); for (size_t i = 0; i != ten_dominant_intervals.size(); ++i) { - BOOST_CHECK(fabs(ten_dominant_intervals[i].first - templ[i].first) <= epsilon); - BOOST_CHECK(fabs(ten_dominant_intervals[i].second - templ[i].second) <= epsilon); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(ten_dominant_intervals[i].first, templ[i].first, + Gudhi::Persistence_representations::epsi); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(ten_dominant_intervals[i].second, templ[i].second, + Gudhi::Persistence_representations::epsi); } } @@ -102,7 +100,7 @@ BOOST_AUTO_TEST_CASE(check_histogram_of_lengths) { template_histogram.push_back(1); template_histogram.push_back(1); for (size_t i = 0; i != histogram.size(); ++i) { - BOOST_CHECK(fabs(histogram[i] - template_histogram[i]) <= epsilon); + BOOST_CHECK(histogram[i] == template_histogram[i]); } } @@ -123,7 +121,7 @@ BOOST_AUTO_TEST_CASE(check_cumulative_histograms_of_lengths) { template_cumulative_histogram.push_back(45); for (size_t i = 0; i != cumulative_histogram.size(); ++i) { - BOOST_CHECK(fabs(cumulative_histogram[i] - template_cumulative_histogram[i]) <= epsilon); + BOOST_CHECK(cumulative_histogram[i] == template_cumulative_histogram[i]); } } BOOST_AUTO_TEST_CASE(check_characteristic_function_of_diagram) { @@ -143,15 +141,8 @@ BOOST_AUTO_TEST_CASE(check_characteristic_function_of_diagram) { template_char_funct_diag.push_back(0.0676303); for (size_t i = 0; i != char_funct_diag.size(); ++i) { - // cout << char_funct_diag[i] << std::endl; - if (fabs(char_funct_diag[i] - template_char_funct_diag[i]) >= 0.0001) { - std::cout << "Boost test fail check_characteristic_function_of_diagram : " << std::endl; - std::cerr << char_funct_diag[i] << " " << template_char_funct_diag[i] << std::endl; - std::cerr << fabs(char_funct_diag[i] - template_char_funct_diag[i]) << std::endl; - std::cerr << 0.0001 << std::endl; - //getchar(); - } - BOOST_CHECK(fabs(char_funct_diag[i] - template_char_funct_diag[i]) <= 0.0001); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(char_funct_diag[i], template_char_funct_diag[i], + Gudhi::Persistence_representations::epsi); } } @@ -174,110 +165,110 @@ BOOST_AUTO_TEST_CASE(check_cumulative_characteristic_function_of_diagram) { template_char_funct_diag_cumul.push_back(9.48386); for (size_t i = 0; i != cumul_char_funct_diag.size(); ++i) { - // cout << cumul_char_funct_diag[i] << std::endl; - BOOST_CHECK(fabs(cumul_char_funct_diag[i] - template_char_funct_diag_cumul[i]) <= 0.0001); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(cumul_char_funct_diag[i], template_char_funct_diag_cumul[i], + Gudhi::Persistence_representations::epsi); } } BOOST_AUTO_TEST_CASE(check_compute_persistent_betti_numbers) { Persistence_intervals p("data/file_with_diagram"); - std::vector > pbns; - pbns.push_back(std::pair(0.0290362, 1)); - pbns.push_back(std::pair(0.0307676, 2)); - pbns.push_back(std::pair(0.0366312, 3)); - pbns.push_back(std::pair(0.0544614, 4)); - pbns.push_back(std::pair(0.0920033, 5)); - pbns.push_back(std::pair(0.104599, 6)); - pbns.push_back(std::pair(0.114718, 7)); - pbns.push_back(std::pair(0.117379, 8)); - pbns.push_back(std::pair(0.123493, 9)); - pbns.push_back(std::pair(0.133638, 10)); - pbns.push_back(std::pair(0.137798, 9)); - pbns.push_back(std::pair(0.149798, 10)); - pbns.push_back(std::pair(0.155421, 11)); - pbns.push_back(std::pair(0.158443, 12)); - pbns.push_back(std::pair(0.176956, 13)); - pbns.push_back(std::pair(0.183234, 12)); - pbns.push_back(std::pair(0.191069, 13)); - pbns.push_back(std::pair(0.191333, 14)); - pbns.push_back(std::pair(0.191836, 15)); - pbns.push_back(std::pair(0.192675, 16)); - pbns.push_back(std::pair(0.208564, 17)); - pbns.push_back(std::pair(0.218425, 18)); - pbns.push_back(std::pair(0.219902, 17)); - pbns.push_back(std::pair(0.23233, 16)); - pbns.push_back(std::pair(0.234558, 17)); - pbns.push_back(std::pair(0.237166, 16)); - pbns.push_back(std::pair(0.247352, 17)); - pbns.push_back(std::pair(0.267421, 18)); - pbns.push_back(std::pair(0.268093, 19)); - pbns.push_back(std::pair(0.278734, 18)); - pbns.push_back(std::pair(0.284722, 19)); - pbns.push_back(std::pair(0.284998, 20)); - pbns.push_back(std::pair(0.294069, 21)); - pbns.push_back(std::pair(0.306293, 22)); - pbns.push_back(std::pair(0.322361, 21)); - pbns.push_back(std::pair(0.323152, 22)); - pbns.push_back(std::pair(0.371021, 23)); - pbns.push_back(std::pair(0.372395, 24)); - pbns.push_back(std::pair(0.387744, 25)); - pbns.push_back(std::pair(0.435537, 26)); - pbns.push_back(std::pair(0.462911, 25)); - pbns.push_back(std::pair(0.483569, 26)); - pbns.push_back(std::pair(0.489209, 25)); - pbns.push_back(std::pair(0.517115, 24)); - pbns.push_back(std::pair(0.522197, 23)); - pbns.push_back(std::pair(0.532665, 22)); - pbns.push_back(std::pair(0.545262, 23)); - pbns.push_back(std::pair(0.587227, 22)); - pbns.push_back(std::pair(0.593036, 23)); - pbns.push_back(std::pair(0.602647, 24)); - pbns.push_back(std::pair(0.605044, 25)); - pbns.push_back(std::pair(0.621962, 24)); - pbns.push_back(std::pair(0.629449, 23)); - pbns.push_back(std::pair(0.636719, 22)); - pbns.push_back(std::pair(0.64957, 21)); - pbns.push_back(std::pair(0.650781, 22)); - pbns.push_back(std::pair(0.654951, 23)); - pbns.push_back(std::pair(0.683489, 24)); - pbns.push_back(std::pair(0.687172, 23)); - pbns.push_back(std::pair(0.69703, 22)); - pbns.push_back(std::pair(0.701174, 21)); - pbns.push_back(std::pair(0.717623, 22)); - pbns.push_back(std::pair(0.722023, 21)); - pbns.push_back(std::pair(0.722298, 20)); - pbns.push_back(std::pair(0.725347, 19)); - pbns.push_back(std::pair(0.73071, 18)); - pbns.push_back(std::pair(0.758355, 17)); - pbns.push_back(std::pair(0.770913, 18)); - pbns.push_back(std::pair(0.790833, 17)); - pbns.push_back(std::pair(0.821211, 16)); - pbns.push_back(std::pair(0.849305, 17)); - pbns.push_back(std::pair(0.853669, 16)); - pbns.push_back(std::pair(0.866659, 15)); - pbns.push_back(std::pair(0.872896, 16)); - pbns.push_back(std::pair(0.889597, 15)); - pbns.push_back(std::pair(0.900231, 14)); - pbns.push_back(std::pair(0.903847, 13)); - pbns.push_back(std::pair(0.906299, 12)); - pbns.push_back(std::pair(0.910852, 11)); - pbns.push_back(std::pair(0.93453, 10)); - pbns.push_back(std::pair(0.944757, 9)); - pbns.push_back(std::pair(0.947812, 8)); - pbns.push_back(std::pair(0.959154, 7)); - pbns.push_back(std::pair(0.975654, 6)); - pbns.push_back(std::pair(0.976719, 5)); - pbns.push_back(std::pair(0.977343, 4)); - pbns.push_back(std::pair(0.980129, 3)); - pbns.push_back(std::pair(0.987842, 2)); - pbns.push_back(std::pair(0.990127, 1)); - pbns.push_back(std::pair(0.994537, 0)); + std::vector > pbns; + pbns.push_back(std::pair(0.0290362, 1)); + pbns.push_back(std::pair(0.0307676, 2)); + pbns.push_back(std::pair(0.0366312, 3)); + pbns.push_back(std::pair(0.0544614, 4)); + pbns.push_back(std::pair(0.0920033, 5)); + pbns.push_back(std::pair(0.104599, 6)); + pbns.push_back(std::pair(0.114718, 7)); + pbns.push_back(std::pair(0.117379, 8)); + pbns.push_back(std::pair(0.123493, 9)); + pbns.push_back(std::pair(0.133638, 10)); + pbns.push_back(std::pair(0.137798, 9)); + pbns.push_back(std::pair(0.149798, 10)); + pbns.push_back(std::pair(0.155421, 11)); + pbns.push_back(std::pair(0.158443, 12)); + pbns.push_back(std::pair(0.176956, 13)); + pbns.push_back(std::pair(0.183234, 12)); + pbns.push_back(std::pair(0.191069, 13)); + pbns.push_back(std::pair(0.191333, 14)); + pbns.push_back(std::pair(0.191836, 15)); + pbns.push_back(std::pair(0.192675, 16)); + pbns.push_back(std::pair(0.208564, 17)); + pbns.push_back(std::pair(0.218425, 18)); + pbns.push_back(std::pair(0.219902, 17)); + pbns.push_back(std::pair(0.23233, 16)); + pbns.push_back(std::pair(0.234558, 17)); + pbns.push_back(std::pair(0.237166, 16)); + pbns.push_back(std::pair(0.247352, 17)); + pbns.push_back(std::pair(0.267421, 18)); + pbns.push_back(std::pair(0.268093, 19)); + pbns.push_back(std::pair(0.278734, 18)); + pbns.push_back(std::pair(0.284722, 19)); + pbns.push_back(std::pair(0.284998, 20)); + pbns.push_back(std::pair(0.294069, 21)); + pbns.push_back(std::pair(0.306293, 22)); + pbns.push_back(std::pair(0.322361, 21)); + pbns.push_back(std::pair(0.323152, 22)); + pbns.push_back(std::pair(0.371021, 23)); + pbns.push_back(std::pair(0.372395, 24)); + pbns.push_back(std::pair(0.387744, 25)); + pbns.push_back(std::pair(0.435537, 26)); + pbns.push_back(std::pair(0.462911, 25)); + pbns.push_back(std::pair(0.483569, 26)); + pbns.push_back(std::pair(0.489209, 25)); + pbns.push_back(std::pair(0.517115, 24)); + pbns.push_back(std::pair(0.522197, 23)); + pbns.push_back(std::pair(0.532665, 22)); + pbns.push_back(std::pair(0.545262, 23)); + pbns.push_back(std::pair(0.587227, 22)); + pbns.push_back(std::pair(0.593036, 23)); + pbns.push_back(std::pair(0.602647, 24)); + pbns.push_back(std::pair(0.605044, 25)); + pbns.push_back(std::pair(0.621962, 24)); + pbns.push_back(std::pair(0.629449, 23)); + pbns.push_back(std::pair(0.636719, 22)); + pbns.push_back(std::pair(0.64957, 21)); + pbns.push_back(std::pair(0.650781, 22)); + pbns.push_back(std::pair(0.654951, 23)); + pbns.push_back(std::pair(0.683489, 24)); + pbns.push_back(std::pair(0.687172, 23)); + pbns.push_back(std::pair(0.69703, 22)); + pbns.push_back(std::pair(0.701174, 21)); + pbns.push_back(std::pair(0.717623, 22)); + pbns.push_back(std::pair(0.722023, 21)); + pbns.push_back(std::pair(0.722298, 20)); + pbns.push_back(std::pair(0.725347, 19)); + pbns.push_back(std::pair(0.73071, 18)); + pbns.push_back(std::pair(0.758355, 17)); + pbns.push_back(std::pair(0.770913, 18)); + pbns.push_back(std::pair(0.790833, 17)); + pbns.push_back(std::pair(0.821211, 16)); + pbns.push_back(std::pair(0.849305, 17)); + pbns.push_back(std::pair(0.853669, 16)); + pbns.push_back(std::pair(0.866659, 15)); + pbns.push_back(std::pair(0.872896, 16)); + pbns.push_back(std::pair(0.889597, 15)); + pbns.push_back(std::pair(0.900231, 14)); + pbns.push_back(std::pair(0.903847, 13)); + pbns.push_back(std::pair(0.906299, 12)); + pbns.push_back(std::pair(0.910852, 11)); + pbns.push_back(std::pair(0.93453, 10)); + pbns.push_back(std::pair(0.944757, 9)); + pbns.push_back(std::pair(0.947812, 8)); + pbns.push_back(std::pair(0.959154, 7)); + pbns.push_back(std::pair(0.975654, 6)); + pbns.push_back(std::pair(0.976719, 5)); + pbns.push_back(std::pair(0.977343, 4)); + pbns.push_back(std::pair(0.980129, 3)); + pbns.push_back(std::pair(0.987842, 2)); + pbns.push_back(std::pair(0.990127, 1)); + pbns.push_back(std::pair(0.994537, 0)); std::vector > pbns_new = p.compute_persistent_betti_numbers(); for (size_t i = 0; i != pbns.size(); ++i) { - // cout << pbns_new[i].first << "," << pbns_new[i].second << std::endl; - BOOST_CHECK(fabs(pbns[i].first - pbns_new[i].first) <= epsilon); - BOOST_CHECK(fabs(pbns[i].second - pbns_new[i].second) <= epsilon); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(pbns[i].first, pbns_new[i].first, + Gudhi::Persistence_representations::epsi); + BOOST_CHECK(pbns[i].second == pbns_new[i].second); } } @@ -297,7 +288,7 @@ BOOST_AUTO_TEST_CASE(check_k_n_n) { knn_template.push_back(0.786945); for (size_t i = 0; i != knn.size(); ++i) { - // cout << knn[i] << std::endl; - BOOST_CHECK(fabs(knn[i] - knn_template[i]) <= 0.000005); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(knn[i], knn_template[i], + Gudhi::Persistence_representations::epsi); } } diff --git a/src/Persistence_representations/test/persistence_intervals_with_distances_test.cpp b/src/Persistence_representations/test/persistence_intervals_with_distances_test.cpp index 7b70eee3..631e4d70 100644 --- a/src/Persistence_representations/test/persistence_intervals_with_distances_test.cpp +++ b/src/Persistence_representations/test/persistence_intervals_with_distances_test.cpp @@ -24,8 +24,9 @@ #define BOOST_TEST_MODULE "Persistence_intervals_with_distances_test" #include #include -#include "gudhi/Persistence_intervals_with_distances.h" -#include "gudhi/common_persistence_representations.h" +#include +#include +#include #include @@ -38,9 +39,7 @@ BOOST_AUTO_TEST_CASE(check_bottleneck_distances_computation) { double dist = p.distance(q); - // std::cout << "dist : " << dist << std::endl; - - BOOST_CHECK(almost_equal(dist, 0.389043)); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(dist, 0.389043, Gudhi::Persistence_representations::epsi); } BOOST_AUTO_TEST_CASE(check_default_parameters_in_distance) { @@ -51,11 +50,7 @@ BOOST_AUTO_TEST_CASE(check_default_parameters_in_distance) { double max_parameter_distance = p.distance(q, std::numeric_limits::max()); double inf_parameter_distance = p.distance(q, std::numeric_limits::infinity()); - // std::cout << "default_parameter_distance : " << default_parameter_distance << std::endl; - // std::cout << "max_parameter_distance : " << max_parameter_distance << std::endl; - // std::cout << "inf_parameter_distance : " << inf_parameter_distance << std::endl; - - BOOST_CHECK(default_parameter_distance == max_parameter_distance); - BOOST_CHECK(inf_parameter_distance == max_parameter_distance); - BOOST_CHECK(inf_parameter_distance == max_parameter_distance); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(default_parameter_distance, max_parameter_distance); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(inf_parameter_distance, max_parameter_distance); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(inf_parameter_distance, max_parameter_distance); } diff --git a/src/Persistence_representations/test/persistence_lanscapes_on_grid_test.cpp b/src/Persistence_representations/test/persistence_lanscapes_on_grid_test.cpp index 6b1608fe..8e2808d0 100644 --- a/src/Persistence_representations/test/persistence_lanscapes_on_grid_test.cpp +++ b/src/Persistence_representations/test/persistence_lanscapes_on_grid_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_landscape) { Persistence_landscape_on_grid l("data/file_with_diagram_1", 100, std::numeric_limits::max()); l.print_to_file("landscape_from_file_with_diagram_1"); @@ -53,16 +56,14 @@ BOOST_AUTO_TEST_CASE(check_construction_of_landscape_using_only_ten_levels) { std::vector v2 = g.vectorize(level); BOOST_CHECK(v1.size() == v2.size()); for (size_t i = 0; i != v1.size(); ++i) { - BOOST_CHECK(v1[i] == v2[i]); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(v1[i], v2[i]); } } } BOOST_AUTO_TEST_CASE(check_computations_of_integrals) { Persistence_landscape_on_grid p("data/file_with_diagram_1", 100, std::numeric_limits::max()); - double integral = p.compute_integral_of_landscape(); - // cerr << "integral : " << integral << endl;getchar(); - BOOST_CHECK(fabs(integral - 27.343) <= 0.00005); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.compute_integral_of_landscape(), 27.343, epsilon); } BOOST_AUTO_TEST_CASE(check_computations_of_integrals_for_each_level_separatelly) { @@ -92,9 +93,8 @@ BOOST_AUTO_TEST_CASE(check_computations_of_integrals_for_each_level_separatelly) integrals_fir_different_levels.push_back(0.202633); for (size_t level = 0; level != integrals_fir_different_levels.size(); ++level) { - double integral = p.compute_integral_of_landscape(level); - // cerr << integral << endl; - BOOST_CHECK(fabs(integral - integrals_fir_different_levels[level]) <= 0.00005); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.compute_integral_of_landscape(level), integrals_fir_different_levels[level], + epsilon); } } @@ -109,9 +109,8 @@ BOOST_AUTO_TEST_CASE(check_computations_of_integrals_of_powers_of_landscape) { integrals_fir_different_powers.push_back(0.23011); for (size_t power = 0; power != 5; ++power) { - double integral = p.compute_integral_of_landscape(power); - // cerr << integral << endl; - BOOST_CHECK(fabs(integral - integrals_fir_different_powers[power]) <= 0.00001); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.compute_integral_of_landscape(power), integrals_fir_different_powers[power], + epsilon); } } @@ -145,8 +144,8 @@ BOOST_AUTO_TEST_CASE(check_computations_of_values_on_different_points) { double x = 0.0012321; double dx = 0.05212; for (size_t i = 0; i != 10; ++i) { - BOOST_CHECK(almost_equal(p.compute_value_at_a_given_point(0, x), results_level_0[i])); - BOOST_CHECK(almost_equal(p.compute_value_at_a_given_point(10, x), results_level_10[i])); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.compute_value_at_a_given_point(0, x), results_level_0[i], epsilon); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.compute_value_at_a_given_point(10, x), results_level_10[i], epsilon); x += dx; } } @@ -179,22 +178,14 @@ BOOST_AUTO_TEST_CASE(check_computations_of_maxima_and_norms) { Persistence_landscape_on_grid second("data/file_with_diagram_2", 0., 1., 100); Persistence_landscape_on_grid sum = p + second; - // cerr << p.compute_maximum() << endl; - // cerr << p.compute_norm_of_landscape(1) << endl; - // cerr << p.compute_norm_of_landscape(2) << endl; - // cerr << p.compute_norm_of_landscape(3) << endl; - // cerr << compute_distance_of_landscapes_on_grid(p,sum,1) << endl; - // cerr << compute_distance_of_landscapes_on_grid(p,sum,2) << endl; - // cerr << compute_distance_of_landscapes_on_grid(p,sum,std::numeric_limits::max()) << endl; - - BOOST_CHECK(fabs(p.compute_maximum() - 0.46) <= 0.00001); - BOOST_CHECK(fabs(p.compute_norm_of_landscape(1) - 27.3373) <= 0.00001); - BOOST_CHECK(fabs(p.compute_norm_of_landscape(2) - 1.84143) <= 0.00001); - BOOST_CHECK(fabs(p.compute_norm_of_landscape(3) - 0.927067) <= 0.00001); - BOOST_CHECK(fabs(compute_distance_of_landscapes_on_grid(p, sum, 1) - 16.8519) <= 0.00005); - BOOST_CHECK(fabs(compute_distance_of_landscapes_on_grid(p, sum, 2) - 1.44542) <= 0.00001); - BOOST_CHECK(fabs(compute_distance_of_landscapes_on_grid(p, sum, std::numeric_limits::max()) - 0.45) <= - 0.00001); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.compute_maximum(), 0.46, epsilon); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.compute_norm_of_landscape(1), 27.3373 , epsilon); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.compute_norm_of_landscape(2), 1.84143 , epsilon); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.compute_norm_of_landscape(3), 0.927067, epsilon); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(compute_distance_of_landscapes_on_grid(p, sum, 1), 16.8519, epsilon); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(compute_distance_of_landscapes_on_grid(p, sum, 2), 1.44542, epsilon); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(compute_distance_of_landscapes_on_grid(p, sum, std::numeric_limits::max()), + 0.45, epsilon); } BOOST_AUTO_TEST_CASE(check_default_parameters_of_distances) { @@ -209,7 +200,7 @@ BOOST_AUTO_TEST_CASE(check_default_parameters_of_distances) { double dist_numeric_limit_max = p.distance(q, std::numeric_limits::max()); double dist_infinity = p.distance(q, std::numeric_limits::infinity()); - BOOST_CHECK(dist_numeric_limit_max == dist_infinity); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(dist_numeric_limit_max, dist_infinity); } BOOST_AUTO_TEST_CASE(check_computations_of_averages) { @@ -226,16 +217,15 @@ BOOST_AUTO_TEST_CASE(check_computations_of_averages) { BOOST_AUTO_TEST_CASE(check_computations_of_distances) { Persistence_landscape_on_grid p("data/file_with_diagram", 0., 1., 10000); Persistence_landscape_on_grid q("data/file_with_diagram_1", 0., 1., 10000); - BOOST_CHECK(fabs(p.distance(q) - 25.5779) <= 0.00005); - BOOST_CHECK(fabs(p.distance(q, 2) - 2.04891) <= 0.00001); - BOOST_CHECK(fabs(p.distance(q, std::numeric_limits::max()) - 0.359) <= 0.00001); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.distance(q), 25.5779, epsilon); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.distance(q, 2), 2.04891, epsilon); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.distance(q, std::numeric_limits::max()), 0.359, epsilon); } BOOST_AUTO_TEST_CASE(check_computations_of_scalar_product) { Persistence_landscape_on_grid p("data/file_with_diagram", 0., 1., 10000); Persistence_landscape_on_grid q("data/file_with_diagram_1", 0., 1., 10000); - // std::cerr << p.compute_scalar_product( q ) << std::endl; - BOOST_CHECK(almost_equal(p.compute_scalar_product(q), 0.754367)); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.compute_scalar_product(q), 0.754367, epsilon); } // Below I am storing the code used to generate tests for that functionality. diff --git a/src/Persistence_representations/test/read_persistence_from_file_test.cpp b/src/Persistence_representations/test/read_persistence_from_file_test.cpp index 76d7cdb0..afdc822c 100644 --- a/src/Persistence_representations/test/read_persistence_from_file_test.cpp +++ b/src/Persistence_representations/test/read_persistence_from_file_test.cpp @@ -21,7 +21,7 @@ */ #define BOOST_TEST_DYN_LINK -#define BOOST_TEST_MODULE "Persistence_representations" +#define BOOST_TEST_MODULE "read_persistence_from_file_test" #include #include diff --git a/src/Persistence_representations/test/vector_representation_test.cpp b/src/Persistence_representations/test/vector_representation_test.cpp index 3f3e2abe..7e4ce3ee 100644 --- a/src/Persistence_representations/test/vector_representation_test.cpp +++ b/src/Persistence_representations/test/vector_representation_test.cpp @@ -26,7 +26,7 @@ #include #define BOOST_TEST_DYN_LINK -#define BOOST_TEST_MODULE "Persistence_representations" +#define BOOST_TEST_MODULE "vector_representation_test" #include #include #include -- cgit v1.2.3 From c64433834bdf168975aa7785b03cdcfdd67c6915 Mon Sep 17 00:00:00 2001 From: pdlotko Date: Sun, 7 Jan 2018 08:09:22 +0000 Subject: reading ug fixed. git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/persistence_representations_fix_reading@3114 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: b1476d1db101bc4c7377d9e5e34445ee6cd7cf9a --- .../include/gudhi/Persistence_heat_maps.h | 4 ++-- .../include/gudhi/Persistence_landscape.h | 3 ++- .../include/gudhi/Persistence_vectors.h | 5 ++--- .../test/persistence_intervals_test.cpp | 3 +-- .../test/persistence_lanscapes_test.cpp | 10 +++------- 5 files changed, 10 insertions(+), 15 deletions(-) (limited to 'src/Persistence_representations') diff --git a/src/Persistence_representations/include/gudhi/Persistence_heat_maps.h b/src/Persistence_representations/include/gudhi/Persistence_heat_maps.h index 04dd78ad..2d4221c0 100644 --- a/src/Persistence_representations/include/gudhi/Persistence_heat_maps.h +++ b/src/Persistence_representations/include/gudhi/Persistence_heat_maps.h @@ -797,8 +797,8 @@ void Persistence_heat_maps::load_from_file(const char* file std::string temp; std::getline(in, temp); - - while (!in.eof()) { + //change + while (in.good()) { std::getline(in, temp); std::stringstream lineSS; lineSS << temp; diff --git a/src/Persistence_representations/include/gudhi/Persistence_landscape.h b/src/Persistence_representations/include/gudhi/Persistence_landscape.h index 5c300112..e8d53cb4 100644 --- a/src/Persistence_representations/include/gudhi/Persistence_landscape.h +++ b/src/Persistence_representations/include/gudhi/Persistence_landscape.h @@ -954,7 +954,8 @@ void Persistence_landscape::load_landscape_from_file(const char* filename) { std::vector > landscapeAtThisLevel; bool isThisAFirsLine = true; - while (!in.eof()) { + //change + while (in.good()) { getline(in, line); if (!(line.length() == 0 || line[0] == '#')) { std::stringstream lineSS; diff --git a/src/Persistence_representations/include/gudhi/Persistence_vectors.h b/src/Persistence_representations/include/gudhi/Persistence_vectors.h index 0fb49eee..efa61d95 100644 --- a/src/Persistence_representations/include/gudhi/Persistence_vectors.h +++ b/src/Persistence_representations/include/gudhi/Persistence_vectors.h @@ -617,9 +617,8 @@ void Vector_distances_in_diagram::load_from_file(const char* filename) { } double number; - while (true) { - in >> number; - if (in.eof()) break; + //change + while (in >> number) { this->sorted_vector_of_distances.push_back(number); } in.close(); diff --git a/src/Persistence_representations/test/persistence_intervals_test.cpp b/src/Persistence_representations/test/persistence_intervals_test.cpp index 545330c4..8bcd2508 100644 --- a/src/Persistence_representations/test/persistence_intervals_test.cpp +++ b/src/Persistence_representations/test/persistence_intervals_test.cpp @@ -35,8 +35,7 @@ double epsilon = 0.0000005; // cout << "Left most end of the interval : " << min_max_.first << std::endl; // cout << "Right most end of the interval : " << min_max_.second << std::endl; -BOOST_AUTO_TEST_CASE(check_min_max_function) { - std::cerr << "First test \n"; +BOOST_AUTO_TEST_CASE(check_min_max_function) { Persistence_intervals p("data/file_with_diagram"); std::pair min_max_ = p.get_x_range(); diff --git a/src/Persistence_representations/test/persistence_lanscapes_test.cpp b/src/Persistence_representations/test/persistence_lanscapes_test.cpp index 81adb6fa..006e5dcf 100644 --- a/src/Persistence_representations/test/persistence_lanscapes_test.cpp +++ b/src/Persistence_representations/test/persistence_lanscapes_test.cpp @@ -216,13 +216,9 @@ BOOST_AUTO_TEST_CASE(check_computations_of_distances) { Persistence_landscape p(diag); std::vector > diag2 = read_persistence_intervals_in_one_dimension_from_file("data/file_with_diagram_1"); - Persistence_landscape q(diag2); - std::cout << "p.distance(q) = " << p.distance(q) << std::endl; - BOOST_CHECK(fabs(p.distance(q) - 25.5824) <= 0.00005); - std::cout << "p.distance(q, 2) = " << p.distance(q, 2) << std::endl; - BOOST_CHECK(fabs(p.distance(q, 2) - 2.1264) <= 0.0001); - std::cout << "p.distance(q, std::numeric_limits::max()) = " << - p.distance(q, std::numeric_limits::max()) << std::endl; + Persistence_landscape q(diag2); + BOOST_CHECK(fabs(p.distance(q) - 25.5824) <= 0.00005); + BOOST_CHECK(fabs(p.distance(q, 2) - 2.1264) <= 0.0001); BOOST_CHECK(fabs(p.distance(q, std::numeric_limits::max()) - 0.359068) <= 0.00001); } -- cgit v1.2.3 From 97a6bdd67d8cff9bc8c0126df86be044d393583c Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Mon, 8 Jan 2018 14:04:26 +0000 Subject: clang-format files git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@3118 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: c8371fc65da4f9912b602a4f3a6701661e46580e --- .../doc/Persistence_representations_doc.h | 7 +-- .../example/persistence_vectors.cpp | 2 +- .../test/persistence_heat_maps_test.cpp | 14 ++--- .../test/persistence_intervals_test.cpp | 6 +-- .../test/persistence_lanscapes_on_grid_test.cpp | 10 ++-- .../test/persistence_lanscapes_test.cpp | 60 ++++++---------------- .../test/read_persistence_from_file_test.cpp | 10 ++-- .../test/vector_representation_test.cpp | 6 +-- ...h_m_weighted_by_arctan_of_their_persistence.cpp | 2 +- ...te_p_h_m_weighted_by_distance_from_diagonal.cpp | 3 +- ...ate_p_h_m_weighted_by_squared_diag_distance.cpp | 4 +- ...ompute_scalar_product_of_landscapes_on_grid.cpp | 7 +-- .../create_landscapes_on_grid.cpp | 1 - .../average_persistence_vectors.cpp | 3 +- .../compute_distance_of_persistence_vectors.cpp | 3 +- ...mpute_scalar_product_of_persistence_vectors.cpp | 3 +- .../create_persistence_vectors.cpp | 3 +- .../plot_persistence_vectors.cpp | 3 +- 18 files changed, 53 insertions(+), 94 deletions(-) (limited to 'src/Persistence_representations') diff --git a/src/Persistence_representations/doc/Persistence_representations_doc.h b/src/Persistence_representations/doc/Persistence_representations_doc.h index c77e75e2..978fb5bd 100644 --- a/src/Persistence_representations/doc/Persistence_representations_doc.h +++ b/src/Persistence_representations/doc/Persistence_representations_doc.h @@ -83,8 +83,8 @@ namespace Persistence_representations { \li Persistence vectors (allow averaging, computation of distances, scalar products, vectorizations and real value characteristics). \li Persistence diagrams / barcodes (allow computation of distances, vectorizations and real value characteristics). - - + + Note that at the while functionalities like averaging, distances and scalar products are fixed, there is no canonical way of vectorizing and computing real valued characteristics of objects. Therefore the vectorizations and computation of real value characteristics procedures are quite likely to evolve in the furthering @@ -139,7 +139,8 @@ namespace Persistence_representations { possible ways to proceed: \li Use non exact representation on a grid described in the Section \ref sec_landscapes_on_grid. - \li Compute just a number of initial nonzero landscapes. This option is available from C++ level as a last parameter of the constructor of persistence landscape (set by default to std::numeric_limits::max()). + \li Compute just a number of initial nonzero landscapes. This option is available from C++ level as a last parameter of + the constructor of persistence landscape (set by default to std::numeric_limits::max()). diff --git a/src/Persistence_representations/example/persistence_vectors.cpp b/src/Persistence_representations/example/persistence_vectors.cpp index 59eca152..834ae644 100644 --- a/src/Persistence_representations/example/persistence_vectors.cpp +++ b/src/Persistence_representations/example/persistence_vectors.cpp @@ -30,7 +30,7 @@ #include using Vector_distances_in_diagram = - Gudhi::Persistence_representations::Vector_distances_in_diagram; + Gudhi::Persistence_representations::Vector_distances_in_diagram; int main(int argc, char** argv) { // create two simple vectors with birth--death pairs: diff --git a/src/Persistence_representations/test/persistence_heat_maps_test.cpp b/src/Persistence_representations/test/persistence_heat_maps_test.cpp index 4da13b86..e36108b7 100644 --- a/src/Persistence_representations/test/persistence_heat_maps_test.cpp +++ b/src/Persistence_representations/test/persistence_heat_maps_test.cpp @@ -142,15 +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); - GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.distance(p), 0., epsilon); + 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(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); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(r.distance(r), 0., epsilon); } BOOST_AUTO_TEST_CASE(check_projections_to_R_for_heat_maps) { @@ -174,11 +174,11 @@ BOOST_AUTO_TEST_CASE(check_scalar_products_for_heat_maps) { 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(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); + 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/Persistence_representations/test/persistence_intervals_test.cpp b/src/Persistence_representations/test/persistence_intervals_test.cpp index c8f67966..f555e243 100644 --- a/src/Persistence_representations/test/persistence_intervals_test.cpp +++ b/src/Persistence_representations/test/persistence_intervals_test.cpp @@ -266,8 +266,7 @@ BOOST_AUTO_TEST_CASE(check_compute_persistent_betti_numbers) { std::vector > pbns_new = p.compute_persistent_betti_numbers(); for (size_t i = 0; i != pbns.size(); ++i) { - GUDHI_TEST_FLOAT_EQUALITY_CHECK(pbns[i].first, pbns_new[i].first, - Gudhi::Persistence_representations::epsi); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(pbns[i].first, pbns_new[i].first, Gudhi::Persistence_representations::epsi); BOOST_CHECK(pbns[i].second == pbns_new[i].second); } } @@ -288,7 +287,6 @@ BOOST_AUTO_TEST_CASE(check_k_n_n) { knn_template.push_back(0.786945); for (size_t i = 0; i != knn.size(); ++i) { - GUDHI_TEST_FLOAT_EQUALITY_CHECK(knn[i], knn_template[i], - Gudhi::Persistence_representations::epsi); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(knn[i], knn_template[i], Gudhi::Persistence_representations::epsi); } } diff --git a/src/Persistence_representations/test/persistence_lanscapes_on_grid_test.cpp b/src/Persistence_representations/test/persistence_lanscapes_on_grid_test.cpp index 8e2808d0..130ac8cc 100644 --- a/src/Persistence_representations/test/persistence_lanscapes_on_grid_test.cpp +++ b/src/Persistence_representations/test/persistence_lanscapes_on_grid_test.cpp @@ -179,8 +179,8 @@ BOOST_AUTO_TEST_CASE(check_computations_of_maxima_and_norms) { Persistence_landscape_on_grid sum = p + second; GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.compute_maximum(), 0.46, epsilon); - GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.compute_norm_of_landscape(1), 27.3373 , epsilon); - GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.compute_norm_of_landscape(2), 1.84143 , epsilon); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.compute_norm_of_landscape(1), 27.3373, epsilon); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.compute_norm_of_landscape(2), 1.84143, epsilon); GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.compute_norm_of_landscape(3), 0.927067, epsilon); GUDHI_TEST_FLOAT_EQUALITY_CHECK(compute_distance_of_landscapes_on_grid(p, sum, 1), 16.8519, epsilon); GUDHI_TEST_FLOAT_EQUALITY_CHECK(compute_distance_of_landscapes_on_grid(p, sum, 2), 1.44542, epsilon); @@ -189,12 +189,10 @@ BOOST_AUTO_TEST_CASE(check_computations_of_maxima_and_norms) { } BOOST_AUTO_TEST_CASE(check_default_parameters_of_distances) { - std::vector > diag = - read_persistence_intervals_in_dimension("data/file_with_diagram"); + std::vector > diag = read_persistence_intervals_in_dimension("data/file_with_diagram"); Persistence_landscape_on_grid p(diag, 0., 1., 100); - std::vector > diag1 = - read_persistence_intervals_in_dimension("data/file_with_diagram_1"); + std::vector > diag1 = read_persistence_intervals_in_dimension("data/file_with_diagram_1"); Persistence_landscape_on_grid q(diag1, 0., 1., 100); double dist_numeric_limit_max = p.distance(q, std::numeric_limits::max()); diff --git a/src/Persistence_representations/test/persistence_lanscapes_test.cpp b/src/Persistence_representations/test/persistence_lanscapes_test.cpp index e7267bec..e98ef894 100644 --- a/src/Persistence_representations/test/persistence_lanscapes_test.cpp +++ b/src/Persistence_representations/test/persistence_lanscapes_test.cpp @@ -35,12 +35,12 @@ using namespace Gudhi::Persistence_representations; double epsilon = 0.0005; -BOOST_AUTO_TEST_CASE(check_construction_of_landscape) { +BOOST_AUTO_TEST_CASE(check_construction_of_landscape) { std::vector > diag = - read_persistence_intervals_in_one_dimension_from_file("data/file_with_diagram"); + read_persistence_intervals_in_one_dimension_from_file("data/file_with_diagram"); Persistence_landscape p(diag); - Persistence_landscape q; - q.load_landscape_from_file("data/file_with_landscape_from_file_with_diagram"); + Persistence_landscape q; + q.load_landscape_from_file("data/file_with_landscape_from_file_with_diagram"); BOOST_CHECK(p == q); } @@ -48,12 +48,10 @@ BOOST_AUTO_TEST_CASE(check_construction_of_landscape_form_gudhi_style_file) { Persistence_landscape p("data/persistence_file_with_four_entries_per_line", 1); // p.print_to_file("persistence_file_with_four_entries_per_line_landscape"); Persistence_landscape q; - q.load_landscape_from_file("data/persistence_file_with_four_entries_per_line_landscape"); + q.load_landscape_from_file("data/persistence_file_with_four_entries_per_line_landscape"); BOOST_CHECK(p == q); } - - BOOST_AUTO_TEST_CASE(check_computations_of_integrals) { std::vector > diag = read_persistence_intervals_in_one_dimension_from_file("data/file_with_diagram"); @@ -123,18 +121,18 @@ BOOST_AUTO_TEST_CASE(check_computations_of_values_on_different_points) { read_persistence_intervals_in_one_dimension_from_file("data/file_with_diagram"); Persistence_landscape p(diag); - GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.compute_value_at_a_given_point(1, 0.0), 0. , epsilon); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.compute_value_at_a_given_point(1, 0.0), 0., epsilon); GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.compute_value_at_a_given_point(1, 0.1), 0.0692324, epsilon); - GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.compute_value_at_a_given_point(1, 0.2), 0.163369 , epsilon); - GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.compute_value_at_a_given_point(1, 0.3), 0.217115 , epsilon); - GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.compute_value_at_a_given_point(2, 0.0), 0. , epsilon); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.compute_value_at_a_given_point(1, 0.2), 0.163369, epsilon); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.compute_value_at_a_given_point(1, 0.3), 0.217115, epsilon); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.compute_value_at_a_given_point(2, 0.0), 0., epsilon); GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.compute_value_at_a_given_point(2, 0.1), 0.0633688, epsilon); - GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.compute_value_at_a_given_point(2, 0.2), 0.122361 , epsilon); - GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.compute_value_at_a_given_point(2, 0.3), 0.195401 , epsilon); - GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.compute_value_at_a_given_point(3, 0.0), 0. , epsilon); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.compute_value_at_a_given_point(2, 0.2), 0.122361, epsilon); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.compute_value_at_a_given_point(2, 0.3), 0.195401, epsilon); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.compute_value_at_a_given_point(3, 0.0), 0., epsilon); GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.compute_value_at_a_given_point(3, 0.1), 0.0455386, epsilon); GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.compute_value_at_a_given_point(3, 0.2), 0.0954012, epsilon); - GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.compute_value_at_a_given_point(3, 0.3), 0.185282 , epsilon); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.compute_value_at_a_given_point(3, 0.3), 0.185282, epsilon); } BOOST_AUTO_TEST_CASE(check_computations_sum_differences_and_multiplications) { @@ -170,14 +168,14 @@ BOOST_AUTO_TEST_CASE(check_computations_of_maxima_and_norms) { second.load_landscape_from_file("data/file_with_landscape_from_file_with_diagram_1"); Persistence_landscape sum = p + second; - GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.compute_maximum() , 0.431313, epsilon); - GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.compute_norm_of_landscape(1), 2.34992 , epsilon); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.compute_maximum(), 0.431313, epsilon); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.compute_norm_of_landscape(1), 2.34992, epsilon); GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.compute_norm_of_landscape(2), 0.706095, epsilon); GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.compute_norm_of_landscape(3), 0.501867, epsilon); GUDHI_TEST_FLOAT_EQUALITY_CHECK(compute_distance_of_landscapes(p, sum, 1), 27.9323, epsilon); GUDHI_TEST_FLOAT_EQUALITY_CHECK(compute_distance_of_landscapes(p, sum, 2), 2.35199, epsilon); - GUDHI_TEST_FLOAT_EQUALITY_CHECK(compute_distance_of_landscapes(p, sum, std::numeric_limits::max()), - 0.464478, epsilon); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(compute_distance_of_landscapes(p, sum, std::numeric_limits::max()), 0.464478, + epsilon); } BOOST_AUTO_TEST_CASE(check_default_parameters_of_distances) { @@ -232,30 +230,6 @@ BOOST_AUTO_TEST_CASE(check_computations_of_scalar_product) { GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.compute_scalar_product(q), 0.754498, epsilon); } - - - - - - - - - - - - - - - - - - - - - - - - // Below I am storing the code used to generate tests for that functionality. /* if ( argc != 2 ) diff --git a/src/Persistence_representations/test/read_persistence_from_file_test.cpp b/src/Persistence_representations/test/read_persistence_from_file_test.cpp index afdc822c..276b92ab 100644 --- a/src/Persistence_representations/test/read_persistence_from_file_test.cpp +++ b/src/Persistence_representations/test/read_persistence_from_file_test.cpp @@ -30,8 +30,6 @@ using namespace Gudhi; using namespace Gudhi::Persistence_representations; - - BOOST_AUTO_TEST_CASE(test_read_file_with_four_elements_per_line) { std::vector > what_we_should_get; what_we_should_get.push_back(std::make_pair(0, 2)); @@ -39,7 +37,7 @@ BOOST_AUTO_TEST_CASE(test_read_file_with_four_elements_per_line) { what_we_should_get.push_back(std::make_pair(10, 90)); what_we_should_get.push_back(std::make_pair(4, 4)); std::vector > what_we_get = read_persistence_intervals_in_one_dimension_from_file( - "data/persistence_file_with_four_entries_per_line", 1, 1000); + "data/persistence_file_with_four_entries_per_line", 1, 1000); // for ( size_t i = 0 ; i != what_we_get.size() ; ++i ) //{ @@ -76,7 +74,6 @@ BOOST_AUTO_TEST_CASE(test_read_file_with_three_elements_per_line) { } } - BOOST_AUTO_TEST_CASE(test_read_file_with_two_elements_per_line) { std::vector > what_we_should_get; what_we_should_get.push_back(std::make_pair(4, 10)); @@ -84,12 +81,11 @@ BOOST_AUTO_TEST_CASE(test_read_file_with_two_elements_per_line) { what_we_should_get.push_back(std::make_pair(0, 1)); what_we_should_get.push_back(std::make_pair(1, 4)); - std::vector > what_we_get = - read_persistence_intervals_in_one_dimension_from_file("data/persistence_file_with_two_entries_per_line", -1, 9999); + std::vector > what_we_get = read_persistence_intervals_in_one_dimension_from_file( + "data/persistence_file_with_two_entries_per_line", -1, 9999); BOOST_CHECK(what_we_should_get.size() == what_we_get.size()); for (size_t i = 0; i != what_we_get.size(); ++i) { BOOST_CHECK(what_we_should_get[i] == what_we_get[i]); } } - diff --git a/src/Persistence_representations/test/vector_representation_test.cpp b/src/Persistence_representations/test/vector_representation_test.cpp index 7e4ce3ee..c545dce7 100644 --- a/src/Persistence_representations/test/vector_representation_test.cpp +++ b/src/Persistence_representations/test/vector_representation_test.cpp @@ -295,12 +295,10 @@ BOOST_AUTO_TEST_CASE(check_distance_computations) { } BOOST_AUTO_TEST_CASE(check_default_parameters_of_distances) { - std::vector > diag = - read_persistence_intervals_in_dimension("data/file_with_diagram"); + std::vector > diag = read_persistence_intervals_in_dimension("data/file_with_diagram"); Vector_distances_in_diagram p(diag, 100); - std::vector > diag1 = - read_persistence_intervals_in_dimension("data/file_with_diagram_1"); + std::vector > diag1 = read_persistence_intervals_in_dimension("data/file_with_diagram_1"); Vector_distances_in_diagram q(diag1, 100); double dist_numeric_limit_max = p.distance(q, std::numeric_limits::max()); diff --git a/src/Persistence_representations/utilities/persistence_heat_maps/create_p_h_m_weighted_by_arctan_of_their_persistence.cpp b/src/Persistence_representations/utilities/persistence_heat_maps/create_p_h_m_weighted_by_arctan_of_their_persistence.cpp index 47c70484..b4a1daa5 100644 --- a/src/Persistence_representations/utilities/persistence_heat_maps/create_p_h_m_weighted_by_arctan_of_their_persistence.cpp +++ b/src/Persistence_representations/utilities/persistence_heat_maps/create_p_h_m_weighted_by_arctan_of_their_persistence.cpp @@ -29,7 +29,7 @@ using arc_tan_of_persistence_of_point = Gudhi::Persistence_representations::arc_tan_of_persistence_of_point; using Persistence_heat_maps = - Gudhi::Persistence_representations::Persistence_heat_maps; + Gudhi::Persistence_representations::Persistence_heat_maps; int main(int argc, char** argv) { std::cout << "This program creates persistence heat map files (*.mps) of persistence diagrams files (*.pers) " diff --git a/src/Persistence_representations/utilities/persistence_heat_maps/create_p_h_m_weighted_by_distance_from_diagonal.cpp b/src/Persistence_representations/utilities/persistence_heat_maps/create_p_h_m_weighted_by_distance_from_diagonal.cpp index 659a5105..c50f9ddb 100644 --- a/src/Persistence_representations/utilities/persistence_heat_maps/create_p_h_m_weighted_by_distance_from_diagonal.cpp +++ b/src/Persistence_representations/utilities/persistence_heat_maps/create_p_h_m_weighted_by_distance_from_diagonal.cpp @@ -28,8 +28,7 @@ #include using distance_from_diagonal_scaling = Gudhi::Persistence_representations::distance_from_diagonal_scaling; -using Persistence_heat_maps = - Gudhi::Persistence_representations::Persistence_heat_maps; +using Persistence_heat_maps = Gudhi::Persistence_representations::Persistence_heat_maps; int main(int argc, char** argv) { std::cout << "This program creates persistence heat map files (*.mps) of persistence diagrams files (*.pers) " diff --git a/src/Persistence_representations/utilities/persistence_heat_maps/create_p_h_m_weighted_by_squared_diag_distance.cpp b/src/Persistence_representations/utilities/persistence_heat_maps/create_p_h_m_weighted_by_squared_diag_distance.cpp index 9497b188..59ff3c24 100644 --- a/src/Persistence_representations/utilities/persistence_heat_maps/create_p_h_m_weighted_by_squared_diag_distance.cpp +++ b/src/Persistence_representations/utilities/persistence_heat_maps/create_p_h_m_weighted_by_squared_diag_distance.cpp @@ -28,9 +28,9 @@ #include using squared_distance_from_diagonal_scaling = - Gudhi::Persistence_representations::squared_distance_from_diagonal_scaling; + Gudhi::Persistence_representations::squared_distance_from_diagonal_scaling; using Persistence_heat_maps = - Gudhi::Persistence_representations::Persistence_heat_maps; + Gudhi::Persistence_representations::Persistence_heat_maps; int main(int argc, char** argv) { std::cout << "This program creates persistence heat map files (*.mps) of persistence diagrams files (*.pers) " diff --git a/src/Persistence_representations/utilities/persistence_landscapes_on_grid/compute_scalar_product_of_landscapes_on_grid.cpp b/src/Persistence_representations/utilities/persistence_landscapes_on_grid/compute_scalar_product_of_landscapes_on_grid.cpp index e2222487..01de3dee 100644 --- a/src/Persistence_representations/utilities/persistence_landscapes_on_grid/compute_scalar_product_of_landscapes_on_grid.cpp +++ b/src/Persistence_representations/utilities/persistence_landscapes_on_grid/compute_scalar_product_of_landscapes_on_grid.cpp @@ -29,9 +29,10 @@ using Persistence_landscape_on_grid = Gudhi::Persistence_representations::Persistence_landscape_on_grid; int main(int argc, char** argv) { - std::cout << "This program computes scalar product of persistence landscapes on grid stored in a file (the file needs to " - << "be created beforehand). \n" - << "The parameters of this programs are names of files with persistence landscapes on grid.\n"; + std::cout + << "This program computes scalar product of persistence landscapes on grid stored in a file (the file needs to " + << "be created beforehand). \n" + << "The parameters of this programs are names of files with persistence landscapes on grid.\n"; if (argc < 3) { std::cout << "Wrong number of parameters, the program will now terminate \n"; diff --git a/src/Persistence_representations/utilities/persistence_landscapes_on_grid/create_landscapes_on_grid.cpp b/src/Persistence_representations/utilities/persistence_landscapes_on_grid/create_landscapes_on_grid.cpp index 2827f982..78e8ef57 100644 --- a/src/Persistence_representations/utilities/persistence_landscapes_on_grid/create_landscapes_on_grid.cpp +++ b/src/Persistence_representations/utilities/persistence_landscapes_on_grid/create_landscapes_on_grid.cpp @@ -48,7 +48,6 @@ int main(int argc, char** argv) { return 1; } - size_t size_of_grid = (size_t)atoi(argv[1]); double min_ = atof(argv[2]); double max_ = atof(argv[3]); diff --git a/src/Persistence_representations/utilities/persistence_vectors/average_persistence_vectors.cpp b/src/Persistence_representations/utilities/persistence_vectors/average_persistence_vectors.cpp index 8de7725c..0144e76f 100644 --- a/src/Persistence_representations/utilities/persistence_vectors/average_persistence_vectors.cpp +++ b/src/Persistence_representations/utilities/persistence_vectors/average_persistence_vectors.cpp @@ -26,8 +26,7 @@ #include using Euclidean_distance = Gudhi::Euclidean_distance; -using Vector_distances_in_diagram = - Gudhi::Persistence_representations::Vector_distances_in_diagram; +using Vector_distances_in_diagram = Gudhi::Persistence_representations::Vector_distances_in_diagram; int main(int argc, char** argv) { std::cout << "This program computes average of persistence vectors stored in files (the files needs to " diff --git a/src/Persistence_representations/utilities/persistence_vectors/compute_distance_of_persistence_vectors.cpp b/src/Persistence_representations/utilities/persistence_vectors/compute_distance_of_persistence_vectors.cpp index f8b71e5b..7e66d25e 100644 --- a/src/Persistence_representations/utilities/persistence_vectors/compute_distance_of_persistence_vectors.cpp +++ b/src/Persistence_representations/utilities/persistence_vectors/compute_distance_of_persistence_vectors.cpp @@ -28,8 +28,7 @@ #include using Euclidean_distance = Gudhi::Euclidean_distance; -using Vector_distances_in_diagram = - Gudhi::Persistence_representations::Vector_distances_in_diagram; +using Vector_distances_in_diagram = Gudhi::Persistence_representations::Vector_distances_in_diagram; int main(int argc, char** argv) { std::cout << "This program compute distance of persistence vectors stored in a file (the file needs to be created " diff --git a/src/Persistence_representations/utilities/persistence_vectors/compute_scalar_product_of_persistence_vectors.cpp b/src/Persistence_representations/utilities/persistence_vectors/compute_scalar_product_of_persistence_vectors.cpp index bda0b61b..303c6e3e 100644 --- a/src/Persistence_representations/utilities/persistence_vectors/compute_scalar_product_of_persistence_vectors.cpp +++ b/src/Persistence_representations/utilities/persistence_vectors/compute_scalar_product_of_persistence_vectors.cpp @@ -28,8 +28,7 @@ #include using Euclidean_distance = Gudhi::Euclidean_distance; -using Vector_distances_in_diagram = - Gudhi::Persistence_representations::Vector_distances_in_diagram; +using Vector_distances_in_diagram = Gudhi::Persistence_representations::Vector_distances_in_diagram; int main(int argc, char** argv) { std::cout << "This program computes scalar product of persistence vectors stored in a file (the file needs to " diff --git a/src/Persistence_representations/utilities/persistence_vectors/create_persistence_vectors.cpp b/src/Persistence_representations/utilities/persistence_vectors/create_persistence_vectors.cpp index 753675cb..cc5e5393 100644 --- a/src/Persistence_representations/utilities/persistence_vectors/create_persistence_vectors.cpp +++ b/src/Persistence_representations/utilities/persistence_vectors/create_persistence_vectors.cpp @@ -28,8 +28,7 @@ #include using Euclidean_distance = Gudhi::Euclidean_distance; -using Vector_distances_in_diagram = - Gudhi::Persistence_representations::Vector_distances_in_diagram; +using Vector_distances_in_diagram = Gudhi::Persistence_representations::Vector_distances_in_diagram; int main(int argc, char** argv) { std::cout << "This program creates persistence vectors files (*.vect) of persistence diagrams files (*.pers) " diff --git a/src/Persistence_representations/utilities/persistence_vectors/plot_persistence_vectors.cpp b/src/Persistence_representations/utilities/persistence_vectors/plot_persistence_vectors.cpp index e52b8f7d..aa33107d 100644 --- a/src/Persistence_representations/utilities/persistence_vectors/plot_persistence_vectors.cpp +++ b/src/Persistence_representations/utilities/persistence_vectors/plot_persistence_vectors.cpp @@ -26,8 +26,7 @@ #include using Euclidean_distance = Gudhi::Euclidean_distance; -using Vector_distances_in_diagram = - Gudhi::Persistence_representations::Vector_distances_in_diagram; +using Vector_distances_in_diagram = Gudhi::Persistence_representations::Vector_distances_in_diagram; int main(int argc, char** argv) { std::cout << "This program create a Gnuplot script to plot persistence vector. Please call this program with the " -- 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/Persistence_representations') 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 06ff6fac211d2823c7d14a6d2f4a4db03f48d2e3 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Fri, 26 Jan 2018 14:01:39 +0000 Subject: Seperate installation and examples from main page Move cover complex utilities from examples GIC.cpp example was not compiled, nor tested. It is removed. Persistence representation : no need to link with Boost_SYSTEM git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@3164 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: cf2bfa6c6de2ed359aaa165b9f80bca7e06defb1 --- src/Nerve_GIC/doc/Intro_graph_induced_complex.h | 29 -- src/Nerve_GIC/example/CMakeLists.txt | 12 - src/Nerve_GIC/example/GIC.cpp | 95 ----- .../example/KeplerMapperVisuFromTxtFile.py | 72 ---- src/Nerve_GIC/example/Nerve.cpp | 96 ----- src/Nerve_GIC/example/Nerve.txt | 63 ---- src/Nerve_GIC/example/VoronoiGIC.cpp | 90 ----- src/Nerve_GIC/example/km.py | 390 --------------------- src/Nerve_GIC/example/km.py.COPYRIGHT | 26 -- src/Nerve_GIC/utilities/CMakeLists.txt | 22 ++ .../utilities/KeplerMapperVisuFromTxtFile.py | 72 ++++ src/Nerve_GIC/utilities/Nerve.cpp | 96 +++++ src/Nerve_GIC/utilities/Nerve.txt | 63 ++++ src/Nerve_GIC/utilities/VoronoiGIC.cpp | 90 +++++ src/Nerve_GIC/utilities/km.py | 390 +++++++++++++++++++++ src/Nerve_GIC/utilities/km.py.COPYRIGHT | 26 ++ .../example/CMakeLists.txt | 5 - .../test/CMakeLists.txt | 14 +- src/common/doc/examples.h | 99 ++++++ src/common/doc/installation.h | 263 ++++++++++++++ src/common/doc/main_page.h | 305 +--------------- 21 files changed, 1130 insertions(+), 1188 deletions(-) delete mode 100644 src/Nerve_GIC/example/GIC.cpp delete mode 100755 src/Nerve_GIC/example/KeplerMapperVisuFromTxtFile.py delete mode 100644 src/Nerve_GIC/example/Nerve.cpp delete mode 100644 src/Nerve_GIC/example/Nerve.txt delete mode 100644 src/Nerve_GIC/example/VoronoiGIC.cpp delete mode 100755 src/Nerve_GIC/example/km.py delete mode 100644 src/Nerve_GIC/example/km.py.COPYRIGHT create mode 100644 src/Nerve_GIC/utilities/CMakeLists.txt create mode 100755 src/Nerve_GIC/utilities/KeplerMapperVisuFromTxtFile.py create mode 100644 src/Nerve_GIC/utilities/Nerve.cpp create mode 100644 src/Nerve_GIC/utilities/Nerve.txt create mode 100644 src/Nerve_GIC/utilities/VoronoiGIC.cpp create mode 100755 src/Nerve_GIC/utilities/km.py create mode 100644 src/Nerve_GIC/utilities/km.py.COPYRIGHT create mode 100644 src/common/doc/examples.h create mode 100644 src/common/doc/installation.h (limited to 'src/Persistence_representations') diff --git a/src/Nerve_GIC/doc/Intro_graph_induced_complex.h b/src/Nerve_GIC/doc/Intro_graph_induced_complex.h index 7578cc53..344cb031 100644 --- a/src/Nerve_GIC/doc/Intro_graph_induced_complex.h +++ b/src/Nerve_GIC/doc/Intro_graph_induced_complex.h @@ -177,7 +177,6 @@ namespace cover_complex { * \image html "funcGICvisu.jpg" "Visualization with neato" * * \copyright GNU General Public License v3. - * \verbatim Contact: gudhi-users@lists.gforge.inria.fr \endverbatim */ /** @} */ // end defgroup cover_complex @@ -186,31 +185,3 @@ namespace cover_complex { } // namespace Gudhi #endif // DOC_COVER_COMPLEX_INTRO_COVER_COMPLEX_H_ - - -/* * \subsection gicexample Example with cover from function - * - * This example builds the GIC of a point cloud sampled on a 3D human shape (human.off). - * The cover C comes from the preimages of intervals (with length 0.075 and gain 0) - * covering the height function (coordinate 2), - * and the graph G comes from a Rips complex built with threshold 0.075. - * Note that if the gain is too big, the number of cliques increases a lot, - * which make the computation time much larger. - * - * \include Nerve_GIC/GIC.cpp - * - * When launching: - * - * \code $> ./GIC ../../data/points/human.off 0.075 2 0.075 0 --v - * \endcode - * - * the program outputs SC.txt, which can be visualized with python and firefox as before: - * - * \image html "gicvisu.jpg" "Visualization with KeplerMapper" - * */ - - -/* * Using e.g. - * - * \code $> python KeplerMapperVisuFromTxtFile.py && firefox SC.html - * \endcode */ diff --git a/src/Nerve_GIC/example/CMakeLists.txt b/src/Nerve_GIC/example/CMakeLists.txt index 73728dc0..434637fa 100644 --- a/src/Nerve_GIC/example/CMakeLists.txt +++ b/src/Nerve_GIC/example/CMakeLists.txt @@ -3,26 +3,14 @@ project(Nerve_GIC_examples) if (NOT CGAL_VERSION VERSION_LESS 4.8.1) - add_executable ( Nerve Nerve.cpp ) add_executable ( CoordGIC CoordGIC.cpp ) add_executable ( FuncGIC FuncGIC.cpp ) - add_executable ( VoronoiGIC VoronoiGIC.cpp ) if (TBB_FOUND) - target_link_libraries(Nerve ${TBB_LIBRARIES}) target_link_libraries(CoordGIC ${TBB_LIBRARIES}) target_link_libraries(FuncGIC ${TBB_LIBRARIES}) - target_link_libraries(VoronoiGIC ${TBB_LIBRARIES}) endif() - file(COPY KeplerMapperVisuFromTxtFile.py km.py DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) - - add_test(NAME Nerve_GIC_example_nerve COMMAND $ - "${CMAKE_SOURCE_DIR}/data/points/human.off" "2" "10" "0.3") - - add_test(NAME Nerve_GIC_example_VoronoiGIC COMMAND $ - "${CMAKE_SOURCE_DIR}/data/points/human.off" "100") - add_test(NAME Nerve_GIC_example_CoordGIC COMMAND $ "${CMAKE_SOURCE_DIR}/data/points/tore3D_1307.off" "0") diff --git a/src/Nerve_GIC/example/GIC.cpp b/src/Nerve_GIC/example/GIC.cpp deleted file mode 100644 index 2bc24a4d..00000000 --- a/src/Nerve_GIC/example/GIC.cpp +++ /dev/null @@ -1,95 +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): Mathieu Carrière - * - * 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 - -void usage(int nbArgs, char *const progName) { - std::cerr << "Error: Number of arguments (" << nbArgs << ") is not correct\n"; - std::cerr << "Usage: " << progName << " filename.off threshold coordinate resolution gain [--v] \n"; - std::cerr << " i.e.: " << progName << " ../../data/points/human.off 0.075 2 0.075 0 --v \n"; - exit(-1); // ----- >> -} - -int main(int argc, char **argv) { - if ((argc != 6) && (argc != 7)) usage(argc, argv[0]); - - using Point = std::vector; - - std::string off_file_name(argv[1]); - double threshold = atof(argv[2]); - int coord = atoi(argv[3]); - double resolution = atof(argv[4]); - double gain = atof(argv[5]); - bool verb = 0; - if (argc == 7) verb = 1; - - // ---------------------------------------------------------------------------- - // Init of a graph induced complex from an OFF file - // ---------------------------------------------------------------------------- - - Gudhi::graph_induced_complex::Graph_induced_complex GIC; - GIC.set_verbose(verb); - - bool check = GIC.read_point_cloud(off_file_name); - - if (!check) { - std::cout << "Incorrect OFF file." << std::endl; - } else { - GIC.set_color_from_coordinate(coord); - GIC.set_function_from_coordinate(coord); - - GIC.set_graph_from_rips(threshold, Gudhi::Euclidean_distance()); - - GIC.set_resolution_with_interval_length(resolution); - GIC.set_gain(gain); - GIC.set_cover_from_function(); - - GIC.find_GIC_simplices(); - - GIC.plot_TXT_for_KeplerMapper(); - - Gudhi::Simplex_tree<> stree; - GIC.create_complex(stree); - - // ---------------------------------------------------------------------------- - // Display information about the graph induced complex - // ---------------------------------------------------------------------------- - - if (verb) { - std::cout << "Graph induced complex is of dimension " << stree.dimension() << " - " << stree.num_simplices() - << " simplices - " << stree.num_vertices() << " vertices." << std::endl; - - std::cout << "Iterator on graph induced complex simplices" << std::endl; - for (auto f_simplex : stree.filtration_simplex_range()) { - for (auto vertex : stree.simplex_vertex_range(f_simplex)) { - std::cout << vertex << " "; - } - std::cout << std::endl; - } - } - } - - return 0; -} diff --git a/src/Nerve_GIC/example/KeplerMapperVisuFromTxtFile.py b/src/Nerve_GIC/example/KeplerMapperVisuFromTxtFile.py deleted file mode 100755 index d2897774..00000000 --- a/src/Nerve_GIC/example/KeplerMapperVisuFromTxtFile.py +++ /dev/null @@ -1,72 +0,0 @@ -#!/usr/bin/env python - -import km -import numpy as np -from collections import defaultdict - -"""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): Mathieu Carriere - - 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 . -""" - -__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) diff --git a/src/Nerve_GIC/example/Nerve.cpp b/src/Nerve_GIC/example/Nerve.cpp deleted file mode 100644 index 6abdedc7..00000000 --- a/src/Nerve_GIC/example/Nerve.cpp +++ /dev/null @@ -1,96 +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): Mathieu Carrière - * - * 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 - -void usage(int nbArgs, char *const progName) { - std::cerr << "Error: Number of arguments (" << nbArgs << ") is not correct\n"; - std::cerr << "Usage: " << progName << " filename.off coordinate resolution gain [--v] \n"; - std::cerr << " i.e.: " << progName << " ../../data/points/human.off 2 10 0.3 --v \n"; - exit(-1); // ----- >> -} - -int main(int argc, char **argv) { - if ((argc != 5) && (argc != 6)) usage(argc, argv[0]); - - using Point = std::vector; - - std::string off_file_name(argv[1]); - int coord = atoi(argv[2]); - int resolution = atoi(argv[3]); - double gain = atof(argv[4]); - bool verb = 0; - if (argc == 6) verb = 1; - - // -------------------------------- - // Init of a Nerve from an OFF file - // -------------------------------- - - Gudhi::cover_complex::Cover_complex SC; - SC.set_verbose(verb); - - bool check = SC.read_point_cloud(off_file_name); - - if (!check) { - std::cout << "Incorrect OFF file." << std::endl; - } else { - SC.set_type("Nerve"); - - SC.set_color_from_coordinate(coord); - SC.set_function_from_coordinate(coord); - - SC.set_graph_from_OFF(); - SC.set_resolution_with_interval_number(resolution); - SC.set_gain(gain); - SC.set_cover_from_function(); - - SC.find_simplices(); - - SC.write_info(); - - Gudhi::Simplex_tree<> stree; - SC.create_complex(stree); - SC.compute_PD(); - - // ---------------------------------------------------------------------------- - // Display information about the graph induced complex - // ---------------------------------------------------------------------------- - - if (verb) { - std::cout << "Nerve is of dimension " << stree.dimension() << " - " << stree.num_simplices() << " simplices - " - << stree.num_vertices() << " vertices." << std::endl; - - std::cout << "Iterator on Nerve simplices" << std::endl; - for (auto f_simplex : stree.filtration_simplex_range()) { - for (auto vertex : stree.simplex_vertex_range(f_simplex)) { - std::cout << vertex << " "; - } - std::cout << std::endl; - } - } - } - - return 0; -} diff --git a/src/Nerve_GIC/example/Nerve.txt b/src/Nerve_GIC/example/Nerve.txt deleted file mode 100644 index 839ff45e..00000000 --- a/src/Nerve_GIC/example/Nerve.txt +++ /dev/null @@ -1,63 +0,0 @@ -Min function value = -0.979672 and Max function value = 0.816414 -Interval 0 = [-0.979672, -0.761576] -Interval 1 = [-0.838551, -0.581967] -Interval 2 = [-0.658942, -0.402359] -Interval 3 = [-0.479334, -0.22275] -Interval 4 = [-0.299725, -0.0431415] -Interval 5 = [-0.120117, 0.136467] -Interval 6 = [0.059492, 0.316076] -Interval 7 = [0.239101, 0.495684] -Interval 8 = [0.418709, 0.675293] -Interval 9 = [0.598318, 0.816414] -Computing preimages... -Computing connected components... -.txt generated. It can be visualized with e.g. python KeplerMapperVisuFromTxtFile.py and firefox. -5 interval(s) in dimension 0: - [-0.909111, 0.00817529] - [-0.171433, 0.367392] - [-0.171433, 0.367392] - [-0.909111, 0.745853] -0 interval(s) in dimension 1: -Nerve is of dimension 1 - 41 simplices - 21 vertices. -Iterator on Nerve simplices -1 -0 -4 -4 0 -2 -2 1 -8 -8 2 -5 -5 4 -9 -9 8 -13 -13 5 -14 -14 9 -19 -19 13 -25 -32 -20 -32 20 -33 -33 25 -26 -26 14 -26 19 -42 -42 26 -34 -34 33 -27 -27 20 -35 -35 27 -35 34 -42 35 -44 -44 35 -54 -54 44 \ No newline at end of file diff --git a/src/Nerve_GIC/example/VoronoiGIC.cpp b/src/Nerve_GIC/example/VoronoiGIC.cpp deleted file mode 100644 index 32431cc2..00000000 --- a/src/Nerve_GIC/example/VoronoiGIC.cpp +++ /dev/null @@ -1,90 +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): Mathieu Carrière - * - * 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 - -void usage(int nbArgs, char *const progName) { - std::cerr << "Error: Number of arguments (" << nbArgs << ") is not correct\n"; - std::cerr << "Usage: " << progName << " filename.off N [--v] \n"; - std::cerr << " i.e.: " << progName << " ../../data/points/human.off 100 --v \n"; - exit(-1); // ----- >> -} - -int main(int argc, char **argv) { - if ((argc != 3) && (argc != 4)) usage(argc, argv[0]); - - using Point = std::vector; - - std::string off_file_name(argv[1]); - int m = atoi(argv[2]); - bool verb = 0; - if (argc == 4) verb = 1; - - // ---------------------------------------------------------------------------- - // Init of a graph induced complex from an OFF file - // ---------------------------------------------------------------------------- - - Gudhi::cover_complex::Cover_complex GIC; - GIC.set_verbose(verb); - - bool check = GIC.read_point_cloud(off_file_name); - - if (!check) { - std::cout << "Incorrect OFF file." << std::endl; - } else { - GIC.set_type("GIC"); - - GIC.set_color_from_coordinate(); - - GIC.set_graph_from_OFF(); - GIC.set_cover_from_Voronoi(Gudhi::Euclidean_distance(), m); - - GIC.find_simplices(); - - GIC.plot_OFF(); - - Gudhi::Simplex_tree<> stree; - GIC.create_complex(stree); - - // ---------------------------------------------------------------------------- - // Display information about the graph induced complex - // ---------------------------------------------------------------------------- - - if (verb) { - std::cout << "Graph induced complex is of dimension " << stree.dimension() << " - " << stree.num_simplices() - << " simplices - " << stree.num_vertices() << " vertices." << std::endl; - - std::cout << "Iterator on graph induced complex simplices" << std::endl; - for (auto f_simplex : stree.filtration_simplex_range()) { - for (auto vertex : stree.simplex_vertex_range(f_simplex)) { - std::cout << vertex << " "; - } - std::cout << std::endl; - } - } - } - - return 0; -} diff --git a/src/Nerve_GIC/example/km.py b/src/Nerve_GIC/example/km.py deleted file mode 100755 index 53024aab..00000000 --- a/src/Nerve_GIC/example/km.py +++ /dev/null @@ -1,390 +0,0 @@ -from __future__ import division -import numpy as np -from collections import defaultdict -import json -import itertools -from sklearn import cluster, preprocessing, manifold -from datetime import datetime -import sys - -class KeplerMapper(object): - # With this class you can build topological networks from (high-dimensional) data. - # - # 1) Fit a projection/lens/function to a dataset and transform it. - # For instance "mean_of_row(x) for x in X" - # 2) Map this projection with overlapping intervals/hypercubes. - # Cluster the points inside the interval - # (Note: we cluster on the inverse image/original data to lessen projection loss). - # If two clusters/nodes have the same members (due to the overlap), then: - # connect these with an edge. - # 3) Visualize the network using HTML and D3.js. - # - # functions - # --------- - # fit_transform: Create a projection (lens) from a dataset - # map: Apply Mapper algorithm on this projection and build a simplicial complex - # visualize: Turns the complex dictionary into a HTML/D3.js visualization - - def __init__(self, verbose=2): - self.verbose = verbose - - self.chunk_dist = [] - self.overlap_dist = [] - self.d = [] - self.nr_cubes = 0 - self.overlap_perc = 0 - self.clusterer = False - - def fit_transform(self, X, projection="sum", scaler=preprocessing.MinMaxScaler()): - # Creates the projection/lens from X. - # - # Input: X. Input features as a numpy array. - # Output: projected_X. original data transformed to a projection (lens). - # - # parameters - # ---------- - # projection: Projection parameter is either a string, - # a scikit class with fit_transform, like manifold.TSNE(), - # or a list of dimension indices. - # scaler: if None, do no scaling, else apply scaling to the projection - # Default: Min-Max scaling - - self.scaler = scaler - self.projection = str(projection) - - # Detect if projection is a class (for scikit-learn) - #if str(type(projection))[1:6] == "class": #TODO: de-ugly-fy - # reducer = projection - # if self.verbose > 0: - # try: - # projection.set_params(**{"verbose":self.verbose}) - # except: - # pass - # print("\n..Projecting data using: \n\t%s\n"%str(projection)) - # X = reducer.fit_transform(X) - - # Detect if projection is a string (for standard functions) - if isinstance(projection, str): - if self.verbose > 0: - print("\n..Projecting data using: %s"%(projection)) - # Stats lenses - if projection == "sum": # sum of row - X = np.sum(X, axis=1).reshape((X.shape[0],1)) - if projection == "mean": # mean of row - X = np.mean(X, axis=1).reshape((X.shape[0],1)) - if projection == "median": # mean of row - X = np.median(X, axis=1).reshape((X.shape[0],1)) - if projection == "max": # max of row - X = np.max(X, axis=1).reshape((X.shape[0],1)) - if projection == "min": # min of row - X = np.min(X, axis=1).reshape((X.shape[0],1)) - if projection == "std": # std of row - X = np.std(X, axis=1).reshape((X.shape[0],1)) - - if projection == "dist_mean": # Distance of x to mean of X - X_mean = np.mean(X, axis=0) - X = np.sum(np.sqrt((X - X_mean)**2), axis=1).reshape((X.shape[0],1)) - - # Detect if projection is a list (with dimension indices) - if isinstance(projection, list): - if self.verbose > 0: - print("\n..Projecting data using: %s"%(str(projection))) - X = X[:,np.array(projection)] - - # Scaling - if scaler is not None: - if self.verbose > 0: - print("\n..Scaling with: %s\n"%str(scaler)) - X = scaler.fit_transform(X) - - return X - - def map(self, projected_X, inverse_X=None, clusterer=cluster.DBSCAN(eps=0.5,min_samples=3), nr_cubes=10, overlap_perc=0.1): - # This maps the data to a simplicial complex. Returns a dictionary with nodes and links. - # - # Input: projected_X. A Numpy array with the projection/lens. - # Output: complex. A dictionary with "nodes", "links" and "meta information" - # - # parameters - # ---------- - # projected_X projected_X. A Numpy array with the projection/lens. Required. - # inverse_X Numpy array or None. If None then the projection itself is used for clustering. - # clusterer Scikit-learn API compatible clustering algorithm. Default: DBSCAN - # nr_cubes Int. The number of intervals/hypercubes to create. - # overlap_perc Float. The percentage of overlap "between" the intervals/hypercubes. - - start = datetime.now() - - # Helper function - def cube_coordinates_all(nr_cubes, nr_dimensions): - # Helper function to get origin coordinates for our intervals/hypercubes - # Useful for looping no matter the number of cubes or dimensions - # Example: if there are 4 cubes per dimension and 3 dimensions - # return the bottom left (origin) coordinates of 64 hypercubes, - # as a sorted list of Numpy arrays - # TODO: elegance-ify... - l = [] - for x in range(nr_cubes): - l += [x] * nr_dimensions - return [np.array(list(f)) for f in sorted(set(itertools.permutations(l,nr_dimensions)))] - - nodes = defaultdict(list) - links = defaultdict(list) - complex = {} - self.nr_cubes = nr_cubes - self.clusterer = clusterer - self.overlap_perc = overlap_perc - - if self.verbose > 0: - print("Mapping on data shaped %s using dimensions\n"%(str(projected_X.shape))) - - # If inverse image is not provided, we use the projection as the inverse image (suffer projection loss) - if inverse_X is None: - inverse_X = projected_X - - # We chop up the min-max column ranges into 'nr_cubes' parts - self.chunk_dist = (np.max(projected_X, axis=0) - np.min(projected_X, axis=0))/nr_cubes - - # We calculate the overlapping windows distance - self.overlap_dist = self.overlap_perc * self.chunk_dist - - # We find our starting point - self.d = np.min(projected_X, axis=0) - - # Use a dimension index array on the projected X - # (For now this uses the entire dimensionality, but we keep for experimentation) - di = np.array([x for x in range(projected_X.shape[1])]) - - # Prefix'ing the data with ID's - ids = np.array([x for x in range(projected_X.shape[0])]) - projected_X = np.c_[ids,projected_X] - inverse_X = np.c_[ids,inverse_X] - - # Subdivide the projected data X in intervals/hypercubes with overlap - if self.verbose > 0: - total_cubes = len(cube_coordinates_all(nr_cubes,projected_X.shape[1])) - print("Creating %s hypercubes."%total_cubes) - - for i, coor in enumerate(cube_coordinates_all(nr_cubes,di.shape[0])): - # Slice the hypercube - hypercube = projected_X[ np.invert(np.any((projected_X[:,di+1] >= self.d[di] + (coor * self.chunk_dist[di])) & - (projected_X[:,di+1] < self.d[di] + (coor * self.chunk_dist[di]) + self.chunk_dist[di] + self.overlap_dist[di]) == False, axis=1 )) ] - - if self.verbose > 1: - print("There are %s points in cube_%s / %s with starting range %s"% - (hypercube.shape[0],i,total_cubes,self.d[di] + (coor * self.chunk_dist[di]))) - - # If at least one sample inside the hypercube - if hypercube.shape[0] > 0: - # Cluster the data point(s) in the cube, skipping the id-column - # Note that we apply clustering on the inverse image (original data samples) that fall inside the cube. - inverse_x = inverse_X[[int(nn) for nn in hypercube[:,0]]] - - clusterer.fit(inverse_x[:,1:]) - - if self.verbose > 1: - print("Found %s clusters in cube_%s\n"%(np.unique(clusterer.labels_[clusterer.labels_ > -1]).shape[0],i)) - - #Now for every (sample id in cube, predicted cluster label) - for a in np.c_[hypercube[:,0],clusterer.labels_]: - if a[1] != -1: #if not predicted as noise - cluster_id = str(coor[0])+"_"+str(i)+"_"+str(a[1])+"_"+str(coor)+"_"+str(self.d[di] + (coor * self.chunk_dist[di])) # TODO: de-rudimentary-ify - nodes[cluster_id].append( int(a[0]) ) # Append the member id's as integers - else: - if self.verbose > 1: - print("Cube_%s is empty.\n"%(i)) - - # Create links when clusters from different hypercubes have members with the same sample id. - candidates = itertools.combinations(nodes.keys(),2) - for candidate in candidates: - # if there are non-unique members in the union - if len(nodes[candidate[0]]+nodes[candidate[1]]) != len(set(nodes[candidate[0]]+nodes[candidate[1]])): - links[candidate[0]].append( candidate[1] ) - - # Reporting - if self.verbose > 0: - nr_links = 0 - for k in links: - nr_links += len(links[k]) - print("\ncreated %s edges and %s nodes in %s."%(nr_links,len(nodes),str(datetime.now()-start))) - - complex["nodes"] = nodes - complex["links"] = links - complex["meta"] = self.projection - - return complex - - def visualize(self, complex, color_function="", path_html="mapper_visualization_output.html", title="My Data", - graph_link_distance=30, graph_gravity=0.1, graph_charge=-120, custom_tooltips=None, width_html=0, - height_html=0, show_tooltips=True, show_title=True, show_meta=True, res=0,gain=0,minimum=0,maximum=0): - # Turns the dictionary 'complex' in a html file with d3.js - # - # Input: complex. Dictionary (output from calling .map()) - # Output: a HTML page saved as a file in 'path_html'. - # - # parameters - # ---------- - # color_function string. Not fully implemented. Default: "" (distance to origin) - # path_html file path as string. Where to save the HTML page. - # title string. HTML page document title and first heading. - # graph_link_distance int. Edge length. - # graph_gravity float. "Gravity" to center of layout. - # graph_charge int. charge between nodes. - # custom_tooltips None or Numpy Array. You could use "y"-label array for this. - # width_html int. Width of canvas. Default: 0 (full width) - # height_html int. Height of canvas. Default: 0 (full height) - # show_tooltips bool. default:True - # show_title bool. default:True - # show_meta bool. default:True - - # Format JSON for D3 graph - json_s = {} - json_s["nodes"] = [] - json_s["links"] = [] - k2e = {} # a key to incremental int dict, used for id's when linking - - for e, k in enumerate(complex["nodes"]): - # Tooltip and node color formatting, TODO: de-mess-ify - if custom_tooltips is not None: - tooltip_s = "

Cluster %s

"%k + " ".join(str(custom_tooltips[complex["nodes"][k][0]]).split(" ")) - if maximum == minimum: - tooltip_i = 0 - else: - tooltip_i = int(30*(custom_tooltips[complex["nodes"][k][0]]-minimum)/(maximum-minimum)) - json_s["nodes"].append({"name": str(k), "tooltip": tooltip_s, "group": 2 * int(np.log(complex["nodes"][k][2])), "color": tooltip_i}) - else: - tooltip_s = "

Cluster %s

Contains %s members."%(k,len(complex["nodes"][k])) - json_s["nodes"].append({"name": str(k), "tooltip": tooltip_s, "group": 2 * int(np.log(len(complex["nodes"][k]))), "color": str(k.split("_")[0])}) - k2e[k] = e - for k in complex["links"]: - for link in complex["links"][k]: - json_s["links"].append({"source": k2e[k], "target":k2e[link],"value":1}) - - # Width and height of graph in HTML output - if width_html == 0: - width_css = "100%" - width_js = 'document.getElementById("holder").offsetWidth-20' - else: - width_css = "%spx" % width_html - width_js = "%s" % width_html - if height_html == 0: - height_css = "100%" - height_js = 'document.getElementById("holder").offsetHeight-20' - else: - height_css = "%spx" % height_html - height_js = "%s" % height_html - - # Whether to show certain UI elements or not - if show_tooltips == False: - tooltips_display = "display: none;" - else: - tooltips_display = "" - - if show_meta == False: - meta_display = "display: none;" - else: - meta_display = "" - - if show_title == False: - title_display = "display: none;" - else: - title_display = "" - - with open(path_html,"wb") as outfile: - html = """ - - - %s | KeplerMapper - - - -
-

%s

-

- Lens
%s

- Length of intervals
%s

- Overlap percentage
%s%%

- Color Function
%s -

-
- - """%(title,width_css, height_css, title_display, meta_display, tooltips_display, title,complex["meta"],res,gain*100,color_function,width_js,height_js,graph_charge,graph_link_distance,graph_gravity,json.dumps(json_s)) - outfile.write(html.encode("utf-8")) - if self.verbose > 0: - print("\nWrote d3.js graph to '%s'"%path_html) diff --git a/src/Nerve_GIC/example/km.py.COPYRIGHT b/src/Nerve_GIC/example/km.py.COPYRIGHT deleted file mode 100644 index bef7b121..00000000 --- a/src/Nerve_GIC/example/km.py.COPYRIGHT +++ /dev/null @@ -1,26 +0,0 @@ -km.py is a fork of https://github.com/MLWave/kepler-mapper. -Only the visualization part has been kept (Mapper part has been removed). - -This file has te following Copyright : - -The MIT License (MIT) - -Copyright (c) 2015 Triskelion - HJ van Veen - info@mlwave.com - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/src/Nerve_GIC/utilities/CMakeLists.txt b/src/Nerve_GIC/utilities/CMakeLists.txt new file mode 100644 index 00000000..a0508dc2 --- /dev/null +++ b/src/Nerve_GIC/utilities/CMakeLists.txt @@ -0,0 +1,22 @@ +cmake_minimum_required(VERSION 2.6) +project(Nerve_GIC_examples) + +if (NOT CGAL_VERSION VERSION_LESS 4.8.1) + + add_executable ( Nerve Nerve.cpp ) + add_executable ( VoronoiGIC VoronoiGIC.cpp ) + + if (TBB_FOUND) + target_link_libraries(Nerve ${TBB_LIBRARIES}) + target_link_libraries(VoronoiGIC ${TBB_LIBRARIES}) + endif() + + file(COPY KeplerMapperVisuFromTxtFile.py km.py DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) + + add_test(NAME Nerve_GIC_utilities_nerve COMMAND $ + "${CMAKE_SOURCE_DIR}/data/points/human.off" "2" "10" "0.3") + + add_test(NAME Nerve_GIC_utilities_VoronoiGIC COMMAND $ + "${CMAKE_SOURCE_DIR}/data/points/human.off" "100") + +endif (NOT CGAL_VERSION VERSION_LESS 4.8.1) diff --git a/src/Nerve_GIC/utilities/KeplerMapperVisuFromTxtFile.py b/src/Nerve_GIC/utilities/KeplerMapperVisuFromTxtFile.py new file mode 100755 index 00000000..d2897774 --- /dev/null +++ b/src/Nerve_GIC/utilities/KeplerMapperVisuFromTxtFile.py @@ -0,0 +1,72 @@ +#!/usr/bin/env python + +import km +import numpy as np +from collections import defaultdict + +"""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): Mathieu Carriere + + 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 . +""" + +__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) diff --git a/src/Nerve_GIC/utilities/Nerve.cpp b/src/Nerve_GIC/utilities/Nerve.cpp new file mode 100644 index 00000000..6abdedc7 --- /dev/null +++ b/src/Nerve_GIC/utilities/Nerve.cpp @@ -0,0 +1,96 @@ +/* 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): Mathieu Carrière + * + * 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 + +void usage(int nbArgs, char *const progName) { + std::cerr << "Error: Number of arguments (" << nbArgs << ") is not correct\n"; + std::cerr << "Usage: " << progName << " filename.off coordinate resolution gain [--v] \n"; + std::cerr << " i.e.: " << progName << " ../../data/points/human.off 2 10 0.3 --v \n"; + exit(-1); // ----- >> +} + +int main(int argc, char **argv) { + if ((argc != 5) && (argc != 6)) usage(argc, argv[0]); + + using Point = std::vector; + + std::string off_file_name(argv[1]); + int coord = atoi(argv[2]); + int resolution = atoi(argv[3]); + double gain = atof(argv[4]); + bool verb = 0; + if (argc == 6) verb = 1; + + // -------------------------------- + // Init of a Nerve from an OFF file + // -------------------------------- + + Gudhi::cover_complex::Cover_complex SC; + SC.set_verbose(verb); + + bool check = SC.read_point_cloud(off_file_name); + + if (!check) { + std::cout << "Incorrect OFF file." << std::endl; + } else { + SC.set_type("Nerve"); + + SC.set_color_from_coordinate(coord); + SC.set_function_from_coordinate(coord); + + SC.set_graph_from_OFF(); + SC.set_resolution_with_interval_number(resolution); + SC.set_gain(gain); + SC.set_cover_from_function(); + + SC.find_simplices(); + + SC.write_info(); + + Gudhi::Simplex_tree<> stree; + SC.create_complex(stree); + SC.compute_PD(); + + // ---------------------------------------------------------------------------- + // Display information about the graph induced complex + // ---------------------------------------------------------------------------- + + if (verb) { + std::cout << "Nerve is of dimension " << stree.dimension() << " - " << stree.num_simplices() << " simplices - " + << stree.num_vertices() << " vertices." << std::endl; + + std::cout << "Iterator on Nerve simplices" << std::endl; + for (auto f_simplex : stree.filtration_simplex_range()) { + for (auto vertex : stree.simplex_vertex_range(f_simplex)) { + std::cout << vertex << " "; + } + std::cout << std::endl; + } + } + } + + return 0; +} diff --git a/src/Nerve_GIC/utilities/Nerve.txt b/src/Nerve_GIC/utilities/Nerve.txt new file mode 100644 index 00000000..839ff45e --- /dev/null +++ b/src/Nerve_GIC/utilities/Nerve.txt @@ -0,0 +1,63 @@ +Min function value = -0.979672 and Max function value = 0.816414 +Interval 0 = [-0.979672, -0.761576] +Interval 1 = [-0.838551, -0.581967] +Interval 2 = [-0.658942, -0.402359] +Interval 3 = [-0.479334, -0.22275] +Interval 4 = [-0.299725, -0.0431415] +Interval 5 = [-0.120117, 0.136467] +Interval 6 = [0.059492, 0.316076] +Interval 7 = [0.239101, 0.495684] +Interval 8 = [0.418709, 0.675293] +Interval 9 = [0.598318, 0.816414] +Computing preimages... +Computing connected components... +.txt generated. It can be visualized with e.g. python KeplerMapperVisuFromTxtFile.py and firefox. +5 interval(s) in dimension 0: + [-0.909111, 0.00817529] + [-0.171433, 0.367392] + [-0.171433, 0.367392] + [-0.909111, 0.745853] +0 interval(s) in dimension 1: +Nerve is of dimension 1 - 41 simplices - 21 vertices. +Iterator on Nerve simplices +1 +0 +4 +4 0 +2 +2 1 +8 +8 2 +5 +5 4 +9 +9 8 +13 +13 5 +14 +14 9 +19 +19 13 +25 +32 +20 +32 20 +33 +33 25 +26 +26 14 +26 19 +42 +42 26 +34 +34 33 +27 +27 20 +35 +35 27 +35 34 +42 35 +44 +44 35 +54 +54 44 \ No newline at end of file diff --git a/src/Nerve_GIC/utilities/VoronoiGIC.cpp b/src/Nerve_GIC/utilities/VoronoiGIC.cpp new file mode 100644 index 00000000..32431cc2 --- /dev/null +++ b/src/Nerve_GIC/utilities/VoronoiGIC.cpp @@ -0,0 +1,90 @@ +/* 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): Mathieu Carrière + * + * 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 + +void usage(int nbArgs, char *const progName) { + std::cerr << "Error: Number of arguments (" << nbArgs << ") is not correct\n"; + std::cerr << "Usage: " << progName << " filename.off N [--v] \n"; + std::cerr << " i.e.: " << progName << " ../../data/points/human.off 100 --v \n"; + exit(-1); // ----- >> +} + +int main(int argc, char **argv) { + if ((argc != 3) && (argc != 4)) usage(argc, argv[0]); + + using Point = std::vector; + + std::string off_file_name(argv[1]); + int m = atoi(argv[2]); + bool verb = 0; + if (argc == 4) verb = 1; + + // ---------------------------------------------------------------------------- + // Init of a graph induced complex from an OFF file + // ---------------------------------------------------------------------------- + + Gudhi::cover_complex::Cover_complex GIC; + GIC.set_verbose(verb); + + bool check = GIC.read_point_cloud(off_file_name); + + if (!check) { + std::cout << "Incorrect OFF file." << std::endl; + } else { + GIC.set_type("GIC"); + + GIC.set_color_from_coordinate(); + + GIC.set_graph_from_OFF(); + GIC.set_cover_from_Voronoi(Gudhi::Euclidean_distance(), m); + + GIC.find_simplices(); + + GIC.plot_OFF(); + + Gudhi::Simplex_tree<> stree; + GIC.create_complex(stree); + + // ---------------------------------------------------------------------------- + // Display information about the graph induced complex + // ---------------------------------------------------------------------------- + + if (verb) { + std::cout << "Graph induced complex is of dimension " << stree.dimension() << " - " << stree.num_simplices() + << " simplices - " << stree.num_vertices() << " vertices." << std::endl; + + std::cout << "Iterator on graph induced complex simplices" << std::endl; + for (auto f_simplex : stree.filtration_simplex_range()) { + for (auto vertex : stree.simplex_vertex_range(f_simplex)) { + std::cout << vertex << " "; + } + std::cout << std::endl; + } + } + } + + return 0; +} diff --git a/src/Nerve_GIC/utilities/km.py b/src/Nerve_GIC/utilities/km.py new file mode 100755 index 00000000..53024aab --- /dev/null +++ b/src/Nerve_GIC/utilities/km.py @@ -0,0 +1,390 @@ +from __future__ import division +import numpy as np +from collections import defaultdict +import json +import itertools +from sklearn import cluster, preprocessing, manifold +from datetime import datetime +import sys + +class KeplerMapper(object): + # With this class you can build topological networks from (high-dimensional) data. + # + # 1) Fit a projection/lens/function to a dataset and transform it. + # For instance "mean_of_row(x) for x in X" + # 2) Map this projection with overlapping intervals/hypercubes. + # Cluster the points inside the interval + # (Note: we cluster on the inverse image/original data to lessen projection loss). + # If two clusters/nodes have the same members (due to the overlap), then: + # connect these with an edge. + # 3) Visualize the network using HTML and D3.js. + # + # functions + # --------- + # fit_transform: Create a projection (lens) from a dataset + # map: Apply Mapper algorithm on this projection and build a simplicial complex + # visualize: Turns the complex dictionary into a HTML/D3.js visualization + + def __init__(self, verbose=2): + self.verbose = verbose + + self.chunk_dist = [] + self.overlap_dist = [] + self.d = [] + self.nr_cubes = 0 + self.overlap_perc = 0 + self.clusterer = False + + def fit_transform(self, X, projection="sum", scaler=preprocessing.MinMaxScaler()): + # Creates the projection/lens from X. + # + # Input: X. Input features as a numpy array. + # Output: projected_X. original data transformed to a projection (lens). + # + # parameters + # ---------- + # projection: Projection parameter is either a string, + # a scikit class with fit_transform, like manifold.TSNE(), + # or a list of dimension indices. + # scaler: if None, do no scaling, else apply scaling to the projection + # Default: Min-Max scaling + + self.scaler = scaler + self.projection = str(projection) + + # Detect if projection is a class (for scikit-learn) + #if str(type(projection))[1:6] == "class": #TODO: de-ugly-fy + # reducer = projection + # if self.verbose > 0: + # try: + # projection.set_params(**{"verbose":self.verbose}) + # except: + # pass + # print("\n..Projecting data using: \n\t%s\n"%str(projection)) + # X = reducer.fit_transform(X) + + # Detect if projection is a string (for standard functions) + if isinstance(projection, str): + if self.verbose > 0: + print("\n..Projecting data using: %s"%(projection)) + # Stats lenses + if projection == "sum": # sum of row + X = np.sum(X, axis=1).reshape((X.shape[0],1)) + if projection == "mean": # mean of row + X = np.mean(X, axis=1).reshape((X.shape[0],1)) + if projection == "median": # mean of row + X = np.median(X, axis=1).reshape((X.shape[0],1)) + if projection == "max": # max of row + X = np.max(X, axis=1).reshape((X.shape[0],1)) + if projection == "min": # min of row + X = np.min(X, axis=1).reshape((X.shape[0],1)) + if projection == "std": # std of row + X = np.std(X, axis=1).reshape((X.shape[0],1)) + + if projection == "dist_mean": # Distance of x to mean of X + X_mean = np.mean(X, axis=0) + X = np.sum(np.sqrt((X - X_mean)**2), axis=1).reshape((X.shape[0],1)) + + # Detect if projection is a list (with dimension indices) + if isinstance(projection, list): + if self.verbose > 0: + print("\n..Projecting data using: %s"%(str(projection))) + X = X[:,np.array(projection)] + + # Scaling + if scaler is not None: + if self.verbose > 0: + print("\n..Scaling with: %s\n"%str(scaler)) + X = scaler.fit_transform(X) + + return X + + def map(self, projected_X, inverse_X=None, clusterer=cluster.DBSCAN(eps=0.5,min_samples=3), nr_cubes=10, overlap_perc=0.1): + # This maps the data to a simplicial complex. Returns a dictionary with nodes and links. + # + # Input: projected_X. A Numpy array with the projection/lens. + # Output: complex. A dictionary with "nodes", "links" and "meta information" + # + # parameters + # ---------- + # projected_X projected_X. A Numpy array with the projection/lens. Required. + # inverse_X Numpy array or None. If None then the projection itself is used for clustering. + # clusterer Scikit-learn API compatible clustering algorithm. Default: DBSCAN + # nr_cubes Int. The number of intervals/hypercubes to create. + # overlap_perc Float. The percentage of overlap "between" the intervals/hypercubes. + + start = datetime.now() + + # Helper function + def cube_coordinates_all(nr_cubes, nr_dimensions): + # Helper function to get origin coordinates for our intervals/hypercubes + # Useful for looping no matter the number of cubes or dimensions + # Example: if there are 4 cubes per dimension and 3 dimensions + # return the bottom left (origin) coordinates of 64 hypercubes, + # as a sorted list of Numpy arrays + # TODO: elegance-ify... + l = [] + for x in range(nr_cubes): + l += [x] * nr_dimensions + return [np.array(list(f)) for f in sorted(set(itertools.permutations(l,nr_dimensions)))] + + nodes = defaultdict(list) + links = defaultdict(list) + complex = {} + self.nr_cubes = nr_cubes + self.clusterer = clusterer + self.overlap_perc = overlap_perc + + if self.verbose > 0: + print("Mapping on data shaped %s using dimensions\n"%(str(projected_X.shape))) + + # If inverse image is not provided, we use the projection as the inverse image (suffer projection loss) + if inverse_X is None: + inverse_X = projected_X + + # We chop up the min-max column ranges into 'nr_cubes' parts + self.chunk_dist = (np.max(projected_X, axis=0) - np.min(projected_X, axis=0))/nr_cubes + + # We calculate the overlapping windows distance + self.overlap_dist = self.overlap_perc * self.chunk_dist + + # We find our starting point + self.d = np.min(projected_X, axis=0) + + # Use a dimension index array on the projected X + # (For now this uses the entire dimensionality, but we keep for experimentation) + di = np.array([x for x in range(projected_X.shape[1])]) + + # Prefix'ing the data with ID's + ids = np.array([x for x in range(projected_X.shape[0])]) + projected_X = np.c_[ids,projected_X] + inverse_X = np.c_[ids,inverse_X] + + # Subdivide the projected data X in intervals/hypercubes with overlap + if self.verbose > 0: + total_cubes = len(cube_coordinates_all(nr_cubes,projected_X.shape[1])) + print("Creating %s hypercubes."%total_cubes) + + for i, coor in enumerate(cube_coordinates_all(nr_cubes,di.shape[0])): + # Slice the hypercube + hypercube = projected_X[ np.invert(np.any((projected_X[:,di+1] >= self.d[di] + (coor * self.chunk_dist[di])) & + (projected_X[:,di+1] < self.d[di] + (coor * self.chunk_dist[di]) + self.chunk_dist[di] + self.overlap_dist[di]) == False, axis=1 )) ] + + if self.verbose > 1: + print("There are %s points in cube_%s / %s with starting range %s"% + (hypercube.shape[0],i,total_cubes,self.d[di] + (coor * self.chunk_dist[di]))) + + # If at least one sample inside the hypercube + if hypercube.shape[0] > 0: + # Cluster the data point(s) in the cube, skipping the id-column + # Note that we apply clustering on the inverse image (original data samples) that fall inside the cube. + inverse_x = inverse_X[[int(nn) for nn in hypercube[:,0]]] + + clusterer.fit(inverse_x[:,1:]) + + if self.verbose > 1: + print("Found %s clusters in cube_%s\n"%(np.unique(clusterer.labels_[clusterer.labels_ > -1]).shape[0],i)) + + #Now for every (sample id in cube, predicted cluster label) + for a in np.c_[hypercube[:,0],clusterer.labels_]: + if a[1] != -1: #if not predicted as noise + cluster_id = str(coor[0])+"_"+str(i)+"_"+str(a[1])+"_"+str(coor)+"_"+str(self.d[di] + (coor * self.chunk_dist[di])) # TODO: de-rudimentary-ify + nodes[cluster_id].append( int(a[0]) ) # Append the member id's as integers + else: + if self.verbose > 1: + print("Cube_%s is empty.\n"%(i)) + + # Create links when clusters from different hypercubes have members with the same sample id. + candidates = itertools.combinations(nodes.keys(),2) + for candidate in candidates: + # if there are non-unique members in the union + if len(nodes[candidate[0]]+nodes[candidate[1]]) != len(set(nodes[candidate[0]]+nodes[candidate[1]])): + links[candidate[0]].append( candidate[1] ) + + # Reporting + if self.verbose > 0: + nr_links = 0 + for k in links: + nr_links += len(links[k]) + print("\ncreated %s edges and %s nodes in %s."%(nr_links,len(nodes),str(datetime.now()-start))) + + complex["nodes"] = nodes + complex["links"] = links + complex["meta"] = self.projection + + return complex + + def visualize(self, complex, color_function="", path_html="mapper_visualization_output.html", title="My Data", + graph_link_distance=30, graph_gravity=0.1, graph_charge=-120, custom_tooltips=None, width_html=0, + height_html=0, show_tooltips=True, show_title=True, show_meta=True, res=0,gain=0,minimum=0,maximum=0): + # Turns the dictionary 'complex' in a html file with d3.js + # + # Input: complex. Dictionary (output from calling .map()) + # Output: a HTML page saved as a file in 'path_html'. + # + # parameters + # ---------- + # color_function string. Not fully implemented. Default: "" (distance to origin) + # path_html file path as string. Where to save the HTML page. + # title string. HTML page document title and first heading. + # graph_link_distance int. Edge length. + # graph_gravity float. "Gravity" to center of layout. + # graph_charge int. charge between nodes. + # custom_tooltips None or Numpy Array. You could use "y"-label array for this. + # width_html int. Width of canvas. Default: 0 (full width) + # height_html int. Height of canvas. Default: 0 (full height) + # show_tooltips bool. default:True + # show_title bool. default:True + # show_meta bool. default:True + + # Format JSON for D3 graph + json_s = {} + json_s["nodes"] = [] + json_s["links"] = [] + k2e = {} # a key to incremental int dict, used for id's when linking + + for e, k in enumerate(complex["nodes"]): + # Tooltip and node color formatting, TODO: de-mess-ify + if custom_tooltips is not None: + tooltip_s = "

Cluster %s

"%k + " ".join(str(custom_tooltips[complex["nodes"][k][0]]).split(" ")) + if maximum == minimum: + tooltip_i = 0 + else: + tooltip_i = int(30*(custom_tooltips[complex["nodes"][k][0]]-minimum)/(maximum-minimum)) + json_s["nodes"].append({"name": str(k), "tooltip": tooltip_s, "group": 2 * int(np.log(complex["nodes"][k][2])), "color": tooltip_i}) + else: + tooltip_s = "

Cluster %s

Contains %s members."%(k,len(complex["nodes"][k])) + json_s["nodes"].append({"name": str(k), "tooltip": tooltip_s, "group": 2 * int(np.log(len(complex["nodes"][k]))), "color": str(k.split("_")[0])}) + k2e[k] = e + for k in complex["links"]: + for link in complex["links"][k]: + json_s["links"].append({"source": k2e[k], "target":k2e[link],"value":1}) + + # Width and height of graph in HTML output + if width_html == 0: + width_css = "100%" + width_js = 'document.getElementById("holder").offsetWidth-20' + else: + width_css = "%spx" % width_html + width_js = "%s" % width_html + if height_html == 0: + height_css = "100%" + height_js = 'document.getElementById("holder").offsetHeight-20' + else: + height_css = "%spx" % height_html + height_js = "%s" % height_html + + # Whether to show certain UI elements or not + if show_tooltips == False: + tooltips_display = "display: none;" + else: + tooltips_display = "" + + if show_meta == False: + meta_display = "display: none;" + else: + meta_display = "" + + if show_title == False: + title_display = "display: none;" + else: + title_display = "" + + with open(path_html,"wb") as outfile: + html = """ + + + %s | KeplerMapper + + + +
+

%s

+

+ Lens
%s

+ Length of intervals
%s

+ Overlap percentage
%s%%

+ Color Function
%s +

+
+ + """%(title,width_css, height_css, title_display, meta_display, tooltips_display, title,complex["meta"],res,gain*100,color_function,width_js,height_js,graph_charge,graph_link_distance,graph_gravity,json.dumps(json_s)) + outfile.write(html.encode("utf-8")) + if self.verbose > 0: + print("\nWrote d3.js graph to '%s'"%path_html) diff --git a/src/Nerve_GIC/utilities/km.py.COPYRIGHT b/src/Nerve_GIC/utilities/km.py.COPYRIGHT new file mode 100644 index 00000000..bef7b121 --- /dev/null +++ b/src/Nerve_GIC/utilities/km.py.COPYRIGHT @@ -0,0 +1,26 @@ +km.py is a fork of https://github.com/MLWave/kepler-mapper. +Only the visualization part has been kept (Mapper part has been removed). + +This file has te following Copyright : + +The MIT License (MIT) + +Copyright (c) 2015 Triskelion - HJ van Veen - info@mlwave.com + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/src/Persistence_representations/example/CMakeLists.txt b/src/Persistence_representations/example/CMakeLists.txt index b8ce8ea6..eb3258f8 100644 --- a/src/Persistence_representations/example/CMakeLists.txt +++ b/src/Persistence_representations/example/CMakeLists.txt @@ -2,28 +2,23 @@ cmake_minimum_required(VERSION 2.6) project(Persistence_representations_example) add_executable ( Persistence_representations_example_landscape_on_grid persistence_landscape_on_grid.cpp ) -target_link_libraries(Persistence_representations_example_landscape_on_grid ${Boost_SYSTEM_LIBRARY}) add_test(NAME Persistence_representations_example_landscape_on_grid COMMAND $) add_executable ( Persistence_representations_example_landscape persistence_landscape.cpp ) -target_link_libraries(Persistence_representations_example_landscape ${Boost_SYSTEM_LIBRARY}) add_test(NAME Persistence_representations_example_landscape COMMAND $) add_executable ( Persistence_representations_example_intervals persistence_intervals.cpp ) -target_link_libraries(Persistence_representations_example_intervals ${Boost_SYSTEM_LIBRARY}) add_test(NAME Persistence_representations_example_intervals COMMAND $ "${CMAKE_SOURCE_DIR}/data/persistence_diagram/first.pers") add_executable ( Persistence_representations_example_vectors persistence_vectors.cpp ) -target_link_libraries(Persistence_representations_example_vectors ${Boost_SYSTEM_LIBRARY}) add_test(NAME Persistence_representations_example_vectors COMMAND $) add_executable ( Persistence_representations_example_heat_maps persistence_heat_maps.cpp ) -target_link_libraries(Persistence_representations_example_heat_maps ${Boost_SYSTEM_LIBRARY}) add_test(NAME Persistence_representations_example_heat_maps COMMAND $) diff --git a/src/Persistence_representations/test/CMakeLists.txt b/src/Persistence_representations/test/CMakeLists.txt index 4483de07..335a71ef 100644 --- a/src/Persistence_representations/test/CMakeLists.txt +++ b/src/Persistence_representations/test/CMakeLists.txt @@ -6,38 +6,38 @@ include(GUDHI_test_coverage) # copy data directory for tests purpose. file(COPY data DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) add_executable ( Persistence_intervals_test_unit persistence_intervals_test.cpp ) -target_link_libraries(Persistence_intervals_test_unit ${Boost_SYSTEM_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) +target_link_libraries(Persistence_intervals_test_unit ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) gudhi_add_coverage_test(Persistence_intervals_test_unit) add_executable (Vector_representation_test_unit vector_representation_test.cpp ) -target_link_libraries(Vector_representation_test_unit ${Boost_SYSTEM_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) +target_link_libraries(Vector_representation_test_unit ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) gudhi_add_coverage_test(Vector_representation_test_unit) add_executable (Persistence_lanscapes_test_unit persistence_lanscapes_test.cpp ) -target_link_libraries(Persistence_lanscapes_test_unit ${Boost_SYSTEM_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) +target_link_libraries(Persistence_lanscapes_test_unit ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) gudhi_add_coverage_test(Persistence_lanscapes_test_unit) add_executable ( Persistence_lanscapes_on_grid_test_unit persistence_lanscapes_on_grid_test.cpp ) -target_link_libraries(Persistence_lanscapes_on_grid_test_unit ${Boost_SYSTEM_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) +target_link_libraries(Persistence_lanscapes_on_grid_test_unit ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) gudhi_add_coverage_test(Persistence_lanscapes_on_grid_test_unit) add_executable (Persistence_heat_maps_test_unit persistence_heat_maps_test.cpp ) -target_link_libraries(Persistence_heat_maps_test_unit ${Boost_SYSTEM_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) +target_link_libraries(Persistence_heat_maps_test_unit ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) gudhi_add_coverage_test(Persistence_heat_maps_test_unit) add_executable ( Read_persistence_from_file_test_unit read_persistence_from_file_test.cpp ) -target_link_libraries(Read_persistence_from_file_test_unit ${Boost_SYSTEM_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) +target_link_libraries(Read_persistence_from_file_test_unit ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) gudhi_add_coverage_test(Read_persistence_from_file_test_unit) if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1) add_executable (Persistence_intervals_with_distances_test_unit persistence_intervals_with_distances_test.cpp ) - target_link_libraries(Persistence_intervals_with_distances_test_unit ${Boost_SYSTEM_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) + target_link_libraries(Persistence_intervals_with_distances_test_unit ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) if (TBB_FOUND) target_link_libraries(Persistence_intervals_with_distances_test_unit ${TBB_LIBRARIES}) endif(TBB_FOUND) diff --git a/src/common/doc/examples.h b/src/common/doc/examples.h new file mode 100644 index 00000000..40f202c7 --- /dev/null +++ b/src/common/doc/examples.h @@ -0,0 +1,99 @@ +// List of GUDHI examples - Doxygen needs at least a file tag to analyse comments +// In user_version, `find . -name "*.cpp"` in example and utilities folders +/*! @file Examples + * @example Alpha_complex/Alpha_complex_from_off.cpp + * @example Alpha_complex/Alpha_complex_from_points.cpp + * @example Bottleneck_distance/bottleneck_basic_example.cpp + * @example Bottleneck_distance/alpha_rips_persistence_bottleneck_distance.cpp + * @example Witness_complex/example_nearest_landmark_table.cpp + * @example Witness_complex/example_witness_complex_off.cpp + * @example Witness_complex/example_witness_complex_sphere.cpp + * @example Witness_complex/example_strong_witness_complex_off.cpp + * @example Simplex_tree/mini_simplex_tree.cpp + * @example Simplex_tree/graph_expansion_with_blocker.cpp + * @example Simplex_tree/simple_simplex_tree.cpp + * @example Simplex_tree/simplex_tree_from_cliques_of_graph.cpp + * @example Simplex_tree/example_alpha_shapes_3_simplex_tree_from_off_file.cpp + * @example Simplex_tree/cech_complex_cgal_mini_sphere_3d.cpp + * @example Persistent_cohomology/plain_homology.cpp + * @example Persistent_cohomology/persistence_from_file.cpp + * @example Persistent_cohomology/rips_persistence_step_by_step.cpp + * @example Persistent_cohomology/rips_persistence_via_boundary_matrix.cpp + * @example Persistent_cohomology/custom_persistence_sort.cpp + * @example Persistent_cohomology/persistence_from_simple_simplex_tree.cpp + * @example Persistent_cohomology/rips_multifield_persistence.cpp + * @example Skeleton_blocker/Skeleton_blocker_from_simplices.cpp + * @example Skeleton_blocker/Skeleton_blocker_iteration.cpp + * @example Skeleton_blocker/Skeleton_blocker_link.cpp + * @example Contraction/Garland_heckbert.cpp + * @example Contraction/Rips_contraction.cpp + * @example Bitmap_cubical_complex/Random_bitmap_cubical_complex.cpp + * @example common/example_CGAL_3D_points_off_reader.cpp + * @example common/example_vector_double_points_off_reader.cpp + * @example common/example_CGAL_points_off_reader.cpp + * @example Rips_complex/example_one_skeleton_rips_from_distance_matrix.cpp + * @example Rips_complex/example_one_skeleton_rips_from_points.cpp + * @example Rips_complex/example_rips_complex_from_csv_distance_matrix_file.cpp + * @example Rips_complex/example_rips_complex_from_off_file.cpp + * @example Persistence_representations/persistence_intervals.cpp + * @example Persistence_representations/persistence_vectors.cpp + * @example Persistence_representations/persistence_heat_maps.cpp + * @example Persistence_representations/persistence_landscape_on_grid.cpp + * @example Persistence_representations/persistence_landscape.cpp + * @example Tangential_complex/example_basic.cpp + * @example Tangential_complex/example_with_perturb.cpp + * @example Subsampling/example_custom_kernel.cpp + * @example Subsampling/example_choose_n_farthest_points.cpp + * @example Subsampling/example_sparsify_point_set.cpp + * @example Subsampling/example_pick_n_random_points.cpp + * @example Nerve_GIC/CoordGIC.cpp + * @example Nerve_GIC/Nerve.cpp + * @example Nerve_GIC/FuncGIC.cpp + * @example Nerve_GIC/VoronoiGIC.cpp + * @example Spatial_searching/example_spatial_searching.cpp + * @example Alpha_complex/alpha_complex_3d_persistence.cpp + * @example Alpha_complex/alpha_complex_persistence.cpp + * @example Alpha_complex/weighted_periodic_alpha_complex_3d_persistence.cpp + * @example Alpha_complex/weighted_alpha_complex_3d_persistence.cpp + * @example Alpha_complex/periodic_alpha_complex_3d_persistence.cpp + * @example Alpha_complex/exact_alpha_complex_3d_persistence.cpp + * @example Bottleneck_distance/bottleneck_distance.cpp + * @example Witness_complex/weak_witness_persistence.cpp + * @example Witness_complex/strong_witness_persistence.cpp + * @example Bitmap_cubical_complex/cubical_complex_persistence.cpp + * @example Bitmap_cubical_complex/periodic_cubical_complex_persistence.cpp + * @example common/off_file_from_shape_generator.cpp + * @example Rips_complex/rips_distance_matrix_persistence.cpp + * @example Rips_complex/rips_persistence.cpp + * @example Persistence_representations/persistence_landscapes_on_grid/create_landscapes_on_grid.cpp + * @example Persistence_representations/persistence_landscapes_on_grid/plot_landscapes_on_grid.cpp + * @example Persistence_representations/persistence_landscapes_on_grid/compute_scalar_product_of_landscapes_on_grid.cpp + * @example Persistence_representations/persistence_landscapes_on_grid/compute_distance_of_landscapes_on_grid.cpp + * @example Persistence_representations/persistence_landscapes_on_grid/average_landscapes_on_grid.cpp + * @example Persistence_representations/persistence_intervals/compute_birth_death_range_in_persistence_diagram.cpp + * @example Persistence_representations/persistence_intervals/compute_number_of_dominant_intervals.cpp + * @example Persistence_representations/persistence_intervals/plot_persistence_Betti_numbers.cpp + * @example Persistence_representations/persistence_intervals/plot_persistence_intervals.cpp + * @example Persistence_representations/persistence_intervals/plot_histogram_of_intervals_lengths.cpp + * @example Persistence_representations/persistence_intervals/compute_bottleneck_distance.cpp + * @example Persistence_representations/persistence_heat_maps/create_pssk.cpp + * @example Persistence_representations/persistence_heat_maps/create_p_h_m_weighted_by_arctan_of_their_persistence.cpp + * @example Persistence_representations/persistence_heat_maps/create_p_h_m_weighted_by_squared_diag_distance.cpp + * @example Persistence_representations/persistence_heat_maps/compute_distance_of_persistence_heat_maps.cpp + * @example Persistence_representations/persistence_heat_maps/compute_scalar_product_of_persistence_heat_maps.cpp + * @example Persistence_representations/persistence_heat_maps/create_p_h_m_weighted_by_distance_from_diagonal.cpp + * @example Persistence_representations/persistence_heat_maps/average_persistence_heat_maps.cpp + * @example Persistence_representations/persistence_heat_maps/plot_persistence_heat_map.cpp + * @example Persistence_representations/persistence_heat_maps/create_persistence_heat_maps.cpp + * @example Persistence_representations/persistence_vectors/plot_persistence_vectors.cpp + * @example Persistence_representations/persistence_vectors/compute_distance_of_persistence_vectors.cpp + * @example Persistence_representations/persistence_vectors/average_persistence_vectors.cpp + * @example Persistence_representations/persistence_vectors/create_persistence_vectors.cpp + * @example Persistence_representations/persistence_vectors/compute_scalar_product_of_persistence_vectors.cpp + * @example Persistence_representations/persistence_landscapes/average_landscapes.cpp + * @example Persistence_representations/persistence_landscapes/compute_scalar_product_of_landscapes.cpp + * @example Persistence_representations/persistence_landscapes/create_landscapes.cpp + * @example Persistence_representations/persistence_landscapes/compute_distance_of_landscapes.cpp + * @example Persistence_representations/persistence_landscapes/plot_landscapes.cpp + */ + diff --git a/src/common/doc/installation.h b/src/common/doc/installation.h new file mode 100644 index 00000000..25675cc5 --- /dev/null +++ b/src/common/doc/installation.h @@ -0,0 +1,263 @@ +/*! \page installation GUDHI installation + * \tableofcontents + * As GUDHI is a header only library, there is no need to install the library. + * + * Examples of GUDHI headers inclusion can be found in \ref demos. + * + * \section compiling Compiling + * The library uses c++11 and requires Boost with version 1.48.0 or + * more recent. It is a multi-platform library and compiles on Linux, Mac OSX and Visual Studio 2015. + * + * \subsection demos Demos and examples + * To build the demos and examples, run the following commands in a terminal: +\verbatim cd /path-to-gudhi/ +mkdir build +cd build/ +cmake .. +make \endverbatim + * A list of examples is available here. + * + * \subsection testsuites Test suites + * To test your build, run the following command in a terminal: + * \verbatim make test \endverbatim + * + * \subsection documentationgeneration Documentation + * To generate the documentation, Doxygen is required. + * Run the following command in a terminal: +\verbatim +make doxygen +# Documentation will be generated in the folder YYYY-MM-DD-hh-mm-ss_GUDHI_X.Y.Z/doc/html/ +# You can customize the directory name by calling `cmake -DUSER_VERSION_DIR=/my/custom/folder` +\endverbatim + * + * \section optionallibrary Optional third-party library + * \subsection gmp GMP + * The multi-field persistent homology algorithm requires GMP which is a free library for arbitrary-precision + * arithmetic, operating on signed integers, rational numbers, and floating point numbers. + * + * The following example requires the GNU Multiple Precision Arithmetic + * Library (GMP) and will not be built if GMP is not installed: + * \li + * Persistent_cohomology/rips_multifield_persistence.cpp + * + * Having GMP version 4.2 or higher installed is recommended. + * + * \subsection cgal CGAL + * The \ref alpha_complex data structure, \ref bottleneck_distance, and few examples requires CGAL, which is a C++ + * library which provides easy access to efficient and reliable geometric algorithms. + * + * \note There is no need to install CGAL, you can just cmake . && make CGAL (or even + * cmake -DCGAL_HEADER_ONLY=ON . for CGAL version ≥ 4.8.0), thereafter you will be able to compile + * GUDHI by calling cmake -DCGAL_DIR=/your/path/to/CGAL-X.Y .. && make + * + * Having CGAL version 4.4.0 or higher installed is recommended. The procedure to install this library according to + * your operating system is detailed here http://doc.cgal.org/latest/Manual/installation.html + * + * The following examples/utilities require the Computational Geometry Algorithms + * Library (CGAL \cite cgal:eb-15b) and will not be built if CGAL is not installed: + * \li + * Alpha_complex/alpha_complex_3d_persistence.cpp + * \li + * Alpha_complex/exact_alpha_complex_3d_persistence.cpp + * \li + * Alpha_complex/weighted_alpha_complex_3d_persistence.cpp + * \li + * Simplex_tree/example_alpha_shapes_3_simplex_tree_from_off_file.cpp + * + * The following examples/utilities require CGAL version ≥ 4.6.0: + * \li + * Witness_complex/strong_witness_persistence.cpp + * \li + * Witness_complex/weak_witness_persistence.cpp + * \li + * Witness_complex/example_strong_witness_complex_off.cpp + * \li + * Witness_complex/example_witness_complex_off.cpp + * \li + * Witness_complex/example_witness_complex_sphere.cpp + * + * The following example requires CGAL version ≥ 4.7.0: + * \li + * Alpha_complex/Alpha_complex_from_off.cpp + * \li + * Alpha_complex/Alpha_complex_from_points.cpp + * \li + * Alpha_complex/alpha_complex_persistence.cpp + * \li + * Alpha_complex/periodic_alpha_complex_3d_persistence.cpp + * \li + * Persistent_cohomology/custom_persistence_sort.cpp + * + * The following example requires CGAL version ≥ 4.8.1: + * \li + * Bottleneck_distance/alpha_rips_persistence_bottleneck_distance.cpp.cpp + * \li + * Bottleneck_distance/bottleneck_basic_example.cpp + * \li + * Bottleneck_distance/bottleneck_distance.cpp + * \li + * Nerve_GIC/CoordGIC.cpp + * \li + * Nerve_GIC/FuncGIC.cpp + * \li + * Nerve_GIC/Nerve.cpp + * \li + * Nerve_GIC/VoronoiGIC.cpp + * \li + * Spatial_searching/example_spatial_searching.cpp + * \li + * Subsampling/example_choose_n_farthest_points.cpp + * \li + * Subsampling/example_custom_kernel.cpp + * \li + * Subsampling/example_pick_n_random_points.cpp + * \li + * Subsampling/example_sparsify_point_set.cpp + * \li + * Tangential_complex/example_basic.cpp + * \li + * Tangential_complex/example_with_perturb.cpp + * + * \subsection eigen3 Eigen3 + * The \ref alpha_complex data structure and few examples requires + * Eigen3 is a C++ template library for linear algebra: + * matrices, vectors, numerical solvers, and related algorithms. + * + * The following examples/utilities require the Eigen3 and will not be + * built if Eigen3 is not installed: + * \li + * Alpha_complex/Alpha_complex_from_off.cpp + * \li + * Alpha_complex/Alpha_complex_from_points.cpp + * \li + * Alpha_complex/alpha_complex_persistence.cpp + * \li + * Alpha_complex/periodic_alpha_complex_3d_persistence.cpp + * \li + * Bottleneck_distance/alpha_rips_persistence_bottleneck_distance.cpp.cpp + * \li + * Persistent_cohomology/custom_persistence_sort.cpp + * \li + * Spatial_searching/example_spatial_searching.cpp + * \li + * Subsampling/example_choose_n_farthest_points.cpp + * \li + * Subsampling/example_custom_kernel.cpp + * \li + * Subsampling/example_pick_n_random_points.cpp + * \li + * Subsampling/example_sparsify_point_set.cpp + * \li + * Tangential_complex/example_basic.cpp + * \li + * Tangential_complex/example_with_perturb.cpp + * \li + * Witness_complex/strong_witness_persistence.cpp + * \li + * Witness_complex/weak_witness_persistence.cpp + * \li + * Witness_complex/example_strong_witness_complex_off.cpp + * \li + * Witness_complex/example_witness_complex_off.cpp + * \li + * Witness_complex/example_witness_complex_sphere.cpp + * + * \subsection tbb Threading Building Blocks + * Intel® TBB lets you easily write parallel + * C++ programs that take full advantage of multicore performance, that are portable and composable, and that have + * future-proof scalability. + * + * Having Intel® TBB installed is recommended to parallelize and accelerate some GUDHI computations. + * + * The following examples/utilities are using Intel® TBB if installed: + * \li + * Alpha_complex/Alpha_complex_from_off.cpp + * \li + * Alpha_complex/Alpha_complex_from_points.cpp + * \li + * Alpha_complex/alpha_complex_3d_persistence.cpp + * \li + * Alpha_complex/alpha_complex_persistence.cpp + * \li + * Alpha_complex/exact_alpha_complex_3d_persistence.cpp + * \li + * Alpha_complex/periodic_alpha_complex_3d_persistence.cpp + * \li + * Alpha_complex/weighted_alpha_complex_3d_persistence.cpp + * \li + * Bitmap_cubical_complex/cubical_complex_persistence.cpp + * \li + * Bitmap_cubical_complex/periodic_cubical_complex_persistence.cpp + * \li + * Bitmap_cubical_complex/Random_bitmap_cubical_complex.cpp + * \li + * Nerve_GIC/CoordGIC.cpp + * \li + * Nerve_GIC/FuncGIC.cpp + * \li + * Nerve_GIC/Nerve.cpp + * \li + * Nerve_GIC/VoronoiGIC.cpp + * \li + * Simplex_tree/simple_simplex_tree.cpp + * \li + * Simplex_tree/example_alpha_shapes_3_simplex_tree_from_off_file.cpp + * \li + * Simplex_tree/simplex_tree_from_cliques_of_graph.cpp + * \li + * Simplex_tree/graph_expansion_with_blocker.cpp + * \li + * Persistent_cohomology/alpha_complex_3d_persistence.cpp + * \li + * Persistent_cohomology/alpha_complex_persistence.cpp + * \li + * Persistent_cohomology/rips_persistence_via_boundary_matrix.cpp + * \li + * Persistent_cohomology/persistence_from_file.cpp + * \li + * Persistent_cohomology/persistence_from_simple_simplex_tree.cpp + * \li + * Persistent_cohomology/plain_homology.cpp + * \li + * Persistent_cohomology/rips_multifield_persistence.cpp + * \li + * Persistent_cohomology/rips_persistence_step_by_step.cpp + * \li + * Persistent_cohomology/exact_alpha_complex_3d_persistence.cpp + * \li + * Persistent_cohomology/weighted_alpha_complex_3d_persistence.cpp + * \li + * Persistent_cohomology/custom_persistence_sort.cpp + * \li + * Rips_complex/example_one_skeleton_rips_from_points.cpp + * \li + * Rips_complex/example_rips_complex_from_off_file.cpp + * \li + * Rips_complex/rips_distance_matrix_persistence.cpp + * \li + * Rips_complex/rips_persistence.cpp + * \li + * Witness_complex/strong_witness_persistence.cpp + * \li + * Witness_complex/weak_witness_persistence.cpp + * \li + * Witness_complex/example_nearest_landmark_table.cpp + * + * \section Contributions Bug reports and contributions + * Please help us improving the quality of the GUDHI library. You may report bugs or suggestions to: + * \verbatim Contact: gudhi-users@lists.gforge.inria.fr \endverbatim + * + * GUDHI is open to external contributions. If you want to join our development team, please contact us. + * +*/ + +/*! \page Citation Acknowledging the GUDHI library + * We kindly ask users to cite the GUDHI library as appropriately as possible in their papers, and to mention the use + * of the GUDHI library on the web pages of their projects using GUDHI and provide us with links to these web pages. + * Feel free to contact us in case you have any question or remark on this topic. + * + * We provide \ref GudhiBibtex entries for the modules of the User and Reference Manual, as well as for publications + * directly related to the GUDHI library. + * \section GudhiBibtex GUDHI bibtex + * \verbinclude biblio/how_to_cite_gudhi.bib +*/ diff --git a/src/common/doc/main_page.h b/src/common/doc/main_page.h index 148ee670..b3e9ea03 100644 --- a/src/common/doc/main_page.h +++ b/src/common/doc/main_page.h @@ -93,7 +93,7 @@ - \subsection CoverComplexDataStructure Cover Complexes: Nerves and Graph Induced Complexes + \subsection CoverComplexDataStructure Cover Complexes \image html "gicvisu.jpg" "Graph Induced Complex of a point cloud." @@ -101,6 +101,7 @@ Author: Mathieu Carrière
Introduced in: GUDHI 2.1.0
Copyright: GPL v3
+ Requires: \ref cgal ≥ 4.8.1
Nerves and Graph Induced Complexes are cover complexes, i.e. simplicial complexes that provably contain @@ -250,305 +251,3 @@
*/ - -/*! \page installation GUDHI installation - * \tableofcontents - * As GUDHI is a header only library, there is no need to install the library. - * - * Examples of GUDHI headers inclusion can be found in \ref demos. - * - * \section compiling Compiling - * The library uses c++11 and requires Boost with version 1.48.0 or - * more recent. It is a multi-platform library and compiles on Linux, Mac OSX and Visual Studio 2015. - * - * \subsection demos Demos and examples - * To build the demos and examples, run the following commands in a terminal: -\verbatim cd /path-to-gudhi/ -mkdir build -cd build/ -cmake .. -make \endverbatim - * A list of examples is available here. - * - * \subsection testsuites Test suites - * To test your build, run the following command in a terminal: - * \verbatim make test \endverbatim - * - * \subsection documentationgeneration Documentation - * To generate the documentation, Doxygen is required. - * Run the following command in a terminal: -\verbatim -make doxygen -# Documentation will be generated in the folder YYYY-MM-DD-hh-mm-ss_GUDHI_X.Y.Z/doc/html/ -# You can customize the directory name by calling `cmake -DUSER_VERSION_DIR=/my/custom/folder` -\endverbatim - * - * \section optionallibrary Optional third-party library - * \subsection gmp GMP - * The multi-field persistent homology algorithm requires GMP which is a free library for arbitrary-precision - * arithmetic, operating on signed integers, rational numbers, and floating point numbers. - * - * The following example requires the GNU Multiple Precision Arithmetic - * Library (GMP) and will not be built if GMP is not installed: - * \li - * Persistent_cohomology/rips_multifield_persistence.cpp - * - * Having GMP version 4.2 or higher installed is recommended. - * - * \subsection cgal CGAL - * The \ref alpha_complex data structure, \ref bottleneck_distance, and few examples requires CGAL, which is a C++ - * library which provides easy access to efficient and reliable geometric algorithms. - * - * \note There is no need to install CGAL, you can just cmake . && make CGAL (or even - * cmake -DCGAL_HEADER_ONLY=ON . for CGAL version ≥ 4.8.0), thereafter you will be able to compile - * GUDHI by calling cmake -DCGAL_DIR=/your/path/to/CGAL-X.Y .. && make - * - * Having CGAL version 4.4.0 or higher installed is recommended. The procedure to install this library according to - * your operating system is detailed here http://doc.cgal.org/latest/Manual/installation.html - * - * The following examples/utilities require the Computational Geometry Algorithms - * Library (CGAL \cite cgal:eb-15b) and will not be built if CGAL is not installed: - * \li - * Alpha_complex/alpha_complex_3d_persistence.cpp - * \li - * Alpha_complex/exact_alpha_complex_3d_persistence.cpp - * \li - * Alpha_complex/weighted_alpha_complex_3d_persistence.cpp - * \li - * Simplex_tree/example_alpha_shapes_3_simplex_tree_from_off_file.cpp - * - * The following examples/utilities require CGAL version ≥ 4.6.0: - * \li - * Witness_complex/strong_witness_persistence.cpp - * \li - * Witness_complex/weak_witness_persistence.cpp - * \li - * Witness_complex/example_strong_witness_complex_off.cpp - * \li - * Witness_complex/example_witness_complex_off.cpp - * \li - * Witness_complex/example_witness_complex_sphere.cpp - * - * The following example requires CGAL version ≥ 4.7.0: - * \li - * Alpha_complex/Alpha_complex_from_off.cpp - * \li - * Alpha_complex/Alpha_complex_from_points.cpp - * \li - * Alpha_complex/alpha_complex_persistence.cpp - * \li - * Alpha_complex/periodic_alpha_complex_3d_persistence.cpp - * \li - * Persistent_cohomology/custom_persistence_sort.cpp - * - * The following example requires CGAL version ≥ 4.8.1: - * \li - * Bottleneck_distance/alpha_rips_persistence_bottleneck_distance.cpp.cpp - * \li - * Bottleneck_distance/bottleneck_basic_example.cpp - * \li - * Bottleneck_distance/bottleneck_distance.cpp - * \li - * Spatial_searching/example_spatial_searching.cpp - * \li - * Subsampling/example_choose_n_farthest_points.cpp - * \li - * Subsampling/example_custom_kernel.cpp - * \li - * Subsampling/example_pick_n_random_points.cpp - * \li - * Subsampling/example_sparsify_point_set.cpp - * \li - * Tangential_complex/example_basic.cpp - * \li - * Tangential_complex/example_with_perturb.cpp - * - * \subsection eigen3 Eigen3 - * The \ref alpha_complex data structure and few examples requires - * Eigen3 is a C++ template library for linear algebra: - * matrices, vectors, numerical solvers, and related algorithms. - * - * The following examples/utilities require the Eigen3 and will not be - * built if Eigen3 is not installed: - * \li - * Alpha_complex/Alpha_complex_from_off.cpp - * \li - * Alpha_complex/Alpha_complex_from_points.cpp - * \li - * Alpha_complex/alpha_complex_persistence.cpp - * \li - * Alpha_complex/periodic_alpha_complex_3d_persistence.cpp - * \li - * Bottleneck_distance/alpha_rips_persistence_bottleneck_distance.cpp.cpp - * \li - * Persistent_cohomology/custom_persistence_sort.cpp - * \li - * Spatial_searching/example_spatial_searching.cpp - * \li - * Subsampling/example_choose_n_farthest_points.cpp - * \li - * Subsampling/example_custom_kernel.cpp - * \li - * Subsampling/example_pick_n_random_points.cpp - * \li - * Subsampling/example_sparsify_point_set.cpp - * \li - * Tangential_complex/example_basic.cpp - * \li - * Tangential_complex/example_with_perturb.cpp - * \li - * Witness_complex/strong_witness_persistence.cpp - * \li - * Witness_complex/weak_witness_persistence.cpp - * \li - * Witness_complex/example_strong_witness_complex_off.cpp - * \li - * Witness_complex/example_witness_complex_off.cpp - * \li - * Witness_complex/example_witness_complex_sphere.cpp - * - * \subsection tbb Threading Building Blocks - * Intel® TBB lets you easily write parallel - * C++ programs that take full advantage of multicore performance, that are portable and composable, and that have - * future-proof scalability. - * - * Having Intel® TBB installed is recommended to parallelize and accelerate some GUDHI computations. - * - * The following examples/utilities are using Intel® TBB if installed: - * \li - * Alpha_complex/Alpha_complex_from_off.cpp - * \li - * Alpha_complex/Alpha_complex_from_points.cpp - * \li - * Alpha_complex/alpha_complex_3d_persistence.cpp - * \li - * Alpha_complex/alpha_complex_persistence.cpp - * \li - * Alpha_complex/exact_alpha_complex_3d_persistence.cpp - * \li - * Alpha_complex/periodic_alpha_complex_3d_persistence.cpp - * \li - * Alpha_complex/weighted_alpha_complex_3d_persistence.cpp - * \li - * Bitmap_cubical_complex/cubical_complex_persistence.cpp - * \li - * Bitmap_cubical_complex/periodic_cubical_complex_persistence.cpp - * \li - * Bitmap_cubical_complex/Random_bitmap_cubical_complex.cpp - * \li - * Simplex_tree/simple_simplex_tree.cpp - * \li - * Simplex_tree/example_alpha_shapes_3_simplex_tree_from_off_file.cpp - * \li - * Simplex_tree/simplex_tree_from_cliques_of_graph.cpp - * \li - * Simplex_tree/graph_expansion_with_blocker.cpp - * \li - * Persistent_cohomology/alpha_complex_3d_persistence.cpp - * \li - * Persistent_cohomology/alpha_complex_persistence.cpp - * \li - * Persistent_cohomology/rips_persistence_via_boundary_matrix.cpp - * \li - * Persistent_cohomology/persistence_from_file.cpp - * \li - * Persistent_cohomology/persistence_from_simple_simplex_tree.cpp - * \li - * Persistent_cohomology/plain_homology.cpp - * \li - * Persistent_cohomology/rips_multifield_persistence.cpp - * \li - * Persistent_cohomology/rips_persistence_step_by_step.cpp - * \li - * Persistent_cohomology/exact_alpha_complex_3d_persistence.cpp - * \li - * Persistent_cohomology/weighted_alpha_complex_3d_persistence.cpp - * \li - * Persistent_cohomology/custom_persistence_sort.cpp - * \li - * Rips_complex/example_one_skeleton_rips_from_points.cpp - * \li - * Rips_complex/example_rips_complex_from_off_file.cpp - * \li - * Rips_complex/rips_distance_matrix_persistence.cpp - * \li - * Rips_complex/rips_persistence.cpp - * \li - * Witness_complex/strong_witness_persistence.cpp - * \li - * Witness_complex/weak_witness_persistence.cpp - * \li - * Witness_complex/example_nearest_landmark_table.cpp - * - * \section Contributions Bug reports and contributions - * Please help us improving the quality of the GUDHI library. You may report bugs or suggestions to: - * \verbatim Contact: gudhi-users@lists.gforge.inria.fr \endverbatim - * - * GUDHI is open to external contributions. If you want to join our development team, please contact us. - * -*/ - -/*! \page Citation Acknowledging the GUDHI library - * We kindly ask users to cite the GUDHI library as appropriately as possible in their papers, and to mention the use - * of the GUDHI library on the web pages of their projects using GUDHI and provide us with links to these web pages. - * Feel free to contact us in case you have any question or remark on this topic. - * - * We provide \ref GudhiBibtex entries for the modules of the User and Reference Manual, as well as for publications - * directly related to the GUDHI library. - * \section GudhiBibtex GUDHI bibtex - * \verbinclude biblio/how_to_cite_gudhi.bib -*/ - -// List of GUDHI examples - Doxygen needs at least a file tag to analyse comments -/*! @file Examples - * @example Alpha_complex/Alpha_complex_from_off.cpp - * @example Alpha_complex/Alpha_complex_from_points.cpp - * @example Alpha_complex/alpha_complex_3d_persistence.cpp - * @example Alpha_complex/alpha_complex_persistence.cpp - * @example Alpha_complex/exact_alpha_complex_3d_persistence.cpp - * @example Alpha_complex/periodic_alpha_complex_3d_persistence.cpp - * @example Alpha_complex/weighted_alpha_complex_3d_persistence.cpp - * @example Bottleneck_distance/alpha_rips_persistence_bottleneck_distance.cpp - * @example Bottleneck_distance/bottleneck_basic_example.cpp - * @example Bottleneck_distance/bottleneck_distance.cpp - * @example Bitmap_cubical_complex/cubical_complex_persistence.cpp - * @example Bitmap_cubical_complex/periodic_cubical_complex_persistence.cpp - * @example Bitmap_cubical_complex/Random_bitmap_cubical_complex.cpp - * @example common/example_CGAL_3D_points_off_reader.cpp - * @example common/example_CGAL_points_off_reader.cpp - * @example Contraction/Garland_heckbert.cpp - * @example Contraction/Rips_contraction.cpp - * @example Persistent_cohomology/rips_persistence_via_boundary_matrix.cpp - * @example Persistent_cohomology/persistence_from_file.cpp - * @example Persistent_cohomology/persistence_from_simple_simplex_tree.cpp - * @example Persistent_cohomology/plain_homology.cpp - * @example Persistent_cohomology/rips_multifield_persistence.cpp - * @example Persistent_cohomology/custom_persistence_sort.cpp - * @example Persistent_cohomology/rips_persistence_step_by_step.cpp - * @example Rips_complex/example_one_skeleton_rips_from_points.cpp - * @example Rips_complex/example_rips_complex_from_off_file.cpp - * @example Rips_complex/rips_persistence.cpp - * @example Rips_complex/rips_distance_matrix_persistence.cpp - * @example Simplex_tree/mini_simplex_tree.cpp - * @example Simplex_tree/simple_simplex_tree.cpp - * @example Simplex_tree/example_alpha_shapes_3_simplex_tree_from_off_file.cpp - * @example Simplex_tree/simplex_tree_from_cliques_of_graph.cpp - * @example Simplex_tree/graph_expansion_with_blocker.cpp - * @example Skeleton_blocker/Skeleton_blocker_from_simplices.cpp - * @example Skeleton_blocker/Skeleton_blocker_iteration.cpp - * @example Skeleton_blocker/Skeleton_blocker_link.cpp - * @example Spatial_searching/example_spatial_searching.cpp - * @example Subsampling/example_choose_n_farthest_points.cpp - * @example Subsampling/example_custom_kernel.cpp - * @example Subsampling/example_pick_n_random_points.cpp - * @example Subsampling/example_sparsify_point_set.cpp - * @example Tangential_complex/example_basic.cpp - * @example Tangential_complex/example_with_perturb.cpp - * @example Witness_complex/example_nearest_landmark_table.cpp - * @example Witness_complex/example_strong_witness_complex_off.cpp - * @example Witness_complex/example_witness_complex_off.cpp - * @example Witness_complex/example_witness_complex_sphere.cpp - * @example Witness_complex/weak_witness_persistence.cpp - * @example Witness_complex/strong_witness_persistence.cpp - */ - -- 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/Persistence_representations') 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 b92ea601f15a239957ec6beba78ee2deee3d32d6 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Tue, 30 Jan 2018 08:54:00 +0000 Subject: Fix --v to -v for Cover complex git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@3182 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 46e36af1a3e9aae8f1b12d2ee7fc749eb531f505 --- src/Nerve_GIC/doc/Intro_graph_induced_complex.h | 8 ++++---- src/Nerve_GIC/example/CoordGIC.cpp | 4 ++-- src/Nerve_GIC/example/FuncGIC.cpp | 4 ++-- src/Nerve_GIC/utilities/Nerve.cpp | 4 ++-- src/Nerve_GIC/utilities/VoronoiGIC.cpp | 4 ++-- src/Nerve_GIC/utilities/covercomplex.md | 8 ++++---- .../doc/Persistence_representations_doc.h | 2 +- 7 files changed, 17 insertions(+), 17 deletions(-) (limited to 'src/Persistence_representations') diff --git a/src/Nerve_GIC/doc/Intro_graph_induced_complex.h b/src/Nerve_GIC/doc/Intro_graph_induced_complex.h index 474f0f0e..2b648425 100644 --- a/src/Nerve_GIC/doc/Intro_graph_induced_complex.h +++ b/src/Nerve_GIC/doc/Intro_graph_induced_complex.h @@ -70,7 +70,7 @@ namespace cover_complex { * * When launching: * - * \code $> ./Nerve ../../data/points/human.off 2 10 0.3 --v + * \code $> ./Nerve ../../data/points/human.off 2 10 0.3 -v * \endcode * * the program output is: @@ -113,7 +113,7 @@ namespace cover_complex { * * When launching: * - * \code $> ./VoronoiGIC ../../data/points/human.off 700 --v + * \code $> ./VoronoiGIC ../../data/points/human.off 700 -v * \endcode * * the program outputs SC.off. Using e.g. @@ -146,7 +146,7 @@ namespace cover_complex { * * When launching: * - * \code $> ./CoordGIC ../../data/points/KleinBottle5D.off 0 --v + * \code $> ./CoordGIC ../../data/points/KleinBottle5D.off 0 -v * \endcode * * the program outputs SC.dot. Using e.g. @@ -169,7 +169,7 @@ namespace cover_complex { * * When launching: * - * \code $> ./FuncGIC ../../data/points/COIL_database/lucky_cat.off ../../data/points/COIL_database/lucky_cat_PCA1 --v + * \code $> ./FuncGIC ../../data/points/COIL_database/lucky_cat.off ../../data/points/COIL_database/lucky_cat_PCA1 -v * \endcode * * the program outputs again SC.dot which gives the following visualization after using neato: diff --git a/src/Nerve_GIC/example/CoordGIC.cpp b/src/Nerve_GIC/example/CoordGIC.cpp index c03fcbb3..c92cf235 100644 --- a/src/Nerve_GIC/example/CoordGIC.cpp +++ b/src/Nerve_GIC/example/CoordGIC.cpp @@ -27,8 +27,8 @@ void usage(int nbArgs, char *const progName) { std::cerr << "Error: Number of arguments (" << nbArgs << ") is not correct\n"; - std::cerr << "Usage: " << progName << " filename.off coordinate [--v] \n"; - std::cerr << " i.e.: " << progName << " ../../data/points/human.off 2 --v \n"; + std::cerr << "Usage: " << progName << " filename.off coordinate [-v] \n"; + std::cerr << " i.e.: " << progName << " ../../data/points/human.off 2 -v \n"; exit(-1); // ----- >> } diff --git a/src/Nerve_GIC/example/FuncGIC.cpp b/src/Nerve_GIC/example/FuncGIC.cpp index 3762db4e..cb0f0d63 100644 --- a/src/Nerve_GIC/example/FuncGIC.cpp +++ b/src/Nerve_GIC/example/FuncGIC.cpp @@ -27,9 +27,9 @@ void usage(int nbArgs, char *const progName) { std::cerr << "Error: Number of arguments (" << nbArgs << ") is not correct\n"; - std::cerr << "Usage: " << progName << " filename.off function [--v] \n"; + std::cerr << "Usage: " << progName << " filename.off function [-v] \n"; std::cerr << " i.e.: " << progName << " ../../data/points/COIL_database/lucky_cat.off " - "../../data/points/COIL_database/lucky_cat_PCA1 --v \n"; + "../../data/points/COIL_database/lucky_cat_PCA1 -v \n"; exit(-1); // ----- >> } diff --git a/src/Nerve_GIC/utilities/Nerve.cpp b/src/Nerve_GIC/utilities/Nerve.cpp index 6abdedc7..aefc3874 100644 --- a/src/Nerve_GIC/utilities/Nerve.cpp +++ b/src/Nerve_GIC/utilities/Nerve.cpp @@ -27,8 +27,8 @@ void usage(int nbArgs, char *const progName) { std::cerr << "Error: Number of arguments (" << nbArgs << ") is not correct\n"; - std::cerr << "Usage: " << progName << " filename.off coordinate resolution gain [--v] \n"; - std::cerr << " i.e.: " << progName << " ../../data/points/human.off 2 10 0.3 --v \n"; + std::cerr << "Usage: " << progName << " filename.off coordinate resolution gain [-v] \n"; + std::cerr << " i.e.: " << progName << " ../../data/points/human.off 2 10 0.3 -v \n"; exit(-1); // ----- >> } diff --git a/src/Nerve_GIC/utilities/VoronoiGIC.cpp b/src/Nerve_GIC/utilities/VoronoiGIC.cpp index 32431cc2..54bb871e 100644 --- a/src/Nerve_GIC/utilities/VoronoiGIC.cpp +++ b/src/Nerve_GIC/utilities/VoronoiGIC.cpp @@ -27,8 +27,8 @@ void usage(int nbArgs, char *const progName) { std::cerr << "Error: Number of arguments (" << nbArgs << ") is not correct\n"; - std::cerr << "Usage: " << progName << " filename.off N [--v] \n"; - std::cerr << " i.e.: " << progName << " ../../data/points/human.off 100 --v \n"; + std::cerr << "Usage: " << progName << " filename.off N [-v] \n"; + std::cerr << " i.e.: " << progName << " ../../data/points/human.off 100 -v \n"; exit(-1); // ----- >> } diff --git a/src/Nerve_GIC/utilities/covercomplex.md b/src/Nerve_GIC/utilities/covercomplex.md index 692e44e7..41489b66 100644 --- a/src/Nerve_GIC/utilities/covercomplex.md +++ b/src/Nerve_GIC/utilities/covercomplex.md @@ -27,14 +27,14 @@ Finally, the next ne lines represent the edges, characterized by the ID of their **Usage** -`Nerve coordinate resolution gain [--v]` +`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. +* `-v` is optional, it activates verbose mode. **Example** @@ -57,12 +57,12 @@ The program also writes a file `*_sc.off`, that is an OFF file that can be visua **Usage** -`VoroniGIC samples_number [--v]` +`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. +* `-v` is optional, it activates verbose mode. **Example** diff --git a/src/Persistence_representations/doc/Persistence_representations_doc.h b/src/Persistence_representations/doc/Persistence_representations_doc.h index d781211a..38bd3a21 100644 --- a/src/Persistence_representations/doc/Persistence_representations_doc.h +++ b/src/Persistence_representations/doc/Persistence_representations_doc.h @@ -67,7 +67,7 @@ namespace Persistence_representations { \li Concept of representation of persistence that allows computations of distances. \li Concept of representation of persistence that allows computations of scalar products. \li Concept of representation of persistence that allows vectorization. - \li Concept of representation of persistence that allows computations of real--valued characteristics of objects. + \li Concept of representation of persistence that allows computations of real-valued characteristics of objects. At the moment an implementation of the following representations of persistence are available (further details of -- cgit v1.2.3 From 265484997185f3bf900744406206a2d64ca0a20d Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Fri, 2 Feb 2018 14:15:49 +0000 Subject: Fix after version release of Cover complex and Persistence representation installations Fix utils download link git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@3211 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 9596df8b0d0cdc3d8df79aa367a26b34a96d7f5e --- src/Nerve_GIC/example/CMakeLists.txt | 3 +++ src/Nerve_GIC/utilities/CMakeLists.txt | 4 ++++ src/Persistence_representations/example/CMakeLists.txt | 8 +++++--- src/Persistence_representations/utilities/CMakeLists.txt | 6 ++++++ .../utilities/persistence_intervals/CMakeLists.txt | 6 ++++++ src/common/doc/header.html | 4 ++-- src/cython/doc/_templates/layout.html | 4 ++-- 7 files changed, 28 insertions(+), 7 deletions(-) (limited to 'src/Persistence_representations') diff --git a/src/Nerve_GIC/example/CMakeLists.txt b/src/Nerve_GIC/example/CMakeLists.txt index f2626927..542c6af4 100644 --- a/src/Nerve_GIC/example/CMakeLists.txt +++ b/src/Nerve_GIC/example/CMakeLists.txt @@ -23,4 +23,7 @@ if (NOT CGAL_VERSION VERSION_LESS 4.8.1) "lucky_cat.off" "lucky_cat_PCA1") + install(TARGETS CoordGIC DESTINATION bin) + install(TARGETS FuncGIC DESTINATION bin) + endif (NOT CGAL_VERSION VERSION_LESS 4.8.1) diff --git a/src/Nerve_GIC/utilities/CMakeLists.txt b/src/Nerve_GIC/utilities/CMakeLists.txt index 7762c8a0..7a838a8c 100644 --- a/src/Nerve_GIC/utilities/CMakeLists.txt +++ b/src/Nerve_GIC/utilities/CMakeLists.txt @@ -21,4 +21,8 @@ if (NOT CGAL_VERSION VERSION_LESS 4.8.1) add_test(NAME Nerve_GIC_utilities_VoronoiGIC COMMAND $ "human.off" "100") + install(TARGETS Nerve DESTINATION bin) + install(TARGETS VoronoiGIC DESTINATION bin) + install(FILES KeplerMapperVisuFromTxtFile.py km.py km.py.COPYRIGHT DESTINATION bin) + endif (NOT CGAL_VERSION VERSION_LESS 4.8.1) diff --git a/src/Persistence_representations/example/CMakeLists.txt b/src/Persistence_representations/example/CMakeLists.txt index eb3258f8..54d719ac 100644 --- a/src/Persistence_representations/example/CMakeLists.txt +++ b/src/Persistence_representations/example/CMakeLists.txt @@ -4,24 +4,26 @@ project(Persistence_representations_example) add_executable ( Persistence_representations_example_landscape_on_grid persistence_landscape_on_grid.cpp ) add_test(NAME Persistence_representations_example_landscape_on_grid COMMAND $) +install(TARGETS Persistence_representations_example_landscape_on_grid DESTINATION bin) add_executable ( Persistence_representations_example_landscape persistence_landscape.cpp ) add_test(NAME Persistence_representations_example_landscape COMMAND $) +install(TARGETS Persistence_representations_example_landscape DESTINATION bin) add_executable ( Persistence_representations_example_intervals persistence_intervals.cpp ) add_test(NAME Persistence_representations_example_intervals COMMAND $ "${CMAKE_SOURCE_DIR}/data/persistence_diagram/first.pers") +install(TARGETS Persistence_representations_example_intervals DESTINATION bin) add_executable ( Persistence_representations_example_vectors persistence_vectors.cpp ) add_test(NAME Persistence_representations_example_vectors COMMAND $) +install(TARGETS Persistence_representations_example_vectors DESTINATION bin) add_executable ( Persistence_representations_example_heat_maps persistence_heat_maps.cpp ) add_test(NAME Persistence_representations_example_heat_maps COMMAND $) - - - +install(TARGETS Persistence_representations_example_heat_maps DESTINATION bin) diff --git a/src/Persistence_representations/utilities/CMakeLists.txt b/src/Persistence_representations/utilities/CMakeLists.txt index 137eb0c1..fc51b1d6 100644 --- a/src/Persistence_representations/utilities/CMakeLists.txt +++ b/src/Persistence_representations/utilities/CMakeLists.txt @@ -10,6 +10,8 @@ function(add_persistence_representation_creation_utility creation_utility) add_test(NAME Persistence_representation_utilities_${creation_utility} COMMAND $ ${ARGN} "${CMAKE_CURRENT_BINARY_DIR}/../first.pers" "${CMAKE_CURRENT_BINARY_DIR}/../second.pers") + + install(TARGETS ${creation_utility} DESTINATION bin) endfunction(add_persistence_representation_creation_utility) function(add_persistence_representation_plot_utility plot_utility tool_extension) @@ -26,6 +28,8 @@ function(add_persistence_representation_plot_utility plot_utility tool_extension #add_test(NAME Persistence_representation_utilities_${plot_utility}_second_gnuplot COMMAND ${GNUPLOT_PATH} # "-e" "load '${CMAKE_CURRENT_BINARY_DIR}/../second.pers${tool_extension}_GnuplotScript'") endif() + + install(TARGETS ${plot_utility} DESTINATION bin) endfunction(add_persistence_representation_plot_utility) function(add_persistence_representation_function_utility function_utility tool_extension) @@ -44,6 +48,8 @@ function(add_persistence_representation_function_utility function_utility tool_e "${CMAKE_CURRENT_BINARY_DIR}/../first.pers${tool_extension}" "${CMAKE_CURRENT_BINARY_DIR}/../second.pers${tool_extension}") endif() + + install(TARGETS ${function_utility} DESTINATION bin) endfunction(add_persistence_representation_function_utility) add_subdirectory(persistence_heat_maps) diff --git a/src/Persistence_representations/utilities/persistence_intervals/CMakeLists.txt b/src/Persistence_representations/utilities/persistence_intervals/CMakeLists.txt index 897e12a3..875ff45e 100644 --- a/src/Persistence_representations/utilities/persistence_intervals/CMakeLists.txt +++ b/src/Persistence_representations/utilities/persistence_intervals/CMakeLists.txt @@ -7,6 +7,8 @@ add_executable ( plot_histogram_of_intervals_lengths plot_histogram_of_intervals add_test(NAME plot_histogram_of_intervals_lengths COMMAND $ "${CMAKE_CURRENT_BINARY_DIR}/../first.pers" "-1") +install(TARGETS plot_histogram_of_intervals_lengths DESTINATION bin) + add_persistence_representation_plot_utility(plot_persistence_intervals "") add_persistence_representation_plot_utility(plot_persistence_Betti_numbers "") @@ -18,6 +20,8 @@ add_test(NAME Persistence_representation_utilities_compute_number_of_dominant_in COMMAND $ "${CMAKE_CURRENT_BINARY_DIR}/../first.pers" "-1" "2") +install(TARGETS compute_number_of_dominant_intervals DESTINATION bin) + if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1) add_executable ( compute_bottleneck_distance compute_bottleneck_distance.cpp ) @@ -29,4 +33,6 @@ if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1) "-1" "${CMAKE_CURRENT_BINARY_DIR}/../first.pers" "${CMAKE_CURRENT_BINARY_DIR}/../second.pers") + + install(TARGETS compute_bottleneck_distance DESTINATION bin) endif (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1) diff --git a/src/common/doc/header.html b/src/common/doc/header.html index 9c514381..d69b28fa 100644 --- a/src/common/doc/header.html +++ b/src/common/doc/header.html @@ -56,8 +56,8 @@ $extrastylesheet
  • diff --git a/src/cython/doc/_templates/layout.html b/src/cython/doc/_templates/layout.html index 8e4eba40..c9356116 100644 --- a/src/cython/doc/_templates/layout.html +++ b/src/cython/doc/_templates/layout.html @@ -198,8 +198,8 @@
  • -- cgit v1.2.3