diff options
author | pdlotko <pdlotko@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2017-04-06 15:36:53 +0000 |
---|---|---|
committer | pdlotko <pdlotko@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2017-04-06 15:36:53 +0000 |
commit | 8252d6eb78c9fe355a2167ad68e9106fcaa8fcdb (patch) | |
tree | f925ae2c44c5c84d7f3d1d9ba6821cc5953d7e36 /src/Gudhi_stat/include/gudhi/read_persitence_from_file.h | |
parent | 39cd1e8ab33bd069236649edc10459925cea83f4 (diff) |
Answering MG3 comments.
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/gudhi_stat@2313 636b058d-ea47-450e-bf9e-a15bfbe3eedb
Former-commit-id: 3bae7a55d05831af55a5b1c3e0d2695383af325f
Diffstat (limited to 'src/Gudhi_stat/include/gudhi/read_persitence_from_file.h')
-rw-r--r-- | src/Gudhi_stat/include/gudhi/read_persitence_from_file.h | 41 |
1 files changed, 29 insertions, 12 deletions
diff --git a/src/Gudhi_stat/include/gudhi/read_persitence_from_file.h b/src/Gudhi_stat/include/gudhi/read_persitence_from_file.h index c2fb7875..38cdecd5 100644 --- a/src/Gudhi_stat/include/gudhi/read_persitence_from_file.h +++ b/src/Gudhi_stat/include/gudhi/read_persitence_from_file.h @@ -42,7 +42,7 @@ namespace Gudhi_stat * This procedure reads birth-death dagta from a file. We assume that in the file, there may be one type of string 'inf' or 'Inf'. If the second parameter of the program is set to -1, * then those vales are ignored. If the second parameter of this program is set to a positive value, then the infinite intervals will be substituted by that number. **/ -std::vector< std::pair< double,double > > read_file_that_may_contain_inf_string( char* filename , double what_to_substitute_for_infinite_bar = -1 ) +std::vector< std::pair< double,double > > read_persistence_file_that_may_contain_inf_string( char* filename , double what_to_substitute_for_infinite_bar = -1 ) { bool dbg = true; @@ -88,9 +88,7 @@ std::vector< std::pair< double,double > > read_file_that_may_contain_inf_string( } if ( beginn > endd ) { - double b = beginn; - beginn = endd; - endd = b; + std::swap(beginn,endd); } if ( dbg ) { @@ -150,7 +148,7 @@ std::vector< std::string > readFileNames( const char* filenameWithFilenames ) * like 'inf' are not allowed. * If begin of the interval is greater than the end of the interval, those two numbers are swapped. **/ -std::vector< std::pair< double , double > > read_standard_file( const char* filename ) +std::vector< std::pair< double , double > > read_standard_persistence_file( const char* filename ) { bool dbg = false; @@ -177,9 +175,7 @@ std::vector< std::pair< double , double > > read_standard_file( const char* file if ( beginn == endd )continue; if ( beginn > endd ) { - double b = beginn; - beginn = endd; - endd = b; + std::swap(beginn,endd); } barcode.push_back( std::make_pair( beginn , endd ) ); if (dbg) @@ -205,7 +201,7 @@ std::vector< std::pair< double , double > > read_standard_file( const char* file * Note that this procedure reads persistence in a single dimension. The dimension of intervals that * are to be read are determined by the second parameter of the function. **/ -std::vector< std::pair< double , double > > read_gudhi_file( const char* filename , size_t dimension = 0 ) +std::vector< std::pair< double , double > > read_gudhi_persistence_file_in_one_dimension( const char* filename , size_t dimension = 0 , double what_to_substitute_for_infinite_bar = -1) { bool dbg = false; std::ifstream in; @@ -225,6 +221,29 @@ std::vector< std::pair< double , double > > read_gudhi_file( const char* filenam { std::cerr << "This line: " << line << " contains infinite interval. We will skip it. \n"; } + if ( what_to_substitute_for_infinite_bar != -1 ) + { + double beginn, field, dim; + std::stringstream lineSS(line); + lineSS >> field; + lineSS >> dim; + lineSS >> beginn; + if ( dim == dimension ) + { + if ( beginn > what_to_substitute_for_infinite_bar ) + { + barcode.push_back( std::make_pair( what_to_substitute_for_infinite_bar , beginn ) ); + } + else + { + barcode.push_back( std::make_pair( beginn , what_to_substitute_for_infinite_bar ) ); + } + if (dbg) + { + std::cerr << beginn << " , " << what_to_substitute_for_infinite_bar << std::endl; + } + } + } continue; } std::stringstream lineSS(line); @@ -235,9 +254,7 @@ std::vector< std::pair< double , double > > read_gudhi_file( const char* filenam lineSS >> endd; if ( beginn > endd ) { - double b = beginn; - beginn = endd; - endd = b; + std::swap(beginn,endd); } if ( dim == dimension ) { |