summaryrefslogtreecommitdiff
path: root/src/Gudhi_stat/include/gudhi/persistence_representations
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/Gudhi_stat/include/gudhi/persistence_representations
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/Gudhi_stat/include/gudhi/persistence_representations')
-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
7 files changed, 37 insertions, 99 deletions
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;
-}
-
-