diff options
author | pdlotko <pdlotko@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2017-04-14 07:44:21 +0000 |
---|---|---|
committer | pdlotko <pdlotko@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2017-04-14 07:44:21 +0000 |
commit | 399033b54b3f84ae1860665ca2071436ff010582 (patch) | |
tree | 24b735325f5ceb39b88dcdeb2cd7afdaf51a4c1a /src/Gudhi_stat/include | |
parent | 564deeab5f8c3b6251016e08cbecf1c47c7f5610 (diff) |
Answer to Vincent's comments.
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/gudhi_stat@2348 636b058d-ea47-450e-bf9e-a15bfbe3eedb
Former-commit-id: 14d2d7d14089c17e4e7949b1f8e46990d0b16181
Diffstat (limited to 'src/Gudhi_stat/include')
5 files changed, 44 insertions, 37 deletions
diff --git a/src/Gudhi_stat/include/gudhi/persistence_representations/Persistence_heat_maps.h b/src/Gudhi_stat/include/gudhi/persistence_representations/Persistence_heat_maps.h index 3cfd52f5..56890267 100644 --- a/src/Gudhi_stat/include/gudhi/persistence_representations/Persistence_heat_maps.h +++ b/src/Gudhi_stat/include/gudhi/persistence_representations/Persistence_heat_maps.h @@ -576,9 +576,12 @@ void Persistence_heat_maps<Scalling_of_kernels>::construct( const std::vector< s if ( dbg )std::cerr << "Entering construct procedure \n"; Scalling_of_kernels f; this->f = f; + + if ( dbg )std::cerr << "min and max passed to construct() procedure: " << min_ << " " << max_ << std::endl; if ( min_ == max_ ) { + if (dbg)std::cerr << "min and max parameters will be etermined based on intervals \n"; //in this case, we want the program to set up the min_ and max_ values by itself. min_ = std::numeric_limits<int>::max(); max_ = -std::numeric_limits<int>::max(); @@ -705,8 +708,13 @@ Persistence_heat_maps<Scalling_of_kernels>::Persistence_heat_maps( const char* f else { intervals_ = read_persistence_intervals_in_one_dimension_from_file( filename , dimension ); - } - this->construct( intervals_ , filter, erase_below_diagonal , number_of_pixels , min_ , max_ ); + } + //std::cerr << "intervals_.size() : " << intervals_.size() << std::endl; + //for ( size_t i = 0 ; i != intervals_.size() ; ++i ) + //{ + // std::cerr << intervals_[i].first << " " << intervals_[i].second << std::endl; + //} + this->construct( intervals_ , filter, erase_below_diagonal , number_of_pixels , min_ , max_ ); this->set_up_parameters_for_basic_classes(); } @@ -865,7 +873,7 @@ void Persistence_heat_maps<Scalling_of_kernels>::load_from_file( const char* fil in.open( filename ); //checking if the file exist / if it was open. - if ( !( access( filename, F_OK ) != -1 ) ) + if ( !in.good() ) { std::cerr << "The file : " << filename << " do not exist. The program will now terminate \n"; throw "The file from which you are trying to read the persistence landscape do not exist. The program will now terminate \n"; diff --git a/src/Gudhi_stat/include/gudhi/persistence_representations/Persistence_landscape.h b/src/Gudhi_stat/include/gudhi/persistence_representations/Persistence_landscape.h index 925d784f..c274a81f 100644 --- a/src/Gudhi_stat/include/gudhi/persistence_representations/Persistence_landscape.h +++ b/src/Gudhi_stat/include/gudhi/persistence_representations/Persistence_landscape.h @@ -32,7 +32,6 @@ #include <fstream> #include <sstream> #include <algorithm> -#include <unistd.h> //gudhi include @@ -1028,9 +1027,9 @@ void Persistence_landscape::load_landscape_from_file( const char* filename ) //this constructor reads persistence landscape form a file. This file have to be created by this software beforehead - std::ifstream in; - in.open( filename ); - if ( !( access( filename, F_OK ) != -1 ) ) + std::ifstream in; + in.open( filename ); + if ( !in.good() ) { std::cerr << "The file : " << filename << " do not exist. The program will now terminate \n"; throw "The file from which you are trying to read the persistence landscape do not exist. The program will now terminate \n"; diff --git a/src/Gudhi_stat/include/gudhi/persistence_representations/Persistence_landscape_on_grid.h b/src/Gudhi_stat/include/gudhi/persistence_representations/Persistence_landscape_on_grid.h index 3103172d..3d51c0a7 100644 --- a/src/Gudhi_stat/include/gudhi/persistence_representations/Persistence_landscape_on_grid.h +++ b/src/Gudhi_stat/include/gudhi/persistence_representations/Persistence_landscape_on_grid.h @@ -31,7 +31,6 @@ #include <fstream> #include <sstream> #include <algorithm> -#include <unistd.h> #include <cmath> #include <limits> @@ -1018,7 +1017,7 @@ public: - + @@ -1328,16 +1327,17 @@ Persistence_landscape_on_grid::Persistence_landscape_on_grid(const char* filenam this->set_up_values_of_landscapes( p , grid_min_ , grid_max_ , number_of_points_ , number_of_levels_of_landscape ); } + void Persistence_landscape_on_grid::load_landscape_from_file( const char* filename ) { + std::ifstream in; + in.open( filename ); //check if the file exist. - if ( !( access( filename, F_OK ) != -1 ) ) + if ( !in.good() ) { std::cerr << "The file : " << filename << " do not exist. The program will now terminate \n"; throw "The file from which you are trying to read the persistence landscape do not exist. The program will now terminate \n"; } - std::ifstream in; - in.open( filename ); size_t number_of_points_in_the_grid = 0; in >> this->grid_min >> this->grid_max >> number_of_points_in_the_grid; diff --git a/src/Gudhi_stat/include/gudhi/persistence_representations/persistence_vectors.h b/src/Gudhi_stat/include/gudhi/persistence_representations/persistence_vectors.h index aa1f23c2..d56f92c4 100644 --- a/src/Gudhi_stat/include/gudhi/persistence_representations/persistence_vectors.h +++ b/src/Gudhi_stat/include/gudhi/persistence_representations/persistence_vectors.h @@ -734,15 +734,15 @@ void Vector_distances_in_diagram<F>::write_to_file( const char* filename )const template < typename F> void Vector_distances_in_diagram<F>::load_from_file( const char* filename ) { + std::ifstream in; + in.open( filename ); //check if the file exist. - if ( !( access( filename, F_OK ) != -1 ) ) + if ( !in.good() ) { std::cerr << "The file : " << filename << " do not exist. The program will now terminate \n"; throw "The file from which you are trying to read the persistence landscape do not exist. The program will now terminate \n"; } - std::ifstream in; - in.open( filename ); - + double number; while ( true ) { diff --git a/src/Gudhi_stat/include/gudhi/read_persistence_from_file.h b/src/Gudhi_stat/include/gudhi/read_persistence_from_file.h index a340b40c..5042826c 100644 --- a/src/Gudhi_stat/include/gudhi/read_persistence_from_file.h +++ b/src/Gudhi_stat/include/gudhi/read_persistence_from_file.h @@ -29,7 +29,7 @@ #include <sstream> #include <vector> #include <algorithm> -#include <unistd.h> + namespace Gudhi @@ -47,7 +47,8 @@ std::vector< std::pair< double,double > > read_persistence_file_that_may_contain bool dbg = true; - if ( !( access( filename, F_OK ) != -1 ) ) + std::ifstream in(filename); + if ( !in.good() ) { std::cerr << "The file : " << filename << " do not exist. The program will now terminate \n"; throw "The file from which you are trying to read do not exist. The program will now terminate \n"; @@ -55,9 +56,7 @@ std::vector< std::pair< double,double > > read_persistence_file_that_may_contain std::string line; std::vector< std::pair<double,double> > barcode; - - std::ifstream in; - in.open( filename ); + while (!in.eof()) { getline(in,line); @@ -108,15 +107,14 @@ std::vector< std::string > readFileNames( const char* filenameWithFilenames ) { bool dbg = false; - if ( !( access( filenameWithFilenames, F_OK ) != -1 ) ) + std::ifstream in(filenameWithFilenames); + if ( !in.good() ) { std::cerr << "The file : " << filenameWithFilenames << " do not exist. The program will now terminate \n"; throw "The file from which you are trying to read do not exist. The program will now terminate \n"; } - std::vector< std::string > result; - std::ifstream in; - in.open( filenameWithFilenames ); + std::vector< std::string > result; std::string line; while (!in.eof()) { @@ -154,7 +152,7 @@ std::vector< std::pair< double , double > > read_standard_persistence_file( cons std::ifstream in; in.open( filename ); - if ( !( access( filename, F_OK ) != -1 ) ) + if ( !in.good() ) { std::cerr << "The file : " << filename << " do not exist. The program will now terminate \n"; throw "The file from which you are trying to read the persistence landscape do not exist. The program will now terminate \n"; @@ -204,13 +202,14 @@ std::vector< std::pair< double , double > > read_standard_persistence_file( cons 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; - if ( !( access( filename, F_OK ) != -1 ) ) + std::ifstream in; + in.open( filename ); + if ( !in.good() ) { std::cerr << "The file : " << filename << " do not exist. The program will now terminate \n"; throw "The file from which you are trying to read the persistence landscape do not exist. The program will now terminate \n"; } - std::ifstream in; - in.open( filename ); + std::string line; std::vector< std::pair<double,double> > barcode; @@ -279,7 +278,8 @@ std::vector< std::pair< double , double > > read_gudhi_persistence_file_in_one_d std::vector< std::vector< double > > read_numbers_from_file_line_by_line( const char* filename ) { bool dbg = false; - if ( !( access( filename, F_OK ) != -1 ) ) + std::ifstream in(filename); + if ( !in.good() ) { std::cerr << "The file : " << filename << " do not exist. The program will now terminate \n"; throw "The file from which you are trying to read the persistence landscape do not exist. The program will now terminate \n"; @@ -288,7 +288,7 @@ std::vector< std::vector< double > > read_numbers_from_file_line_by_line( const std::vector< std::vector< double > > result; double number; - std::ifstream in(filename); + std::string line; while ( in.good() ) { @@ -325,17 +325,17 @@ std::vector< std::vector< double > > read_numbers_from_file_line_by_line( const std::vector<std::pair<double,double>> read_persistence_intervals_in_one_dimension_from_file(std::string const& filename, int dimension=-1 , double what_to_substitute_for_infinite_bar = -1 ) { bool dbg = false; - + std::ifstream in; + in.open( filename ); //checking if the file exist: - if ( !( access( filename.c_str() , F_OK ) != -1 ) ) + if ( !in.good() ) { std::cerr << "The file : " << filename << " do not exist. The program will now terminate \n"; throw "The file from which you are trying to read the persistence landscape do not exist. The program will now terminate \n"; } - std::ifstream in; - in.open( filename ); + std::string line; std::vector< std::pair<double,double> > barcode; @@ -352,8 +352,8 @@ std::vector<std::pair<double,double>> read_persistence_intervals_in_one_dimensio { //check how many entries we have in the line. std::stringstream ss( line ); - int number; - std::vector<int> this_line; + double number; + std::vector<double> this_line; while ( ss >> number ) { this_line.push_back( number ); |