summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Gudhi_stat/example/persistence_intervals.cpp2
-rw-r--r--src/Gudhi_stat/include/gudhi/persistence_representations/Persistence_intervals.h28
-rw-r--r--src/Gudhi_stat/include/gudhi/persistence_representations/Persistence_intervals_with_distances.h13
-rw-r--r--src/Gudhi_stat/test/persistence_intervals_test.cpp6
-rw-r--r--src/Gudhi_stat/utilities/persistence_intervals/compute_birth_death_range_in_persistence_diagram.cpp2
5 files changed, 15 insertions, 36 deletions
diff --git a/src/Gudhi_stat/example/persistence_intervals.cpp b/src/Gudhi_stat/example/persistence_intervals.cpp
index 60d5a811..33d45485 100644
--- a/src/Gudhi_stat/example/persistence_intervals.cpp
+++ b/src/Gudhi_stat/example/persistence_intervals.cpp
@@ -42,7 +42,7 @@ int main( int argc , char** argv )
}
Persistence_intervals p( argv[1] );
- std::pair<double,double> min_max_ = p.min_max();
+ std::pair<double,double> min_max_ = p.get_x_range();
std::cout << "Birth-death range : " << min_max_.first << " " << min_max_.second << std::endl;
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 2ff4d7f7..64d8c502 100644
--- a/src/Gudhi_stat/include/gudhi/persistence_representations/Persistence_intervals.h
+++ b/src/Gudhi_stat/include/gudhi/persistence_representations/Persistence_intervals.h
@@ -58,18 +58,20 @@ public:
* are smaller or equal the second elements of pairs.
**/
Persistence_intervals( const std::vector< std::pair< double,double > >& intervals );
-
- /**
- * The procedure returns a pair the first element of which is the leftmost end of the interval, and the second element of which is the rightmost end of the interval.
- **/
- std::pair<double,double> min_max()const;
/**
* This procedure returns x-range of a given persistence diagram.
**/
std::pair< double , double > get_x_range()const
{
- return this->min_max();
+ double min_ = std::numeric_limits<int>::max();
+ double max_ = -std::numeric_limits<int>::max();
+ for ( size_t i = 0 ; i != this->intervals.size() ; ++i )
+ {
+ if ( this->intervals[i].first < min_ )min_ = this->intervals[i].first;
+ if ( this->intervals[i].second > max_ )max_ = this->intervals[i].second;
+ }
+ return std::make_pair( min_ , max_ );
}
/**
@@ -160,7 +162,7 @@ public:
std::string nameStr = nameSS.str();
out.open( nameStr );
- std::pair<double,double> min_max_values = this->min_max();
+ std::pair<double,double> min_max_values = this->get_x_range();
if ( min_x == max_x )
{
out << "set xrange [" << min_max_values.first - 0.1*(min_max_values.second-min_max_values.first) << " : " << min_max_values.second + 0.1*(min_max_values.second-min_max_values.first) << " ]" << std::endl;
@@ -676,18 +678,6 @@ std::vector< double > Persistence_intervals::k_n_n( size_t k , size_t where_to_c
}
-std::pair<double,double> Persistence_intervals::min_max()const
-{
- double min_ = std::numeric_limits<int>::max();
- double max_ = -std::numeric_limits<int>::max();
- for ( size_t i = 0 ; i != this->intervals.size() ; ++i )
- {
- if ( this->intervals[i].first < min_ )min_ = this->intervals[i].first;
- if ( this->intervals[i].second > max_ )max_ = this->intervals[i].second;
- }
- return std::make_pair( min_ , max_ );
-}
-
double Persistence_intervals::project_to_R( int number_of_function )const
{
double result = 0;
diff --git a/src/Gudhi_stat/include/gudhi/persistence_representations/Persistence_intervals_with_distances.h b/src/Gudhi_stat/include/gudhi/persistence_representations/Persistence_intervals_with_distances.h
index 84a95e95..3c1d8a45 100644
--- a/src/Gudhi_stat/include/gudhi/persistence_representations/Persistence_intervals_with_distances.h
+++ b/src/Gudhi_stat/include/gudhi/persistence_representations/Persistence_intervals_with_distances.h
@@ -35,18 +35,7 @@ namespace Gudhi_stat
class Persistence_intervals_with_distances : public Persistence_intervals
{
public:
- /**
- * This is a constructor of a class Persistence_intervals_with_distances from a text file. Each line of the input file is supposed to contain two numbers of a type doube (or convertable to double)
- * representing the birth and the death of the persistence interval. If the pairs are not sorted so that birth <= death, then the constructor will sort then that way.
- * The second parameter of a constructor is a dimension of intervals to be read from a file. If your file contains only birt-death pairs, use the default value.
- **/
- Persistence_intervals_with_distances( const char* filename , unsigned dimension = std::numeric_limits<unsigned>::max() ):Persistence_intervals( filename , dimension ){}
-
- /**
- * This is a constructor of a class Persistence_intervals_with_distances from a vector of pairs. Each pair is assumed to represent a persistence interval. We assume that the first elemnets of pairs
- * are smaller or equal the second elements of pairs.
- **/
- Persistence_intervals_with_distances( const std::vector< std::pair< double,double > >& intervals ):Persistence_intervals( intervals ){}
+ using Persistence_intervals::Persistence_intervals;
/**
*Computations of distance from the current persistnce diagram to the persistence diagram given as a parameter of this function.
diff --git a/src/Gudhi_stat/test/persistence_intervals_test.cpp b/src/Gudhi_stat/test/persistence_intervals_test.cpp
index 6dec1bb7..4fb73da1 100644
--- a/src/Gudhi_stat/test/persistence_intervals_test.cpp
+++ b/src/Gudhi_stat/test/persistence_intervals_test.cpp
@@ -47,7 +47,7 @@ double epsilon = 0.0000005;
BOOST_AUTO_TEST_CASE(check_min_max_function)
{
Persistence_intervals p( "data/file_with_diagram" );
- std::pair<double,double> min_max_ = p.min_max();
+ std::pair<double,double> min_max_ = p.get_x_range();
//cout << min_max_.first << " " << min_max_.second << std::endl;getchar();
@@ -150,7 +150,7 @@ BOOST_AUTO_TEST_CASE(check_cumulative_histograms_of_lengths)
BOOST_AUTO_TEST_CASE(check_characteristic_function_of_diagram)
{
Persistence_intervals p( "data/file_with_diagram" );
- std::pair<double,double> min_max_ = p.min_max();
+ std::pair<double,double> min_max_ = p.get_x_range();
std::vector< double > char_funct_diag = p.characteristic_function_of_diagram( min_max_.first , min_max_.second );
std::vector< double > template_char_funct_diag;
template_char_funct_diag.push_back( 0.370665 );
@@ -183,7 +183,7 @@ BOOST_AUTO_TEST_CASE(check_characteristic_function_of_diagram)
BOOST_AUTO_TEST_CASE(check_cumulative_characteristic_function_of_diagram)
{
Persistence_intervals p( "data/file_with_diagram" );
- std::pair<double,double> min_max_ = p.min_max();
+ std::pair<double,double> min_max_ = p.get_x_range();
std::vector< double > cumul_char_funct_diag = p.cumulative_characteristic_function_of_diagram( min_max_.first , min_max_.second );
std::vector< double > template_char_funct_diag_cumul;
diff --git a/src/Gudhi_stat/utilities/persistence_intervals/compute_birth_death_range_in_persistence_diagram.cpp b/src/Gudhi_stat/utilities/persistence_intervals/compute_birth_death_range_in_persistence_diagram.cpp
index a3e19400..291bd557 100644
--- a/src/Gudhi_stat/utilities/persistence_intervals/compute_birth_death_range_in_persistence_diagram.cpp
+++ b/src/Gudhi_stat/utilities/persistence_intervals/compute_birth_death_range_in_persistence_diagram.cpp
@@ -62,7 +62,7 @@ int main( int argc , char** argv )
{
std::cout << "Creating diagram based on a file : " << filenames[file_no] << std::endl;
Persistence_intervals p( filenames[file_no] , dimension );
- std::pair<double,double> min_max_ = p.min_max();
+ std::pair<double,double> min_max_ = p.get_x_range();
if ( min_max_.first < min_ )min_ = min_max_.first;
if ( min_max_.second > max_ )max_ = min_max_.second;
}