From d03c111cbb3329018d72c7ed8bea2d7ac9a57045 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Mon, 21 Nov 2016 09:59:09 +0000 Subject: Add distance matrix reader test cases git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/distance_matrix_in_rips_module@1763 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: cae9765c56ff6e0a213a7835bab56f3618e4d942 --- data/distance_matrix/full_square_distance_matrix.csv | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 data/distance_matrix/full_square_distance_matrix.csv (limited to 'data/distance_matrix/full_square_distance_matrix.csv') diff --git a/data/distance_matrix/full_square_distance_matrix.csv b/data/distance_matrix/full_square_distance_matrix.csv new file mode 100644 index 00000000..7225a5fd --- /dev/null +++ b/data/distance_matrix/full_square_distance_matrix.csv @@ -0,0 +1,5 @@ +0;0.94;0.77;0.99;0.11; +0.94;0;0.26;0.99;0.39; +0.77;0.26;0;0.28;0.97; +0.99;0.99;0.28;0;0.30; +0.11;0.39;0.97;0.30;0; -- cgit v1.2.3 From 71f9bed6df48dedc0d4e8ef620496af9c494eccc Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Tue, 22 Nov 2016 13:29:59 +0000 Subject: Fix examples and tests git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/distance_matrix_in_rips_module@1767 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 4a1c78aec05d443e0525bf24a0cc7f7b5c628629 --- .../full_square_distance_matrix.csv | 12 +- src/Persistent_cohomology/example/CMakeLists.txt | 9 +- src/Persistent_cohomology/example/README | 50 ++++--- .../example/rips_distance_matrix_persistence.cpp | 145 +++++++++++++++++++++ .../example/rips_persistence.cpp | 5 +- src/Rips_complex/doc/Intro_rips_complex.h | 8 +- src/Rips_complex/example/CMakeLists.txt | 20 ++- .../full_skeleton_rips_distance_for_doc.txt | 32 ----- .../example/full_skeleton_rips_for_doc.txt | 26 ++++ .../example/full_skeleton_rips_points_for_doc.txt | 26 ---- .../example/one_skeleton_rips_distance_for_doc.txt | 17 --- .../example/one_skeleton_rips_for_doc.txt | 20 +++ .../example/one_skeleton_rips_points_for_doc.txt | 20 --- src/common/include/gudhi/reader_utils.h | 21 ++- src/common/test/test_distance_matrix_reader.cpp | 2 +- 15 files changed, 264 insertions(+), 149 deletions(-) create mode 100644 src/Persistent_cohomology/example/rips_distance_matrix_persistence.cpp delete mode 100644 src/Rips_complex/example/full_skeleton_rips_distance_for_doc.txt create mode 100644 src/Rips_complex/example/full_skeleton_rips_for_doc.txt delete mode 100644 src/Rips_complex/example/full_skeleton_rips_points_for_doc.txt delete mode 100644 src/Rips_complex/example/one_skeleton_rips_distance_for_doc.txt create mode 100644 src/Rips_complex/example/one_skeleton_rips_for_doc.txt delete mode 100644 src/Rips_complex/example/one_skeleton_rips_points_for_doc.txt (limited to 'data/distance_matrix/full_square_distance_matrix.csv') diff --git a/data/distance_matrix/full_square_distance_matrix.csv b/data/distance_matrix/full_square_distance_matrix.csv index 7225a5fd..51512b03 100644 --- a/data/distance_matrix/full_square_distance_matrix.csv +++ b/data/distance_matrix/full_square_distance_matrix.csv @@ -1,5 +1,7 @@ -0;0.94;0.77;0.99;0.11; -0.94;0;0.26;0.99;0.39; -0.77;0.26;0;0.28;0.97; -0.99;0.99;0.28;0;0.30; -0.11;0.39;0.97;0.30;0; +0;6.0827625303;5.8309518948;9.4339811321;13.0384048104;18.0277563773;17.88854382; +6.0827625303;0;6.7082039325;6.3245553203;15.6524758425;19.6468827044;17.1172427686; +5.8309518948;6.7082039325;0;5;8.94427191;13.152946438;12.0830459736; +9.4339811321;6.3245553203;5;0;12.0415945788;14.7648230602;11; +13.0384048104;15.6524758425;8.94427191;12.0415945788;0;5.3851648071;9.4868329805; +18.0277563773;19.6468827044;13.152946438;14.7648230602;5.3851648071;0;7.2801098893; +17.88854382;17.1172427686;12.0830459736;11;9.4868329805;7.2801098893;0; \ No newline at end of file diff --git a/src/Persistent_cohomology/example/CMakeLists.txt b/src/Persistent_cohomology/example/CMakeLists.txt index e50e8ca9..b2ac9736 100644 --- a/src/Persistent_cohomology/example/CMakeLists.txt +++ b/src/Persistent_cohomology/example/CMakeLists.txt @@ -11,6 +11,9 @@ target_link_libraries(plain_homology ${Boost_SYSTEM_LIBRARY}) add_executable(persistence_from_simple_simplex_tree persistence_from_simple_simplex_tree.cpp) target_link_libraries(persistence_from_simple_simplex_tree ${Boost_SYSTEM_LIBRARY}) +add_executable(rips_distance_matrix_persistence rips_distance_matrix_persistence.cpp) +target_link_libraries(rips_distance_matrix_persistence ${Boost_SYSTEM_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY}) + add_executable(rips_persistence rips_persistence.cpp) target_link_libraries(rips_persistence ${Boost_SYSTEM_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY}) @@ -23,6 +26,7 @@ target_link_libraries(persistence_from_file ${Boost_SYSTEM_LIBRARY} ${Boost_PROG if (TBB_FOUND) target_link_libraries(plain_homology ${TBB_LIBRARIES}) target_link_libraries(persistence_from_simple_simplex_tree ${TBB_LIBRARIES}) + target_link_libraries(rips_distance_matrix_persistence ${TBB_LIBRARIES}) target_link_libraries(rips_persistence ${TBB_LIBRARIES}) target_link_libraries(rips_persistence_via_boundary_matrix ${TBB_LIBRARIES}) target_link_libraries(persistence_from_file ${TBB_LIBRARIES}) @@ -30,7 +34,8 @@ endif() add_test(plain_homology ${CMAKE_CURRENT_BINARY_DIR}/plain_homology) add_test(persistence_from_simple_simplex_tree ${CMAKE_CURRENT_BINARY_DIR}/persistence_from_simple_simplex_tree 1 0) -add_test(rips_persistence_3 ${CMAKE_CURRENT_BINARY_DIR}/rips_persistence ${CMAKE_SOURCE_DIR}/data/points/Kl.txt -r 0.16 -d 3 -p 3 -m 100) +add_test(rips_distance_matrix ${CMAKE_CURRENT_BINARY_DIR}/rips_distance_matrix_persistence ${CMAKE_SOURCE_DIR}/data/distance_matrix/full_square_distance_matrix.csv -r 1.0 -d 3 -p 3 -m 0) +add_test(rips_persistence_3 ${CMAKE_CURRENT_BINARY_DIR}/rips_persistence ${CMAKE_SOURCE_DIR}/data/points/tore3D_1307.off -r 0.25 -m 0.5 -d 3 -p 3) add_test(rips_persistence_via_boundary_matrix_3 ${CMAKE_CURRENT_BINARY_DIR}/rips_persistence_via_boundary_matrix ${CMAKE_SOURCE_DIR}/data/points/Kl.txt -r 0.16 -d 3 -p 3 -m 100) add_test(persistence_from_file_3_2_0 ${CMAKE_CURRENT_BINARY_DIR}/persistence_from_file ${CMAKE_SOURCE_DIR}/data/filtered_simplicial_complex/bunny_5000_complex.fsc -p 2 -m 0) add_test(persistence_from_file_3_3_100 ${CMAKE_CURRENT_BINARY_DIR}/persistence_from_file ${CMAKE_SOURCE_DIR}/data/filtered_simplicial_complex/bunny_5000_complex.fsc -p 3 -m 100) @@ -42,7 +47,7 @@ if(GMP_FOUND) if (TBB_FOUND) target_link_libraries(rips_multifield_persistence ${TBB_LIBRARIES}) endif(TBB_FOUND) - add_test(rips_multifield_persistence_2_71 ${CMAKE_CURRENT_BINARY_DIR}/rips_multifield_persistence ${CMAKE_SOURCE_DIR}/data/points/Kl.txt -r 0.2 -d 3 -p 2 -q 71 -m 100) + add_test(rips_multifield_persistence_2_71 ${CMAKE_CURRENT_BINARY_DIR}/rips_multifield_persistence ${CMAKE_SOURCE_DIR}/data/points/tore3D_1307.off -r 0.25 -m 0.5 -d 3 -p 2 -q 71) endif(GMPXX_FOUND) endif(GMP_FOUND) diff --git a/src/Persistent_cohomology/example/README b/src/Persistent_cohomology/example/README index 7803e5ab..1063ea41 100644 --- a/src/Persistent_cohomology/example/README +++ b/src/Persistent_cohomology/example/README @@ -10,13 +10,13 @@ Example of use of RIPS: Computation of the persistent homology with Z/2Z coefficients of the Rips complex on points sampling a Klein bottle: -./rips_persistence ../../data/points/Kl.txt -r 0.25 -d 3 -p 2 -m 100 +./rips_persistence ../../data/points/tore3D_1307.off -r 0.25 -m 0.5 -d 3 -p 2 output: -210 0 0 inf -210 1 0.0702103 inf -2 1 0.0702103 inf -2 2 0.159992 inf +2 0 0 inf +2 1 0.0983494 inf +2 1 0.104347 inf +2 2 0.138335 inf Every line is of this format: p1*...*pr dim b d @@ -29,31 +29,45 @@ where with Z/3Z coefficients: -./rips_persistence ../../data/points/Kl.txt -r 0.25 -d 3 -p 3 -m 100 +./rips_persistence ../../data/points/tore3D_1307.off -r 0.25 -m 0.5 -d 3 -p 3 output: -3 0 0 inf -3 1 0.0702103 inf +3 0 0 inf +3 1 0.0983494 inf +3 1 0.104347 inf +3 2 0.138335 inf and the computation with Z/2Z and Z/3Z coefficients simultaneously: -./rips_multifield_persistence ../../data/points/Kl.txt -r 0.25 -d 3 -p 2 -q 3 -m 100 +./rips_multifield_persistence ../../data/points/tore3D_1307.off -r 0.25 -m 0.12 -d 3 -p 2 -q 3 output: -6 0 0 inf -6 1 0.0702103 inf -2 1 0.0702103 inf -2 2 0.159992 inf +6 0 0 inf +6 1 0.0983494 inf +6 1 0.104347 inf +6 2 0.138335 inf +6 0 0 0.122545 +6 0 0 0.121171 +6 0 0 0.120964 +6 0 0 0.12057 +6 0 0 0.12047 +6 0 0 0.120414 and finally the computation with all Z/pZ for 2 <= p <= 71 (20 first prime numbers): - ./rips_multifield_persistence ../../data/points/Kl.txt -r 0.25 -d 3 -p 2 -q 71 -m 100 + ./rips_multifield_persistence ../../data/points/Kl.txt -r 0.25 -m 0.5 -d 3 -p 2 -q 71 output: -557940830126698960967415390 0 0 inf -557940830126698960967415390 1 0.0702103 inf -2 1 0.0702103 inf -2 2 0.159992 inf +557940830126698960967415390 0 0 inf +557940830126698960967415390 1 0.0983494 inf +557940830126698960967415390 1 0.104347 inf +557940830126698960967415390 2 0.138335 inf +557940830126698960967415390 0 0 0.122545 +557940830126698960967415390 0 0 0.121171 +557940830126698960967415390 0 0 0.120964 +557940830126698960967415390 0 0 0.12057 +557940830126698960967415390 0 0 0.12047 +557940830126698960967415390 0 0 0.120414 *********************************************************************************************************************** Example of use of ALPHA: diff --git a/src/Persistent_cohomology/example/rips_distance_matrix_persistence.cpp b/src/Persistent_cohomology/example/rips_distance_matrix_persistence.cpp new file mode 100644 index 00000000..7a9e9c8b --- /dev/null +++ b/src/Persistent_cohomology/example/rips_distance_matrix_persistence.cpp @@ -0,0 +1,145 @@ +/* This file is part of the Gudhi Library. The Gudhi library + * (Geometric Understanding in Higher Dimensions) is a generic C++ + * library for computational topology. + * + * Author(s): Pawel Dlotko, Vincent Rouvreau + * + * Copyright (C) 2016 INRIA + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include +#include +#include + +#include + +#include +#include +#include // infinity + +// Types definition +using Simplex_tree = Gudhi::Simplex_tree; +using Filtration_value = Simplex_tree::Filtration_value; +using Rips_complex = Gudhi::rips_complex::Rips_complex; +using Field_Zp = Gudhi::persistent_cohomology::Field_Zp; +using Persistent_cohomology = Gudhi::persistent_cohomology::Persistent_cohomology; +using Distance_matrix = std::vector>; + +void program_options(int argc, char * argv[] + , std::string & csv_matrix_file + , std::string & filediag + , Filtration_value & threshold + , int & dim_max + , int & p + , Filtration_value & min_persistence); + +int main(int argc, char * argv[]) { + std::string csv_matrix_file; + std::string filediag; + Filtration_value threshold; + int dim_max; + int p; + Filtration_value min_persistence; + + program_options(argc, argv, csv_matrix_file, filediag, threshold, dim_max, p, min_persistence); + + Distance_matrix distances = read_lower_triangular_matrix_from_csv_file(csv_matrix_file); + Rips_complex rips_complex_from_file(distances, threshold); + + // Construct the Rips complex in a Simplex Tree + Simplex_tree simplex_tree; + + if (rips_complex_from_file.create_complex(simplex_tree, dim_max)) { + std::cout << "The complex contains " << simplex_tree.num_simplices() << " simplices \n"; + std::cout << " and has dimension " << simplex_tree.dimension() << " \n"; + + // Sort the simplices in the order of the filtration + simplex_tree.initialize_filtration(); + + // Compute the persistence diagram of the complex + Persistent_cohomology pcoh(simplex_tree); + // initializes the coefficient field for homology + pcoh.init_coefficients(p); + + pcoh.compute_persistent_cohomology(min_persistence); + + // Output the diagram in filediag + if (filediag.empty()) { + pcoh.output_diagram(); + } else { + std::ofstream out(filediag); + pcoh.output_diagram(out); + out.close(); + } + } + return 0; +} + +void program_options(int argc, char * argv[] + , std::string & csv_matrix_file + , std::string & filediag + , Filtration_value & threshold + , int & dim_max + , int & p + , Filtration_value & min_persistence) { + namespace po = boost::program_options; + po::options_description hidden("Hidden options"); + hidden.add_options() + ("input-file", po::value(&csv_matrix_file), + "Name of file containing a distance matrix. Can be square or lower triangular matrix. Separator is ';'."); + + po::options_description visible("Allowed options", 100); + visible.add_options() + ("help,h", "produce help message") + ("output-file,o", po::value(&filediag)->default_value(std::string()), + "Name of file in which the persistence diagram is written. Default print in std::cout") + ("max-edge-length,r", + po::value(&threshold)->default_value(std::numeric_limits::infinity()), + "Maximal length of an edge for the Rips complex construction.") + ("cpx-dimension,d", po::value(&dim_max)->default_value(1), + "Maximal dimension of the Rips complex we want to compute.") + ("field-charac,p", po::value(&p)->default_value(11), + "Characteristic p of the coefficient field Z/pZ for computing homology.") + ("min-persistence,m", po::value(&min_persistence), + "Minimal lifetime of homology feature to be recorded. Default is 0. Enter a negative value to see zero length intervals"); + + po::positional_options_description pos; + pos.add("input-file", 1); + + po::options_description all; + all.add(visible).add(hidden); + + po::variables_map vm; + po::store(po::command_line_parser(argc, argv). + options(all).positional(pos).run(), vm); + po::notify(vm); + + if (vm.count("help") || !vm.count("input-file")) { + std::cout << std::endl; + std::cout << "Compute the persistent homology with coefficient field Z/pZ \n"; + std::cout << "of a Rips complex defined on a set of distance matrix.\n \n"; + std::cout << "The output diagram contains one bar per line, written with the convention: \n"; + std::cout << " p dim b d \n"; + std::cout << "where dim is the dimension of the homological feature,\n"; + std::cout << "b and d are respectively the birth and death of the feature and \n"; + std::cout << "p is the characteristic of the field Z/pZ used for homology coefficients." << std::endl << std::endl; + + std::cout << "Usage: " << argv[0] << " [options] input-file" << std::endl << std::endl; + std::cout << visible << std::endl; + std::abort(); + } +} diff --git a/src/Persistent_cohomology/example/rips_persistence.cpp b/src/Persistent_cohomology/example/rips_persistence.cpp index 709c2eab..3fa8aa30 100644 --- a/src/Persistent_cohomology/example/rips_persistence.cpp +++ b/src/Persistent_cohomology/example/rips_persistence.cpp @@ -104,14 +104,15 @@ void program_options(int argc, char * argv[] po::options_description hidden("Hidden options"); hidden.add_options() ("input-file", po::value(&off_file_points), - "Name of file containing a point set. Format is one point per line: X1 ... Xd "); + "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()), + ("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.") diff --git a/src/Rips_complex/doc/Intro_rips_complex.h b/src/Rips_complex/doc/Intro_rips_complex.h index d01b14bb..0ae89ffc 100644 --- a/src/Rips_complex/doc/Intro_rips_complex.h +++ b/src/Rips_complex/doc/Intro_rips_complex.h @@ -73,7 +73,7 @@ namespace rips_complex { * * the program output is: * - * \include Rips_complex/one_skeleton_rips_points_for_doc.txt + * \include Rips_complex/one_skeleton_rips_for_doc.txt * * \subsection ripsoffexample Example from OFF file * @@ -93,7 +93,7 @@ namespace rips_complex { * * the program output is: * - * \include Rips_complex/full_skeleton_rips_points_for_doc.txt + * \include Rips_complex/full_skeleton_rips_for_doc.txt * * * @@ -116,7 +116,7 @@ namespace rips_complex { * * the program output is: * - * \include Rips_complex/one_skeleton_rips_distance_for_doc.txt + * \include Rips_complex/one_skeleton_rips_for_doc.txt * * \subsection ripscsvdistanceexample Example from a distance matrix read in a csv file * @@ -135,7 +135,7 @@ namespace rips_complex { * * the program output is: * - * \include Rips_complex/full_skeleton_rips_distance_for_doc.txt + * \include Rips_complex/full_skeleton_rips_for_doc.txt * * \copyright GNU General Public License v3. * \verbatim Contact: gudhi-users@lists.gforge.inria.fr \endverbatim diff --git a/src/Rips_complex/example/CMakeLists.txt b/src/Rips_complex/example/CMakeLists.txt index 9ba9d941..c15a13d0 100644 --- a/src/Rips_complex/example/CMakeLists.txt +++ b/src/Rips_complex/example/CMakeLists.txt @@ -32,19 +32,17 @@ add_test(ripsoffreader_doc_12_1 ${CMAKE_CURRENT_BINARY_DIR}/ripsoffreader alphac add_test(ripsoffreader_doc_12_3 ${CMAKE_CURRENT_BINARY_DIR}/ripsoffreader alphacomplexdoc.off 12.0 3 ${CMAKE_CURRENT_BINARY_DIR}/ripsoffreader_result_12_3.txt) file(COPY "${CMAKE_SOURCE_DIR}/data/distance_matrix/full_square_distance_matrix.csv" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) -add_test(ripscsvdistancereader_doc_1_1 ${CMAKE_CURRENT_BINARY_DIR}/ripscsvdistancereader full_square_distance_matrix.csv 1.0 1 ${CMAKE_CURRENT_BINARY_DIR}/ripscsvreader_result_1_1.txt) -add_test(ripscsvdistancereader_doc_1_3 ${CMAKE_CURRENT_BINARY_DIR}/ripscsvdistancereader full_square_distance_matrix.csv 1.0 3 ${CMAKE_CURRENT_BINARY_DIR}/ripscsvreader_result_1_3.txt) +add_test(ripscsvdistancereader_doc_12_1 ${CMAKE_CURRENT_BINARY_DIR}/ripscsvdistancereader full_square_distance_matrix.csv 12.0 1 ${CMAKE_CURRENT_BINARY_DIR}/ripscsvreader_result_12_1.txt) +add_test(ripscsvdistancereader_doc_12_3 ${CMAKE_CURRENT_BINARY_DIR}/ripscsvdistancereader full_square_distance_matrix.csv 12.0 3 ${CMAKE_CURRENT_BINARY_DIR}/ripscsvreader_result_12_3.txt) if (DIFF_PATH) # Do not forget to copy test results files in current binary dir - file(COPY "one_skeleton_rips_points_for_doc.txt" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) - file(COPY "full_skeleton_rips_points_for_doc.txt" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) - file(COPY "one_skeleton_rips_distance_for_doc.txt" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) - file(COPY "full_skeleton_rips_distance_for_doc.txt" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) - - add_test(ripsoffreader_doc_12_1_diff_files ${DIFF_PATH} ${CMAKE_CURRENT_BINARY_DIR}/ripsoffreader_result_12_1.txt ${CMAKE_CURRENT_BINARY_DIR}/one_skeleton_rips_points_for_doc.txt) - add_test(ripsoffreader_doc_12_3_diff_files ${DIFF_PATH} ${CMAKE_CURRENT_BINARY_DIR}/ripsoffreader_result_12_3.txt ${CMAKE_CURRENT_BINARY_DIR}/full_skeleton_rips_points_for_doc.txt) - add_test(ripscsvreader_doc_1_1_diff_files ${DIFF_PATH} ${CMAKE_CURRENT_BINARY_DIR}/ripscsvreader_result_1_1.txt ${CMAKE_CURRENT_BINARY_DIR}/one_skeleton_rips_distance_for_doc.txt) - add_test(ripscsvreader_doc_1_3_diff_files ${DIFF_PATH} ${CMAKE_CURRENT_BINARY_DIR}/ripscsvreader_result_1_3.txt ${CMAKE_CURRENT_BINARY_DIR}/full_skeleton_rips_distance_for_doc.txt) + file(COPY "one_skeleton_rips_for_doc.txt" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) + file(COPY "full_skeleton_rips_for_doc.txt" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) + + add_test(ripsoffreader_doc_12_1_diff_files ${DIFF_PATH} ${CMAKE_CURRENT_BINARY_DIR}/ripsoffreader_result_12_1.txt ${CMAKE_CURRENT_BINARY_DIR}/one_skeleton_rips_for_doc.txt) + add_test(ripsoffreader_doc_12_3_diff_files ${DIFF_PATH} ${CMAKE_CURRENT_BINARY_DIR}/ripsoffreader_result_12_3.txt ${CMAKE_CURRENT_BINARY_DIR}/full_skeleton_rips_for_doc.txt) + add_test(ripscsvreader_doc_12_1_diff_files ${DIFF_PATH} ${CMAKE_CURRENT_BINARY_DIR}/ripscsvreader_result_12_1.txt ${CMAKE_CURRENT_BINARY_DIR}/one_skeleton_rips_for_doc.txt) + add_test(ripscsvreader_doc_12_3_diff_files ${DIFF_PATH} ${CMAKE_CURRENT_BINARY_DIR}/ripscsvreader_result_12_3.txt ${CMAKE_CURRENT_BINARY_DIR}/full_skeleton_rips_for_doc.txt) endif() diff --git a/src/Rips_complex/example/full_skeleton_rips_distance_for_doc.txt b/src/Rips_complex/example/full_skeleton_rips_distance_for_doc.txt deleted file mode 100644 index 6744532d..00000000 --- a/src/Rips_complex/example/full_skeleton_rips_distance_for_doc.txt +++ /dev/null @@ -1,32 +0,0 @@ -Rips complex is of dimension 3 - 30 simplices - 5 vertices. -Iterator on rips complex simplices in the filtration order, with [filtration value]: - ( 0 ) -> [0] - ( 1 ) -> [0] - ( 2 ) -> [0] - ( 3 ) -> [0] - ( 4 ) -> [0] - ( 4 0 ) -> [0.11] - ( 2 1 ) -> [0.26] - ( 3 2 ) -> [0.28] - ( 4 3 ) -> [0.3] - ( 4 1 ) -> [0.39] - ( 2 0 ) -> [0.77] - ( 1 0 ) -> [0.94] - ( 2 1 0 ) -> [0.94] - ( 4 1 0 ) -> [0.94] - ( 4 2 ) -> [0.97] - ( 4 2 0 ) -> [0.97] - ( 4 2 1 ) -> [0.97] - ( 4 2 1 0 ) -> [0.97] - ( 4 3 2 ) -> [0.97] - ( 3 0 ) -> [0.99] - ( 3 1 ) -> [0.99] - ( 3 1 0 ) -> [0.99] - ( 3 2 0 ) -> [0.99] - ( 3 2 1 ) -> [0.99] - ( 3 2 1 0 ) -> [0.99] - ( 4 3 0 ) -> [0.99] - ( 4 3 1 ) -> [0.99] - ( 4 3 1 0 ) -> [0.99] - ( 4 3 2 0 ) -> [0.99] - ( 4 3 2 1 ) -> [0.99] diff --git a/src/Rips_complex/example/full_skeleton_rips_for_doc.txt b/src/Rips_complex/example/full_skeleton_rips_for_doc.txt new file mode 100644 index 00000000..319931e0 --- /dev/null +++ b/src/Rips_complex/example/full_skeleton_rips_for_doc.txt @@ -0,0 +1,26 @@ +Rips complex is of dimension 3 - 24 simplices - 7 vertices. +Iterator on rips complex simplices in the filtration order, with [filtration value]: + ( 0 ) -> [0] + ( 1 ) -> [0] + ( 2 ) -> [0] + ( 3 ) -> [0] + ( 4 ) -> [0] + ( 5 ) -> [0] + ( 6 ) -> [0] + ( 3 2 ) -> [5] + ( 5 4 ) -> [5.38516] + ( 2 0 ) -> [5.83095] + ( 1 0 ) -> [6.08276] + ( 3 1 ) -> [6.32456] + ( 2 1 ) -> [6.7082] + ( 2 1 0 ) -> [6.7082] + ( 3 2 1 ) -> [6.7082] + ( 6 5 ) -> [7.28011] + ( 4 2 ) -> [8.94427] + ( 3 0 ) -> [9.43398] + ( 3 1 0 ) -> [9.43398] + ( 3 2 0 ) -> [9.43398] + ( 3 2 1 0 ) -> [9.43398] + ( 6 4 ) -> [9.48683] + ( 6 5 4 ) -> [9.48683] + ( 6 3 ) -> [11] diff --git a/src/Rips_complex/example/full_skeleton_rips_points_for_doc.txt b/src/Rips_complex/example/full_skeleton_rips_points_for_doc.txt deleted file mode 100644 index 319931e0..00000000 --- a/src/Rips_complex/example/full_skeleton_rips_points_for_doc.txt +++ /dev/null @@ -1,26 +0,0 @@ -Rips complex is of dimension 3 - 24 simplices - 7 vertices. -Iterator on rips complex simplices in the filtration order, with [filtration value]: - ( 0 ) -> [0] - ( 1 ) -> [0] - ( 2 ) -> [0] - ( 3 ) -> [0] - ( 4 ) -> [0] - ( 5 ) -> [0] - ( 6 ) -> [0] - ( 3 2 ) -> [5] - ( 5 4 ) -> [5.38516] - ( 2 0 ) -> [5.83095] - ( 1 0 ) -> [6.08276] - ( 3 1 ) -> [6.32456] - ( 2 1 ) -> [6.7082] - ( 2 1 0 ) -> [6.7082] - ( 3 2 1 ) -> [6.7082] - ( 6 5 ) -> [7.28011] - ( 4 2 ) -> [8.94427] - ( 3 0 ) -> [9.43398] - ( 3 1 0 ) -> [9.43398] - ( 3 2 0 ) -> [9.43398] - ( 3 2 1 0 ) -> [9.43398] - ( 6 4 ) -> [9.48683] - ( 6 5 4 ) -> [9.48683] - ( 6 3 ) -> [11] diff --git a/src/Rips_complex/example/one_skeleton_rips_distance_for_doc.txt b/src/Rips_complex/example/one_skeleton_rips_distance_for_doc.txt deleted file mode 100644 index 9bb1a7ab..00000000 --- a/src/Rips_complex/example/one_skeleton_rips_distance_for_doc.txt +++ /dev/null @@ -1,17 +0,0 @@ -Rips complex is of dimension 1 - 15 simplices - 5 vertices. -Iterator on rips complex simplices in the filtration order, with [filtration value]: - ( 0 ) -> [0] - ( 1 ) -> [0] - ( 2 ) -> [0] - ( 3 ) -> [0] - ( 4 ) -> [0] - ( 4 0 ) -> [0.11] - ( 2 1 ) -> [0.26] - ( 3 2 ) -> [0.28] - ( 4 3 ) -> [0.3] - ( 4 1 ) -> [0.39] - ( 2 0 ) -> [0.77] - ( 1 0 ) -> [0.94] - ( 4 2 ) -> [0.97] - ( 3 0 ) -> [0.99] - ( 3 1 ) -> [0.99] diff --git a/src/Rips_complex/example/one_skeleton_rips_for_doc.txt b/src/Rips_complex/example/one_skeleton_rips_for_doc.txt new file mode 100644 index 00000000..b0e25cc5 --- /dev/null +++ b/src/Rips_complex/example/one_skeleton_rips_for_doc.txt @@ -0,0 +1,20 @@ +Rips complex is of dimension 1 - 18 simplices - 7 vertices. +Iterator on rips complex simplices in the filtration order, with [filtration value]: + ( 0 ) -> [0] + ( 1 ) -> [0] + ( 2 ) -> [0] + ( 3 ) -> [0] + ( 4 ) -> [0] + ( 5 ) -> [0] + ( 6 ) -> [0] + ( 3 2 ) -> [5] + ( 5 4 ) -> [5.38516] + ( 2 0 ) -> [5.83095] + ( 1 0 ) -> [6.08276] + ( 3 1 ) -> [6.32456] + ( 2 1 ) -> [6.7082] + ( 6 5 ) -> [7.28011] + ( 4 2 ) -> [8.94427] + ( 3 0 ) -> [9.43398] + ( 6 4 ) -> [9.48683] + ( 6 3 ) -> [11] diff --git a/src/Rips_complex/example/one_skeleton_rips_points_for_doc.txt b/src/Rips_complex/example/one_skeleton_rips_points_for_doc.txt deleted file mode 100644 index b0e25cc5..00000000 --- a/src/Rips_complex/example/one_skeleton_rips_points_for_doc.txt +++ /dev/null @@ -1,20 +0,0 @@ -Rips complex is of dimension 1 - 18 simplices - 7 vertices. -Iterator on rips complex simplices in the filtration order, with [filtration value]: - ( 0 ) -> [0] - ( 1 ) -> [0] - ( 2 ) -> [0] - ( 3 ) -> [0] - ( 4 ) -> [0] - ( 5 ) -> [0] - ( 6 ) -> [0] - ( 3 2 ) -> [5] - ( 5 4 ) -> [5.38516] - ( 2 0 ) -> [5.83095] - ( 1 0 ) -> [6.08276] - ( 3 1 ) -> [6.32456] - ( 2 1 ) -> [6.7082] - ( 6 5 ) -> [7.28011] - ( 4 2 ) -> [8.94427] - ( 3 0 ) -> [9.43398] - ( 6 4 ) -> [9.48683] - ( 6 3 ) -> [11] diff --git a/src/common/include/gudhi/reader_utils.h b/src/common/include/gudhi/reader_utils.h index 3799e583..ddec5ba7 100644 --- a/src/common/include/gudhi/reader_utils.h +++ b/src/common/include/gudhi/reader_utils.h @@ -223,10 +223,9 @@ bool read_hasse_simplex(std::istream & in_, std::vector< Simplex_key > & boundar template< typename Filtration_value > std::vector< std::vector< Filtration_value > > read_lower_triangular_matrix_from_csv_file(const std::string& filename, const char separator=';') { - bool dbg = false; - if (dbg) { - std::cerr << "Using procedure read_lower_triangular_matrix_from_csv_file \n"; - } +#ifdef DEBUG_TRACES + std::cout << "Using procedure read_lower_triangular_matrix_from_csv_file \n"; +#endif // DEBUG_TRACES std::vector< std::vector< Filtration_value > > result; std::ifstream in; in.open(filename.c_str()); @@ -278,15 +277,15 @@ std::vector< std::vector< Filtration_value > > read_lower_triangular_matrix_from } in.close(); - if (dbg) { - std::cerr << "Here is the matrix we read : \n"; - for (size_t i = 0; i != result.size(); ++i) { - for (size_t j = 0; j != result[i].size(); ++j) { - std::cerr << result[i][j] << " "; - } - std::cerr << std::endl; +#ifdef DEBUG_TRACES + std::cerr << "Here is the matrix we read : \n"; + for (size_t i = 0; i != result.size(); ++i) { + for (size_t j = 0; j != result[i].size(); ++j) { + std::cerr << result[i][j] << " "; } + std::cerr << std::endl; } +#endif // DEBUG_TRACES return result; } // read_lower_triangular_matrix_from_csv_file diff --git a/src/common/test/test_distance_matrix_reader.cpp b/src/common/test/test_distance_matrix_reader.cpp index a4c46bb1..95a73bd9 100644 --- a/src/common/test/test_distance_matrix_reader.cpp +++ b/src/common/test/test_distance_matrix_reader.cpp @@ -77,7 +77,7 @@ BOOST_AUTO_TEST_CASE( full_square_distance_matrix ) std::cout << std::endl; } std::cout << "from_full_square size = " << from_full_square.size() << std::endl; - BOOST_CHECK(from_full_square.size() == 5); + BOOST_CHECK(from_full_square.size() == 7); for (std::size_t i = 0; i < from_full_square.size(); i++) { std::cout << "from_full_square[" << i << "] size = " << from_full_square[i].size() << std::endl; BOOST_CHECK(from_full_square[i].size() == i); -- cgit v1.2.3