summaryrefslogtreecommitdiff
path: root/src/Gudhi_stat/include
diff options
context:
space:
mode:
authorpdlotko <pdlotko@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2017-04-12 13:07:58 +0000
committerpdlotko <pdlotko@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2017-04-12 13:07:58 +0000
commit8f4c961a93fe928d06c7776a9e8f5ecd00fab9ca (patch)
tree0222aa7a5db950b15e7b1adf9f75cec2204c55fa /src/Gudhi_stat/include
parente729d07cc53e4b6a189ebbfbfe4eb5db5449fbe0 (diff)
a few more correction. First of all, bottleneck distance is added (although there is something strange in the results, FG has been pinged about this). Second of all, all the programs in utylites should now read general files (and dimension of persistence to be read is one of the parameteds of files). This still need to be tested and will be tested soon.
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/gudhi_stat@2339 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: e60d14f07db223646597230d7f0bd78dd090bc0b
Diffstat (limited to 'src/Gudhi_stat/include')
-rw-r--r--src/Gudhi_stat/include/gudhi/permutation_test.h2
-rw-r--r--src/Gudhi_stat/include/gudhi/persistence_representations/PSSK.h12
-rw-r--r--src/Gudhi_stat/include/gudhi/persistence_representations/Persistence_heat_maps.h16
-rw-r--r--src/Gudhi_stat/include/gudhi/persistence_representations/Persistence_intervals.h39
-rw-r--r--src/Gudhi_stat/include/gudhi/persistence_representations/Persistence_intervals_with_distances.h76
-rw-r--r--src/Gudhi_stat/include/gudhi/persistence_representations/Persistence_landscape.h21
-rw-r--r--src/Gudhi_stat/include/gudhi/persistence_representations/Persistence_landscape_on_grid.h82
-rw-r--r--src/Gudhi_stat/include/gudhi/persistence_representations/persistence_vectors.h20
-rw-r--r--src/Gudhi_stat/include/gudhi/topological_process.h5
9 files changed, 190 insertions, 83 deletions
diff --git a/src/Gudhi_stat/include/gudhi/permutation_test.h b/src/Gudhi_stat/include/gudhi/permutation_test.h
index b4c1a8ba..69b0790b 100644
--- a/src/Gudhi_stat/include/gudhi/permutation_test.h
+++ b/src/Gudhi_stat/include/gudhi/permutation_test.h
@@ -37,6 +37,8 @@ namespace Gudhi
namespace Gudhi_stat
{
+//TODO change the reading procedures so that they accept the dimension value (by default std::nnumeric_limits<unsigned>::max().
+
template <typename Representation_of_persistence>
double permutation_test( const std::vector<Representation_of_persistence*>& data_1 , const std::vector<Representation_of_persistence*>& data_2 , size_t number_of_permutations , double exponent = 1 )
{
diff --git a/src/Gudhi_stat/include/gudhi/persistence_representations/PSSK.h b/src/Gudhi_stat/include/gudhi/persistence_representations/PSSK.h
index 7a299a86..d2fd3a86 100644
--- a/src/Gudhi_stat/include/gudhi/persistence_representations/PSSK.h
+++ b/src/Gudhi_stat/include/gudhi/persistence_representations/PSSK.h
@@ -53,10 +53,18 @@ public:
}
- PSSK( const char* filename , std::vector< std::vector<double> > filter = create_Gaussian_filter(5,1) , size_t number_of_pixels = 1000 , double min_ = -1 , double max_ = -1 ):
+ PSSK( const char* filename , std::vector< std::vector<double> > filter = create_Gaussian_filter(5,1) , size_t number_of_pixels = 1000 , double min_ = -1 , double max_ = -1 , unsigned dimension = std::numeric_limits<unsigned>::max() ):
Persistence_heat_maps()
{
- std::vector< std::pair< double , double > > intervals_ = read_standard_persistence_file( filename );
+ std::vector< std::pair< double , double > > intervals_;
+ if ( dimension == std::numeric_limits<unsigned>::max() )
+ {
+ intervals_ = read_persistence_intervals_in_one_dimension_from_file( filename );
+ }
+ else
+ {
+ intervals_ = read_persistence_intervals_in_one_dimension_from_file( filename , dimension );
+ }
this->construct( intervals_ , filter , number_of_pixels , min_ , max_ );
}
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 f82f3100..3cfd52f5 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
@@ -230,14 +230,14 @@ public:
**/
/**
* Construction that takes at the input the following parameters:
- * (1) A a name of a file with persistence intervals. The file shold be readable by the function read_standard_persistence_file. All other parameters are optional. They are:
+ * (1) A a name of a file with persistence intervals. The file shold be readable by the function read_persistence_intervals_in_one_dimension_from_file. All other parameters are optional. They are:
* (2) a Gausian filter generated by create_Gaussian_filter filter (the default value of this vaiable is a Gaussian filter of a radius 5),
* (3) a boolean value which determines if the area of image below diagonal should, or should not be erased (it will be erased by default).
* (4) a number of pixels in each direction (set to 1000 by default).
* (5) a min x and y value of points that are to be taken into account. By default it is set to std::numeric_limits<double>::max(), in which case the program compute the values based on the data,
* (6) a max x and y value of points that are to be taken into account. By default it is set to std::numeric_limits<double>::max(), in which case the program compute the values based on the data.
**/
- Persistence_heat_maps( const char* filename , std::vector< std::vector<double> > filter = create_Gaussian_filter(5,1), bool erase_below_diagonal = false , size_t number_of_pixels = 1000 , double min_ = std::numeric_limits<double>::max() , double max_ = std::numeric_limits<double>::max() );
+ Persistence_heat_maps( const char* filename , std::vector< std::vector<double> > filter = create_Gaussian_filter(5,1), bool erase_below_diagonal = false , size_t number_of_pixels = 1000 , double min_ = std::numeric_limits<double>::max() , double max_ = std::numeric_limits<double>::max() , unsigned dimension = std::numeric_limits<unsigned>::max() );
/**
@@ -695,9 +695,17 @@ Persistence_heat_maps<Scalling_of_kernels>::Persistence_heat_maps( const std::ve
template <typename Scalling_of_kernels>
Persistence_heat_maps<Scalling_of_kernels>::Persistence_heat_maps( const char* filename ,
std::vector< std::vector<double> > filter,
- bool erase_below_diagonal , size_t number_of_pixels , double min_ , double max_ )
+ bool erase_below_diagonal , size_t number_of_pixels , double min_ , double max_ , unsigned dimension )
{
- std::vector< std::pair< double , double > > intervals_ = read_standard_persistence_file( filename );
+ std::vector< std::pair< double , double > > intervals_;
+ if ( dimension == std::numeric_limits<unsigned>::max() )
+ {
+ intervals_ = read_persistence_intervals_in_one_dimension_from_file( filename );
+ }
+ else
+ {
+ intervals_ = read_persistence_intervals_in_one_dimension_from_file( filename , dimension );
+ }
this->construct( intervals_ , filter, erase_below_diagonal , number_of_pixels , min_ , max_ );
this->set_up_parameters_for_basic_classes();
}
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 2c3e4803..2ff4d7f7 100644
--- a/src/Gudhi_stat/include/gudhi/persistence_representations/Persistence_intervals.h
+++ b/src/Gudhi_stat/include/gudhi/persistence_representations/Persistence_intervals.h
@@ -25,8 +25,6 @@
//gudhi include
#include <gudhi/read_persistence_from_file.h>
-//Bottleneck distance:
-//#include <gudhi/Bottleneck.h>
//standard include
#include <limits>
@@ -51,8 +49,9 @@ public:
/**
* This is a constructor of a class Persistence_intervals 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( const char* filename );
+ Persistence_intervals( const char* filename , unsigned dimension = std::numeric_limits<unsigned>::max() );
/**
* This is a constructor of a class Persistence_intervals from a vector of pairs. Each pair is assumed to represent a persistence interval. We assume that the first elemnets of pairs
@@ -247,26 +246,6 @@ public:
return this->number_of_functions_for_vectorization;
}
- /**
- *Computations of distance from the current persistnce diagram to the persistence diagram given as a parameter of this function.
- *The last but one parameter, power, is here in case we would like to compute p=th Wasserstein distance. At the moment, this method only implement Bottleneck distance,
- * which is infinity Wasserstein distance. Therefore any power which is not the default std::numeric_limits< double >::max() will be ignored and an
- * exception will be thrown.
- * The last parameter, tolerance, it is an additiv error of the approimation, set by default to zero.
- **/
- double distance( const Persistence_intervals& second , double power = std::numeric_limits< double >::max() , double tolerance = 0) const
- {
- if ( power >= std::numeric_limits< double >::max() )
- {
- //return Gudhi::persistence_diagram::bottleneck_distance(this->intervals, second.intervals, tolerance);
- return 1;
- }
- else
- {
- std::cerr << "At the moment Gudhi do not support Wasserstein distances. We only support Bottleneck distance." << std::endl;
- throw "At the moment Gudhi do not support Wasserstein distances. We only support Bottleneck distance.";
- }
- }
//end of implementation of functions needed for concepts.
//end of implementation of functions needed for concepts.
@@ -303,7 +282,7 @@ protected:
};
-Persistence_intervals::Persistence_intervals( const char* filename )
+Persistence_intervals::Persistence_intervals( const char* filename , unsigned dimension )
{
//bool dbg = false;
//ifstream in;
@@ -336,10 +315,14 @@ Persistence_intervals::Persistence_intervals( const char* filename )
// }
//}
//in.close();
- //standard file with barcode
- this->intervals = read_standard_persistence_file( filename );
- //gudhi file with barcode
- //this->intervals = read_gudhi_persistence_file_in_one_dimension( filename , dimension );
+ if ( dimension == std::numeric_limits<unsigned>::max() )
+ {
+ this->intervals = read_persistence_intervals_in_one_dimension_from_file( filename );
+ }
+ else
+ {
+ this->intervals = read_persistence_intervals_in_one_dimension_from_file( filename , dimension );
+ }
this->set_up_numbers_of_functions_for_vectorization_and_projections_to_reals();
}//Persistence_intervals
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
new file mode 100644
index 00000000..84a95e95
--- /dev/null
+++ b/src/Gudhi_stat/include/gudhi/persistence_representations/Persistence_intervals_with_distances.h
@@ -0,0 +1,76 @@
+/* This file is part of the Gudhi hiLibrary. The Gudhi library
+ * (Geometric Understanding in Higher Dimensions) is a generic C++
+ * library for computational topology.
+ *
+ * Author(s): Pawel Dlotko
+ *
+ * Copyright (C) 2015 INRIA (France)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef Persistence_intervals_WITH_DISTANCES_H_
+#define Persistence_intervals_WITH_DISTANCES_H_
+
+
+#include <gudhi/persistence_representations/Persistence_intervals.h>
+#include <gudhi/Bottleneck.h>
+
+namespace Gudhi
+{
+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 ){}
+
+ /**
+ *Computations of distance from the current persistnce diagram to the persistence diagram given as a parameter of this function.
+ *The last but one parameter, power, is here in case we would like to compute p=th Wasserstein distance. At the moment, this method only implement Bottleneck distance,
+ * which is infinity Wasserstein distance. Therefore any power which is not the default std::numeric_limits< double >::max() will be ignored and an
+ * exception will be thrown.
+ * The last parameter, tolerance, it is an additiv error of the approimation, set by default to zero.
+ **/
+ double distance( const Persistence_intervals_with_distances& second , double power = std::numeric_limits< double >::max() , double tolerance = 0) const
+ {
+ if ( power >= std::numeric_limits< double >::max() )
+ {
+ return Gudhi::persistence_diagram::bottleneck_distance(this->intervals, second.intervals, tolerance);
+ }
+ else
+ {
+ std::cerr << "At the moment Gudhi do not support Wasserstein distances. We only support Bottleneck distance." << std::endl;
+ throw "At the moment Gudhi do not support Wasserstein distances. We only support Bottleneck distance.";
+ }
+ }
+};
+
+
+}//namespace gudhi stat
+}//namespace gudhi
+
+#endif
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 0d8fe5fe..681f5d8d 100644
--- a/src/Gudhi_stat/include/gudhi/persistence_representations/Persistence_landscape.h
+++ b/src/Gudhi_stat/include/gudhi/persistence_representations/Persistence_landscape.h
@@ -80,7 +80,7 @@ public:
* Constructor that reads persistence intervals from file and creates persistence landscape. The format of the input file is the following: in each line we put birth-death pair. Last line is assumed
* to be empty. Even if the points within a line are not ordered, they will be ordered while the input is read.
**/
- Persistence_landscape(const char* filename , size_t dimension = 0);
+ Persistence_landscape(const char* filename , size_t dimension = std::numeric_limits<unsigned>::max() );
@@ -548,13 +548,18 @@ Persistence_landscape::Persistence_landscape(const char* filename , size_t dimen
if ( dbg )
{
std::cerr << "Using constructor : Persistence_landscape(char* filename)" << std::endl;
- }
- //standard file with barcode
- //std::vector< std::pair< double , double > > barcode = read_standard_persistence_file( filename );
- //gudhi file with barcode
- std::vector< std::pair< double , double > > barcode = read_gudhi_persistence_file_in_one_dimension( filename , dimension );
- this->construct_persistence_landscape_from_barcode( barcode );
- this->set_up_numbers_of_functions_for_vectorization_and_projections_to_reals();
+ }
+ std::vector< std::pair< double , double > > barcode;
+ if ( dimension == std::numeric_limits<unsigned>::max() )
+ {
+ barcode = read_persistence_intervals_in_one_dimension_from_file( filename );
+ }
+ else
+ {
+ barcode = read_persistence_intervals_in_one_dimension_from_file( filename , dimension );
+ }
+ this->construct_persistence_landscape_from_barcode( barcode );
+ this->set_up_numbers_of_functions_for_vectorization_and_projections_to_reals();
}
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 02a80435..1f4cb3ff 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
@@ -33,6 +33,7 @@
#include <algorithm>
#include <unistd.h>
#include <cmath>
+#include <limits>
//gudhi include
@@ -84,14 +85,14 @@ public:
* to be empty. Even if the points within a line are not ordered, they will be ordered while the input is read. The additional parameters of this procedure are: ranges of grid, resoltion of a grid
* number of landscape functions to be created and the dimension of intervals that are need to be read from a file (in case of Gudhi format files).
**/
- Persistence_landscape_on_grid(const char* filename , double grid_min_, double grid_max_ , size_t number_of_points_ , unsigned number_of_levels_of_landscape , size_t dimension_ = 0 );
+ Persistence_landscape_on_grid(const char* filename , double grid_min_, double grid_max_ , size_t number_of_points_ , unsigned number_of_levels_of_landscape , unsigned short dimension_ = std::numeric_limits<unsigned short>::max() );
/**
* Constructor that reads persistence intervals from file and creates persistence landscape. The format of the input file is the following: in each line we put birth-death pair. Last line is assumed
* to be empty. Even if the points within a line are not ordered, they will be ordered while the input is read. The additional parameters of this procedure are: ranges of grid, resoltion of a grid
* and the dimension of intervals that are need to be read from a file (in case of Gudhi format files).
**/
- Persistence_landscape_on_grid(const char* filename , double grid_min_, double grid_max_ , size_t number_of_points_ , size_t dimension_ = 0 );
+ Persistence_landscape_on_grid(const char* filename , double grid_min_, double grid_max_ , size_t number_of_points_ , unsigned short dimension_ = std::numeric_limits<unsigned short>::max() );
/**
@@ -99,14 +100,15 @@ public:
* to be empty. Even if the points within a line are not ordered, they will be ordered while the input is read. The additional parameter is the resoution of a grid and the number of landscape
* functions to be created. The remaning parameters are calculated based on data.
**/
- Persistence_landscape_on_grid(const char* filename , size_t number_of_points , unsigned number_of_levels_of_landscape );
+ Persistence_landscape_on_grid(const char* filename , size_t number_of_points , unsigned number_of_levels_of_landscape , unsigned short dimension = std::numeric_limits<unsigned short>::max() );
/**
* Constructor that reads persistence intervals from file and creates persistence landscape. The format of the input file is the following: in each line we put birth-death pair. Last line is assumed
- * to be empty. Even if the points within a line are not ordered, they will be ordered while the input is read. The additional parameter is the resoution of a grid. The remaning paraameters are
- * calculated based on data.
+ * to be empty. Even if the points within a line are not ordered, they will be ordered while the input is read. The additional parameter is the resoution of a grid. The last parameter is the dimension
+ * of a persistence to read from the file. If your file contains only persistence pair in a single dimension, please set it up to std::numeric_limits<unsigned>::max().
+ * The remaning parameters are calculated based on data.
**/
- Persistence_landscape_on_grid(const char* filename , size_t number_of_points );
+ Persistence_landscape_on_grid(const char* filename , size_t number_of_points , unsigned short dimension = std::numeric_limits<unsigned short>::max() );
/**
@@ -1256,33 +1258,45 @@ Persistence_landscape_on_grid::Persistence_landscape_on_grid( const std::vector<
}
-Persistence_landscape_on_grid::Persistence_landscape_on_grid(const char* filename , double grid_min_, double grid_max_ , size_t number_of_points_ , size_t dimension )
+Persistence_landscape_on_grid::Persistence_landscape_on_grid(const char* filename , double grid_min_, double grid_max_ , size_t number_of_points_ , unsigned short dimension )
{
- //standard file with barcode
- std::vector< std::pair< double , double > > p = read_standard_persistence_file( filename );
- //gudhi file with barcode
- //std::vector< std::pair< double , double > > p = read_gudhi_persistence_file_in_one_dimension( filename , dimension );
-
- this->set_up_values_of_landscapes( p , grid_min_ , grid_max_ , number_of_points_ );
+ std::vector< std::pair< double , double > > p;
+ if ( dimension == std::numeric_limits<unsigned short>::max() )
+ {
+ p = read_persistence_intervals_in_one_dimension_from_file( filename );
+ }
+ else
+ {
+ p = read_persistence_intervals_in_one_dimension_from_file( filename , dimension );
+ }
+ this->set_up_values_of_landscapes( p , grid_min_ , grid_max_ , number_of_points_ );
}
-Persistence_landscape_on_grid::Persistence_landscape_on_grid(const char* filename , double grid_min_, double grid_max_ , size_t number_of_points_, unsigned number_of_levels_of_landscape, size_t dimension )
+Persistence_landscape_on_grid::Persistence_landscape_on_grid(const char* filename , double grid_min_, double grid_max_ , size_t number_of_points_, unsigned number_of_levels_of_landscape, unsigned short dimension )
{
- //standard file with barcode
- std::vector< std::pair< double , double > > p = read_standard_persistence_file( filename );
- //gudhi file with barcode
- //std::vector< std::pair< double , double > > p = read_gudhi_persistence_file_in_one_dimension( filename , dimension );
-
- this->set_up_values_of_landscapes( p , grid_min_ , grid_max_ , number_of_points_ , number_of_levels_of_landscape );
+ std::vector< std::pair< double , double > > p;
+ if ( dimension == std::numeric_limits<unsigned short>::max() )
+ {
+ p = read_persistence_intervals_in_one_dimension_from_file( filename );
+ }
+ else
+ {
+ p = read_persistence_intervals_in_one_dimension_from_file( filename , dimension );
+ }
+ this->set_up_values_of_landscapes( p , grid_min_ , grid_max_ , number_of_points_ , number_of_levels_of_landscape );
}
-Persistence_landscape_on_grid::Persistence_landscape_on_grid(const char* filename , size_t number_of_points_ )
+Persistence_landscape_on_grid::Persistence_landscape_on_grid(const char* filename , size_t number_of_points_ , unsigned short dimension )
{
- //standard file with barcode
- std::vector< std::pair< double , double > > p = read_standard_persistence_file( filename );
- //gudhi file with barcode
- //std::vector< std::pair< double , double > > p = read_gudhi_persistence_file_in_one_dimension( filename , dimension );
-
+ std::vector< std::pair< double , double > > p;
+ if ( dimension == std::numeric_limits<unsigned short>::max() )
+ {
+ p = read_persistence_intervals_in_one_dimension_from_file( filename );
+ }
+ else
+ {
+ p = read_persistence_intervals_in_one_dimension_from_file( filename , dimension );
+ }
double grid_min_ = std::numeric_limits<double>::max();
double grid_max_ = -std::numeric_limits<double>::max();
for ( size_t i = 0 ; i != p.size() ; ++i )
@@ -1293,13 +1307,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_ );
}
-Persistence_landscape_on_grid::Persistence_landscape_on_grid(const char* filename , size_t number_of_points_ , unsigned number_of_levels_of_landscape )
+Persistence_landscape_on_grid::Persistence_landscape_on_grid(const char* filename , size_t number_of_points_ , unsigned number_of_levels_of_landscape , unsigned short dimension )
{
- //standard file with barcode
- std::vector< std::pair< double , double > > p = read_standard_persistence_file( filename );
- //gudhi file with barcode
- //std::vector< std::pair< double , double > > p = read_gudhi_persistence_file_in_one_dimension( filename , dimension );
-
+ std::vector< std::pair< double , double > > p;
+ if ( dimension == std::numeric_limits<unsigned short>::max() )
+ {
+ p = read_persistence_intervals_in_one_dimension_from_file( filename );
+ }
+ else
+ {
+ p = read_persistence_intervals_in_one_dimension_from_file( filename , dimension );
+ }
double grid_min_ = std::numeric_limits<double>::max();
double grid_max_ = -std::numeric_limits<double>::max();
for ( size_t i = 0 ; i != p.size() ; ++i )
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 b1a3e4fd..aa1f23c2 100644
--- a/src/Gudhi_stat/include/gudhi/persistence_representations/persistence_vectors.h
+++ b/src/Gudhi_stat/include/gudhi/persistence_representations/persistence_vectors.h
@@ -105,7 +105,7 @@ public:
/**
* The constructor taking as an input a file with birth-death pairs. The second parameter is the desiered length of the output vectors.
**/
- Vector_distances_in_diagram( const char* filename , size_t where_to_cut );
+ Vector_distances_in_diagram( const char* filename , size_t where_to_cut , unsigned dimension = std::numeric_limits<unsigned>::max() );
/**
@@ -432,13 +432,17 @@ Vector_distances_in_diagram<F>::Vector_distances_in_diagram( const std::vector<
}
template <typename F>
-Vector_distances_in_diagram<F>::Vector_distances_in_diagram( const char* filename , size_t where_to_cut ):where_to_cut(where_to_cut)
-{
- //standard file with barcode
- std::vector< std::pair< double , double > > intervals = read_standard_persistence_file( filename );
- //gudhi file with barcode
- //std::vector< std::pair< double , double > > intervals = read_gudhi_persistence_file( filename , dimension );
-
+Vector_distances_in_diagram<F>::Vector_distances_in_diagram( const char* filename , size_t where_to_cut , unsigned dimension ):where_to_cut(where_to_cut)
+{
+ std::vector< std::pair< double , double > > intervals;
+ if ( dimension == std::numeric_limits<unsigned>::max() )
+ {
+ intervals = read_persistence_intervals_in_one_dimension_from_file( filename );
+ }
+ else
+ {
+ intervals = read_persistence_intervals_in_one_dimension_from_file( filename , dimension );
+ }
this->intervals = intervals;
this->compute_sorted_vector_of_distances_via_heap( where_to_cut );
//this->compute_sorted_vector_of_distances_via_vector_sorting( where_to_cut );
diff --git a/src/Gudhi_stat/include/gudhi/topological_process.h b/src/Gudhi_stat/include/gudhi/topological_process.h
index 17bea5ab..03edbb85 100644
--- a/src/Gudhi_stat/include/gudhi/topological_process.h
+++ b/src/Gudhi_stat/include/gudhi/topological_process.h
@@ -39,6 +39,9 @@ namespace Gudhi
{
namespace Gudhi_stat
{
+
+
+//TODO, change reading procedures so that they also accept the value of dimension.
//over here we will need a few version of construct_representation_from_file procedure, since different representations may require different parameters. This is a procedure that in my
//oppinion cannot be standarize, since construction of representation cannot. But, the remaining part of the code in my opinion is free from any details of representation.
@@ -62,7 +65,7 @@ std::vector< std::vector< std::pair< double , double > > > read_persistence_pair
for ( size_t i = 0 ; i != files.size() ; ++i )
{
- std::vector< std::pair< double , double > > diag = read_standard_persistence_file( files[i].c_str() );
+ std::vector< std::pair< double , double > > diag = read_persistence_intervals_in_one_dimension_from_file( files[i].c_str() );
result.push_back( diag );
if ( dbg )
{