From 6d759732282c4b79a4c93a0dbceb4667af2c8940 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Mon, 5 Feb 2018 08:45:01 +0000 Subject: clang format files git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/rips_complex_from_correlation_matrix@3216 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 09a40b92cc8e0cc1a08f962de14daed975338d1c --- .../rips_correlation_matrix_persistence.cpp | 83 ++++++++++------------ 1 file changed, 38 insertions(+), 45 deletions(-) (limited to 'src/Rips_complex/utilities') diff --git a/src/Rips_complex/utilities/rips_correlation_matrix_persistence.cpp b/src/Rips_complex/utilities/rips_correlation_matrix_persistence.cpp index 676ef793..3fe0edb0 100644 --- a/src/Rips_complex/utilities/rips_correlation_matrix_persistence.cpp +++ b/src/Rips_complex/utilities/rips_correlation_matrix_persistence.cpp @@ -39,7 +39,7 @@ 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 Correlation_matrix = std::vector>; -using intervals_common = Gudhi::Persistence_interval_common< double , int >; +using intervals_common = Gudhi::Persistence_interval_common; void program_options(int argc, char* argv[], std::string& csv_matrix_file, std::string& filediag, Filtration_value& correlation_min, int& dim_max, int& p, Filtration_value& min_persistence); @@ -69,16 +69,14 @@ int main(int argc, char* argv[]) { } Filtration_value threshold; - //If the correlation_min, being minimal corelation is in the range [0,1], - //change it to 1-correlation_min - if ( ( correlation_min>=0 ) && ( correlation_min<=1 ) ) - { - threshold = 1-correlation_min; - } - else - { - std::cout << "Wrong value of the treshold corelation (should be between 0 and 1). The program will now terminate.\n"; - return 1; + // If the correlation_min, being minimal corelation is in the range [0,1], + // change it to 1-correlation_min + if ((correlation_min >= 0) && (correlation_min <= 1)) { + threshold = 1 - correlation_min; + } else { + std::cout + << "Wrong value of the treshold corelation (should be between 0 and 1). The program will now terminate.\n"; + return 1; } Rips_complex rips_complex_from_file(correlations, threshold); @@ -97,34 +95,30 @@ int main(int argc, char* argv[]) { Persistent_cohomology pcoh(simplex_tree); // initializes the coefficient field for homology pcoh.init_coefficients(p); - //compute persistence + // compute persistence pcoh.compute_persistent_cohomology(min_persistence); - - //invert the persistence diagram + // invert the persistence diagram auto pairs = pcoh.get_persistent_pairs(); - std::vector< intervals_common > processed_persistence_intervals; - processed_persistence_intervals.reserve( pairs.size() ); - for (auto pair :pairs ) - { - double birth = 1-simplex_tree.filtration( get<0>(pair) ); - double death = 1-simplex_tree.filtration( get<1>(pair) ); - unsigned dimension = (unsigned)simplex_tree.dimension( get<0>(pair) ); - int field = get<2>(pair); - processed_persistence_intervals.push_back( - intervals_common(birth, death,dimension,field) - ); + std::vector processed_persistence_intervals; + processed_persistence_intervals.reserve(pairs.size()); + for (auto pair : pairs) { + double birth = 1 - simplex_tree.filtration(get<0>(pair)); + double death = 1 - simplex_tree.filtration(get<1>(pair)); + unsigned dimension = (unsigned)simplex_tree.dimension(get<0>(pair)); + int field = get<2>(pair); + processed_persistence_intervals.push_back(intervals_common(birth, death, dimension, field)); } - //sort the processed intervals: - std::sort( processed_persistence_intervals.begin() , processed_persistence_intervals.end() ); + // sort the processed intervals: + std::sort(processed_persistence_intervals.begin(), processed_persistence_intervals.end()); - //and write them to a file + // and write them to a file if (filediag.empty()) { write_persistence_intervals_to_stream(processed_persistence_intervals); } else { std::ofstream out(filediag); - write_persistence_intervals_to_stream(processed_persistence_intervals,out); + write_persistence_intervals_to_stream(processed_persistence_intervals, out); out.close(); } return 0; @@ -134,23 +128,22 @@ void program_options(int argc, char* argv[], std::string& csv_matrix_file, std:: Filtration_value& correlation_min, 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 corelation 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 corelation 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") - ("min-edge-corelation,c", - po::value(&correlation_min)->default_value(0), - "Minimal corelation 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")( + "min-edge-corelation,c", po::value(&correlation_min)->default_value(0), + "Minimal corelation 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); -- cgit v1.2.3