summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorpdlotko <pdlotko@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2017-04-06 15:36:53 +0000
committerpdlotko <pdlotko@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2017-04-06 15:36:53 +0000
commit8252d6eb78c9fe355a2167ad68e9106fcaa8fcdb (patch)
treef925ae2c44c5c84d7f3d1d9ba6821cc5953d7e36 /src
parent39cd1e8ab33bd069236649edc10459925cea83f4 (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')
-rw-r--r--src/Gudhi_stat/example/vector_representation.cpp6
-rw-r--r--src/Gudhi_stat/include/gudhi/bootstrap.h3
-rw-r--r--src/Gudhi_stat/include/gudhi/persistence_representations/PSSK.h2
-rw-r--r--src/Gudhi_stat/include/gudhi/persistence_representations/Persistence_heat_maps.h4
-rw-r--r--src/Gudhi_stat/include/gudhi/persistence_representations/Persistence_intervals.h25
-rw-r--r--src/Gudhi_stat/include/gudhi/persistence_representations/Persistence_landscape.h4
-rw-r--r--src/Gudhi_stat/include/gudhi/persistence_representations/Persistence_landscape_on_grid.h8
-rw-r--r--src/Gudhi_stat/include/gudhi/persistence_representations/Vector_distances_in_diagram.h14
-rw-r--r--src/Gudhi_stat/include/gudhi/persistence_representations/coo_kernel.h79
-rw-r--r--src/Gudhi_stat/include/gudhi/read_persitence_from_file.h41
-rw-r--r--src/Gudhi_stat/include/gudhi/topological_process.h2
-rw-r--r--src/Gudhi_stat/test/persistence_lanscapes_test.cpp26
-rw-r--r--src/Gudhi_stat/test/vector_representation_test.cpp36
-rw-r--r--src/Gudhi_stat/utilities/Hausdorff_subsampling.cpp29
-rw-r--r--src/Gudhi_stat/utilities/Multiplicative_bootstrap.cpp2
-rw-r--r--src/Gudhi_stat/utilities/permutation_test.cpp4
-rw-r--r--src/Gudhi_stat/utilities/persistence_intervals/plot_persistence_intervals.cpp2
-rw-r--r--src/Gudhi_stat/utilities/persistence_vectors/average_persistence_vectors.cpp6
-rw-r--r--src/Gudhi_stat/utilities/persistence_vectors/compute_distance_of_persistence_vectors.cpp4
-rw-r--r--src/Gudhi_stat/utilities/persistence_vectors/compute_scalar_product_of_persistence_vectors.cpp4
-rw-r--r--src/Gudhi_stat/utilities/persistence_vectors/create_persistence_vectors.cpp4
-rw-r--r--src/Gudhi_stat/utilities/persistence_vectors/plot_persistence_vectors.cpp2
-rw-r--r--src/common/include/gudhi/distance_functions.h7
23 files changed, 151 insertions, 163 deletions
diff --git a/src/Gudhi_stat/example/vector_representation.cpp b/src/Gudhi_stat/example/vector_representation.cpp
index 476deeba..e1225726 100644
--- a/src/Gudhi_stat/example/vector_representation.cpp
+++ b/src/Gudhi_stat/example/vector_representation.cpp
@@ -55,15 +55,15 @@ int main( int argc , char** argv )
persistence2.push_back( std::make_pair(6,10) );
//create two persistence vectors based on persistence1 and persistence2:
- Vector_distances_in_diagram<Euclidean_distance<double> > v1 = Vector_distances_in_diagram<Euclidean_distance<double> >( persistence1 , std::numeric_limits<size_t>::max() );
- Vector_distances_in_diagram<Euclidean_distance<double> > v2 = Vector_distances_in_diagram<Euclidean_distance<double> >( persistence2 , std::numeric_limits<size_t>::max() );
+ Vector_distances_in_diagram<Euclidean_distance > v1 = Vector_distances_in_diagram<Euclidean_distance >( persistence1 , std::numeric_limits<size_t>::max() );
+ Vector_distances_in_diagram<Euclidean_distance > v2 = Vector_distances_in_diagram<Euclidean_distance >( persistence2 , std::numeric_limits<size_t>::max() );
//writing to a stream:
std::cout << "v1 : " << v1 << std::endl;
std::cout << "v2 : " << v2 << std::endl;
//averages:
- Vector_distances_in_diagram<Euclidean_distance<double> > average;
+ Vector_distances_in_diagram<Euclidean_distance > average;
average.compute_average( {&v1,&v2} );
std::cout << "Average : " << average << std::endl;
diff --git a/src/Gudhi_stat/include/gudhi/bootstrap.h b/src/Gudhi_stat/include/gudhi/bootstrap.h
index f88cc8e7..d2ab35d5 100644
--- a/src/Gudhi_stat/include/gudhi/bootstrap.h
+++ b/src/Gudhi_stat/include/gudhi/bootstrap.h
@@ -137,6 +137,9 @@ double bootstrap( size_t number_of_points , CharacteristicFunction f , DistanceB
size_t position_of_quantile = floor(quantile*vector_of_distances.size());
if ( position_of_quantile ) --position_of_quantile;
+
+
+
if ( dbg )
{
std::cerr << "quantile : " << quantile << std::endl;
diff --git a/src/Gudhi_stat/include/gudhi/persistence_representations/PSSK.h b/src/Gudhi_stat/include/gudhi/persistence_representations/PSSK.h
index 22513097..7a299a86 100644
--- a/src/Gudhi_stat/include/gudhi/persistence_representations/PSSK.h
+++ b/src/Gudhi_stat/include/gudhi/persistence_representations/PSSK.h
@@ -56,7 +56,7 @@ 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 ):
Persistence_heat_maps()
{
- std::vector< std::pair< double , double > > intervals_ = read_standard_file( filename );
+ std::vector< std::pair< double , double > > intervals_ = read_standard_persistence_file( filename );
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 dd95fbec..d12f37fa 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
@@ -206,7 +206,7 @@ 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_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_standard_persistence_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).
@@ -676,7 +676,7 @@ Persistence_heat_maps<Scalling_of_kernels>::Persistence_heat_maps( const char* f
std::vector< std::vector<double> > filter,
bool erase_below_diagonal , size_t number_of_pixels , double min_ , double max_ )
{
- std::vector< std::pair< double , double > > intervals_ = read_standard_file( filename );
+ std::vector< std::pair< double , double > > intervals_ = read_standard_persistence_file( filename );
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 0ecc0b63..43135b41 100644
--- a/src/Gudhi_stat/include/gudhi/persistence_representations/Persistence_intervals.h
+++ b/src/Gudhi_stat/include/gudhi/persistence_representations/Persistence_intervals.h
@@ -25,6 +25,8 @@
//gudhi include
#include <gudhi/read_persitence_from_file.h>
+//Bottleneck distance:
+//#include <gudhi/Bottleneck.h>
//standard include
#include <limits>
@@ -247,14 +249,25 @@ public:
/**
*Computations of distance from the current persistnce diagram to the persistence diagram given as a parameter of this function.
- *The last parameter, power, is here in case we would like to compute p=th Wasserstein distance. At the moment, for the bottleneck distances, it will be ignored.
+ *The last 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.
**/
- double distance( const Persistence_intervals& second , double power = 1) const
+ double distance( const Persistence_intervals& second , double power = std::numeric_limits< double >::max() , double tolerance = 0.00000001 ) const
{
- return 1;
- //waiting for Francois Godi for the code. We will compute here the Bottleneck distnace.
+ 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.
@@ -323,9 +336,9 @@ Persistence_intervals::Persistence_intervals( const char* filename )
//}
//in.close();
//standard file with barcode
- this->intervals = read_standard_file( filename );
+ this->intervals = read_standard_persistence_file( filename );
//gudhi file with barcode
- //this->intervals = read_gudhi_file( filename , dimension );
+ //this->intervals = read_gudhi_persistence_file_in_one_dimension( 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_landscape.h b/src/Gudhi_stat/include/gudhi/persistence_representations/Persistence_landscape.h
index ef487cbe..a0f8cbd2 100644
--- a/src/Gudhi_stat/include/gudhi/persistence_representations/Persistence_landscape.h
+++ b/src/Gudhi_stat/include/gudhi/persistence_representations/Persistence_landscape.h
@@ -549,9 +549,9 @@ Persistence_landscape::Persistence_landscape(const char* filename , size_t dimen
std::cerr << "Using constructor : Persistence_landscape(char* filename)" << std::endl;
}
//standard file with barcode
- //std::vector< std::pair< double , double > > barcode = read_standard_file( filename );
+ //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_file( filename , dimension );
+ 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();
}
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 d29a51ab..07e80447 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
@@ -1115,9 +1115,9 @@ 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 )
{
//standard file with barcode
- std::vector< std::pair< double , double > > p = read_standard_file( filename );
+ 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_file( filename , dimension );
+ //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_ );
}
@@ -1125,9 +1125,9 @@ Persistence_landscape_on_grid::Persistence_landscape_on_grid(const char* filenam
Persistence_landscape_on_grid::Persistence_landscape_on_grid(const char* filename , size_t number_of_points_ )
{
//standard file with barcode
- std::vector< std::pair< double , double > > p = read_standard_file( filename );
+ 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_file( filename , dimension );
+ //std::vector< std::pair< double , double > > p = read_gudhi_persistence_file_in_one_dimension( filename , dimension );
double grid_min_ = std::numeric_limits<double>::max();
double grid_max_ = -std::numeric_limits<double>::max();
diff --git a/src/Gudhi_stat/include/gudhi/persistence_representations/Vector_distances_in_diagram.h b/src/Gudhi_stat/include/gudhi/persistence_representations/Vector_distances_in_diagram.h
index 7021e262..0e512bd3 100644
--- a/src/Gudhi_stat/include/gudhi/persistence_representations/Vector_distances_in_diagram.h
+++ b/src/Gudhi_stat/include/gudhi/persistence_representations/Vector_distances_in_diagram.h
@@ -33,6 +33,7 @@
//gudhi include
#include <gudhi/read_persitence_from_file.h>
#include <gudhi/common_gudhi_stat.h>
+#include <gudhi/distance_functions.h>
namespace Gudhi
@@ -40,7 +41,7 @@ namespace Gudhi
namespace Gudhi_stat
{
-
+/*
template <typename T>
struct Euclidean_distance
{
@@ -64,13 +65,14 @@ struct Euclidean_distance
return sqrt( result );
}
};
+* */
template <typename T>
struct Maximum_distance
{
double operator() ( const std::pair< T,T >& f , const std::pair<T,T>& s )
{
- return std::min( fabs( f.first - s.first ) , fabs( f.second - s.second ) );
+ return std::max( fabs( f.first - s.first ) , fabs( f.second - s.second ) );
}
};
@@ -78,7 +80,9 @@ struct Maximum_distance
/**
-* This is an implementation of idea presented in the paper by Steve, Matthew and Max. The parameter of the class is the class that computes distance used to construct the vectors. The typical function is
+* This is an implementation of idea presented in the paper 'Stable Topological Signatures for Points on 3D Shapes' by
+* M. Carriere, S. Y. Oudot and M. Ovsjanikov published in Computer Graphics Forum (proc. SGP 2015).
+* The parameter of the class is the class that computes distance used to construct the vectors. The typical function is
* either Eucludean of maximum (Manhattan) distance.
* This class implements the following concepts: Vectorized_topological_data, Topological_data_with_distances, Real_valued_topological_data, Topological_data_with_averages, Topological_data_with_scalar_product
*
@@ -434,9 +438,9 @@ 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_file( filename );
+ 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_file( filename , dimension );
+ //std::vector< std::pair< double , double > > intervals = read_gudhi_persistence_file( filename , dimension );
this->intervals = intervals;
this->compute_sorted_vector_of_distances_via_heap( where_to_cut );
diff --git a/src/Gudhi_stat/include/gudhi/persistence_representations/coo_kernel.h b/src/Gudhi_stat/include/gudhi/persistence_representations/coo_kernel.h
deleted file mode 100644
index 02c9527a..00000000
--- a/src/Gudhi_stat/include/gudhi/persistence_representations/coo_kernel.h
+++ /dev/null
@@ -1,79 +0,0 @@
-//this is an implementation of a kernel by Mathieu Carrière,
-//Steve Y. Oudot, and Maksim Ovsjanikov presended in Stable Topological
-//Signatures for Points on 3D Shapes. Proc. Sympos. on Geometry Processing, 2015
-
-#pragma once
-#include <cmath>
-#include <climits>
-
-#include "persistence_intervals.h"
-#include "kernel.h"
-#include "Distances_of_points_in_diagram.h"
-
-template <typename T , typename F>
-class coo_kernel : public Persistence_kernel<T>
-{
-public:
- //Distances_of_points_in_diagram( std::vector< std::pair< T , T > > intervals , F f , size_t where_to_cut );
- //Distances_of_points_in_diagram( char* filename , F f , size_t where_to_cut );
-
- coo_kernel( std::vector< Persistence_intervals<T> >& intervals , F f , size_t where_to_cut = 100 );
- coo_kernel( char* filename , F f , size_t where_to_cut = 100 );
-
- //i tutaj pojawia sie problem, bo reprezentacja jest liczona wielokrotnie, strata czasu.
- double compute_scalar_product( size_t number_of_first_barcode , size_t number_of_second_barcode );
-private:
- //in this case, we will construct the representation of diagrams in the vector space. That is why, we store here some more stuff compared to
- //the Persistence_kernel class.
- std::vector< Distances_of_points_in_diagram<T,F> > representation;
- void constuct_representation( std::vector< Persistence_intervals<T> >& intervals , F f , size_t where_to_cut);
-};
-
-template <typename T , typename F>
-coo_kernel<T,F>::coo_kernel( std::vector< Persistence_intervals<T> >& intervals , F f , size_t where_to_cut ):Persistence_kernel<T>(intervals)
-{
- this->constuct_representation(intervals, f , where_to_cut);
-}
-
-template <typename T , typename F>
-coo_kernel<T,F>::coo_kernel( char* filename , F f , size_t where_to_cut )
-{
- cerr << "Constuct representation \n";
- std::vector< Persistence_intervals<T> > intervals;
- std::vector<std::string> names = readFileNames( filename );
- for ( size_t file_no = 0 ; file_no != names.size() ; ++file_no )
- {
- cout << "Reading file : " << names[file_no] << endl;
- Persistence_intervals<T> interval( (char*)names[file_no].c_str() );
- intervals.push_back( interval );
- }
- this->constuct_representation(intervals, f , where_to_cut);
-}
-
-template <typename T , typename F>
-void coo_kernel<T,F>::constuct_representation( std::vector< Persistence_intervals<T> >& intervals , F f , size_t where_to_cut)
-{
- std::vector< Distances_of_points_in_diagram<T,F> > representation( intervals.size() );
- this->representation = representation;
- #pragma omp parallel for
- for ( size_t i = 0 ; i < intervals.size() ; ++i )
- {
- this->representation[i] = Distances_of_points_in_diagram<T,F>( intervals[i].intervals , f , where_to_cut );
-
- }
- this->number_of_intervals = intervals.size();
-}
-
-template <typename T , typename F>
-double coo_kernel<T,F>::compute_scalar_product( size_t number_of_first_barcode , size_t number_of_second_barcode )
-{
- double result = 0;
- size_t range = std::min( this->representation[number_of_first_barcode].size() , this->representation[number_of_second_barcode].size() );
- for ( size_t i = 0 ; i != range ; ++i )
- {
- result += this->representation[number_of_first_barcode].vector_in_position(i)*this->representation[number_of_second_barcode].vector_in_position(i);
- }
- return result;
-}
-
-
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 )
{
diff --git a/src/Gudhi_stat/include/gudhi/topological_process.h b/src/Gudhi_stat/include/gudhi/topological_process.h
index 4a41c0a7..17bea5ab 100644
--- a/src/Gudhi_stat/include/gudhi/topological_process.h
+++ b/src/Gudhi_stat/include/gudhi/topological_process.h
@@ -62,7 +62,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_file( files[i].c_str() );
+ std::vector< std::pair< double , double > > diag = read_standard_persistence_file( files[i].c_str() );
result.push_back( diag );
if ( dbg )
{
diff --git a/src/Gudhi_stat/test/persistence_lanscapes_test.cpp b/src/Gudhi_stat/test/persistence_lanscapes_test.cpp
index 957ddbfb..266be4de 100644
--- a/src/Gudhi_stat/test/persistence_lanscapes_test.cpp
+++ b/src/Gudhi_stat/test/persistence_lanscapes_test.cpp
@@ -43,7 +43,7 @@ double epsilon = 0.0000005;
BOOST_AUTO_TEST_CASE(check_construction_of_landscape)
{
- std::vector< std::pair< double , double > > diag = read_standard_file( "data/file_with_diagram" );
+ std::vector< std::pair< double , double > > diag = read_standard_persistence_file( "data/file_with_diagram" );
Persistence_landscape p( diag );
Persistence_landscape q;
q.load_landscape_from_file( "data/file_with_landscape_from_file_with_diagram" );
@@ -53,7 +53,7 @@ BOOST_AUTO_TEST_CASE(check_construction_of_landscape)
BOOST_AUTO_TEST_CASE(check_computations_of_integrals)
{
- std::vector< std::pair< double , double > > diag = read_standard_file( "data/file_with_diagram" );
+ std::vector< std::pair< double , double > > diag = read_standard_persistence_file( "data/file_with_diagram" );
Persistence_landscape p( diag );
double integral = p.compute_integral_of_landscape();
//cerr << integral << " " << 2.34992 << endl;
@@ -63,7 +63,7 @@ BOOST_AUTO_TEST_CASE(check_computations_of_integrals)
BOOST_AUTO_TEST_CASE(check_computations_of_integrals_for_each_level_separatelly)
{
- std::vector< std::pair< double , double > > diag = read_standard_file( "data/file_with_diagram" );
+ std::vector< std::pair< double , double > > diag = read_standard_persistence_file( "data/file_with_diagram" );
Persistence_landscape p( diag );
std::vector< double > integrals_fir_different_levels;
@@ -107,7 +107,7 @@ BOOST_AUTO_TEST_CASE(check_computations_of_integrals_for_each_level_separatelly)
BOOST_AUTO_TEST_CASE(check_computations_of_integrals_of_powers_of_landscape)
{
- std::vector< std::pair< double , double > > diag = read_standard_file( "data/file_with_diagram" );
+ std::vector< std::pair< double , double > > diag = read_standard_persistence_file( "data/file_with_diagram" );
Persistence_landscape p( diag );
std::vector<double> integrals_fir_different_powers;
@@ -126,7 +126,7 @@ BOOST_AUTO_TEST_CASE(check_computations_of_integrals_of_powers_of_landscape)
BOOST_AUTO_TEST_CASE(check_computations_of_values_on_different_points)
{
- std::vector< std::pair< double , double > > diag = read_standard_file( "data/file_with_diagram" );
+ std::vector< std::pair< double , double > > diag = read_standard_persistence_file( "data/file_with_diagram" );
Persistence_landscape p( diag );
@@ -147,7 +147,7 @@ BOOST_AUTO_TEST_CASE(check_computations_of_values_on_different_points)
BOOST_AUTO_TEST_CASE(check_computations_sum_differences_and_multiplications)
{
- std::vector< std::pair< double , double > > diag = read_standard_file( "data/file_with_diagram" );
+ std::vector< std::pair< double , double > > diag = read_standard_persistence_file( "data/file_with_diagram" );
Persistence_landscape p( diag );
Persistence_landscape second;
second.load_landscape_from_file("data/file_with_landscape_from_file_with_diagram_1" );
@@ -175,7 +175,7 @@ BOOST_AUTO_TEST_CASE(check_computations_sum_differences_and_multiplications)
BOOST_AUTO_TEST_CASE(check_computations_of_maxima_and_norms)
{
- std::vector< std::pair< double , double > > diag = read_standard_file( "data/file_with_diagram" );
+ std::vector< std::pair< double , double > > diag = read_standard_persistence_file( "data/file_with_diagram" );
Persistence_landscape p( diag );
Persistence_landscape second;
second.load_landscape_from_file("data/file_with_landscape_from_file_with_diagram_1" );
@@ -192,9 +192,9 @@ BOOST_AUTO_TEST_CASE(check_computations_of_maxima_and_norms)
BOOST_AUTO_TEST_CASE(check_computations_of_averages)
{
- std::vector< std::pair< double , double > > diag = read_standard_file( "data/file_with_diagram" );
+ std::vector< std::pair< double , double > > diag = read_standard_persistence_file( "data/file_with_diagram" );
Persistence_landscape p( diag );
- std::vector< std::pair< double , double > > diag2 = read_standard_file( "data/file_with_diagram_1" );
+ std::vector< std::pair< double , double > > diag2 = read_standard_persistence_file( "data/file_with_diagram_1" );
Persistence_landscape q( diag2 );
Persistence_landscape av;
av.compute_average( {&p,&q} );
@@ -209,9 +209,9 @@ BOOST_AUTO_TEST_CASE(check_computations_of_averages)
BOOST_AUTO_TEST_CASE(check_computations_of_distances)
{
- std::vector< std::pair< double , double > > diag = read_standard_file( "data/file_with_diagram" );
+ std::vector< std::pair< double , double > > diag = read_standard_persistence_file( "data/file_with_diagram" );
Persistence_landscape p( diag );
- std::vector< std::pair< double , double > > diag2 = read_standard_file( "data/file_with_diagram_1" );
+ std::vector< std::pair< double , double > > diag2 = read_standard_persistence_file( "data/file_with_diagram_1" );
Persistence_landscape q( diag2 );
BOOST_CHECK( fabs( p.distance( q )- 25.5824) <= 0.00005 );
BOOST_CHECK( fabs( p.distance( q , 2) - 2.12636 ) <= 0.00001 );
@@ -221,9 +221,9 @@ BOOST_AUTO_TEST_CASE(check_computations_of_distances)
BOOST_AUTO_TEST_CASE(check_computations_of_scalar_product)
{
- std::vector< std::pair< double , double > > diag = read_standard_file( "data/file_with_diagram" );
+ std::vector< std::pair< double , double > > diag = read_standard_persistence_file( "data/file_with_diagram" );
Persistence_landscape p( diag );
- std::vector< std::pair< double , double > > diag2 = read_standard_file( "data/file_with_diagram_1" );
+ std::vector< std::pair< double , double > > diag2 = read_standard_persistence_file( "data/file_with_diagram_1" );
Persistence_landscape q( diag2 );
BOOST_CHECK( fabs( p.compute_scalar_product( q ) - 0.754498 ) <= 0.00001 );
}
diff --git a/src/Gudhi_stat/test/vector_representation_test.cpp b/src/Gudhi_stat/test/vector_representation_test.cpp
index f69673dd..fd512a8c 100644
--- a/src/Gudhi_stat/test/vector_representation_test.cpp
+++ b/src/Gudhi_stat/test/vector_representation_test.cpp
@@ -50,10 +50,10 @@ BOOST_AUTO_TEST_CASE(check_read_write_to_files)
intervals.push_back( std::make_pair(4,7) );
intervals.push_back( std::make_pair(9,10) );
intervals.push_back( std::make_pair(3,11) );
- Vector_distances_in_diagram< Euclidean_distance<double> > p( intervals , -1 );
+ Vector_distances_in_diagram< Euclidean_distance > p( intervals , -1 );
p.write_to_file( "test_vector_representation_write_read" );
- Vector_distances_in_diagram< Euclidean_distance<double> > q;
+ Vector_distances_in_diagram< Euclidean_distance > q;
q.load_from_file( "test_vector_representation_write_read" );
BOOST_CHECK( p == q );
@@ -63,7 +63,7 @@ BOOST_AUTO_TEST_CASE(check_read_write_to_files)
BOOST_AUTO_TEST_CASE(check_sortev_vector_distances_template)
{
- Vector_distances_in_diagram< Euclidean_distance<double> > p( "data/file_with_diagram" , 100 );
+ Vector_distances_in_diagram< Euclidean_distance > p( "data/file_with_diagram" , 100 );
std::vector< double > sortev_vector_distances_template;
sortev_vector_distances_template.push_back( 0.609968 );
@@ -183,7 +183,7 @@ BOOST_AUTO_TEST_CASE(check_sortev_vector_distances_template)
BOOST_AUTO_TEST_CASE(check_projections_to_R)
{
- Vector_distances_in_diagram< Euclidean_distance<double> > p( "data/file_with_diagram" , 100 );
+ Vector_distances_in_diagram< Euclidean_distance > p( "data/file_with_diagram" , 100 );
std::vector< double > proj;
proj.push_back( 0 );
proj.push_back( 0.6099679993 );
@@ -299,8 +299,8 @@ BOOST_AUTO_TEST_CASE(check_projections_to_R)
BOOST_AUTO_TEST_CASE(check_distance_computations)
{
- Vector_distances_in_diagram< Euclidean_distance<double> > p( "data/file_with_diagram" , 100 );
- Vector_distances_in_diagram< Euclidean_distance<double> > p_prime( "data/file_with_diagram" , 10 );
+ Vector_distances_in_diagram< Euclidean_distance > p( "data/file_with_diagram" , 100 );
+ Vector_distances_in_diagram< Euclidean_distance > p_prime( "data/file_with_diagram" , 10 );
std::vector< std::pair<double,double> > intervals(10);
intervals[0] = std::pair<double,double>( 1,2 );
intervals[1] = std::pair<double,double>( 3,4 );
@@ -312,7 +312,7 @@ BOOST_AUTO_TEST_CASE(check_distance_computations)
intervals[7] = std::pair<double,double>( 15,16 );
intervals[8] = std::pair<double,double>( 17,18 );
intervals[9] = std::pair<double,double>( 19,20 );
- Vector_distances_in_diagram< Euclidean_distance<double> > p_bis( intervals , 10 );
+ Vector_distances_in_diagram< Euclidean_distance > p_bis( intervals , 10 );
//cerr << "p_prime.distance( (Abs_Topological_data_with_distances*)(&p_bis) , 1 ) : " << p_prime.distance( (Abs_Topological_data_with_distances*)(&p_bis) , 1 ) << endl;
BOOST_CHECK( almost_equal ( p_prime.distance( p_bis , 1 ) , 1.86428 ) );
}
@@ -321,7 +321,7 @@ BOOST_AUTO_TEST_CASE(check_distance_computations)
BOOST_AUTO_TEST_CASE(check_compute_average)
{
- Vector_distances_in_diagram< Euclidean_distance<double> > p( "data/file_with_diagram" , 100 );
+ Vector_distances_in_diagram< Euclidean_distance > p( "data/file_with_diagram" , 100 );
//compute average
std::vector< std::pair<double,double> > i1(3);
i1[0] = std::pair<double,double>( 1,2 );
@@ -333,13 +333,13 @@ BOOST_AUTO_TEST_CASE(check_compute_average)
i2[1] = std::pair<double,double>( 2,15);
i2[2] = std::pair<double,double>( 6,17 );
- Vector_distances_in_diagram< Euclidean_distance<double> > A( i1 , -1 );
- Vector_distances_in_diagram< Euclidean_distance<double> > B( i1 , -1 );
+ Vector_distances_in_diagram< Euclidean_distance > A( i1 , -1 );
+ Vector_distances_in_diagram< Euclidean_distance > B( i1 , -1 );
- Vector_distances_in_diagram< Euclidean_distance<double> > average;
+ Vector_distances_in_diagram< Euclidean_distance > average;
average.compute_average( {&A,&B} );
- Vector_distances_in_diagram< Euclidean_distance<double> > template_average;
+ Vector_distances_in_diagram< Euclidean_distance > template_average;
template_average.load_from_file( "data/average_of_persistence_vectors" );
BOOST_CHECK( template_average == average );
@@ -360,11 +360,11 @@ BOOST_AUTO_TEST_CASE(check_arythmetic_operations)
i2[1] = std::pair<double,double>( 2,15);
i2[2] = std::pair<double,double>( 6,17 );
- Vector_distances_in_diagram< Euclidean_distance<double> > A( i1 , -1 );
- Vector_distances_in_diagram< Euclidean_distance<double> > B( i1 , -1 );
+ Vector_distances_in_diagram< Euclidean_distance > A( i1 , -1 );
+ Vector_distances_in_diagram< Euclidean_distance > B( i1 , -1 );
- Vector_distances_in_diagram< Euclidean_distance<double> > sum = A+B;
- Vector_distances_in_diagram< Euclidean_distance<double> > difference = A-B;
+ Vector_distances_in_diagram< Euclidean_distance > sum = A+B;
+ Vector_distances_in_diagram< Euclidean_distance > difference = A-B;
BOOST_CHECK( almost_equal( sum.vector_in_position(0) , 7.07107) );
BOOST_CHECK( almost_equal( sum.vector_in_position(1) , 7.07107) );
@@ -380,7 +380,7 @@ BOOST_AUTO_TEST_CASE(check_arythmetic_operations)
BOOST_CHECK( almost_equal( difference.vector_in_position(4) , 0) );
BOOST_CHECK( almost_equal( difference.vector_in_position(5) , 0) );
- Vector_distances_in_diagram< Euclidean_distance<double> > prod = 2.*A;
+ Vector_distances_in_diagram< Euclidean_distance > prod = 2.*A;
BOOST_CHECK( almost_equal( prod.vector_in_position(0) , 7.07107) );
BOOST_CHECK( almost_equal( prod.vector_in_position(1) , 7.07107) );
BOOST_CHECK( almost_equal( prod.vector_in_position(2) , 5.65685) );
@@ -388,7 +388,7 @@ BOOST_AUTO_TEST_CASE(check_arythmetic_operations)
BOOST_CHECK( almost_equal( prod.vector_in_position(4) , 1.41421) );
BOOST_CHECK( almost_equal( prod.vector_in_position(5) , 1.41421) );
- Vector_distances_in_diagram< Euclidean_distance<double> > prod1 = A*2;
+ Vector_distances_in_diagram< Euclidean_distance > prod1 = A*2;
BOOST_CHECK( almost_equal( prod1.vector_in_position(0) , 7.07107) );
BOOST_CHECK( almost_equal( prod1.vector_in_position(1) , 7.07107) );
BOOST_CHECK( almost_equal( prod1.vector_in_position(2) , 5.65685) );
diff --git a/src/Gudhi_stat/utilities/Hausdorff_subsampling.cpp b/src/Gudhi_stat/utilities/Hausdorff_subsampling.cpp
index 5c3be0cc..b05a7adb 100644
--- a/src/Gudhi_stat/utilities/Hausdorff_subsampling.cpp
+++ b/src/Gudhi_stat/utilities/Hausdorff_subsampling.cpp
@@ -73,17 +73,42 @@ int main( int argc , char** argv )
points.push_back( point4 );
size_of_subsample = 2;
*/
-// std::vector< std::vector<double> > all_to_all_distance_matrix_between_points = compute_all_to_all_distance_matrix_between_points< std::vector<double> , Euclidean_distance<double> >( points );
+// std::vector< std::vector<double> > all_to_all_distance_matrix_between_points = compute_all_to_all_distance_matrix_between_points< std::vector<double> , Euclidean_distance >( points );
// Hausdorff_distance_between_subspace_and_the_whole_metric_space distance( all_to_all_distance_matrix_between_points );
std::cout << "Read : " << points.size() << " points.\n";
//comute all-to-all distance matrix:
- std::vector< std::vector<double> > all_to_all_distance_matrix_between_points = compute_all_to_all_distance_matrix_between_points< std::vector<double> , Euclidean_distance<double> >( points );
+ std::vector< std::vector<double> > all_to_all_distance_matrix_between_points = compute_all_to_all_distance_matrix_between_points< std::vector<double> , Euclidean_distance >( points );
Hausdorff_distance_between_subspace_and_the_whole_metric_space distance( all_to_all_distance_matrix_between_points );
identity< std::vector<size_t> > identity_char;
+
+ double max = -1;
+ for ( size_t i = 0 ; i != all_to_all_distance_matrix_between_points.size() ; ++i )
+ {
+ double min = 10000000;
+ for ( size_t j = 0 ; j != all_to_all_distance_matrix_between_points.size() ; ++j )
+ {
+ double distance = 0;
+ if ( i > j )
+ {
+ distance = all_to_all_distance_matrix_between_points[i][j];
+ }
+ else
+ {
+ if ( i < j )distance = all_to_all_distance_matrix_between_points[j][i];
+ }
+ if ( (distance < min)&&(distance != 0) )min = distance;
+ }
+ std::cerr << "min : " << min << std::endl;
+ //getchar();
+ if ( min > max )max = min;
+ }
+ std::cerr << "Max element in distance matrix : " << max << std::endl;
+ getchar();
+
// std::vector<size_t> characteristic_of_all_points = {0,1,2,3};
// std::vector<size_t> characteristic_of_subsampled_points = {2,3};
// std::cerr << "DISTANCE BETWEEN SAMPLE AND SUBSAMPLE: " << distance( characteristic_of_subsampled_points , characteristic_of_all_points ) << std::endl;
diff --git a/src/Gudhi_stat/utilities/Multiplicative_bootstrap.cpp b/src/Gudhi_stat/utilities/Multiplicative_bootstrap.cpp
index 9a607251..33b6c9dc 100644
--- a/src/Gudhi_stat/utilities/Multiplicative_bootstrap.cpp
+++ b/src/Gudhi_stat/utilities/Multiplicative_bootstrap.cpp
@@ -51,7 +51,7 @@ int main( int argc , char** argv )
std::vector< Persistence_landscape* > collection_of_landscapes( filenames.size() );
for ( size_t i = 0 ; i != filenames.size() ; ++i )
{
- std::vector< std::pair< double , double > > diag = read_gudhi_file( filenames[i].c_str() , 1 );//read_standard_file( filenames[i].c_str() );
+ std::vector< std::pair< double , double > > diag = read_gudhi_persistence_file_in_one_dimension( filenames[i].c_str() , 1 );//read_standard_persistence_file( filenames[i].c_str() );
collection_of_landscapes[i] = new Persistence_landscape( diag );
}
diff --git a/src/Gudhi_stat/utilities/permutation_test.cpp b/src/Gudhi_stat/utilities/permutation_test.cpp
index 94f92d29..e431026f 100644
--- a/src/Gudhi_stat/utilities/permutation_test.cpp
+++ b/src/Gudhi_stat/utilities/permutation_test.cpp
@@ -62,7 +62,7 @@ int main( int argc , char** argv )
std::vector< Persistence_landscape* > first_collection( first_group.size() );
for ( size_t i = 0 ; i != first_group.size() ; ++i )
{
- std::vector< std::pair< double , double > > diag = read_standard_file( first_group[i].c_str() );
+ std::vector< std::pair< double , double > > diag = read_standard_persistence_file( first_group[i].c_str() );
Persistence_landscape* l = new Persistence_landscape( diag );
first_collection[i] = l;
}
@@ -70,7 +70,7 @@ int main( int argc , char** argv )
std::vector< Persistence_landscape* > second_collection( second_group.size() );
for ( size_t i = 0 ; i != second_group.size() ; ++i )
{
- std::vector< std::pair< double , double > > diag = read_standard_file( second_group[i].c_str() );
+ std::vector< std::pair< double , double > > diag = read_standard_persistence_file( second_group[i].c_str() );
Persistence_landscape* l = new Persistence_landscape( diag );
second_collection[i] = l;
}
diff --git a/src/Gudhi_stat/utilities/persistence_intervals/plot_persistence_intervals.cpp b/src/Gudhi_stat/utilities/persistence_intervals/plot_persistence_intervals.cpp
index 04a05caa..6df31a6f 100644
--- a/src/Gudhi_stat/utilities/persistence_intervals/plot_persistence_intervals.cpp
+++ b/src/Gudhi_stat/utilities/persistence_intervals/plot_persistence_intervals.cpp
@@ -44,7 +44,7 @@ int main( int argc , char** argv )
std::cout << "To run this program, please provide the name of a file with persistence diagram \n";
return 1;
}
- std::vector< std::pair< double , double > > intervals = read_gudhi_file( argv[1] , 2 );
+ std::vector< std::pair< double , double > > intervals = read_gudhi_persistence_file_in_one_dimension( argv[1] , 2 );
Persistence_intervals b( intervals );
b.plot( argv[1] );
return 0;
diff --git a/src/Gudhi_stat/utilities/persistence_vectors/average_persistence_vectors.cpp b/src/Gudhi_stat/utilities/persistence_vectors/average_persistence_vectors.cpp
index 822d0e2a..b6b11211 100644
--- a/src/Gudhi_stat/utilities/persistence_vectors/average_persistence_vectors.cpp
+++ b/src/Gudhi_stat/utilities/persistence_vectors/average_persistence_vectors.cpp
@@ -49,15 +49,15 @@ int main( int argc , char** argv )
}
std::cout << "Reading persistence vectors...\n";
- std::vector< Vector_distances_in_diagram< Euclidean_distance<double> >* > lands;
+ std::vector< Vector_distances_in_diagram< Euclidean_distance >* > lands;
for ( size_t i = 0 ; i != filenames.size() ; ++i )
{
- Vector_distances_in_diagram< Euclidean_distance<double> >* l = new Vector_distances_in_diagram< Euclidean_distance<double> >;
+ Vector_distances_in_diagram< Euclidean_distance >* l = new Vector_distances_in_diagram< Euclidean_distance >;
l->load_from_file( filenames[i] );
lands.push_back(l );
}
- Vector_distances_in_diagram< Euclidean_distance<double> > av;
+ Vector_distances_in_diagram< Euclidean_distance > av;
av.compute_average( lands );
av.print_to_file( "average.vect" );
diff --git a/src/Gudhi_stat/utilities/persistence_vectors/compute_distance_of_persistence_vectors.cpp b/src/Gudhi_stat/utilities/persistence_vectors/compute_distance_of_persistence_vectors.cpp
index 6d242cd1..d61c6753 100644
--- a/src/Gudhi_stat/utilities/persistence_vectors/compute_distance_of_persistence_vectors.cpp
+++ b/src/Gudhi_stat/utilities/persistence_vectors/compute_distance_of_persistence_vectors.cpp
@@ -56,12 +56,12 @@ int main( int argc , char** argv )
{
filenames.push_back( argv[i] );
}
- std::vector< Vector_distances_in_diagram< Euclidean_distance<double> > > vectors;
+ std::vector< Vector_distances_in_diagram< Euclidean_distance > > vectors;
vectors.reserve( filenames.size() );
for ( size_t file_no = 0 ; file_no != filenames.size() ; ++file_no )
{
//cerr << filenames[file_no] << endl;
- Vector_distances_in_diagram< Euclidean_distance<double> > l;
+ Vector_distances_in_diagram< Euclidean_distance > l;
l.load_from_file( filenames[file_no] );
vectors.push_back( l );
}
diff --git a/src/Gudhi_stat/utilities/persistence_vectors/compute_scalar_product_of_persistence_vectors.cpp b/src/Gudhi_stat/utilities/persistence_vectors/compute_scalar_product_of_persistence_vectors.cpp
index e4c62194..7607c518 100644
--- a/src/Gudhi_stat/utilities/persistence_vectors/compute_scalar_product_of_persistence_vectors.cpp
+++ b/src/Gudhi_stat/utilities/persistence_vectors/compute_scalar_product_of_persistence_vectors.cpp
@@ -41,11 +41,11 @@ int main( int argc , char** argv )
{
filenames.push_back( argv[i] );
}
- std::vector< Vector_distances_in_diagram< Euclidean_distance<double> > > vectors;
+ std::vector< Vector_distances_in_diagram< Euclidean_distance > > vectors;
vectors.reserve( filenames.size() );
for ( size_t file_no = 0 ; file_no != filenames.size() ; ++file_no )
{
- Vector_distances_in_diagram< Euclidean_distance<double> > l;
+ Vector_distances_in_diagram< Euclidean_distance > l;
l.load_from_file( filenames[file_no] );
vectors.push_back( l );
}
diff --git a/src/Gudhi_stat/utilities/persistence_vectors/create_persistence_vectors.cpp b/src/Gudhi_stat/utilities/persistence_vectors/create_persistence_vectors.cpp
index 926e46fd..b016f2e2 100644
--- a/src/Gudhi_stat/utilities/persistence_vectors/create_persistence_vectors.cpp
+++ b/src/Gudhi_stat/utilities/persistence_vectors/create_persistence_vectors.cpp
@@ -43,8 +43,8 @@ int main( int argc , char** argv )
for ( size_t i = 0 ; i != filenames.size() ; ++i )
{
std::cerr << "Creatign persistence vectors based on a file : " << filenames[i] << std::endl;
- //std::vector< std::pair< double , double > > persistence_pairs = read_gudhi_file( filenames[i] , size_t dimension = 0 )
- Vector_distances_in_diagram< Euclidean_distance<double> > l( filenames[i] , -1 );
+ //std::vector< std::pair< double , double > > persistence_pairs = read_gudhi_persistence_file_in_one_dimension( filenames[i] , size_t dimension = 0 )
+ Vector_distances_in_diagram< Euclidean_distance > l( filenames[i] , -1 );
std::stringstream ss;
ss << filenames[i] << ".vect";
l.print_to_file( ss.str().c_str() );
diff --git a/src/Gudhi_stat/utilities/persistence_vectors/plot_persistence_vectors.cpp b/src/Gudhi_stat/utilities/persistence_vectors/plot_persistence_vectors.cpp
index 0ef30be8..4f19877c 100644
--- a/src/Gudhi_stat/utilities/persistence_vectors/plot_persistence_vectors.cpp
+++ b/src/Gudhi_stat/utilities/persistence_vectors/plot_persistence_vectors.cpp
@@ -39,7 +39,7 @@ int main( int argc , char** argv )
std::cout << "Wrong number of parameters, the program will now terminate. \n";
return 1;
}
- Vector_distances_in_diagram< Euclidean_distance<double> > l;
+ Vector_distances_in_diagram< Euclidean_distance > l;
l.load_from_file( argv[1] );
l.plot( argv[1] );
diff --git a/src/common/include/gudhi/distance_functions.h b/src/common/include/gudhi/distance_functions.h
index 22747637..7f33a804 100644
--- a/src/common/include/gudhi/distance_functions.h
+++ b/src/common/include/gudhi/distance_functions.h
@@ -35,7 +35,7 @@
* have the same dimension. */
class Euclidean_distance {
public:
- template< typename Point >
+ template< typename Point >
auto operator()(const Point& p1, const Point& p2) const -> typename std::decay<decltype(*std::begin(p1))>::type {
auto it1 = p1.begin();
auto it2 = p2.begin();
@@ -46,6 +46,11 @@ class Euclidean_distance {
}
return std::sqrt(dist);
}
+ template< typename T >
+ T operator() ( const std::pair< T,T >& f , const std::pair< T,T >& s )
+ {
+ return sqrt( (f.first-s.first)*(f.first-s.first) + (f.second-s.second)*(f.second-s.second) );
+ }
};
#endif // DISTANCE_FUNCTIONS_H_