summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorpdlotko <pdlotko@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2017-03-27 20:29:21 +0000
committerpdlotko <pdlotko@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2017-03-27 20:29:21 +0000
commit09ab60e46ad251fe216c7958ac81eec34d21ed27 (patch)
treef24e5f6e92871479e5aef9f54ab174a5aa32fdee /src
parentd870859227df6ef3bc6b908eaf26fec238ba6595 (diff)
Adding answers to Marc's comments.
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/gudhi_stat@2258 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 4ad10b1ec977bb1fcfdab43c4d9ee9ed6ef120f5
Diffstat (limited to 'src')
-rw-r--r--src/Gudhi_stat/example/persistence_intervals.cpp4
-rw-r--r--src/Gudhi_stat/include/gudhi/persistence_representations/Persistence_intervals.h3
-rw-r--r--src/Gudhi_stat/include/gudhi/persistence_representations/Persistence_landscape.h36
-rw-r--r--src/Gudhi_stat/include/gudhi/read_persitence_from_file.h71
-rw-r--r--src/Gudhi_stat/test/persistence_intervals_test.cpp6
5 files changed, 60 insertions, 60 deletions
diff --git a/src/Gudhi_stat/example/persistence_intervals.cpp b/src/Gudhi_stat/example/persistence_intervals.cpp
index 04c758e6..60d5a811 100644
--- a/src/Gudhi_stat/example/persistence_intervals.cpp
+++ b/src/Gudhi_stat/example/persistence_intervals.cpp
@@ -60,7 +60,7 @@ int main( int argc , char** argv )
std::cout << "( " << ten_dominant_intervals[i].first<< "," << ten_dominant_intervals[i].second <<std::endl;
}
- std::vector< size_t > histogram = p.histograms_of_lengths( 10 );
+ std::vector< size_t > histogram = p.histogram_of_lengths( 10 );
std::cout << "Here is the histogram of barcode's length : " <<std::endl;
for ( size_t i = 0 ; i != histogram.size() ; ++i )
{
@@ -69,7 +69,7 @@ int main( int argc , char** argv )
std::cout <<std::endl;
- std::vector< size_t > cumulative_histogram = p.cumulative_histograms_of_lengths( 10 );
+ std::vector< size_t > cumulative_histogram = p.cumulative_histogram_of_lengths( 10 );
std::cout<< "Cumuative histogram : " <<std::endl;
for ( size_t i = 0 ; i != cumulative_histogram.size() ; ++i )
{
diff --git a/src/Gudhi_stat/include/gudhi/persistence_representations/Persistence_intervals.h b/src/Gudhi_stat/include/gudhi/persistence_representations/Persistence_intervals.h
index b1ac806d..829bc973 100644
--- a/src/Gudhi_stat/include/gudhi/persistence_representations/Persistence_intervals.h
+++ b/src/Gudhi_stat/include/gudhi/persistence_representations/Persistence_intervals.h
@@ -330,9 +330,8 @@ Persistence_intervals::Persistence_intervals( const char* filename )
}//Persistence_intervals
-Persistence_intervals::Persistence_intervals( const std::vector< std::pair< double , double > >& intervals_ )
+Persistence_intervals::Persistence_intervals( const std::vector< std::pair< double , double > >& intervals_ ):intervals(intervals_)
{
- this->intervals = intervals_;
this->set_up_numbers_of_functions_for_vectorization_and_projections_to_reals();
}
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 c71eb3d2..ef487cbe 100644
--- a/src/Gudhi_stat/include/gudhi/persistence_representations/Persistence_landscape.h
+++ b/src/Gudhi_stat/include/gudhi/persistence_representations/Persistence_landscape.h
@@ -57,6 +57,8 @@ namespace Gudhi_stat
* For details of algorithms, please consult ''A persistence landscapes toolbox for topological statistics'' by Peter Bubenik and Pawel Dlotko.
* Persistence landscapes allow vertorization, computations of distances, computations of projections to Real, computations of averages and scalar products. Therefore they implement suitable interfaces.
* It implements the following concepts: Vectorized_topological_data, Topological_data_with_distances, Real_valued_topological_data, Topological_data_with_averages, Topological_data_with_scalar_product
+ * Note that at the moment, due to roundoff errors during the construction of persistence landscapes, elements which are different by 0.000005 are considered the same. If the scale in your persistence diagrams
+ * is comparable to this value, please rescale them before use this code.
**/
class Persistence_landscape
{
@@ -466,23 +468,23 @@ public:
//end of implementation of functions needed for concepts.
- /**
- * This procedure returns x-range of a given level persistence landscape. If a default value is used, the x-range
- * of 0th level landscape is given (and this range contains the ranges of all other landscapes).
- **/
- std::pair< double , double > get_x_range( size_t level = 0 )const
- {
- std::pair< double , double > result;
- if ( level < this->land.size() )
- {
- result = std::make_pair( this->land[level][1].first , this->land[level][ this->land[level].size() - 2 ].first );
- }
- else
- {
- result = std::make_pair( 0,0 );
- }
- return result;
- }
+ //
+ // This procedure returns x-range of a given level persistence landscape. If a default value is used, the x-range
+ //of 0th level landscape is given (and this range contains the ranges of all other landscapes).
+ //
+ //std::pair< double , double > get_x_range( size_t level = 0 )const
+ //{
+ // std::pair< double , double > result;
+ // if ( level < this->land.size() )
+ // {
+ // result = std::make_pair( this->land[level][1].first , this->land[level][ this->land[level].size() - 2 ].first );
+ // }
+ // else
+ // {
+ // result = std::make_pair( 0,0 );
+ // }
+ // return result;
+ //}
/**
* This procedure returns y-range of a given level persistence landscape. If a default value is used, the y-range
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 e16c1f20..c2fb7875 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_names_that_may_contain_inf_string( char* filename , double what_to_substitute_for_infinite_bar = -1 )
+std::vector< std::pair< double,double > > read_file_that_may_contain_inf_string( char* filename , double what_to_substitute_for_infinite_bar = -1 )
{
bool dbg = true;
@@ -63,8 +63,7 @@ std::vector< std::pair< double,double > > read_file_names_that_may_contain_inf_s
getline(in,line);
if ( !(line.length() == 0 || line[0] == '#') )
{
- std::stringstream lineSS;
- lineSS << line;
+ std::stringstream lineSS(line);
double beginn, endd;
if ( (line.find("inf") != std::string::npos) || (line.find("Inf") != std::string::npos) )
{
@@ -171,8 +170,7 @@ std::vector< std::pair< double , double > > read_standard_file( const char* file
getline(in,line);
if ( !(line.length() == 0 || line[0] == '#') )
{
- std::stringstream lineSS;
- lineSS << line;
+ std::stringstream lineSS(line);
double beginn, endd;
lineSS >> beginn;
lineSS >> endd;
@@ -204,21 +202,23 @@ std::vector< std::pair< double , double > > read_standard_file( const char* file
* A birth and a death time of a class.
* Death time may be infitnity, in which case a string 'inf' is used.
* If begin of the interval is greater than the end of the interval, those two numbers are swapped.
+ * 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 )
{
bool dbg = false;
std::ifstream in;
- in.open( filename );
+ in.open( filename );
- std::string line;
- std::vector< std::pair<double,double> > barcode;
+ std::string line;
+ std::vector< std::pair<double,double> > barcode;
- while (!in.eof())
- {
- getline(in,line);
- if ( !(line.length() == 0 || line[0] == '#') )
- {
+ while (!in.eof())
+ {
+ getline(in,line);
+ if ( !(line.length() == 0 || line[0] == '#') )
+ {
if ( line.find("inf") != std::string::npos )
{
if ( dbg )
@@ -227,28 +227,27 @@ std::vector< std::pair< double , double > > read_gudhi_file( const char* filenam
}
continue;
}
- std::stringstream lineSS;
- lineSS << line;
- double beginn, endd, field, dim;
- lineSS >> field;
- lineSS >> dim;
- lineSS >> beginn;
- lineSS >> endd;
- if ( beginn > endd )
- {
- double b = beginn;
- beginn = endd;
- endd = b;
- }
- if ( dim == dimension )
- {
+ std::stringstream lineSS(line);
+ double beginn, endd, field, dim;
+ lineSS >> field;
+ lineSS >> dim;
+ lineSS >> beginn;
+ lineSS >> endd;
+ if ( beginn > endd )
+ {
+ double b = beginn;
+ beginn = endd;
+ endd = b;
+ }
+ if ( dim == dimension )
+ {
barcode.push_back( std::make_pair( beginn , endd ) );
if (dbg)
{
std::cerr << beginn << " , " << endd << std::endl;
}
}
- }
+ }
}
in.close();
return barcode;
@@ -263,20 +262,19 @@ std::vector< std::vector< double > > read_numbers_from_file_line_by_line( const
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::vector< std::vector< double > > result;
double number;
-
+
std::ifstream in(filename);
std::string line;
while ( in.good() )
{
std::getline(in,line);
- std::stringstream ss;
- ss << line;
-
+ std::stringstream ss(line);
+
if ( dbg )std::cerr << "\n Reading line : " << line << std::endl;
-
+
std::vector< double > this_line;
while ( ss.good() )
{
@@ -287,7 +285,7 @@ std::vector< std::vector< double > > read_numbers_from_file_line_by_line( const
if ( this_line.size() && in.good() ) result.push_back( this_line );
}
in.close();
-
+
return result;
}//read_numbers_from_file_line_by_line
@@ -298,3 +296,4 @@ std::vector< std::vector< double > > read_numbers_from_file_line_by_line( const
#endif
+
diff --git a/src/Gudhi_stat/test/persistence_intervals_test.cpp b/src/Gudhi_stat/test/persistence_intervals_test.cpp
index d46d009b..6dec1bb7 100644
--- a/src/Gudhi_stat/test/persistence_intervals_test.cpp
+++ b/src/Gudhi_stat/test/persistence_intervals_test.cpp
@@ -103,10 +103,10 @@ BOOST_AUTO_TEST_CASE(check_dominant_intervals)
}
}
-BOOST_AUTO_TEST_CASE(check_histograms_of_lengths)
+BOOST_AUTO_TEST_CASE(check_histogram_of_lengths)
{
Persistence_intervals p( "data/file_with_diagram" );
- std::vector< size_t > histogram = p.histograms_of_lengths( 10 );
+ std::vector< size_t > histogram = p.histogram_of_lengths( 10 );
std::vector< size_t > template_histogram;
template_histogram.push_back(10);
template_histogram.push_back(5);
@@ -128,7 +128,7 @@ BOOST_AUTO_TEST_CASE(check_histograms_of_lengths)
BOOST_AUTO_TEST_CASE(check_cumulative_histograms_of_lengths)
{
Persistence_intervals p( "data/file_with_diagram" );
- std::vector< size_t > cumulative_histogram = p.cumulative_histograms_of_lengths( 10 );
+ std::vector< size_t > cumulative_histogram = p.cumulative_histogram_of_lengths( 10 );
std::vector< size_t > template_cumulative_histogram;
template_cumulative_histogram.push_back(10);
template_cumulative_histogram.push_back(15);