summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpdlotko <pdlotko@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2016-10-21 12:26:22 +0000
committerpdlotko <pdlotko@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2016-10-21 12:26:22 +0000
commit19451e20b6d47b6a84d5ad89d99497e0e60cd377 (patch)
treed10ab5934dd78ae943070ec131ad0241e360b892
parent60ded8e74aaec4fa519162dd15276c072f2acb2e (diff)
The library changed from inherritance to templates.
Are the files from include/abstract removed? git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/gudhi_stat@1741 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 6f768b08a7a900a56278adcf371a31840916d3ba
-rw-r--r--src/Gudhi_stat/concept/Real_valued_topological_data.h38
-rw-r--r--src/Gudhi_stat/concept/Topological_data_with_averages.h35
-rw-r--r--src/Gudhi_stat/concept/Topological_data_with_distances.h31
-rw-r--r--src/Gudhi_stat/concept/Topological_data_with_scalar_product.h31
-rw-r--r--src/Gudhi_stat/concept/Vectorized_topological_data.h39
-rw-r--r--src/Gudhi_stat/example/persistence_heat_maps.cpp10
-rw-r--r--src/Gudhi_stat/example/persistence_landscape.cpp10
-rw-r--r--src/Gudhi_stat/example/persistence_landscape_on_grid.cpp10
-rw-r--r--src/Gudhi_stat/example/vector_representation.cpp10
-rw-r--r--src/Gudhi_stat/include/gudhi/concretizations/Persistence_heat_maps.h101
-rw-r--r--src/Gudhi_stat/include/gudhi/concretizations/Persistence_intervals.h163
-rw-r--r--src/Gudhi_stat/include/gudhi/concretizations/Persistence_landscape.h127
-rw-r--r--src/Gudhi_stat/include/gudhi/concretizations/Persistence_landscape_on_grid.h230
-rw-r--r--src/Gudhi_stat/include/gudhi/concretizations/Vector_distances_in_diagram.h139
-rw-r--r--src/Gudhi_stat/include/gudhi/concretizations/read_persitence_from_file.h5
-rw-r--r--src/Gudhi_stat/include/gudhi/permutation_test.h80
-rw-r--r--src/Gudhi_stat/include/gudhi/topological_process.h101
-rw-r--r--src/Gudhi_stat/test/persistence_heat_maps_test.cpp84
-rw-r--r--src/Gudhi_stat/test/persistence_lanscapes_on_grid_test.cpp12
-rw-r--r--src/Gudhi_stat/test/persistence_lanscapes_test.cpp10
-rw-r--r--src/Gudhi_stat/test/vector_representation_test.cpp8
-rw-r--r--src/Gudhi_stat/utilities/CMakeLists.txt4
-rw-r--r--src/Gudhi_stat/utilities/permutation_test.cpp84
-rw-r--r--src/Gudhi_stat/utilities/persistence_heat_maps/average_persistence_heat_maps.cpp5
-rw-r--r--src/Gudhi_stat/utilities/persistence_heat_maps/compute_distance_of_persistence_heat_maps.cpp12
-rw-r--r--src/Gudhi_stat/utilities/persistence_heat_maps/compute_scalar_product_of_persistence_heat_maps.cpp10
-rw-r--r--src/Gudhi_stat/utilities/persistence_heat_maps/create_persistence_heat_maps.cpp1
-rw-r--r--src/Gudhi_stat/utilities/persistence_heat_maps/create_persistence_heat_maps_weighted_by_arctan_of_their_persistence.cpp1
-rw-r--r--src/Gudhi_stat/utilities/persistence_heat_maps/create_persistence_heat_maps_weighted_by_distance_from_diagonal.cpp2
-rw-r--r--src/Gudhi_stat/utilities/persistence_heat_maps/create_persistence_heat_maps_weighted_by_squared_distance_from_diagonal.cpp2
-rw-r--r--src/Gudhi_stat/utilities/persistence_heat_maps/create_pssk.cpp3
-rw-r--r--src/Gudhi_stat/utilities/persistence_heat_maps/plot_persistence_heat_map.cpp2
-rw-r--r--src/Gudhi_stat/utilities/persistence_intervals/compute_birth_death_range_in_persistence_diagram.cpp1
-rw-r--r--src/Gudhi_stat/utilities/persistence_intervals/compute_number_of_dominant_intervals.cpp1
-rw-r--r--src/Gudhi_stat/utilities/persistence_intervals/plot_histogram_of_intervals_lengths.cpp1
-rw-r--r--src/Gudhi_stat/utilities/persistence_intervals/plot_persistence_Betti_numebrs.cpp1
-rw-r--r--src/Gudhi_stat/utilities/persistence_intervals/plot_persistence_intervals.cpp1
-rw-r--r--src/Gudhi_stat/utilities/persistence_landscapes/average_landscapes.cpp5
-rw-r--r--src/Gudhi_stat/utilities/persistence_landscapes/compute_distance_of_landscapes.cpp3
-rw-r--r--src/Gudhi_stat/utilities/persistence_landscapes/compute_scalar_product_of_landscapes.cpp3
-rw-r--r--src/Gudhi_stat/utilities/persistence_landscapes/create_landscapes.cpp3
-rw-r--r--src/Gudhi_stat/utilities/persistence_landscapes/plot_landscapes.cpp3
-rw-r--r--src/Gudhi_stat/utilities/persistence_landscapes_on_grid/average_landscapes_on_grid.cpp7
-rw-r--r--src/Gudhi_stat/utilities/persistence_landscapes_on_grid/compute_distance_of_landscapes_on_grid.cpp3
-rw-r--r--src/Gudhi_stat/utilities/persistence_landscapes_on_grid/compute_scalar_product_of_landscapes_on_grid.cpp2
-rw-r--r--src/Gudhi_stat/utilities/persistence_landscapes_on_grid/create_landscapes_on_grid.cpp3
-rw-r--r--src/Gudhi_stat/utilities/persistence_landscapes_on_grid/plot_landscapes_on_grid.cpp3
-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.cpp11
-rw-r--r--src/Gudhi_stat/utilities/persistence_vectors/compute_scalar_product_of_persistence_vectors.cpp20
-rw-r--r--src/Gudhi_stat/utilities/persistence_vectors/create_persistence_vectors.cpp3
-rw-r--r--src/Gudhi_stat/utilities/persistence_vectors/plot_persistence_vectors.cpp3
52 files changed, 1047 insertions, 436 deletions
diff --git a/src/Gudhi_stat/concept/Real_valued_topological_data.h b/src/Gudhi_stat/concept/Real_valued_topological_data.h
new file mode 100644
index 00000000..ead22bf4
--- /dev/null
+++ b/src/Gudhi_stat/concept/Real_valued_topological_data.h
@@ -0,0 +1,38 @@
+/* This file is part of the Gudhi Library. 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/>.
+ */
+
+/** \brief The concept Real_valued_topological_data describes the requirements
+ * for a type to implement a container that allows computations of its projections to R.
+ */
+class Real_valued_topological_data
+{
+public:
+ /**
+ * Typically there are various ways data can be projected to R. This function give us the number of functions for vectorization provided by a given class.
+ **/
+ size_t number_of_projections_to_R();
+ /**
+ * This is a function to compute the projection from this container to reals. The parameter of a function have to be between 0 and the value returned by number_of_projections_to_R().
+ **/
+ double project_to_R;
+};
+
diff --git a/src/Gudhi_stat/concept/Topological_data_with_averages.h b/src/Gudhi_stat/concept/Topological_data_with_averages.h
new file mode 100644
index 00000000..67433860
--- /dev/null
+++ b/src/Gudhi_stat/concept/Topological_data_with_averages.h
@@ -0,0 +1,35 @@
+
+/* This file is part of the Gudhi Library. 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/>.
+ */
+
+
+
+/** \brief The concept Topological_data_with_averages describes the requirements
+ * for a type to implement a container that allows computations of averages.
+ */
+class Topological_data_with_averages
+{
+public:
+ void compute_average( const std::vector< Topological_data_with_averages* >& to_average );
+};
+
+
diff --git a/src/Gudhi_stat/concept/Topological_data_with_distances.h b/src/Gudhi_stat/concept/Topological_data_with_distances.h
new file mode 100644
index 00000000..536ae821
--- /dev/null
+++ b/src/Gudhi_stat/concept/Topological_data_with_distances.h
@@ -0,0 +1,31 @@
+/* This file is part of the Gudhi Library. 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/>.
+ */
+
+/** \brief The concept Topological_data_with_distances describes the requirements
+ * for a type to implement a container that allows computations of distance to another contained of that type.
+ */
+class Topological_data_with_distances
+{
+public:
+ double distance( const Topological_data_with_distances& second , double power = 1);
+};
+
diff --git a/src/Gudhi_stat/concept/Topological_data_with_scalar_product.h b/src/Gudhi_stat/concept/Topological_data_with_scalar_product.h
new file mode 100644
index 00000000..f32271c7
--- /dev/null
+++ b/src/Gudhi_stat/concept/Topological_data_with_scalar_product.h
@@ -0,0 +1,31 @@
+/* This file is part of the Gudhi Library. 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/>.
+ */
+
+
+/** \brief The concept Topological_data_with_scalar_product describes the requirements
+ * for a type to implement a container that allows computations of scalar products.
+ */
+class Topological_data_with_scalar_product
+{
+public:
+ double compute_scalar_product( const Topological_data_with_scalar_product& second );
+};
diff --git a/src/Gudhi_stat/concept/Vectorized_topological_data.h b/src/Gudhi_stat/concept/Vectorized_topological_data.h
new file mode 100644
index 00000000..2dd966fd
--- /dev/null
+++ b/src/Gudhi_stat/concept/Vectorized_topological_data.h
@@ -0,0 +1,39 @@
+/* This file is part of the Gudhi Library. 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/>.
+ */
+
+
+/** \brief The concept Vectorized_topological_data describes the requirements
+ * for a type to implement a container that allows vectorization.
+ */
+class Vectorized_topological_data
+{
+public:
+ /**
+ * There are various ways data can be verctorized. This function give us the number of functions for vectorization provided by a given class.
+ **/
+ size_t number_of_vectorize_functions();
+ /**
+ * This is a function to vectorize given container. The parameter of a function have to be between 0 and the value returned by number_of_vectorize_functions().
+ **/
+ std::vector<double> vectorize( int number_of_function );
+};
+
diff --git a/src/Gudhi_stat/example/persistence_heat_maps.cpp b/src/Gudhi_stat/example/persistence_heat_maps.cpp
index 7f5580da..645f63f7 100644
--- a/src/Gudhi_stat/example/persistence_heat_maps.cpp
+++ b/src/Gudhi_stat/example/persistence_heat_maps.cpp
@@ -75,17 +75,17 @@ int main( int argc , char** argv )
median.compute_median( vector_of_maps );
//to compute L^1 disance between hm1 and hm2:
- std::cout << "The L^1 distance is : " << hm1.distance( (Abs_Topological_data_with_distances*)(&hm2) , 1 ) << std::endl;
+ std::cout << "The L^1 distance is : " << hm1.distance( hm2 , 1 ) << std::endl;
//to average of hm1 and hm2:
- std::vector< Abs_Topological_data_with_averages* > to_average;
- to_average.push_back( (Abs_Topological_data_with_averages*)(&hm1) );
- to_average.push_back( (Abs_Topological_data_with_averages*)(&hm2) );
+ std::vector< Persistence_heat_maps* > to_average;
+ to_average.push_back( &hm1 );
+ to_average.push_back( &hm2 );
Persistence_heat_maps av;
av.compute_average( to_average );
//to compute scalar product of hm1 and hm2:
- std::cout << "Scalar product is : " << hm1.compute_scalar_product( (Abs_Topological_data_with_scalar_product*)(&hm2) ) << std::endl;
+ std::cout << "Scalar product is : " << hm1.compute_scalar_product( hm2 ) << std::endl;
return 0;
}
diff --git a/src/Gudhi_stat/example/persistence_landscape.cpp b/src/Gudhi_stat/example/persistence_landscape.cpp
index f5110153..106864c0 100644
--- a/src/Gudhi_stat/example/persistence_landscape.cpp
+++ b/src/Gudhi_stat/example/persistence_landscape.cpp
@@ -76,17 +76,17 @@ int main( int argc , char** argv )
//here is the average of landscapes:
Persistence_landscape average;
- std::vector< Abs_Topological_data_with_averages* > to_average;
- to_average.push_back( (Abs_Topological_data_with_averages*)(&l1) );
- to_average.push_back( (Abs_Topological_data_with_averages*)(&l2) );
+ std::vector< Persistence_landscape* > to_average;
+ to_average.push_back( &l1 );
+ to_average.push_back( &l2 );
average.compute_average( to_average );
std::cout << "average : " << average << std::endl;
//here is the distance of landscapes:
- std::cout << "Distance : " << l1.distance( (Abs_Topological_data_with_distances*)(&l2) ) << std::endl;
+ std::cout << "Distance : " << l1.distance( l2 ) << std::endl;
//here is the scalar product of landscapes:
- std::cout << "Scalar product : " << l1.compute_scalar_product( (Abs_Topological_data_with_scalar_product*)(&l2) ) << std::endl;
+ std::cout << "Scalar product : " << l1.compute_scalar_product( l2 ) << std::endl;
//here is how to create a file which is suitable for vizualization via gnuplot:
average.plot( "average_landscape" );
diff --git a/src/Gudhi_stat/example/persistence_landscape_on_grid.cpp b/src/Gudhi_stat/example/persistence_landscape_on_grid.cpp
index ddda78d2..223c9d50 100644
--- a/src/Gudhi_stat/example/persistence_landscape_on_grid.cpp
+++ b/src/Gudhi_stat/example/persistence_landscape_on_grid.cpp
@@ -72,17 +72,17 @@ int main( int argc , char** argv )
//here is the average of landscapes:
Persistence_landscape_on_grid average;
- std::vector< Abs_Topological_data_with_averages* > to_average;
- to_average.push_back( (Abs_Topological_data_with_averages*)(&l1) );
- to_average.push_back( (Abs_Topological_data_with_averages*)(&l2) );
+ std::vector< Persistence_landscape_on_grid* > to_average;
+ to_average.push_back( &l1 );
+ to_average.push_back( &l2 );
average.compute_average( to_average );
std::cout << "average : " << average << std::endl;
//here is the distance of landscapes:
- std::cout << "Distance : " << l1.distance( (Abs_Topological_data_with_distances*)(&l2) ) << std::endl;
+ std::cout << "Distance : " << l1.distance( l2 ) << std::endl;
//here is the scalar product of landscapes:
- std::cout << "Scalar product : " << l1.compute_scalar_product( (Abs_Topological_data_with_scalar_product*)(&l2) ) << std::endl;
+ std::cout << "Scalar product : " << l1.compute_scalar_product( l2 ) << std::endl;
//here is how to create a file which is suitable for vizualization via gnuplot:
average.plot( "average_landscape" );
diff --git a/src/Gudhi_stat/example/vector_representation.cpp b/src/Gudhi_stat/example/vector_representation.cpp
index 773c60fa..835b52f9 100644
--- a/src/Gudhi_stat/example/vector_representation.cpp
+++ b/src/Gudhi_stat/example/vector_representation.cpp
@@ -66,17 +66,17 @@ int main( int argc , char** argv )
//averages:
Vector_distances_in_diagram<euclidean_distance<double> > average;
- std::vector< Abs_Topological_data_with_averages* > to_average;
- to_average.push_back( (Abs_Topological_data_with_averages*)(&v1) );
- to_average.push_back( (Abs_Topological_data_with_averages*)(&v2) );
+ std::vector< Vector_distances_in_diagram<euclidean_distance<double> >* > to_average;
+ to_average.push_back( &v1 );
+ to_average.push_back( &v2 );
average.compute_average( to_average );
std::cout << "Average : " << average << std::endl;
//computations of distances:
- std::cout << "l^1 distance : " << v1.distance( (Abs_Topological_data_with_distances*)(&v2) ) << std::endl;
+ std::cout << "l^1 distance : " << v1.distance( v2 ) << std::endl;
//computations of scalar product:
- std::cout << "Scalar product of l1 and l2 : " << v1.compute_scalar_product( (Abs_Topological_data_with_scalar_product*)(&v2) ) << std::endl;
+ std::cout << "Scalar product of l1 and l2 : " << v1.compute_scalar_product( v2 ) << std::endl;
//create a file with a gnuplot script:
v1.plot( "plot_of_vector_representation" );
diff --git a/src/Gudhi_stat/include/gudhi/concretizations/Persistence_heat_maps.h b/src/Gudhi_stat/include/gudhi/concretizations/Persistence_heat_maps.h
index e9175af9..d2c1bfc9 100644
--- a/src/Gudhi_stat/include/gudhi/concretizations/Persistence_heat_maps.h
+++ b/src/Gudhi_stat/include/gudhi/concretizations/Persistence_heat_maps.h
@@ -33,11 +33,6 @@
#include <algorithm>
//gudhi include
-#include <gudhi/abstract_classes/Abs_Vectorized_topological_data.h>
-#include <gudhi/abstract_classes/Abs_Topological_data_with_averages.h>
-#include <gudhi/abstract_classes/Abs_Topological_data_with_distances.h>
-#include <gudhi/abstract_classes/Abs_Real_valued_topological_data.h>
-#include <gudhi/abstract_classes/Abs_Topological_data_with_scalar_product.h>
#include <gudhi/concretizations/read_persitence_from_file.h>
#include <gudhi/common_gudhi_stat.h>
@@ -161,13 +156,10 @@ private:
};
-
-class Persistence_heat_maps :
- public Abs_Vectorized_topological_data ,
- public Abs_Topological_data_with_distances ,
- public Abs_Real_valued_topological_data,
- public Abs_Topological_data_with_averages,
- public Abs_Topological_data_with_scalar_product
+/**
+ * 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
+**/
+class Persistence_heat_maps
{
public:
/**
@@ -321,16 +313,59 @@ public:
void plot( const char* filename );
- //Concretizations of virtual methods:
- std::vector<double> vectorize( int number_of_function );
- double distance( const Abs_Topological_data_with_distances* second_ , double power = 1);
+ //Implementations of functions for various concepts.
+
+ /**
+ * This function produce a vector of doubles based on a persisence heat map. It is required in a concept Vectorized_topological_data
+ */
+ std::vector<double> vectorize( int number_of_function );
+ /**
+ * This function return the number of functions that allows vectorization of persistence heat map. It is required in a concept Vectorized_topological_data.
+ **/
+ size_t number_of_vectorize_functions()
+ {
+ return this->number_of_functions_for_vectorization;
+ }
+
+ /**
+ * This function is required by the Real_valued_topological_data concept. It returns various projections od the persistence heat map to a real line.
+ **/
double project_to_R( int number_of_function );
- void compute_average( const std::vector< Abs_Topological_data_with_averages* >& to_average );
- double compute_scalar_product( const Abs_Topological_data_with_scalar_product* second_ );
+ /**
+ * The function gives the number of possible projections to R. This function is required by the Real_valued_topological_data concept.
+ **/
+ size_t number_of_projections_to_R()
+ {
+ return this->number_of_functions_for_projections_to_reals;
+ }
+
+ /**
+ * A function to compute distance between persistence heat maps.
+ * The parameter of this function is a const reference to an object of a class Persistence_heat_maps.
+ * This function is required in Topological_data_with_distances concept.
+ **/
+ double distance( const Persistence_heat_maps& second_ , double power = 1);
+
+ /**
+ * A function to compute averaged persistence heat map, based on vector of persistence heat maps.
+ * This function is required by Topological_data_with_averages concept.
+ **/
+ void compute_average( const std::vector< Persistence_heat_maps* >& to_average );
+
+ /**
+ * A function to compute scalar product of persistence heat maps.
+ * The parameter of this functionis a const reference to an object of a class Persistence_heat_maps.
+ * This function is required in Topological_data_with_scalar_product concept.
+ **/
+ double compute_scalar_product( const Persistence_heat_maps& second_ );
+
+ //end of implementation of functions needed for concepts.
protected:
//private methods
std::vector< std::vector<double> > check_and_initialize_maps( const std::vector<Persistence_heat_maps*>& maps );
+ size_t number_of_functions_for_vectorization;
+ size_t number_of_functions_for_projections_to_reals;
void construct( const std::vector< std::pair<double,double> >& intervals_ ,
std::vector< std::vector<double> > filter = create_Gaussian_filter(5,1),
double (*scalling_function_with_respect_to_distance_from_diagonal)( const std::pair< double , double >& point_in_diagram ) = constant_function,
@@ -717,12 +752,10 @@ std::vector<double> Persistence_heat_maps::vectorize( int number_of_function )
return result;
}
-double Persistence_heat_maps::distance( const Abs_Topological_data_with_distances* second_ , double power )
-{
- Persistence_heat_maps* second = (Persistence_heat_maps*)second_;
-
+double Persistence_heat_maps::distance( const Persistence_heat_maps& second , double power )
+{
//first we need to check if (*this) and second are defined on the same domain and have the same dimensions:
- if ( !this->check_if_the_same(*second) )
+ if ( !this->check_if_the_same(second) )
{
std::cerr << "The persistence images are of noncompatible sizes. We cannot therefore compute distance between them. The program will now terminate";
throw "The persistence images are of noncompatible sizes. We cannot therefore compute distance between them. The program will now terminate";
@@ -735,7 +768,7 @@ double Persistence_heat_maps::distance( const Abs_Topological_data_with_distance
{
for ( size_t j = 0 ; j != this->heat_map[i].size() ; ++j )
{
- distance += pow( abs(this->heat_map[i][j] - second->heat_map[i][j]) , power );
+ distance += pow( abs(this->heat_map[i][j] - second.heat_map[i][j]) , power );
}
}
return distance;
@@ -754,23 +787,15 @@ double Persistence_heat_maps::project_to_R( int number_of_function )
return result;
}
-void Persistence_heat_maps::compute_average( const std::vector< Abs_Topological_data_with_averages* >& to_average )
-{
- std::vector<Persistence_heat_maps*> maps;
- maps.reserve( to_average.size() );
- for ( size_t i = 0 ; i != to_average.size() ; ++i )
- {
- maps.push_back( (Persistence_heat_maps*)to_average[i] );
- }
- this->compute_mean( maps );
+void Persistence_heat_maps::compute_average( const std::vector< Persistence_heat_maps* >& to_average )
+{
+ this->compute_mean( to_average );
}
-double Persistence_heat_maps::compute_scalar_product( const Abs_Topological_data_with_scalar_product* second_ )
-{
- Persistence_heat_maps* second = (Persistence_heat_maps*)second_;
-
+double Persistence_heat_maps::compute_scalar_product( const Persistence_heat_maps& second )
+{
//first we need to check if (*this) and second are defined on the same domain and have the same dimensions:
- if ( !this->check_if_the_same(*second) )
+ if ( !this->check_if_the_same(second) )
{
std::cerr << "The persistence images are of noncompatible sizes. We cannot therefore compute distance between them. The program will now terminate";
throw "The persistence images are of noncompatible sizes. We cannot therefore compute distance between them. The program will now terminate";
@@ -782,7 +807,7 @@ double Persistence_heat_maps::compute_scalar_product( const Abs_Topological_data
{
for ( size_t j = 0 ; j != this->heat_map[i].size() ; ++j )
{
- scalar_prod += this->heat_map[i][j]*second->heat_map[i][j];
+ scalar_prod += this->heat_map[i][j]*second.heat_map[i][j];
}
}
return scalar_prod;
diff --git a/src/Gudhi_stat/include/gudhi/concretizations/Persistence_intervals.h b/src/Gudhi_stat/include/gudhi/concretizations/Persistence_intervals.h
index f694541b..5d21ba97 100644
--- a/src/Gudhi_stat/include/gudhi/concretizations/Persistence_intervals.h
+++ b/src/Gudhi_stat/include/gudhi/concretizations/Persistence_intervals.h
@@ -24,9 +24,6 @@
#define Persistence_intervals_H_
//gudhi include
-#include <gudhi/abstract_classes/Abs_Vectorized_topological_data.h>
-#include <gudhi/abstract_classes/Abs_Topological_data_with_distances.h>
-#include <gudhi/abstract_classes/Abs_Real_valued_topological_data.h>
#include <gudhi/concretizations/read_persitence_from_file.h>
//standard include
@@ -43,7 +40,10 @@ namespace Gudhi
namespace Gudhi_stat
{
-class Persistence_intervals : public Abs_Vectorized_topological_data , public Abs_Topological_data_with_distances, public Abs_Real_valued_topological_data
+/**
+ * This class implements the following concepts: Vectorized_topological_data, Topological_data_with_distances, Real_valued_topological_data
+**/
+class Persistence_intervals
{
public:
/**
@@ -114,11 +114,11 @@ public:
/**
* Operator that send the diagram to a stream.
**/
- friend ostream& operator << ( ostream& out , const Persistence_intervals& intervals )
+ friend std::ostream& operator << ( std::ostream& out , const Persistence_intervals& intervals )
{
for ( size_t i = 0 ; i != intervals.intervals.size() ; ++i )
{
- out << intervals.intervals[i].first << " " << intervals.intervals[i].second << endl;
+ out << intervals.intervals[i].first << " " << intervals.intervals[i].second << std::endl;
}
return out;
}
@@ -129,38 +129,30 @@ public:
void plot( const char* filename )
{
//this program create a gnuplot script file that allows to plot persistence diagram.
- ofstream out;
+ std::ofstream out;
std::ostringstream nameSS;
nameSS << filename << "_GnuplotScript";
std::string nameStr = nameSS.str();
out.open( (char*)nameStr.c_str() );
std::pair<double,double> min_max_values = this->min_max();
- 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) << " ]" << endl;
- out << "set yrange [" << 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) << " ]" << endl;
- out << "plot '-' using 1:2 notitle \"" << filename << "\", \\" << endl;
- out << " '-' using 1:2 notitle with lp" << endl;
+ 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;
+ out << "set yrange [" << 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;
+ out << "plot '-' using 1:2 notitle \"" << filename << "\", \\" << std::endl;
+ out << " '-' using 1:2 notitle with lp" << std::endl;
for ( size_t i = 0 ; i != this->intervals.size() ; ++i )
{
- out << this->intervals[i].first << " " << this->intervals[i].second << endl;
+ out << this->intervals[i].first << " " << this->intervals[i].second << std::endl;
}
- out << "EOF" << endl;
- out << min_max_values.first - 0.1*(min_max_values.second-min_max_values.first) << " " << min_max_values.first - 0.1*(min_max_values.second-min_max_values.first) << endl;
- out << min_max_values.second + 0.1*(min_max_values.second-min_max_values.first) << " " << min_max_values.second + 0.1*(min_max_values.second-min_max_values.first) << endl;
+ out << "EOF" << std::endl;
+ out << min_max_values.first - 0.1*(min_max_values.second-min_max_values.first) << " " << min_max_values.first - 0.1*(min_max_values.second-min_max_values.first) << std::endl;
+ out << min_max_values.second + 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;
out.close();
- cout << "Gnuplot script to visualize persistence diagram written to the file: " << nameStr << ". Type load '" << nameStr << "' in gnuplot to visualize." << endl;
+ std::cout << "Gnuplot script to visualize persistence diagram written to the file: " << nameStr << ". Type load '" << nameStr << "' in gnuplot to visualize." << std::endl;
}
- /**
- * Return a familly of vectors obtained from the persistence diagram. The i-th vector consist of the lenfth of i dominant persistence intervals.
- **/
- std::vector<double> vectorize( int number_of_function )//comment: in this case, number_of_functions (a static member of Abs_Vectorized_topological_data cannot be set a priori.
- //In this cas, maybe it is better not to make this parameter static.
- {
- return this->length_of_dominant_intervals( number_of_function );
- }
/**
* Retun numbr of points in the diagram.
@@ -176,22 +168,71 @@ public:
return this->intervals[i];
}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ //Implementations of functions for various concepts.
+ /**
+ * This is a simple function projectig the persistence intervals to a real number. The function we use here is a sum of squared lendgths of intervals. It can be naturally interpreted as
+ * sum of step function, where the step hight it equal to the length of the interval.
+ **/
+ double project_to_R( int number_of_function );
+ /**
+ * The function gives the number of possible projections to R. This function is required by the Real_valued_topological_data concept.
+ **/
+ size_t number_of_projections_to_R()
+ {
+ return this->number_of_functions_for_projections_to_reals;
+ }
+
+ /**
+ * Return a familly of vectors obtained from the persistence diagram. The i-th vector consist of the lenfth of i dominant persistence intervals.
+ **/
+ std::vector<double> vectorize( int number_of_function )
+ {
+ return this->length_of_dominant_intervals( number_of_function );
+ }
+ /**
+ * This function return the number of functions that allows vectorization of a persisence diagram. It is required in a concept Vectorized_topological_data.
+ **/
+ size_t number_of_vectorize_functions()
+ {
+ 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 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.
**/
- double distance( const Abs_Topological_data_with_distances* second , double power = 1)
+ double distance( const Persistence_intervals& second , double power = 1)
{
return 1;
//waiting for Francois Godi for the code. We will compute here the Bottleneck distnace.
}
+ //end of implementation of functions needed for concepts.
- /**
- * This is a simple function projectig the persistence intervals to a real number. The function we use here is a sum of squared lendgths of intervals. It can be naturally interpreted as
- * sum of step function, where the step hight it equal to the length of the interval.
- **/
- double project_to_R( int number_of_function );
-
+
+
+
+
+
+
+
+
+
+
+
//For visualization use output from vectorize and build histograms.
std::vector< std::pair< double,double > > output_for_visualization()
@@ -208,7 +249,9 @@ protected:
this->number_of_functions_for_projections_to_reals = 1;
}
- std::vector< std::pair< double,double > > intervals;
+ std::vector< std::pair< double,double > > intervals;
+ size_t number_of_functions_for_vectorization;
+ size_t number_of_functions_for_projections_to_reals;
};
@@ -240,7 +283,7 @@ Persistence_intervals::Persistence_intervals( const char* filename )
// this->intervals.push_back( std::make_pair( first,second ) );
// if ( dbg )
// {
- // cerr << "Adding interval [ " << first << " , " << second << " ]\n";
+ // std::cerr << "Adding interval [ " << first << " , " << second << " ]\n";
// getchar();
// }
//}
@@ -303,7 +346,7 @@ std::vector< std::pair<double,double> > Persistence_intervals::dominant_interval
for ( size_t i = 0 ; i != std::min( where_to_cut , position_length_vector.size() ) ; ++i )
{
result.push_back( this->intervals[ position_length_vector[i].first ] );
- if ( dbg )cerr << "Position : " << position_length_vector[i].first << " length : " << position_length_vector[i].second << endl;
+ if ( dbg )std::cerr << "Position : " << position_length_vector[i].first << " length : " << position_length_vector[i].second << std::endl;
}
return result;
@@ -314,7 +357,7 @@ std::vector< size_t > Persistence_intervals::histograms_of_lengths( size_t numbe
{
bool dbg = false;
- if ( dbg )cerr << "this->intervals.size() : " << this->intervals.size() << endl;
+ if ( dbg )std::cerr << "this->intervals.size() : " << this->intervals.size() << std::endl;
//first find the length of the longest interval:
double lengthOfLongest = 0;
for ( size_t i = 0 ; i != this->intervals.size() ; ++i )
@@ -325,7 +368,7 @@ std::vector< size_t > Persistence_intervals::histograms_of_lengths( size_t numbe
}
}
- if ( dbg ){cerr << "lengthOfLongest : " << lengthOfLongest << endl;}
+ if ( dbg ){std::cerr << "lengthOfLongest : " << lengthOfLongest << std::endl;}
//this is a container we will use to store the resulting histogram
std::vector< size_t > result( number_of_bins + 1 , 0 );
@@ -344,16 +387,16 @@ std::vector< size_t > Persistence_intervals::histograms_of_lengths( size_t numbe
if ( dbg )
{
- cerr << "i : " << i << endl;
- cerr << "Interval : [" << this->intervals[i].first << " , " << this->intervals[i].second << " ] \n";
- cerr << "relative_length_of_this_interval : " << relative_length_of_this_interval << endl;
- cerr << "position : " << position << endl;
+ std::cerr << "i : " << i << std::endl;
+ std::cerr << "Interval : [" << this->intervals[i].first << " , " << this->intervals[i].second << " ] \n";
+ std::cerr << "relative_length_of_this_interval : " << relative_length_of_this_interval << std::endl;
+ std::cerr << "position : " << position << std::endl;
getchar();
}
}
- if ( dbg ){for ( size_t i = 0 ; i != result.size() ; ++i )cerr << result[i] << endl;}
+ if ( dbg ){for ( size_t i = 0 ; i != result.size() ; ++i )std::cerr << result[i] << std::endl;}
return result;
}
@@ -384,7 +427,7 @@ std::vector< double > Persistence_intervals::characteristic_function_of_diagram(
{
if ( dbg )
{
- cerr << "Interval : " << this->intervals[i].first << " , " << this->intervals[i].second << endl;
+ std::cerr << "Interval : " << this->intervals[i].first << " , " << this->intervals[i].second << std::endl;
}
size_t beginIt = 0;
@@ -407,8 +450,8 @@ std::vector< double > Persistence_intervals::characteristic_function_of_diagram(
if ( dbg )
{
- cerr << "beginIt : " << beginIt << endl;
- cerr << "endIt : " << endIt << endl;
+ std::cerr << "beginIt : " << beginIt << std::endl;
+ std::cerr << "endIt : " << endIt << std::endl;
}
@@ -419,12 +462,12 @@ std::vector< double > Persistence_intervals::characteristic_function_of_diagram(
//cerr << "x_max : " << x_max << " x_min : " << x_min << " , number_of_bins : " << number_of_bins << " this->intervals[i].second : " << this->intervals[i].second << " this->intervals[i].first : " << this->intervals[i].first << endl;
if ( dbg )
{
- cerr << "Result at this stage \n";
+ std::cerr << "Result at this stage \n";
for ( size_t aa = 0 ; aa != result.size() ; ++aa )
{
- cerr << result[aa] << " ";
+ std::cerr << result[aa] << " ";
}
- cerr << endl;
+ std::cerr << std::endl;
//getchar();
}
}
@@ -498,10 +541,10 @@ std::vector< double > Persistence_intervals::k_n_n( size_t k , size_t where_to_c
bool dbg = false;
if ( dbg )
{
- cerr << "Here are the intervals : \n";
+ std::cerr << "Here are the intervals : \n";
for ( size_t i = 0 ; i != this->intervals.size() ; ++i )
{
- cerr << "[ " << this->intervals[i].first << " , " << this->intervals[i].second << "] \n";
+ std::cerr << "[ " << this->intervals[i].first << " , " << this->intervals[i].second << "] \n";
}
getchar();
}
@@ -532,12 +575,12 @@ std::vector< double > Persistence_intervals::k_n_n( size_t k , size_t where_to_c
if ( dbg )
{
- cerr << "Here are the distances form the point : [" << this->intervals[i].first << " , " << this->intervals[i].second << "] in the diagram \n";
+ std::cerr << "Here are the distances form the point : [" << this->intervals[i].first << " , " << this->intervals[i].second << "] in the diagram \n";
for ( size_t aa = 0 ; aa != distancesFromI.size() ; ++aa )
{
- cerr << "To : " << i+aa << " : " << distancesFromI[aa] << " ";
+ std::cerr << "To : " << i+aa << " : " << distancesFromI[aa] << " ";
}
- cerr << endl;
+ std::cerr << std::endl;
getchar();
}
@@ -550,21 +593,21 @@ std::vector< double > Persistence_intervals::k_n_n( size_t k , size_t where_to_c
}
if ( dbg )
{
- cerr << "Here is the distance matrix : \n";
+ std::cerr << "Here is the distance matrix : \n";
for ( size_t i = 0 ; i != distances.size() ; ++i )
{
for ( size_t j = 0 ; j != distances.size() ; ++j )
{
- cerr << distances[i][j] << " ";
+ std::cerr << distances[i][j] << " ";
}
- cerr << endl;
+ std::cerr << std::endl;
}
- cerr << endl << endl << "And here are the distances to the diagonal : " << endl;
+ std::cerr << std::endl << std::endl << "And here are the distances to the diagonal : " << std::endl;
for ( size_t i = 0 ; i != distances_from_diagonal. size() ; ++i )
{
- cerr << distances_from_diagonal[i] << " ";
+ std::cerr << distances_from_diagonal[i] << " ";
}
- cerr << endl << endl;
+ std::cerr << std::endl << std::endl;
getchar();
}
@@ -580,7 +623,7 @@ std::vector< double > Persistence_intervals::k_n_n( size_t k , size_t where_to_c
{
if ( dbg )
{
- cerr << "There are not enough neighbors in your set. We set the result to plus infty \n";
+ std::cerr << "There are not enough neighbors in your set. We set the result to plus infty \n";
}
result.push_back( std::numeric_limits<double>::max() );
}
@@ -590,7 +633,7 @@ std::vector< double > Persistence_intervals::k_n_n( size_t k , size_t where_to_c
{
if ( dbg )
{
- cerr << "The k-th n.n. is on a diagonal. Therefore we set up a distance to diagonal \n";
+ std::cerr << "The k-th n.n. is on a diagonal. Therefore we set up a distance to diagonal \n";
}
result.push_back( distances_from_diagonal[i] );
}
diff --git a/src/Gudhi_stat/include/gudhi/concretizations/Persistence_landscape.h b/src/Gudhi_stat/include/gudhi/concretizations/Persistence_landscape.h
index aa74514e..b3caaedc 100644
--- a/src/Gudhi_stat/include/gudhi/concretizations/Persistence_landscape.h
+++ b/src/Gudhi_stat/include/gudhi/concretizations/Persistence_landscape.h
@@ -36,11 +36,6 @@
//gudhi include
-#include <gudhi/abstract_classes/Abs_Vectorized_topological_data.h>
-#include <gudhi/abstract_classes/Abs_Topological_data_with_averages.h>
-#include <gudhi/abstract_classes/Abs_Topological_data_with_distances.h>
-#include <gudhi/abstract_classes/Abs_Real_valued_topological_data.h>
-#include <gudhi/abstract_classes/Abs_Topological_data_with_scalar_product.h>
#include <gudhi/concretizations/read_persitence_from_file.h>
#include <gudhi/common_gudhi_stat.h>
using namespace std;
@@ -62,13 +57,9 @@ namespace Gudhi_stat
* A clas implementing persistence landascpes data structures. For theroretical desciritpion, please consult a paper ''Statistical topological data analysis using persistence landscapes'' by Peter Bubenik.
* For details of algorithms, please consult ''A persistence landscapes toolbox for topological statistics'' by Peter Bubenik and Pawel Dlotko.
* Persistence landscapes allow vertorization, computations of distances, computations of projections to Real, computations of averages and scalar products. Therefore they implement suitable interfaces.
+ * It implements the following concepts: Vectorized_topological_data, Topological_data_with_distances, Real_valued_topological_data, Topological_data_with_averages, Topological_data_with_scalar_product
**/
-class Persistence_landscape :
- public Abs_Vectorized_topological_data ,
- public Abs_Topological_data_with_distances,
- public Abs_Real_valued_topological_data,
- public Abs_Topological_data_with_averages,
- public Abs_Topological_data_with_scalar_product
+class Persistence_landscape
{
public:
/**
@@ -326,16 +317,39 @@ public:
- //concretization of abstract functions:
+
+
+
+
+
+
+
+
+
+
+
+ //Implementations of functions for various concepts.
/**
* The number of projections to R is defined to the number of nonzero landscape functions. I-th projection is an integral of i-th landscape function over whole R.
+ * This function is required by the Real_valued_topological_data concept.
**/
double project_to_R( int number_of_function )
{
return this->compute_integral_of_landscape( (size_t)number_of_function );
}
+
+ /**
+ * The function gives the number of possible projections to R. This function is required by the Real_valued_topological_data concept.
+ **/
+ size_t number_of_projections_to_R()
+ {
+ return this->number_of_functions_for_projections_to_reals;
+ }
+ /**
+ * This function produce a vector of doubles based on a landscape. It is required in a concept Vectorized_topological_data
+ */
std::vector<double> vectorize( int number_of_function )
{
//TODO, think of something smarter over here
@@ -351,14 +365,28 @@ public:
}
return v;
}
- void compute_average( const std::vector< Abs_Topological_data_with_averages* >& to_average )
+ /**
+ * This function return the number of functions that allows vectorization of persistence laandscape. It is required in a concept Vectorized_topological_data.
+ **/
+ size_t number_of_vectorize_functions()
+ {
+ return this->number_of_functions_for_vectorization;
+ }
+
+ /**
+ * A function to compute averaged persistence landscape, based on vector of persistence landscapes.
+ * This function is required by Topological_data_with_averages concept.
+ **/
+ void compute_average( const std::vector< Persistence_landscape* >& to_average )
{
- bool dbg = false;
+ bool dbg = false;
+
+ if ( dbg ){std::cerr << "to_average.size() : " << to_average.size() << std::endl;}
std::vector< Persistence_landscape* > nextLevelMerge( to_average.size() );
for ( size_t i = 0 ; i != to_average.size() ; ++i )
{
- nextLevelMerge[i] = (Persistence_landscape*)to_average[i];
+ nextLevelMerge[i] = to_average[i];
}
bool is_this_first_level = true;//in the loop, we will create dynamically a unmber of intermediate complexes. We have to clean that up, but we cannot erase the initial andscapes we have
//to average. In this case, we simply check if the nextLevelMerge are the input landscapes or the ones created in that loop by usig this extra variable.
@@ -373,8 +401,8 @@ public:
if ( dbg ){cerr << "i : " << i << endl;}
Persistence_landscape* l = new Persistence_landscape;
if ( i+1 != nextLevelMerge.size() )
- {
- (*l) = (*nextLevelMerge[i])+(*nextLevelMerge[i+1]);
+ {
+ (*l) = (*nextLevelMerge[i])+(*nextLevelMerge[i+1]);
}
else
{
@@ -382,7 +410,7 @@ public:
}
nextNextLevelMerge.push_back( l );
}
- if ( dbg ){cerr << "After this iteration \n";}
+ if ( dbg ){cerr << "After this iteration \n";getchar();}
if ( !is_this_first_level )
{
@@ -400,23 +428,53 @@ public:
}
- double distance( const Abs_Topological_data_with_distances* second , double power = 1 )
+ /**
+ * A function to compute distance between persistence landscape.
+ * The parameter of this functionis a Persistence_landscape.
+ * This function is required in Topological_data_with_distances concept.
+ **/
+ double distance( const Persistence_landscape& second , double power = 1 )
{
if ( power != -1 )
{
- return compute_discance_of_landscapes( *this , *((Persistence_landscape*)second) , power );
+ return compute_discance_of_landscapes( *this , second , power );
}
else
{
- return compute_max_norm_discance_of_landscapes( *this , *((Persistence_landscape*)second) );
+ return compute_max_norm_discance_of_landscapes( *this , second );
}
}
- double compute_scalar_product( const Abs_Topological_data_with_scalar_product* second )
+ /**
+ * A function to compute scalar product of persistence landscapes.
+ * The parameter of this functionis a Persistence_landscape.
+ * This function is required in Topological_data_with_scalar_product concept.
+ **/
+ double compute_scalar_product( const Persistence_landscape& second )
{
- return compute_inner_product( (*this) , *((Persistence_landscape*)second) );
- }
+ return compute_inner_product( (*this) , second );
+ }
+ //end of implementation of functions needed for concepts.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
std::vector< std::vector< std::pair<double,double> > > output_for_visualization()
@@ -431,6 +489,8 @@ public:
protected:
std::vector< std::vector< std::pair<double,double> > > land;
+ size_t number_of_functions_for_vectorization;
+ size_t number_of_functions_for_projections_to_reals;
void construct_persistence_landscape_from_barcode( const std::vector< std::pair< double , double > > & p );
Persistence_landscape multiply_lanscape_by_real_number_not_overwrite( double x )const;
@@ -1019,6 +1079,16 @@ Persistence_landscape operation_on_pair_of_landscapes ( const Persistence_landsc
std::vector< std::vector< std::pair<double,double> > > land( std::max( land1.land.size() , land2.land.size() ) );
result.land = land;
T oper;
+
+ if ( operation_on_pair_of_landscapesDBG )
+ {
+ for ( size_t i = 0 ; i != std::min( land1.land.size() , land2.land.size() ) ; ++i )
+ {
+ std::cerr << "land1.land[" << i << "].size() : " << land1.land[i].size() << std::endl;
+ std::cerr << "land2.land[" << i << "].size() : " << land2.land[i].size() << std::endl;
+ }
+ getchar();
+ }
for ( size_t i = 0 ; i != std::min( land1.land.size() , land2.land.size() ) ; ++i )
{
@@ -1031,8 +1101,13 @@ Persistence_landscape operation_on_pair_of_landscapes ( const Persistence_landsc
{
std::cerr << "p : " << p << "\n";
std::cerr << "q : " << q << "\n";
+ std::cerr << "land1.land.size() : " << land1.land.size() << std::endl;
+ std::cerr << "land2.land.size() : " << land2.land.size() << std::endl;
+ std::cerr << "land1.land[" << i << "].size() : " << land1.land[i].size() << std::endl;
+ std::cerr << "land2.land[" << i << "].size() : " << land2.land[i].size() << std::endl;
std::cout << "land1.land[i][p].first : " << land1.land[i][p].first << "\n";
std::cout << "land2.land[i][q].first : " << land2.land[i][q].first << "\n";
+ //getchar();
}
if ( land1.land[i][p].first < land2.land[i][q].first )
@@ -1070,7 +1145,7 @@ Persistence_landscape operation_on_pair_of_landscapes ( const Persistence_landsc
lambda_n.push_back( std::make_pair( land2.land[i][q].first , oper( land1.land[i][p].second , land2.land[i][q].second ) ) );
++p;++q;
}
- if (operation_on_pair_of_landscapesDBG){std::cout << "Next iteration \n";getchar();}
+ if (operation_on_pair_of_landscapesDBG){std::cout << "Next iteration \n";}
}
while ( (p+1 < land1.land[i].size())&&(q+1 >= land2.land[i].size()) )
{
@@ -1125,7 +1200,7 @@ Persistence_landscape operation_on_pair_of_landscapes ( const Persistence_landsc
result.land[i].swap(lambda_n);
}
}
- if ( operation_on_pair_of_landscapesDBG ){std::cout << "operation_on_pair_of_landscapes\n";std::cin.ignore();}
+ if ( operation_on_pair_of_landscapesDBG ){std::cout << "operation_on_pair_of_landscapes END\n";std::cin.ignore();}
return result;
}//operation_on_pair_of_landscapes
diff --git a/src/Gudhi_stat/include/gudhi/concretizations/Persistence_landscape_on_grid.h b/src/Gudhi_stat/include/gudhi/concretizations/Persistence_landscape_on_grid.h
index 988c9f16..80c6628d 100644
--- a/src/Gudhi_stat/include/gudhi/concretizations/Persistence_landscape_on_grid.h
+++ b/src/Gudhi_stat/include/gudhi/concretizations/Persistence_landscape_on_grid.h
@@ -36,11 +36,7 @@
//gudhi include
-#include <gudhi/abstract_classes/Abs_Vectorized_topological_data.h>
-#include <gudhi/abstract_classes/Abs_Topological_data_with_averages.h>
-#include <gudhi/abstract_classes/Abs_Topological_data_with_distances.h>
-#include <gudhi/abstract_classes/Abs_Real_valued_topological_data.h>
-#include <gudhi/abstract_classes/Abs_Topological_data_with_scalar_product.h>
+
#include <gudhi/concretizations/read_persitence_from_file.h>
#include <gudhi/common_gudhi_stat.h>
@@ -54,12 +50,9 @@ namespace Gudhi
namespace Gudhi_stat
{
-class Persistence_landscape_on_grid :
- public Abs_Vectorized_topological_data ,
- public Abs_Topological_data_with_distances,
- public Abs_Real_valued_topological_data,
- public Abs_Topological_data_with_averages,
- public Abs_Topological_data_with_scalar_product
+
+//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
+class Persistence_landscape_on_grid
{
public:
/**
@@ -700,20 +693,120 @@ public:
}
return result;
}
+
+
+ /**
+ * Computations of L^{p} distance between two landscapes on a grid. p is the parameter of the procedure.
+ **/
+ friend double compute_discance_of_landscapes_on_grid( const Persistence_landscape_on_grid& first, const Persistence_landscape_on_grid& second , int p )
+ {
+ bool dbg = false;
+ //This is what we want to compute: (\int_{- \infty}^{+\infty}| first-second |^p)^(1/p). We will do it one step at a time:
+
+ if ( dbg )
+ {
+ cerr << "first : " << first << endl;
+ cerr << "second : " << second << endl;
+ getchar();
+ }
+
+ //first-second :
+ Persistence_landscape_on_grid lan = first-second;
+
+ if ( dbg )
+ {
+ cerr << "Difference : " << lan << endl;
+ }
+
+ //| first-second |:
+ lan.abs();
+
+ if ( dbg )
+ {
+ cerr << "Abs : " << lan << endl;
+ }
+
+ if ( p != -1 )
+ {
+ //\int_{- \infty}^{+\infty}| first-second |^p
+ double result;
+ if ( p != 1 )
+ {
+ if (dbg){cerr << "p : " << p << endl; getchar();}
+ result = lan.compute_integral_of_landscape( (double)p );
+ if (dbg){cerr << "integral : " << result << endl;getchar();}
+ }
+ else
+ {
+ result = lan.compute_integral_of_landscape();
+ if (dbg){cerr << "integral, wihtout power : " << result << endl;getchar();}
+ }
+ //(\int_{- \infty}^{+\infty}| first-second |^p)^(1/p)
+ return pow( result , 1/(double)p );
+ }
+ else
+ {
+ //p == -1
+ return lan.compute_maximum();
+ }
+ }
+
+
+
+
+
+
+
+
+
- //concretization of abstract functions:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ //Functions that are needed for that class to implement the concept.
/**
* The number of projections to R is defined to the number of nonzero landscape functions. I-th projection is an integral of i-th landscape function over whole R.
+ * This function is required by the Real_valued_topological_data concept.
**/
double project_to_R( int number_of_function )
{
return this->compute_integral_of_landscape( (size_t)number_of_function );
}
+
+ /**
+ * The function gives the number of possible projections to R. This function is required by the Real_valued_topological_data concept.
+ **/
+ size_t number_of_projections_to_R()
+ {
+ return number_of_functions_for_projections_to_reals;
+ }
+
+
+
+ /**
+ * This function produce a vector of doubles based on a landscape. It is required in a concept Vectorized_topological_data
+ */
std::vector<double> vectorize( int number_of_function )
{
//TODO, think of something smarter over here
@@ -726,14 +819,27 @@ public:
}
/**
- * A function to compute averaged persistence landscape on a grid, based on vector of persistence landscapes on grid (projected to Abs_Topological_data_with_averages*, since this is a concretization of a virtual method.
+ * This function return the number of functions that allows vectorization of persistence laandscape. It is required in a concept Vectorized_topological_data.
+ **/
+ size_t number_of_vectorize_functions()
+ {
+ return number_of_functions_for_vectorization;
+ }
+
+
+
+
+
+ /**
+ * A function to compute averaged persistence landscape on a grid, based on vector of persistence landscapes on grid.
+ * This function is required by Topological_data_with_averages concept.
**/
- void compute_average( const std::vector< Abs_Topological_data_with_averages* >& to_average )
+ void compute_average( const std::vector< Persistence_landscape_on_grid* >& to_average )
{
bool dbg = false;
//After execution of this procedure, the average is supposed to be in the current object. To make sure that this is the case, we need to do some cleaning first.
- this->values_of_landscapes.clear();
+ this->values_of_landscapes .clear();
this->grid_min = this->grid_max = 0;
//if there is nothing to averate, then the average is a zero landscape.
@@ -792,86 +898,52 @@ public:
/**
- * Computations of L^{p} distance between two landscapes on a grid. p is the parameter of the procedure.
- **/
- friend double compute_discance_of_landscapes_on_grid( const Persistence_landscape_on_grid& first, const Persistence_landscape_on_grid& second , int p )
- {
- bool dbg = false;
- //This is what we want to compute: (\int_{- \infty}^{+\infty}| first-second |^p)^(1/p). We will do it one step at a time:
-
- if ( dbg )
- {
- cerr << "first : " << first << endl;
- cerr << "second : " << second << endl;
- getchar();
- }
-
- //first-second :
- Persistence_landscape_on_grid lan = first-second;
-
- if ( dbg )
- {
- cerr << "Difference : " << lan << endl;
- }
-
- //| first-second |:
- lan.abs();
-
- if ( dbg )
- {
- cerr << "Abs : " << lan << endl;
- }
-
- if ( p != -1 )
- {
- //\int_{- \infty}^{+\infty}| first-second |^p
- double result;
- if ( p != 1 )
- {
- if (dbg){cerr << "p : " << p << endl; getchar();}
- result = lan.compute_integral_of_landscape( (double)p );
- if (dbg){cerr << "integral : " << result << endl;getchar();}
- }
- else
- {
- result = lan.compute_integral_of_landscape();
- if (dbg){cerr << "integral, wihtout power : " << result << endl;getchar();}
- }
- //(\int_{- \infty}^{+\infty}| first-second |^p)^(1/p)
- return pow( result , 1/(double)p );
- }
- else
- {
- //p == -1
- return lan.compute_maximum();
- }
- }
-
- /**
* A function to compute distance between persistence landscape on a grid.
- * The parameter of this functionis a persistence landscapes on grid (projected to Abs_Topological_data_with_averages*, since this is a concretization of a virtual method.
+ * The parameter of this functionis a Persistence_landscape_on_grid.
+ * This function is required in Topological_data_with_distances concept.
**/
- double distance( const Abs_Topological_data_with_distances* second , double power = 1 )
+ double distance( const Persistence_landscape_on_grid& second , double power = 1 )
{
if ( power != -1 )
{
- return compute_discance_of_landscapes_on_grid( *this , *((Persistence_landscape_on_grid*)second) , power );
+ return compute_discance_of_landscapes_on_grid( *this , second , power );
}
else
{
- return compute_max_norm_discance_of_landscapes( *this , *((Persistence_landscape_on_grid*)second) );
+ return compute_max_norm_discance_of_landscapes( *this , second );
}
}
/**
* A function to compute scalar product of persistence landscape on a grid.
- * The parameter of this functionis a persistence landscapes on grid (projected to Abs_Topological_data_with_averages*, since this is a concretization of a virtual method.
+ * The parameter of this functionis a Persistence_landscape_on_grid.
+ * This function is required in Topological_data_with_scalar_product concept.
**/
- double compute_scalar_product( const Abs_Topological_data_with_scalar_product* second )
+ double compute_scalar_product( const Persistence_landscape_on_grid& second )
{
- return compute_inner_product( (*this) , *((Persistence_landscape_on_grid*)second) );
+ return compute_inner_product( (*this) , second );
}
+ //end of implementation of functions needed for concepts.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
/**
* A function that returns values of landsapes. It can be used for vizualization
@@ -891,6 +963,8 @@ protected:
double grid_min;
double grid_max;
std::vector< std::vector< double > > values_of_landscapes;
+ size_t number_of_functions_for_vectorization;
+ size_t number_of_functions_for_projections_to_reals;
void set_up_numbers_of_functions_for_vectorization_and_projections_to_reals()
{
diff --git a/src/Gudhi_stat/include/gudhi/concretizations/Vector_distances_in_diagram.h b/src/Gudhi_stat/include/gudhi/concretizations/Vector_distances_in_diagram.h
index bb350040..7211f6eb 100644
--- a/src/Gudhi_stat/include/gudhi/concretizations/Vector_distances_in_diagram.h
+++ b/src/Gudhi_stat/include/gudhi/concretizations/Vector_distances_in_diagram.h
@@ -30,12 +30,7 @@
#include <iostream>
#include <limits>
-
-#include <gudhi/abstract_classes/Abs_Vectorized_topological_data.h>
-#include <gudhi/abstract_classes/Abs_Topological_data_with_averages.h>
-#include <gudhi/abstract_classes/Abs_Topological_data_with_distances.h>
-#include <gudhi/abstract_classes/Abs_Real_valued_topological_data.h>
-#include <gudhi/abstract_classes/Abs_Topological_data_with_scalar_product.h>
+//gudhi include
#include <gudhi/concretizations/read_persitence_from_file.h>
#include <gudhi/common_gudhi_stat.h>
using namespace std;
@@ -67,16 +62,13 @@ 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
-* either Eucludean of maximum (Manhattan) distance.
+* 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
+*
**/
template <typename F>
-class Vector_distances_in_diagram :
- public Abs_Vectorized_topological_data,
- public Abs_Topological_data_with_distances,
- public Abs_Real_valued_topological_data,
- public Abs_Topological_data_with_averages,
- public Abs_Topological_data_with_scalar_product
+class Vector_distances_in_diagram
{
public:
/**
@@ -168,31 +160,66 @@ public:
return !( *this == second );
}
- //concretization of abstract methods:
+
+
+
+ //Implementations of functions for various concepts.
/**
- * Compute projection to real numbers of persistence vector.
+ * Compute projection to real numbers of persistence vector. This function is required by the Real_valued_topological_data concept
**/
double project_to_R( int number_of_function );
+ /**
+ * The function gives the number of possible projections to R. This function is required by the Real_valued_topological_data concept.
+ **/
+ size_t number_of_projections_to_R()
+ {
+ return this->number_of_functions_for_projections_to_reals;
+ }
/**
- * Compute a vectorization of a persistent vectors.
+ * Compute a vectorization of a persistent vectors. It is required in a concept Vectorized_topological_data.
**/
std::vector<double> vectorize( int number_of_function );
+ /**
+ * This function return the number of functions that allows vectorization of a persisence vector. It is required in a concept Vectorized_topological_data.
+ **/
+ size_t number_of_vectorize_functions()
+ {
+ return this->number_of_functions_for_vectorization;
+ }
/**
- * Compute a average of two persistent vectors.
+ * Compute a average of two persistent vectors. This function is required by Topological_data_with_averages concept.
**/
- void compute_average( const std::vector< Abs_Topological_data_with_averages* >& to_average );
+ void compute_average( const std::vector< Vector_distances_in_diagram* >& to_average );
/**
- * Compute a distance of two persistent vectors.
+ * Compute a distance of two persistent vectors. This function is required in Topological_data_with_distances concept.
**/
- double distance( const Abs_Topological_data_with_distances* second , double power = 1);
+ double distance( const Vector_distances_in_diagram& second , double power = 1);
/**
- * Compute a scalar product of two persistent vectors.
+ * Compute a scalar product of two persistent vectors. This function is required in Topological_data_with_scalar_product concept.
**/
- double compute_scalar_product( const Abs_Topological_data_with_scalar_product* second );
+ double compute_scalar_product( const Vector_distances_in_diagram& second );
+ //end of implementation of functions needed for concepts.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
/**
* For visualization use output from vectorize and build histograms.
@@ -202,6 +229,7 @@ public:
return this->sorted_vector_of_distances;
}
+
/**
* Create a gnuplot script to vizualize the data structure.
**/
@@ -228,6 +256,9 @@ public:
private:
std::vector< std::pair< double , double > > intervals;
std::vector< double > sorted_vector_of_distances;
+ size_t number_of_functions_for_vectorization;
+ size_t number_of_functions_for_projections_to_reals;
+ size_t where_to_cut;
void compute_sorted_vector_of_distances_via_heap( size_t where_to_cut );
void compute_sorted_vector_of_distances_via_vector_sorting( size_t where_to_cut );
@@ -247,7 +278,7 @@ private:
template <typename F>
-Vector_distances_in_diagram<F>::Vector_distances_in_diagram( const std::vector< std::pair< double,double > >& intervals_ , size_t where_to_cut ):Abs_Vectorized_topological_data(where_to_cut)
+Vector_distances_in_diagram<F>::Vector_distances_in_diagram( const std::vector< std::pair< double,double > >& intervals_ , size_t where_to_cut_ ):where_to_cut(where_to_cut_)
{
std::vector< std::pair< double,double > > i( intervals_ );
this->intervals = i;
@@ -279,7 +310,7 @@ Vector_distances_in_diagram<F>& Vector_distances_in_diagram<F>::operator =( cons
template <typename F>
-Vector_distances_in_diagram<F>::Vector_distances_in_diagram( const char* filename , size_t where_to_cut ):Abs_Vectorized_topological_data(where_to_cut)
+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 );
@@ -425,7 +456,7 @@ void Vector_distances_in_diagram<F>::compute_sorted_vector_of_distances_via_vect
-//concretization of abstract methods:
+//Implementations of functions for various concepts.
template <typename F>
double Vector_distances_in_diagram<F>::project_to_R( int number_of_function )
{
@@ -441,7 +472,7 @@ double Vector_distances_in_diagram<F>::project_to_R( int number_of_function )
}
template <typename F>
-void Vector_distances_in_diagram<F>::compute_average( const std::vector< Abs_Topological_data_with_averages* >& to_average )
+void Vector_distances_in_diagram<F>::compute_average( const std::vector< Vector_distances_in_diagram* >& to_average )
{
if ( to_average.size() == 0 )
@@ -452,23 +483,19 @@ void Vector_distances_in_diagram<F>::compute_average( const std::vector< Abs_Top
size_t maximal_length_of_vector = 0;
for ( size_t i = 0 ; i != to_average.size() ; ++i )
- {
- Vector_distances_in_diagram<F>* current = (Vector_distances_in_diagram<F>*)to_average[i];
- if ( current->sorted_vector_of_distances.size() > maximal_length_of_vector )
+ {
+ if ( to_average[i]->sorted_vector_of_distances.size() > maximal_length_of_vector )
{
- maximal_length_of_vector = current->sorted_vector_of_distances.size();
+ maximal_length_of_vector = to_average[i]->sorted_vector_of_distances.size();
}
- }
-
- //cerr << "maximal_length_of_vector : " << maximal_length_of_vector << endl;
+ }
std::vector< double > av( maximal_length_of_vector , 0 );
for ( size_t i = 0 ; i != to_average.size() ; ++i )
- {
- Vector_distances_in_diagram<F>* current = (Vector_distances_in_diagram<F>*)to_average[i];
- for ( size_t j = 0 ; j != current->sorted_vector_of_distances.size() ; ++j )
+ {
+ for ( size_t j = 0 ; j != to_average[i]->sorted_vector_of_distances.size() ; ++j )
{
- av[j] += current->sorted_vector_of_distances[j];
+ av[j] += to_average[i]->sorted_vector_of_distances[j];
}
}
@@ -481,7 +508,7 @@ void Vector_distances_in_diagram<F>::compute_average( const std::vector< Abs_Top
}
template <typename F>
-double Vector_distances_in_diagram<F>::distance( const Abs_Topological_data_with_distances* second , double power )
+double Vector_distances_in_diagram<F>::distance( const Vector_distances_in_diagram& second_ , double power )
{
bool dbg = false;
@@ -490,47 +517,45 @@ double Vector_distances_in_diagram<F>::distance( const Abs_Topological_data_with
std::cerr << "Entering double Vector_distances_in_diagram<F>::distance( const Abs_Topological_data_with_distances* second , double power ) procedure \n";
std::cerr << "Power : " << power << std::endl;
std::cerr << "This : " << *this << std::endl;
- std::cerr << "second : " << *((Vector_distances_in_diagram<F>*)second) << std::endl;
- }
-
- Vector_distances_in_diagram<F>* second_ = ((Vector_distances_in_diagram<F>*)second);
+ std::cerr << "second : " << second_ << std::endl;
+ }
double result = 0;
- for ( size_t i = 0 ; i != std::min(this->sorted_vector_of_distances.size(), second_->sorted_vector_of_distances.size()) ; ++i )
+ for ( size_t i = 0 ; i != std::min(this->sorted_vector_of_distances.size(), second_.sorted_vector_of_distances.size()) ; ++i )
{
if ( power == 1 )
{
if ( dbg )
{
- cerr << "|" << this->sorted_vector_of_distances[i] << " - " << second_->sorted_vector_of_distances[i] << " | : " << fabs( this->sorted_vector_of_distances[i] - second_->sorted_vector_of_distances[i] ) << endl;
+ cerr << "|" << this->sorted_vector_of_distances[i] << " - " << second_.sorted_vector_of_distances[i] << " | : " << fabs( this->sorted_vector_of_distances[i] - second_.sorted_vector_of_distances[i] ) << endl;
}
- result += fabs( this->sorted_vector_of_distances[i] - second_->sorted_vector_of_distances[i] );
+ result += fabs( this->sorted_vector_of_distances[i] - second_.sorted_vector_of_distances[i] );
}
else
{
- result += std::pow( fabs( this->sorted_vector_of_distances[i] - second_->sorted_vector_of_distances[i] ) , power );
+ result += std::pow( fabs( this->sorted_vector_of_distances[i] - second_.sorted_vector_of_distances[i] ) , power );
if ( dbg )
{
- cerr << "| " << this->sorted_vector_of_distances[i] << " - " << second_->sorted_vector_of_distances[i] << " : " << fabs( this->sorted_vector_of_distances[i] - second_->sorted_vector_of_distances[i] ) << endl;
+ cerr << "| " << this->sorted_vector_of_distances[i] << " - " << second_.sorted_vector_of_distances[i] << " : " << fabs( this->sorted_vector_of_distances[i] - second_.sorted_vector_of_distances[i] ) << endl;
}
}
}
- if ( this->sorted_vector_of_distances.size() != second_->sorted_vector_of_distances.size() )
+ if ( this->sorted_vector_of_distances.size() != second_.sorted_vector_of_distances.size() )
{
- if ( this->sorted_vector_of_distances.size() > second_->sorted_vector_of_distances.size() )
+ if ( this->sorted_vector_of_distances.size() > second_.sorted_vector_of_distances.size() )
{
- for ( size_t i = second_->sorted_vector_of_distances.size() ; i != this->sorted_vector_of_distances.size() ; ++i )
+ for ( size_t i = second_.sorted_vector_of_distances.size() ; i != this->sorted_vector_of_distances.size() ; ++i )
{
result += fabs( this->sorted_vector_of_distances[i] );
}
}
else
{
- //this->sorted_vector_of_distances.size() < second_->sorted_vector_of_distances.size()
- for ( size_t i = this->sorted_vector_of_distances.size() ; i != second_->sorted_vector_of_distances.size() ; ++i )
+ //this->sorted_vector_of_distances.size() < second_.sorted_vector_of_distances.size()
+ for ( size_t i = this->sorted_vector_of_distances.size() ; i != second_.sorted_vector_of_distances.size() ; ++i )
{
- result += fabs( second_->sorted_vector_of_distances[i] );
+ result += fabs( second_.sorted_vector_of_distances[i] );
}
}
}
@@ -595,14 +620,12 @@ void Vector_distances_in_diagram<F>::load_from_file( const char* filename )
}
template < typename F>
-double Vector_distances_in_diagram<F>::compute_scalar_product( const Abs_Topological_data_with_scalar_product* second )
+double Vector_distances_in_diagram<F>::compute_scalar_product( const Vector_distances_in_diagram& second_vector )
{
- Vector_distances_in_diagram<F>* second_vector = (Vector_distances_in_diagram<F>*)second;
-
double result = 0;
- for ( size_t i = 0 ; i != std::min(this->sorted_vector_of_distances.size(),second_vector->sorted_vector_of_distances.size()) ; ++i )
+ for ( size_t i = 0 ; i != std::min(this->sorted_vector_of_distances.size(),second_vector.sorted_vector_of_distances.size()) ; ++i )
{
- result += this->sorted_vector_of_distances[i] * second_vector->sorted_vector_of_distances[i];
+ result += this->sorted_vector_of_distances[i] * second_vector.sorted_vector_of_distances[i];
}
return result;
}
diff --git a/src/Gudhi_stat/include/gudhi/concretizations/read_persitence_from_file.h b/src/Gudhi_stat/include/gudhi/concretizations/read_persitence_from_file.h
index 519c44fa..0a740996 100644
--- a/src/Gudhi_stat/include/gudhi/concretizations/read_persitence_from_file.h
+++ b/src/Gudhi_stat/include/gudhi/concretizations/read_persitence_from_file.h
@@ -47,7 +47,7 @@ std::vector< std::pair< double,double > > read_file_names_that_may_contain_inf_s
if ( !( access( filename, F_OK ) != -1 ) )
{
- cerr << "The file : " << filename << " do not exist. The program will now terminate \n";
+ std::cerr << "The file : " << filename << " do not exist. The program will now terminate \n";
throw "The file from which you are trying to read do not exist. The program will now terminate \n";
}
@@ -111,7 +111,7 @@ std::vector< std::string > readFileNames( char* filenameWithFilenames )
if ( !( access( filenameWithFilenames, F_OK ) != -1 ) )
{
- cerr << "The file : " << filename << " do not exist. The program will now terminate \n";
+ std::cerr << "The file : " << filenameWithFilenames << " do not exist. The program will now terminate \n";
throw "The file from which you are trying to read do not exist. The program will now terminate \n";
}
@@ -174,6 +174,7 @@ std::vector< std::pair< double , double > > read_standard_file( const char* file
double beginn, endd;
lineSS >> beginn;
lineSS >> endd;
+ if ( beginn == endd )continue;
if ( beginn > endd )
{
double b = beginn;
diff --git a/src/Gudhi_stat/include/gudhi/permutation_test.h b/src/Gudhi_stat/include/gudhi/permutation_test.h
new file mode 100644
index 00000000..18b94eab
--- /dev/null
+++ b/src/Gudhi_stat/include/gudhi/permutation_test.h
@@ -0,0 +1,80 @@
+/* This file is part of the Gudhi Library. 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 PERMUTATION_TEST_H
+#define PERMUTATION_TEST_H
+
+
+//concretizations
+#include <vector>
+#include <iostream>
+#include <cstdlib>
+#include <algorithm>
+#include <gudhi/concretizations/read_persitence_from_file.h>
+
+using namespace std;
+
+namespace Gudhi
+{
+namespace Gudhi_stat
+{
+
+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 )
+{
+ try
+ {
+ Representation_of_persistence* av_1 = new Representation_of_persistence;
+ av_1->compute_average( data_1 );
+ Representation_of_persistence* av_2 = new Representation_of_persistence;
+ av_2->compute_average( data_2 );
+ double initial_distance = av_1->distance( *av_2 , exponent );
+ double counter = 0;
+
+ for ( size_t i = 0 ; i != number_of_permutations ; ++i )
+ {
+ std::vector<Representation_of_persistence*> all_data;
+ all_data.insert(all_data.end() , data_1.begin() , data_1.end() );
+ all_data.insert(all_data.end() , data_2.begin() , data_2.end() );
+ std::random_shuffle( all_data.begin() , all_data.end() );
+
+ std::vector<Representation_of_persistence*> first_part(&all_data[0],&all_data[data_1.size()]);
+ std::vector<Representation_of_persistence*> second_part(&all_data[data_1.size()],&all_data[all_data.size()]);
+
+ av_1->compute_average( first_part );
+ av_2->compute_average( second_part );
+ double distance_after_permutations = av_1->distance( *av_2 , exponent );
+ if ( distance_after_permutations > initial_distance )++counter;
+ }
+ return counter / (double)number_of_permutations;
+ }
+ catch (...)
+ {
+ std::cout << "The data structure do not support the operations that are neccessay for a permutation test (averaging, distances) \n";
+ }
+ return 0;
+}//permutation_test
+
+}//Gudhi_stat
+}//Gudhi
+
+#endif
diff --git a/src/Gudhi_stat/include/gudhi/topological_process.h b/src/Gudhi_stat/include/gudhi/topological_process.h
new file mode 100644
index 00000000..d8d8e696
--- /dev/null
+++ b/src/Gudhi_stat/include/gudhi/topological_process.h
@@ -0,0 +1,101 @@
+/* This file is part of the Gudhi Library. 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 PERMUTATION_TEST_H
+#define PERMUTATION_TEST_H
+//abstract classes:
+#include <gudhi/abstract_classes/Abs_Topological_data.h>
+#include <gudhi/abstract_classes/Abs_Topological_data_with_averages.h>
+#include <gudhi/abstract_classes/Abs_Topological_data_with_distances.h>
+
+
+//concretizations
+#include <gudhi/concretizations/Vector_distances_in_diagram.h>
+#include <gudhi/concretizations/Persistence_landscape.h>
+#include <gudhi/concretizations/Persistence_landscape_on_grid.h>
+#include <vector>
+
+//extras
+#include <gudhi/common_gudhi_stat.h>
+
+namespace Gudhi
+{
+namespace Gudhi_stat
+{
+
+template <typename Representation>
+class Topological_process
+{
+public:
+ Topological_process();
+ Topological_process( const std::vetor< Representation* >& data_ ):data(data_){}
+ Topological_process( const char* filename );//we assume that the filename contains a list of files with the diagrams.
+ double distance( const Topological_process& second )
+ {
+ if ( this->data.size() != second.data.size() )
+ {
+ throw "Incompatible lengths of topological processes, we cannot compute the distance in this case \n";
+ }
+ double result = 0;
+ for ( size_t i = 0 ; i != this->data.size() ; ++i )
+ {
+ result += this->data[i].distance( secod.data[i] );
+ }
+ return result;
+ }
+
+ compute_average( const std::vector< Representation* >& to_average )
+ {
+ //since we will substitute whatever data we have in this object with an average, we clear the data in this object first:
+ this->data.clear();
+ //then we need to check if all the topological processes in the vector to_average have the same length.
+ if ( to_average.size() == 0 )return;
+ for ( size_t i = 1 ; i != to_average.size() ; ++i )
+ {
+ if ( to_average[0].data.size() != to_average[i].data.size )
+ {
+ throw "Incompatible lengths of topological processes, the averages cannot be computed \n";
+ }
+ }
+ }
+ //scalar products?
+ //confidence bounds?
+private:
+ std::vetor< Representation* > data;
+};
+
+template <typename Representation>
+Topological_process<Representation>::Topological_process( const char* filename )
+{
+ std::vector< std::string > filenames = readFileNames( filename );
+ this->data.reserve( filenames.size() );
+ for ( size_t file = 0 ; file != filenames.size() ; ++file )
+ {
+ std::vector< std::pair<double,double> > intervals_in_this_file = read_file_names_that_may_contain_inf_string( filenames[i] );
+ this-data[i] = new Representation( intervals_in_this_file );
+ }
+}
+
+}//Gudhi_stat
+}//Gudhi
+
+#endif
diff --git a/src/Gudhi_stat/test/persistence_heat_maps_test.cpp b/src/Gudhi_stat/test/persistence_heat_maps_test.cpp
index c4c97d72..d9cba466 100644
--- a/src/Gudhi_stat/test/persistence_heat_maps_test.cpp
+++ b/src/Gudhi_stat/test/persistence_heat_maps_test.cpp
@@ -61,10 +61,10 @@ BOOST_AUTO_TEST_CASE(check_averages_of_heat_maps)
Persistence_heat_maps q( "data/file_with_diagram_1" , filter , constant_function, false , 1000 , 0 , 10 );
Persistence_heat_maps r( "data/file_with_diagram_2" , filter , constant_function, false , 1000 , 0 , 10 );
- std::vector< Abs_Topological_data_with_averages* > to_average;
- to_average.push_back( (Abs_Topological_data_with_averages*)(&p) );
- to_average.push_back( (Abs_Topological_data_with_averages*)(&q) );
- to_average.push_back( (Abs_Topological_data_with_averages*)(&r) );
+ std::vector< Persistence_heat_maps* > to_average;
+ to_average.push_back( &p );
+ to_average.push_back( &q );
+ to_average.push_back( &r );
Persistence_heat_maps av;
av.compute_average( to_average );
@@ -164,28 +164,28 @@ BOOST_AUTO_TEST_CASE(check_distance_for_heat_maps)
Persistence_heat_maps q( "data/file_with_diagram_1" , filter , constant_function, false , 1000 , 0 , 1 );
Persistence_heat_maps r( "data/file_with_diagram_2" , filter , constant_function, false , 1000 , 0 , 1 );
- //cerr << p.distance( (Abs_Topological_data_with_distances*)&p ) << endl;
- //cerr << p.distance( (Abs_Topological_data_with_distances*)&q ) << endl;
- //cerr << p.distance( (Abs_Topological_data_with_distances*)&r ) << endl;
- //cerr << q.distance( (Abs_Topological_data_with_distances*)&p ) << endl;
- //cerr << q.distance( (Abs_Topological_data_with_distances*)&q ) << endl;
- //cerr << q.distance( (Abs_Topological_data_with_distances*)&r ) << endl;
- //cerr << r.distance( (Abs_Topological_data_with_distances*)&p ) << endl;
- //cerr << r.distance( (Abs_Topological_data_with_distances*)&q ) << endl;
- //cerr << r.distance( (Abs_Topological_data_with_distances*)&r ) << endl;
+ //cerr << p.distance( p ) << endl;
+ //cerr << p.distance( q ) << endl;
+ //cerr << p.distance( r ) << endl;
+ //cerr << q.distance( p ) << endl;
+ //cerr << q.distance( q ) << endl;
+ //cerr << q.distance( r ) << endl;
+ //cerr << r.distance( p ) << endl;
+ //cerr << r.distance( q ) << endl;
+ //cerr << r.distance( r ) << endl;
//0 624.183 415.815
//624.183 0 528.06Z
//415.815 528.066 0
- BOOST_CHECK( fabs( p.distance( (Abs_Topological_data_with_distances*)&p ) - 0) < 0.0005);
- BOOST_CHECK( fabs( p.distance( (Abs_Topological_data_with_distances*)&q ) - 624.183)< 0.0005);
- BOOST_CHECK( fabs( p.distance( (Abs_Topological_data_with_distances*)&r ) - 415.815)< 0.0005);
- BOOST_CHECK( fabs( q.distance( (Abs_Topological_data_with_distances*)&p ) - 624.183)< 0.0005);
- BOOST_CHECK( fabs( q.distance( (Abs_Topological_data_with_distances*)&q ) - 0)< 0.0005);
- BOOST_CHECK( fabs( q.distance( (Abs_Topological_data_with_distances*)&r ) - 528.066)< 0.0005);
- BOOST_CHECK( fabs( r.distance( (Abs_Topological_data_with_distances*)&p ) - 415.815)< 0.0005);
- BOOST_CHECK( fabs( r.distance( (Abs_Topological_data_with_distances*)&q ) - 528.066)< 0.0005);
- BOOST_CHECK( fabs( r.distance( (Abs_Topological_data_with_distances*)&r ) - 0)< 0.0005);
+ BOOST_CHECK( fabs( p.distance( p ) - 0) < 0.0005);
+ BOOST_CHECK( fabs( p.distance( q ) - 624.183)< 0.0005);
+ BOOST_CHECK( fabs( p.distance( r ) - 415.815)< 0.0005);
+ BOOST_CHECK( fabs( q.distance( p ) - 624.183)< 0.0005);
+ BOOST_CHECK( fabs( q.distance( q ) - 0)< 0.0005);
+ BOOST_CHECK( fabs( q.distance( r ) - 528.066)< 0.0005);
+ BOOST_CHECK( fabs( r.distance( p ) - 415.815)< 0.0005);
+ BOOST_CHECK( fabs( r.distance( q ) - 528.066)< 0.0005);
+ BOOST_CHECK( fabs( r.distance( r ) - 0)< 0.0005);
}
@@ -214,25 +214,25 @@ BOOST_AUTO_TEST_CASE(check_scalar_products_for_heat_maps)
Persistence_heat_maps q( "data/file_with_diagram_1" , filter , constant_function, false , 1000 , 0 , 1 );
Persistence_heat_maps r( "data/file_with_diagram_2" , filter , constant_function, false , 1000 , 0 , 1 );
- //cerr << p.compute_scalar_product( (Abs_Topological_data_with_scalar_product*)&p ) << endl;
- //cerr << p.compute_scalar_product( (Abs_Topological_data_with_scalar_product*)&q ) << endl;
- //cerr << p.compute_scalar_product( (Abs_Topological_data_with_scalar_product*)&r ) << endl;
- //cerr << q.compute_scalar_product( (Abs_Topological_data_with_scalar_product*)&p ) << endl;
- //cerr << q.compute_scalar_product( (Abs_Topological_data_with_scalar_product*)&q ) << endl;
- //cerr << q.compute_scalar_product( (Abs_Topological_data_with_scalar_product*)&r ) << endl;
- //cerr << r.compute_scalar_product( (Abs_Topological_data_with_scalar_product*)&p ) << endl;
- //cerr << r.compute_scalar_product( (Abs_Topological_data_with_scalar_product*)&q ) << endl;
- //cerr << r.compute_scalar_product( (Abs_Topological_data_with_scalar_product*)&r ) << endl;
-
-
- BOOST_CHECK( fabs( p.compute_scalar_product( (Abs_Topological_data_with_scalar_product*)&p ) - 0.0345687 )< 0.0005);
- BOOST_CHECK( fabs( p.compute_scalar_product( (Abs_Topological_data_with_scalar_product*)&q ) - 0.0509357 )< 0.0005);
- BOOST_CHECK( fabs( p.compute_scalar_product( (Abs_Topological_data_with_scalar_product*)&r ) - 0.0375608 )< 0.0005);
- BOOST_CHECK( fabs( q.compute_scalar_product( (Abs_Topological_data_with_scalar_product*)&p ) - 0.0509357 )< 0.0005);
- BOOST_CHECK( fabs( q.compute_scalar_product( (Abs_Topological_data_with_scalar_product*)&q ) - 1.31293 )< 0.0005);
- BOOST_CHECK( fabs( q.compute_scalar_product( (Abs_Topological_data_with_scalar_product*)&r ) - 0.536799)< 0.0005);
- BOOST_CHECK( fabs( r.compute_scalar_product( (Abs_Topological_data_with_scalar_product*)&p ) - 0.0375608)< 0.0005);
- BOOST_CHECK( fabs( r.compute_scalar_product( (Abs_Topological_data_with_scalar_product*)&q ) - 0.536799)< 0.0005);
- BOOST_CHECK( fabs( r.compute_scalar_product( (Abs_Topological_data_with_scalar_product*)&r ) - 0.672907)< 0.0005);
+ //cerr << p.compute_scalar_product( p ) << endl;
+ //cerr << p.compute_scalar_product( q ) << endl;
+ //cerr << p.compute_scalar_product( r ) << endl;
+ //cerr << q.compute_scalar_product( p ) << endl;
+ //cerr << q.compute_scalar_product( q ) << endl;
+ //cerr << q.compute_scalar_product( r ) << endl;
+ //cerr << r.compute_scalar_product( p ) << endl;
+ //cerr << r.compute_scalar_product( q ) << endl;
+ //cerr << r.compute_scalar_product( r ) << endl;
+
+
+ BOOST_CHECK( fabs( p.compute_scalar_product( p ) - 0.0345687 )< 0.0005);
+ BOOST_CHECK( fabs( p.compute_scalar_product( q ) - 0.0509357 )< 0.0005);
+ BOOST_CHECK( fabs( p.compute_scalar_product( r ) - 0.0375608 )< 0.0005);
+ BOOST_CHECK( fabs( q.compute_scalar_product( p ) - 0.0509357 )< 0.0005);
+ BOOST_CHECK( fabs( q.compute_scalar_product( q ) - 1.31293 )< 0.0005);
+ BOOST_CHECK( fabs( q.compute_scalar_product( r ) - 0.536799)< 0.0005);
+ BOOST_CHECK( fabs( r.compute_scalar_product( p ) - 0.0375608)< 0.0005);
+ BOOST_CHECK( fabs( r.compute_scalar_product( q ) - 0.536799)< 0.0005);
+ BOOST_CHECK( fabs( r.compute_scalar_product( r ) - 0.672907)< 0.0005);
}
diff --git a/src/Gudhi_stat/test/persistence_lanscapes_on_grid_test.cpp b/src/Gudhi_stat/test/persistence_lanscapes_on_grid_test.cpp
index d7d72d6b..17ed9fde 100644
--- a/src/Gudhi_stat/test/persistence_lanscapes_on_grid_test.cpp
+++ b/src/Gudhi_stat/test/persistence_lanscapes_on_grid_test.cpp
@@ -219,7 +219,7 @@ BOOST_AUTO_TEST_CASE(check_computations_of_averages)
{
Persistence_landscape_on_grid p( "data/file_with_diagram", 0,1,100 );
Persistence_landscape_on_grid q( "data/file_with_diagram_1", 0,1,100 );
- std::vector< Abs_Topological_data_with_averages* > to_average;
+ std::vector< Persistence_landscape_on_grid* > to_average;
to_average.push_back( &p );
to_average.push_back( &q );
Persistence_landscape_on_grid av;
@@ -237,9 +237,9 @@ BOOST_AUTO_TEST_CASE(check_computations_of_distances)
{
Persistence_landscape_on_grid p( "data/file_with_diagram", 0,1,10000 );
Persistence_landscape_on_grid q( "data/file_with_diagram_1", 0,1,10000 );
- BOOST_CHECK( fabs( p.distance( &q )- 25.5779) <= 0.00005 );
- BOOST_CHECK( fabs( p.distance( &q , 2) - 2.04891) <= 0.00001 );
- BOOST_CHECK( fabs( p.distance( &q , -1 )-0.359 ) <= 0.00001 );
+ BOOST_CHECK( fabs( p.distance( q )- 25.5779) <= 0.00005 );
+ BOOST_CHECK( fabs( p.distance( q , 2) - 2.04891) <= 0.00001 );
+ BOOST_CHECK( fabs( p.distance( q , -1 )-0.359 ) <= 0.00001 );
}
@@ -247,8 +247,8 @@ BOOST_AUTO_TEST_CASE(check_computations_of_scalar_product)
{
Persistence_landscape_on_grid p( "data/file_with_diagram" , 0,1,10000);
Persistence_landscape_on_grid q( "data/file_with_diagram_1", 0,1,10000 );
- //std::cerr << p.compute_scalar_product( &q ) << std::endl;
- BOOST_CHECK( almost_equal( p.compute_scalar_product( &q ) , p.compute_scalar_product( &q ) ) );
+ //std::cerr << p.compute_scalar_product( q ) << std::endl;
+ BOOST_CHECK( almost_equal( p.compute_scalar_product( q ) , 0.754367 ) );
}
diff --git a/src/Gudhi_stat/test/persistence_lanscapes_test.cpp b/src/Gudhi_stat/test/persistence_lanscapes_test.cpp
index 9506410a..9ec7f880 100644
--- a/src/Gudhi_stat/test/persistence_lanscapes_test.cpp
+++ b/src/Gudhi_stat/test/persistence_lanscapes_test.cpp
@@ -191,7 +191,7 @@ BOOST_AUTO_TEST_CASE(check_computations_of_averages)
{
Persistence_landscape p( "data/file_with_diagram" );
Persistence_landscape q( "data/file_with_diagram_1" );
- std::vector< Abs_Topological_data_with_averages* > to_average;
+ std::vector< Persistence_landscape* > to_average;
to_average.push_back( &p );
to_average.push_back( &q );
Persistence_landscape av;
@@ -209,9 +209,9 @@ BOOST_AUTO_TEST_CASE(check_computations_of_distances)
{
Persistence_landscape p( "data/file_with_diagram" );
Persistence_landscape q( "data/file_with_diagram_1" );
- BOOST_CHECK( fabs( p.distance( &q )- 25.5824) <= 0.00005 );
- BOOST_CHECK( fabs( p.distance( &q , 2) - 2.12636 ) <= 0.00001 );
- BOOST_CHECK( fabs( p.distance( &q , -1 )-0.359068 ) <= 0.00001 );
+ BOOST_CHECK( fabs( p.distance( q )- 25.5824) <= 0.00005 );
+ BOOST_CHECK( fabs( p.distance( q , 2) - 2.12636 ) <= 0.00001 );
+ BOOST_CHECK( fabs( p.distance( q , -1 )-0.359068 ) <= 0.00001 );
}
@@ -219,6 +219,6 @@ BOOST_AUTO_TEST_CASE(check_computations_of_scalar_product)
{
Persistence_landscape p( "data/file_with_diagram" );
Persistence_landscape q( "data/file_with_diagram_1" );
- BOOST_CHECK( fabs( p.compute_scalar_product( &q ) - 0.754498 ) <= 0.00001 );
+ 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 44801ad9..3e14bd59 100644
--- a/src/Gudhi_stat/test/vector_representation_test.cpp
+++ b/src/Gudhi_stat/test/vector_representation_test.cpp
@@ -315,7 +315,7 @@ BOOST_AUTO_TEST_CASE(check_distance_computations)
intervals[9] = std::pair<double,double>( 19,20 );
Vector_distances_in_diagram< euclidean_distance<double> > 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( (Abs_Topological_data_with_distances*)(&p_bis) , 1 ) , 1.86428 ) );
+ BOOST_CHECK( almost_equal ( p_prime.distance( p_bis , 1 ) , 1.86428 ) );
}
@@ -337,9 +337,9 @@ BOOST_AUTO_TEST_CASE(check_compute_average)
Vector_distances_in_diagram< euclidean_distance<double> > A( i1 , -1 );
Vector_distances_in_diagram< euclidean_distance<double> > B( i1 , -1 );
- std::vector< Abs_Topological_data_with_averages* > to_average;
- to_average.push_back( (Abs_Topological_data_with_averages*)(&A) );
- to_average.push_back( (Abs_Topological_data_with_averages*)(&B) );
+ std::vector< Vector_distances_in_diagram< euclidean_distance<double> >* > to_average;
+ to_average.push_back( &A );
+ to_average.push_back( &B );
Vector_distances_in_diagram< euclidean_distance<double> > average;
average.compute_average( to_average );
diff --git a/src/Gudhi_stat/utilities/CMakeLists.txt b/src/Gudhi_stat/utilities/CMakeLists.txt
index 4fc11b57..e97c5708 100644
--- a/src/Gudhi_stat/utilities/CMakeLists.txt
+++ b/src/Gudhi_stat/utilities/CMakeLists.txt
@@ -101,6 +101,6 @@ target_link_libraries(persistence_vectors/plot_persistence_vectors ${Boost_SYSTE
#some stat libraries:
-#add_executable ( permutation_test permutation_test.cpp )
-#target_link_libraries(permutation_test ${Boost_SYSTEM_LIBRARY})
+add_executable ( permutation_test permutation_test.cpp )
+target_link_libraries(permutation_test ${Boost_SYSTEM_LIBRARY})
diff --git a/src/Gudhi_stat/utilities/permutation_test.cpp b/src/Gudhi_stat/utilities/permutation_test.cpp
new file mode 100644
index 00000000..809802d7
--- /dev/null
+++ b/src/Gudhi_stat/utilities/permutation_test.cpp
@@ -0,0 +1,84 @@
+/* This file is part of the Gudhi Library. 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/>.
+ */
+
+
+#include <gudhi/permutation_test.h>
+#include <gudhi/concretizations/Persistence_landscape.h>
+#include <iostream>
+#include <cstring>
+
+using namespace std;
+using namespace Gudhi;
+using namespace Gudhi::Gudhi_stat;
+
+int main( int argc , char** argv )
+{
+
+ std::cout << "This program require the following parameters: \n";
+ std::cout << "(1-2) Names of files each of them contains the names of files with persistence diagrams. The diagrams from a single file are assumed to be in the same group \n";
+ std::cout << "Third parameter is an integer being the number of permutations to be made \n";
+ std::cout << "The last parameter is a double, the power of a distance \n";
+ if ( argc != 5 )
+ {
+ std::cout << "Wrong number of parameters, the program will now terminat \n";
+ return 1;
+ }
+ std::cout << "We will now read the data from files : " << argv[1] << " and " << argv[2] << std::endl;
+ size_t number_of_permutations = (size_t)(atoi(argv[3]));
+ size_t exponent = (double)atof( argv[4] );
+
+ std::vector< std::string > first_group = readFileNames( argv[1] );
+ std::vector< std::string > second_group =readFileNames( argv[2] );
+
+ std::cout << "Here are the filenames in the first group :\n";
+ for ( size_t i = 0 ; i != first_group.size() ; ++i )
+ {
+ std::cout << first_group[i] << std::endl;
+ }
+ std::cout << "Here are the filenames in the second group :\n";
+ for ( size_t i = 0 ; i != second_group.size() ; ++i )
+ {
+ std::cout << second_group[i] << std::endl;
+ }
+
+ 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() );
+ Persistence_landscape* l = new Persistence_landscape( diag );
+ first_collection[i] = l;
+ }
+
+ 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() );
+ Persistence_landscape* l = new Persistence_landscape( diag );
+ second_collection[i] = l;
+ }
+
+ std::cout << "The p-value form a permutation test is : " << permutation_test<Persistence_landscape>( first_collection , second_collection , number_of_permutations , exponent ) << std::endl;
+
+
+
+ return 0;
+}
diff --git a/src/Gudhi_stat/utilities/persistence_heat_maps/average_persistence_heat_maps.cpp b/src/Gudhi_stat/utilities/persistence_heat_maps/average_persistence_heat_maps.cpp
index 811e4557..a3094e07 100644
--- a/src/Gudhi_stat/utilities/persistence_heat_maps/average_persistence_heat_maps.cpp
+++ b/src/Gudhi_stat/utilities/persistence_heat_maps/average_persistence_heat_maps.cpp
@@ -22,7 +22,6 @@
-#include <gudhi/abstract_classes/Abs_Topological_data.h>
#include <gudhi/concretizations/Persistence_heat_maps.h>
@@ -50,12 +49,12 @@ int main( int argc , char** argv )
}
std::cout << "Creating persistence landscapes...\n";
- std::vector< Abs_Topological_data_with_averages* > maps;
+ std::vector< Persistence_heat_maps* > maps;
for ( size_t i = 0 ; i != filenames.size() ; ++i )
{
Persistence_heat_maps* l = new Persistence_heat_maps;
l->load_from_file( filenames[i] );
- maps.push_back( (Abs_Topological_data_with_averages*)l );
+ maps.push_back( l );
}
Persistence_heat_maps av;
diff --git a/src/Gudhi_stat/utilities/persistence_heat_maps/compute_distance_of_persistence_heat_maps.cpp b/src/Gudhi_stat/utilities/persistence_heat_maps/compute_distance_of_persistence_heat_maps.cpp
index e462f009..bfe2a7ab 100644
--- a/src/Gudhi_stat/utilities/persistence_heat_maps/compute_distance_of_persistence_heat_maps.cpp
+++ b/src/Gudhi_stat/utilities/persistence_heat_maps/compute_distance_of_persistence_heat_maps.cpp
@@ -21,8 +21,6 @@
*/
-
-#include <gudhi/abstract_classes/Abs_Topological_data.h>
#include <gudhi/concretizations/Persistence_heat_maps.h>
@@ -53,13 +51,13 @@ int main( int argc , char** argv )
{
filenames.push_back( argv[i] );
}
- std::vector< Abs_Topological_data_with_distances* > maps;
+ std::vector< Persistence_heat_maps > maps;
maps.reserve( filenames.size() );
for ( size_t file_no = 0 ; file_no != filenames.size() ; ++file_no )
{
- Persistence_heat_maps* l = new Persistence_heat_maps;
- l->load_from_file( filenames[file_no] );
- maps.push_back( (Abs_Topological_data_with_distances*)l );
+ Persistence_heat_maps l;
+ l.load_from_file( filenames[file_no] );
+ maps.push_back( l );
}
//and now we will compute the scalar product of landscapes.
@@ -77,7 +75,7 @@ int main( int argc , char** argv )
{
for ( size_t j = i ; j != filenames.size() ; ++j )
{
- distance[i][j] = distance[j][i] = ((Persistence_heat_maps*)maps[i])->distance( maps[j] , p ) ;
+ distance[i][j] = distance[j][i] = maps[i].distance( maps[j] , p ) ;
}
}
diff --git a/src/Gudhi_stat/utilities/persistence_heat_maps/compute_scalar_product_of_persistence_heat_maps.cpp b/src/Gudhi_stat/utilities/persistence_heat_maps/compute_scalar_product_of_persistence_heat_maps.cpp
index c9ffa22e..d6899d1e 100644
--- a/src/Gudhi_stat/utilities/persistence_heat_maps/compute_scalar_product_of_persistence_heat_maps.cpp
+++ b/src/Gudhi_stat/utilities/persistence_heat_maps/compute_scalar_product_of_persistence_heat_maps.cpp
@@ -21,8 +21,6 @@
*/
-
-#include <gudhi/abstract_classes/Abs_Topological_data.h>
#include <gudhi/concretizations/Persistence_heat_maps.h>
@@ -44,12 +42,12 @@ int main( int argc , char** argv )
{
filenames.push_back( argv[i] );
}
- std::vector< Persistence_heat_maps* > maps;
+ std::vector< Persistence_heat_maps > maps;
maps.reserve( filenames.size() );
for ( size_t file_no = 0 ; file_no != filenames.size() ; ++file_no )
{
- Persistence_heat_maps* l = new Persistence_heat_maps;
- l->load_from_file( filenames[file_no] );
+ Persistence_heat_maps l;
+ l.load_from_file( filenames[file_no] );
maps.push_back( l );
}
@@ -68,7 +66,7 @@ int main( int argc , char** argv )
{
for ( size_t j = i ; j != maps.size() ; ++j )
{
- scalar_product[i][j] = scalar_product[j][i] = ((Persistence_heat_maps*)maps[i])->compute_scalar_product( maps[j] ) ;
+ scalar_product[i][j] = scalar_product[j][i] = maps[i].compute_scalar_product( maps[j] ) ;
}
}
diff --git a/src/Gudhi_stat/utilities/persistence_heat_maps/create_persistence_heat_maps.cpp b/src/Gudhi_stat/utilities/persistence_heat_maps/create_persistence_heat_maps.cpp
index 2cc00b87..b300d350 100644
--- a/src/Gudhi_stat/utilities/persistence_heat_maps/create_persistence_heat_maps.cpp
+++ b/src/Gudhi_stat/utilities/persistence_heat_maps/create_persistence_heat_maps.cpp
@@ -22,7 +22,6 @@
-#include <gudhi/abstract_classes/Abs_Topological_data.h>
#include <gudhi/concretizations/Persistence_heat_maps.h>
diff --git a/src/Gudhi_stat/utilities/persistence_heat_maps/create_persistence_heat_maps_weighted_by_arctan_of_their_persistence.cpp b/src/Gudhi_stat/utilities/persistence_heat_maps/create_persistence_heat_maps_weighted_by_arctan_of_their_persistence.cpp
index ae579329..3ce0fcec 100644
--- a/src/Gudhi_stat/utilities/persistence_heat_maps/create_persistence_heat_maps_weighted_by_arctan_of_their_persistence.cpp
+++ b/src/Gudhi_stat/utilities/persistence_heat_maps/create_persistence_heat_maps_weighted_by_arctan_of_their_persistence.cpp
@@ -22,7 +22,6 @@
-#include <gudhi/abstract_classes/Abs_Topological_data.h>
#include <gudhi/concretizations/Persistence_heat_maps.h>
diff --git a/src/Gudhi_stat/utilities/persistence_heat_maps/create_persistence_heat_maps_weighted_by_distance_from_diagonal.cpp b/src/Gudhi_stat/utilities/persistence_heat_maps/create_persistence_heat_maps_weighted_by_distance_from_diagonal.cpp
index 7877d699..4738d946 100644
--- a/src/Gudhi_stat/utilities/persistence_heat_maps/create_persistence_heat_maps_weighted_by_distance_from_diagonal.cpp
+++ b/src/Gudhi_stat/utilities/persistence_heat_maps/create_persistence_heat_maps_weighted_by_distance_from_diagonal.cpp
@@ -21,8 +21,6 @@
*/
-
-#include <gudhi/abstract_classes/Abs_Topological_data.h>
#include <gudhi/concretizations/Persistence_heat_maps.h>
diff --git a/src/Gudhi_stat/utilities/persistence_heat_maps/create_persistence_heat_maps_weighted_by_squared_distance_from_diagonal.cpp b/src/Gudhi_stat/utilities/persistence_heat_maps/create_persistence_heat_maps_weighted_by_squared_distance_from_diagonal.cpp
index 67972afe..8dab998a 100644
--- a/src/Gudhi_stat/utilities/persistence_heat_maps/create_persistence_heat_maps_weighted_by_squared_distance_from_diagonal.cpp
+++ b/src/Gudhi_stat/utilities/persistence_heat_maps/create_persistence_heat_maps_weighted_by_squared_distance_from_diagonal.cpp
@@ -21,8 +21,6 @@
*/
-
-#include <gudhi/abstract_classes/Abs_Topological_data.h>
#include <gudhi/concretizations/Persistence_heat_maps.h>
diff --git a/src/Gudhi_stat/utilities/persistence_heat_maps/create_pssk.cpp b/src/Gudhi_stat/utilities/persistence_heat_maps/create_pssk.cpp
index 1fc9d263..ec35f81c 100644
--- a/src/Gudhi_stat/utilities/persistence_heat_maps/create_pssk.cpp
+++ b/src/Gudhi_stat/utilities/persistence_heat_maps/create_pssk.cpp
@@ -20,9 +20,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-
-
-#include <gudhi/abstract_classes/Abs_Topological_data.h>
#include <gudhi/concretizations/PSSK.h>
diff --git a/src/Gudhi_stat/utilities/persistence_heat_maps/plot_persistence_heat_map.cpp b/src/Gudhi_stat/utilities/persistence_heat_maps/plot_persistence_heat_map.cpp
index 6b67ea57..c4eed502 100644
--- a/src/Gudhi_stat/utilities/persistence_heat_maps/plot_persistence_heat_map.cpp
+++ b/src/Gudhi_stat/utilities/persistence_heat_maps/plot_persistence_heat_map.cpp
@@ -21,8 +21,6 @@
*/
-
-#include <gudhi/abstract_classes/Abs_Topological_data.h>
#include <gudhi/concretizations/Persistence_heat_maps.h>
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 2c55a806..d73165b7 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
@@ -23,7 +23,6 @@
#include <gudhi/reader_utils.h>
-#include <gudhi/abstract_classes/Abs_Topological_data.h>
#include <gudhi/concretizations/Persistence_intervals.h>
#include <iostream>
diff --git a/src/Gudhi_stat/utilities/persistence_intervals/compute_number_of_dominant_intervals.cpp b/src/Gudhi_stat/utilities/persistence_intervals/compute_number_of_dominant_intervals.cpp
index b29aea3a..d4949932 100644
--- a/src/Gudhi_stat/utilities/persistence_intervals/compute_number_of_dominant_intervals.cpp
+++ b/src/Gudhi_stat/utilities/persistence_intervals/compute_number_of_dominant_intervals.cpp
@@ -23,7 +23,6 @@
#include <gudhi/reader_utils.h>
-#include <gudhi/abstract_classes/Abs_Topological_data.h>
#include <gudhi/concretizations/Persistence_intervals.h>
#include <iostream>
diff --git a/src/Gudhi_stat/utilities/persistence_intervals/plot_histogram_of_intervals_lengths.cpp b/src/Gudhi_stat/utilities/persistence_intervals/plot_histogram_of_intervals_lengths.cpp
index 99f7e640..96e6fa47 100644
--- a/src/Gudhi_stat/utilities/persistence_intervals/plot_histogram_of_intervals_lengths.cpp
+++ b/src/Gudhi_stat/utilities/persistence_intervals/plot_histogram_of_intervals_lengths.cpp
@@ -23,7 +23,6 @@
#include <gudhi/reader_utils.h>
-#include <gudhi/abstract_classes/Abs_Topological_data.h>
#include <gudhi/concretizations/Persistence_intervals.h>
#include <iostream>
diff --git a/src/Gudhi_stat/utilities/persistence_intervals/plot_persistence_Betti_numebrs.cpp b/src/Gudhi_stat/utilities/persistence_intervals/plot_persistence_Betti_numebrs.cpp
index e23a4f20..e4efdf79 100644
--- a/src/Gudhi_stat/utilities/persistence_intervals/plot_persistence_Betti_numebrs.cpp
+++ b/src/Gudhi_stat/utilities/persistence_intervals/plot_persistence_Betti_numebrs.cpp
@@ -23,7 +23,6 @@
#include <gudhi/reader_utils.h>
-#include <gudhi/abstract_classes/Abs_Topological_data.h>
#include <gudhi/concretizations/Persistence_intervals.h>
#include <iostream>
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 5950240e..6830a58b 100644
--- a/src/Gudhi_stat/utilities/persistence_intervals/plot_persistence_intervals.cpp
+++ b/src/Gudhi_stat/utilities/persistence_intervals/plot_persistence_intervals.cpp
@@ -23,7 +23,6 @@
#include <gudhi/reader_utils.h>
-#include <gudhi/abstract_classes/Abs_Topological_data.h>
#include <gudhi/concretizations/Persistence_intervals.h>
#include <iostream>
diff --git a/src/Gudhi_stat/utilities/persistence_landscapes/average_landscapes.cpp b/src/Gudhi_stat/utilities/persistence_landscapes/average_landscapes.cpp
index 895146f5..35aec203 100644
--- a/src/Gudhi_stat/utilities/persistence_landscapes/average_landscapes.cpp
+++ b/src/Gudhi_stat/utilities/persistence_landscapes/average_landscapes.cpp
@@ -22,7 +22,6 @@
-#include <gudhi/abstract_classes/Abs_Topological_data.h>
#include <gudhi/concretizations/Persistence_landscape.h>
@@ -51,12 +50,12 @@ int main( int argc , char** argv )
}
std::cout << "Creating persistence landscapes...\n";
- std::vector< Abs_Topological_data_with_averages* > lands;
+ std::vector< Persistence_landscape* > lands;
for ( size_t i = 0 ; i != filenames.size() ; ++i )
{
Persistence_landscape* l = new Persistence_landscape;
l->load_landscape_from_file( filenames[i] );
- lands.push_back( (Abs_Topological_data_with_averages*)l );
+ lands.push_back( l );
}
Persistence_landscape av;
diff --git a/src/Gudhi_stat/utilities/persistence_landscapes/compute_distance_of_landscapes.cpp b/src/Gudhi_stat/utilities/persistence_landscapes/compute_distance_of_landscapes.cpp
index 34ec0bfa..e3c3a33e 100644
--- a/src/Gudhi_stat/utilities/persistence_landscapes/compute_distance_of_landscapes.cpp
+++ b/src/Gudhi_stat/utilities/persistence_landscapes/compute_distance_of_landscapes.cpp
@@ -20,9 +20,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-
-
-#include <gudhi/abstract_classes/Abs_Topological_data.h>
#include <gudhi/concretizations/Persistence_landscape.h>
diff --git a/src/Gudhi_stat/utilities/persistence_landscapes/compute_scalar_product_of_landscapes.cpp b/src/Gudhi_stat/utilities/persistence_landscapes/compute_scalar_product_of_landscapes.cpp
index 443240ff..ef9de9c7 100644
--- a/src/Gudhi_stat/utilities/persistence_landscapes/compute_scalar_product_of_landscapes.cpp
+++ b/src/Gudhi_stat/utilities/persistence_landscapes/compute_scalar_product_of_landscapes.cpp
@@ -20,9 +20,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-
-
-#include <gudhi/abstract_classes/Abs_Topological_data.h>
#include <gudhi/concretizations/Persistence_landscape.h>
diff --git a/src/Gudhi_stat/utilities/persistence_landscapes/create_landscapes.cpp b/src/Gudhi_stat/utilities/persistence_landscapes/create_landscapes.cpp
index fe96a067..212e6b16 100644
--- a/src/Gudhi_stat/utilities/persistence_landscapes/create_landscapes.cpp
+++ b/src/Gudhi_stat/utilities/persistence_landscapes/create_landscapes.cpp
@@ -20,9 +20,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-
-
-#include <gudhi/abstract_classes/Abs_Topological_data.h>
#include <gudhi/concretizations/Persistence_landscape.h>
diff --git a/src/Gudhi_stat/utilities/persistence_landscapes/plot_landscapes.cpp b/src/Gudhi_stat/utilities/persistence_landscapes/plot_landscapes.cpp
index e035e4aa..0d72a17c 100644
--- a/src/Gudhi_stat/utilities/persistence_landscapes/plot_landscapes.cpp
+++ b/src/Gudhi_stat/utilities/persistence_landscapes/plot_landscapes.cpp
@@ -20,9 +20,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-
-
-#include <gudhi/abstract_classes/Abs_Topological_data.h>
#include <gudhi/concretizations/Persistence_landscape.h>
diff --git a/src/Gudhi_stat/utilities/persistence_landscapes_on_grid/average_landscapes_on_grid.cpp b/src/Gudhi_stat/utilities/persistence_landscapes_on_grid/average_landscapes_on_grid.cpp
index 3b580181..2f6875b2 100644
--- a/src/Gudhi_stat/utilities/persistence_landscapes_on_grid/average_landscapes_on_grid.cpp
+++ b/src/Gudhi_stat/utilities/persistence_landscapes_on_grid/average_landscapes_on_grid.cpp
@@ -20,9 +20,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-
-
-#include <gudhi/abstract_classes/Abs_Topological_data.h>
#include <gudhi/concretizations/Persistence_landscape_on_grid.h>
@@ -50,12 +47,12 @@ int main( int argc , char** argv )
}
std::cout << "Creating persistence landscapes...\n";
- std::vector< Abs_Topological_data_with_averages* > lands;
+ std::vector< Persistence_landscape_on_grid* > lands;
for ( size_t i = 0 ; i != filenames.size() ; ++i )
{
Persistence_landscape_on_grid* l = new Persistence_landscape_on_grid;
l->load_landscape_from_file( filenames[i] );
- lands.push_back( (Abs_Topological_data_with_averages*)l );
+ lands.push_back( l );
}
Persistence_landscape_on_grid av;
diff --git a/src/Gudhi_stat/utilities/persistence_landscapes_on_grid/compute_distance_of_landscapes_on_grid.cpp b/src/Gudhi_stat/utilities/persistence_landscapes_on_grid/compute_distance_of_landscapes_on_grid.cpp
index 1813e297..ace5066a 100644
--- a/src/Gudhi_stat/utilities/persistence_landscapes_on_grid/compute_distance_of_landscapes_on_grid.cpp
+++ b/src/Gudhi_stat/utilities/persistence_landscapes_on_grid/compute_distance_of_landscapes_on_grid.cpp
@@ -20,9 +20,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-
-
-#include <gudhi/abstract_classes/Abs_Topological_data.h>
#include <gudhi/concretizations/Persistence_landscape_on_grid.h>
diff --git a/src/Gudhi_stat/utilities/persistence_landscapes_on_grid/compute_scalar_product_of_landscapes_on_grid.cpp b/src/Gudhi_stat/utilities/persistence_landscapes_on_grid/compute_scalar_product_of_landscapes_on_grid.cpp
index 33e111d5..a039a97a 100644
--- a/src/Gudhi_stat/utilities/persistence_landscapes_on_grid/compute_scalar_product_of_landscapes_on_grid.cpp
+++ b/src/Gudhi_stat/utilities/persistence_landscapes_on_grid/compute_scalar_product_of_landscapes_on_grid.cpp
@@ -21,8 +21,6 @@
*/
-
-#include <gudhi/abstract_classes/Abs_Topological_data.h>
#include <gudhi/concretizations/Persistence_landscape_on_grid.h>
diff --git a/src/Gudhi_stat/utilities/persistence_landscapes_on_grid/create_landscapes_on_grid.cpp b/src/Gudhi_stat/utilities/persistence_landscapes_on_grid/create_landscapes_on_grid.cpp
index f6545e44..2b205513 100644
--- a/src/Gudhi_stat/utilities/persistence_landscapes_on_grid/create_landscapes_on_grid.cpp
+++ b/src/Gudhi_stat/utilities/persistence_landscapes_on_grid/create_landscapes_on_grid.cpp
@@ -20,9 +20,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-
-
-#include <gudhi/abstract_classes/Abs_Topological_data.h>
#include <gudhi/concretizations/Persistence_landscape_on_grid.h>
diff --git a/src/Gudhi_stat/utilities/persistence_landscapes_on_grid/plot_landscapes_on_grid.cpp b/src/Gudhi_stat/utilities/persistence_landscapes_on_grid/plot_landscapes_on_grid.cpp
index c12c3862..27946075 100644
--- a/src/Gudhi_stat/utilities/persistence_landscapes_on_grid/plot_landscapes_on_grid.cpp
+++ b/src/Gudhi_stat/utilities/persistence_landscapes_on_grid/plot_landscapes_on_grid.cpp
@@ -20,9 +20,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-
-
-#include <gudhi/abstract_classes/Abs_Topological_data.h>
#include <gudhi/concretizations/Persistence_landscape_on_grid.h>
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 3262b157..cb3ea03d 100644
--- a/src/Gudhi_stat/utilities/persistence_vectors/average_persistence_vectors.cpp
+++ b/src/Gudhi_stat/utilities/persistence_vectors/average_persistence_vectors.cpp
@@ -21,8 +21,6 @@
*/
-
-#include <gudhi/abstract_classes/Abs_Topological_data.h>
#include <gudhi/concretizations/Vector_distances_in_diagram.h>
@@ -51,12 +49,12 @@ int main( int argc , char** argv )
}
std::cout << "Reading persistence vectors...\n";
- std::vector< Abs_Topological_data_with_averages* > lands;
+ std::vector< Vector_distances_in_diagram< euclidean_distance<double> >* > 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> >;
l->load_from_file( filenames[i] );
- lands.push_back( (Abs_Topological_data_with_averages*)l );
+ lands.push_back(l );
}
Vector_distances_in_diagram< euclidean_distance<double> > av;
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 33d92a72..5f8c6b52 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
@@ -20,9 +20,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-
-
-#include <gudhi/abstract_classes/Abs_Topological_data.h>
#include <gudhi/concretizations/Vector_distances_in_diagram.h>
@@ -53,13 +50,13 @@ 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<double> > > 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 = new Vector_distances_in_diagram< euclidean_distance<double> >;
- l->load_from_file( filenames[file_no] );
+ Vector_distances_in_diagram< euclidean_distance<double> > l;
+ l.load_from_file( filenames[file_no] );
vectors.push_back( l );
}
@@ -78,7 +75,7 @@ int main( int argc , char** argv )
{
for ( size_t j = i+1 ; j != vectors.size() ; ++j )
{
- distance[i][j] = distance[j][i] = ((Vector_distances_in_diagram< euclidean_distance<double> >*)vectors[i])->distance( vectors[j] , p ) ;
+ distance[i][j] = distance[j][i] = vectors[i].distance( vectors[j] , p ) ;
}
}
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 5bea2765..a02cd078 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
@@ -20,9 +20,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-
-
-#include <gudhi/abstract_classes/Abs_Topological_data.h>
#include <gudhi/concretizations/Vector_distances_in_diagram.h>
@@ -44,12 +41,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<double> > > 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 = new Vector_distances_in_diagram< euclidean_distance<double> >;
- l->load_from_file( filenames[file_no] );
+ Vector_distances_in_diagram< euclidean_distance<double> > l;
+ l.load_from_file( filenames[file_no] );
vectors.push_back( l );
}
@@ -68,7 +65,7 @@ int main( int argc , char** argv )
{
for ( size_t j = i ; j != vectors.size() ; ++j )
{
- scalar_product[i][j] = scalar_product[j][i] = ((Vector_distances_in_diagram< euclidean_distance<double> >*)vectors[i])->compute_scalar_product( vectors[j] ) ;
+ scalar_product[i][j] = scalar_product[j][i] = vectors[i].compute_scalar_product( vectors[j] ) ;
}
}
@@ -85,13 +82,6 @@ int main( int argc , char** argv )
cout << endl;
out << endl;
}
- out.close();
-
- //cleaning up
- for ( size_t i = 0 ; i != vectors.size() ; ++i )
- {
- delete vectors[i];
- }
-
+ out.close();
return 0;
}
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 657dd2d4..9f6b79cb 100644
--- a/src/Gudhi_stat/utilities/persistence_vectors/create_persistence_vectors.cpp
+++ b/src/Gudhi_stat/utilities/persistence_vectors/create_persistence_vectors.cpp
@@ -20,9 +20,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-
-
-#include <gudhi/abstract_classes/Abs_Topological_data.h>
#include <gudhi/concretizations/Vector_distances_in_diagram.h>
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 53f53654..de19a66d 100644
--- a/src/Gudhi_stat/utilities/persistence_vectors/plot_persistence_vectors.cpp
+++ b/src/Gudhi_stat/utilities/persistence_vectors/plot_persistence_vectors.cpp
@@ -20,9 +20,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-
-
-#include <gudhi/abstract_classes/Abs_Topological_data.h>
#include <gudhi/concretizations/Vector_distances_in_diagram.h>