summaryrefslogtreecommitdiff
path: root/src/Gudhi_stat/utilities
diff options
context:
space:
mode:
authorpdlotko <pdlotko@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2017-04-12 13:07:58 +0000
committerpdlotko <pdlotko@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2017-04-12 13:07:58 +0000
commit8f4c961a93fe928d06c7776a9e8f5ecd00fab9ca (patch)
tree0222aa7a5db950b15e7b1adf9f75cec2204c55fa /src/Gudhi_stat/utilities
parente729d07cc53e4b6a189ebbfbfe4eb5db5449fbe0 (diff)
a few more correction. First of all, bottleneck distance is added (although there is something strange in the results, FG has been pinged about this). Second of all, all the programs in utylites should now read general files (and dimension of persistence to be read is one of the parameteds of files). This still need to be tested and will be tested soon.
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/gudhi_stat@2339 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: e60d14f07db223646597230d7f0bd78dd090bc0b
Diffstat (limited to 'src/Gudhi_stat/utilities')
-rw-r--r--src/Gudhi_stat/utilities/Multiplicative_bootstrap.cpp2
-rw-r--r--src/Gudhi_stat/utilities/permutation_test.cpp2
-rw-r--r--src/Gudhi_stat/utilities/persistence_heat_maps/create_persistence_heat_maps.cpp20
-rw-r--r--src/Gudhi_stat/utilities/persistence_heat_maps/create_persistence_heat_maps_weighted_by_arctan_of_their_persistence.cpp18
-rw-r--r--src/Gudhi_stat/utilities/persistence_heat_maps/create_persistence_heat_maps_weighted_by_distance_from_diagonal.cpp14
-rw-r--r--src/Gudhi_stat/utilities/persistence_heat_maps/create_persistence_heat_maps_weighted_by_squared_distance_from_diagonal.cpp18
-rw-r--r--src/Gudhi_stat/utilities/persistence_heat_maps/create_pssk.cpp17
-rw-r--r--src/Gudhi_stat/utilities/persistence_intervals/CMakeLists.txt15
-rw-r--r--src/Gudhi_stat/utilities/persistence_intervals/compute_birth_death_range_in_persistence_diagram.cpp24
-rw-r--r--src/Gudhi_stat/utilities/persistence_intervals/compute_bottleneck_distance.cpp115
-rw-r--r--src/Gudhi_stat/utilities/persistence_intervals/compute_number_of_dominant_intervals.cpp15
-rw-r--r--src/Gudhi_stat/utilities/persistence_intervals/plot_histogram_of_intervals_lengths.cpp13
-rw-r--r--src/Gudhi_stat/utilities/persistence_intervals/plot_persistence_Betti_numbers.cpp (renamed from src/Gudhi_stat/utilities/persistence_intervals/plot_persistence_Betti_numebrs.cpp)16
-rw-r--r--src/Gudhi_stat/utilities/persistence_intervals/plot_persistence_intervals.cpp16
-rw-r--r--src/Gudhi_stat/utilities/persistence_landscapes/create_landscapes.cpp17
-rw-r--r--src/Gudhi_stat/utilities/persistence_landscapes_on_grid/create_landscapes_on_grid.cpp17
-rw-r--r--src/Gudhi_stat/utilities/persistence_vectors/create_persistence_vectors.cpp16
17 files changed, 295 insertions, 60 deletions
diff --git a/src/Gudhi_stat/utilities/Multiplicative_bootstrap.cpp b/src/Gudhi_stat/utilities/Multiplicative_bootstrap.cpp
index 42534752..7ee389f8 100644
--- a/src/Gudhi_stat/utilities/Multiplicative_bootstrap.cpp
+++ b/src/Gudhi_stat/utilities/Multiplicative_bootstrap.cpp
@@ -51,7 +51,7 @@ int main( int argc , char** argv )
std::vector< Persistence_landscape* > collection_of_landscapes( filenames.size() );
for ( size_t i = 0 ; i != filenames.size() ; ++i )
{
- std::vector< std::pair< double , double > > diag = read_gudhi_persistence_file_in_one_dimension( filenames[i].c_str() , 1 );//read_standard_persistence_file( filenames[i].c_str() );
+ std::vector< std::pair< double , double > > diag = read_persistence_intervals_in_one_dimension_from_file( filenames[i].c_str() );
collection_of_landscapes[i] = new Persistence_landscape( diag );
}
diff --git a/src/Gudhi_stat/utilities/permutation_test.cpp b/src/Gudhi_stat/utilities/permutation_test.cpp
index e431026f..62cd3f10 100644
--- a/src/Gudhi_stat/utilities/permutation_test.cpp
+++ b/src/Gudhi_stat/utilities/permutation_test.cpp
@@ -62,7 +62,7 @@ int main( int argc , char** argv )
std::vector< Persistence_landscape* > first_collection( first_group.size() );
for ( size_t i = 0 ; i != first_group.size() ; ++i )
{
- std::vector< std::pair< double , double > > diag = read_standard_persistence_file( first_group[i].c_str() );
+ std::vector< std::pair< double , double > > diag = read_persistence_intervals_in_one_dimension_from_file( first_group[i].c_str() );
Persistence_landscape* l = new Persistence_landscape( diag );
first_collection[i] = l;
}
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 5d2100aa..d9c7aded 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
@@ -40,26 +40,32 @@ int main( int argc , char** argv )
std::cout << "The first parameter of a program is an integer, a size of a grid.\n";
std::cout << "The second and third parameters are min and max of the grid. If you want those numbers to be computed based on the data, set them both to -1 \n";
std::cerr << "The fourth parameter is an integer, the standard deviation of a gaussian kernel expressed in a number of pixels \n";
- std::cout << "The remaining parameters are the names of files with persistence diagrams. \n";
+ std::cout << "The fifth parameter of this program is a dimension of persistence that will be used in creation of the persistence heat maps.";
+ std::cout << "If our input files contain persistence pairs of various dimension, as a fifth parameter of the procedure please provide the dimension of persistence you want to use.";
+ std::cout << "If in your file there are only birth-death pairs of the same dimension, set the first parameter to -1." << std::endl;
+ std::cout << "The remaining parameters are the names of files with persistence diagrams. \n";
if ( argc < 5 )
{
std::cout << "Wrong parameter list, the program will now terminate \n";
return 1;
- }
-
+ }
size_t size_of_grid = (size_t)atoi( argv[1] );
double min_ = atof( argv[2] );
double max_ = atof( argv[3] );
size_t stdiv = atof( argv[4] );
+ unsigned dimension = std::numeric_limits<unsigned>::max();
+ int dim = atoi( argv[5] );
+ if ( (dim != -1) && (dim >= 0) )
+ {
+ dimension = (unsigned)dim;
+ }
std::vector< const char* > filenames;
- for ( int i = 5 ; i < argc ; ++i )
+ for ( int i = 6 ; i < argc ; ++i )
{
filenames.push_back( argv[i] );
}
-
-
std::cout << "Creating persistence heat maps...\n";
std::vector< std::vector<double> > filter = create_Gaussian_filter(stdiv,1);
@@ -67,7 +73,7 @@ int main( int argc , char** argv )
for ( size_t i = 0 ; i != filenames.size() ; ++i )
{
std::cout << "Creating a heat map based on a file : " << filenames[i] << std::endl;
- Persistence_heat_maps<constant_scaling_function> l( filenames[i] , filter, false , size_of_grid , min_ , max_ );
+ Persistence_heat_maps<constant_scaling_function> l( filenames[i] , filter, false , size_of_grid , min_ , max_ , dimension );
std::stringstream ss;
ss << filenames[i] << ".mps";
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 8496e33e..7cb7eeb7 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
@@ -1,4 +1,4 @@
-/* This file is part of the Gudhi Library. The Gudhi library
+ /* This file is part of the Gudhi Library. The Gudhi library
* (Geometric Understanding in Higher Dimensions) is a generic C++
* library for computational topology.
*
@@ -40,8 +40,11 @@ int main( int argc , char** argv )
std::cout << "The first parameter of a program is an integer, a size of a grid.\n";
std::cout << "The second and third parameters are min and max of the grid. If you want those numbers to be computed based on the data, set them both to -1 \n";
std::cerr << "The fourth parameter is an integer, the standard deviation of a gaussian kernel expressed in a number of pixels \n";
+ std::cout << "The fifth parameter of this program is a dimension of persistence that will be used in creation of the persistence heat maps.";
+ std::cout << "If our input files contain persistence pairs of various dimension, as a fifth parameter of the procedure please provide the dimension of persistence you want to use.";
+ std::cout << "If in your file there are only birth-death pairs of the same dimension, set the first parameter to -1." << std::endl;
std::cout << "The remaining parameters are the names of files with persistence diagrams. \n";
-
+
if ( argc < 5 )
{
std::cout << "Wrong parameter list, the program will now terminate \n";
@@ -53,8 +56,15 @@ int main( int argc , char** argv )
double max_ = atof( argv[3] );
size_t stdiv = atof( argv[4] );
+ unsigned dimension = std::numeric_limits<unsigned>::max();
+ int dim = atoi( argv[5] );
+ if ( (dim != -1) && (dim >= 0) )
+ {
+ dimension = (unsigned)dim;
+ }
+
std::vector< const char* > filenames;
- for ( int i = 5 ; i < argc ; ++i )
+ for ( int i = 6 ; i < argc ; ++i )
{
filenames.push_back( argv[i] );
}
@@ -67,7 +77,7 @@ int main( int argc , char** argv )
for ( size_t i = 0 ; i != filenames.size() ; ++i )
{
std::cout << "Creating a heat map based on a file : " << filenames[i] << std::endl;
- Persistence_heat_maps<arc_tan_of_persistence_of_point> l( filenames[i] , filter, false , size_of_grid , min_ , max_ );
+ Persistence_heat_maps<arc_tan_of_persistence_of_point> l( filenames[i] , filter, false , size_of_grid , min_ , max_ , dimension );
std::stringstream ss;
ss << filenames[i] << ".mps";
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 83d4f3bc..3242e106 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
@@ -39,6 +39,9 @@ int main( int argc , char** argv )
std::cout << "The first parameter of a program is an integer, a size of a grid.\n";
std::cout << "The second and third parameters are min and max of the grid. If you want those numbers to be computed based on the data, set them both to -1 \n";
std::cerr << "The fourth parameter is an integer, the standard deviation of a gaussian kernel expressed in a number of pixels \n";
+ std::cout << "The fifth parameter of this program is a dimension of persistence that will be used in creation of the persistence heat maps.";
+ std::cout << "If our input files contain persistence pairs of various dimension, as a fifth parameter of the procedure please provide the dimension of persistence you want to use.";
+ std::cout << "If in your file there are only birth-death pairs of the same dimension, set the first parameter to -1." << std::endl;
std::cout << "The remaining parameters are the names of files with persistence diagrams. \n";
if ( argc < 5 )
@@ -52,8 +55,15 @@ int main( int argc , char** argv )
double max_ = atof( argv[3] );
size_t stdiv = atof( argv[4] );
+ unsigned dimension = std::numeric_limits<unsigned>::max();
+ int dim = atoi( argv[5] );
+ if ( (dim != -1) && (dim >= 0) )
+ {
+ dimension = (unsigned)dim;
+ }
+
std::vector< const char* > filenames;
- for ( int i = 5 ; i < argc ; ++i )
+ for ( int i = 6 ; i < argc ; ++i )
{
filenames.push_back( argv[i] );
}
@@ -66,7 +76,7 @@ int main( int argc , char** argv )
for ( size_t i = 0 ; i != filenames.size() ; ++i )
{
std::cout << "Creating a heat map based on a file : " << filenames[i] << std::endl;
- Persistence_heat_maps<distance_from_diagonal_scaling> l( filenames[i] , filter , size_of_grid , min_ , max_ );
+ Persistence_heat_maps<distance_from_diagonal_scaling> l( filenames[i] , filter , size_of_grid , min_ , max_ , dimension );
std::stringstream ss;
ss << filenames[i] << ".mps";
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 f62615f5..27846a99 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
@@ -39,8 +39,11 @@ int main( int argc , char** argv )
std::cout << "The first parameter of a program is an integer, a size of a grid.\n";
std::cout << "The second and third parameters are min and max of the grid. If you want those numbers to be computed based on the data, set them both to -1 \n";
std::cerr << "The fourth parameter is an integer, the standard deviation of a gaussian kernel expressed in a number of pixels \n";
+ std::cout << "The fifth parameter of this program is a dimension of persistence that will be used in creation of the persistence heat maps.";
+ std::cout << "If our input files contain persistence pairs of various dimension, as a fifth parameter of the procedure please provide the dimension of persistence you want to use.";
+ std::cout << "If in your file there are only birth-death pairs of the same dimension, set the first parameter to -1." << std::endl;
std::cout << "The remaining parameters are the names of files with persistence diagrams. \n";
-
+
if ( argc < 5 )
{
std::cout << "Wrong parameter list, the program will now terminate \n";
@@ -51,14 +54,19 @@ int main( int argc , char** argv )
double min_ = atof( argv[2] );
double max_ = atof( argv[3] );
size_t stdiv = atof( argv[4] );
+
+ unsigned dimension = std::numeric_limits<unsigned>::max();
+ int dim = atoi( argv[5] );
+ if ( (dim != -1) && (dim >= 0) )
+ {
+ dimension = (unsigned)dim;
+ }
std::vector< const char* > filenames;
- for ( int i = 5 ; i < argc ; ++i )
+ for ( int i = 6 ; i < argc ; ++i )
{
filenames.push_back( argv[i] );
}
-
-
std::cout << "Creating persistence heat maps...\n";
std::vector< std::vector<double> > filter = create_Gaussian_filter(stdiv,1);
@@ -66,7 +74,7 @@ int main( int argc , char** argv )
for ( size_t i = 0 ; i != filenames.size() ; ++i )
{
std::cout << "Creating a heat map based on a file : " << filenames[i] << std::endl;
- Persistence_heat_maps<squared_distance_from_diagonal_scaling> l( filenames[i] , filter, false , size_of_grid , min_ , max_ );
+ Persistence_heat_maps<squared_distance_from_diagonal_scaling> l( filenames[i] , filter, false , size_of_grid , min_ , max_ , dimension );
std::stringstream ss;
ss << filenames[i] << ".mps";
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 d38bb8b9..404a4be3 100644
--- a/src/Gudhi_stat/utilities/persistence_heat_maps/create_pssk.cpp
+++ b/src/Gudhi_stat/utilities/persistence_heat_maps/create_pssk.cpp
@@ -38,8 +38,12 @@ int main( int argc , char** argv )
std::cout << "The first parameter of a program is an integer, a size of a grid.\n";
std::cout << "The second and third parameters are min and max of the grid. If you want those numbers to be computed based on the data, set them both to -1 \n";
std::cerr << "The fourth parameter is an integer, the standard deviation of a gaussian kernel expressed in a number of pixels \n";
+ std::cerr << "The fourth parameter is an integer, the standard deviation of a gaussian kernel expressed in a number of pixels \n";
+ std::cout << "The fifth parameter of this program is a dimension of persistence that will be used in creation of the persistence heat maps.";
+ std::cout << "If our input files contain persistence pairs of various dimension, as a fifth parameter of the procedure please provide the dimension of persistence you want to use.";
+ std::cout << "If in your file there are only birth-death pairs of the same dimension, set the first parameter to -1." << std::endl;
std::cout << "The remaining parameters are the names of files with persistence diagrams. \n";
-
+
if ( argc < 5 )
{
std::cout << "Wrong parameter list, the program will now terminate \n";
@@ -51,8 +55,15 @@ int main( int argc , char** argv )
double max_ = atof( argv[3] );
size_t stdiv = atof( argv[4] );
+ unsigned dimension = std::numeric_limits<unsigned>::max();
+ int dim = atoi( argv[5] );
+ if ( (dim != -1) && (dim >= 0) )
+ {
+ dimension = (unsigned)dim;
+ }
+
std::vector< const char* > filenames;
- for ( int i = 5 ; i < argc ; ++i )
+ for ( int i = 6 ; i < argc ; ++i )
{
filenames.push_back( argv[i] );
}
@@ -63,7 +74,7 @@ int main( int argc , char** argv )
for ( size_t i = 0 ; i != filenames.size() ; ++i )
{
std::cout << "Creating a heat map based on a file : " << filenames[i] << std::endl;
- PSSK l( filenames[i] , filter , size_of_grid , min_ , max_ );
+ PSSK l( filenames[i] , filter , size_of_grid , min_ , max_ , dimension );
std::stringstream ss;
ss << filenames[i] << ".pssk";
diff --git a/src/Gudhi_stat/utilities/persistence_intervals/CMakeLists.txt b/src/Gudhi_stat/utilities/persistence_intervals/CMakeLists.txt
index 96cb1a5e..9420a8ea 100644
--- a/src/Gudhi_stat/utilities/persistence_intervals/CMakeLists.txt
+++ b/src/Gudhi_stat/utilities/persistence_intervals/CMakeLists.txt
@@ -1,8 +1,6 @@
cmake_minimum_required(VERSION 2.6)
project(GUDHI_STAT)
-
-
#persitence diagrams
add_executable ( plot_persistence_intervals plot_persistence_intervals.cpp )
target_link_libraries( plot_persistence_intervals ${Boost_SYSTEM_LIBRARY})
@@ -16,7 +14,14 @@ target_link_libraries( compute_number_of_dominant_intervals ${Boost_SYSTEM_LIBRA
add_executable ( plot_histogram_of_intervals_lengths plot_histogram_of_intervals_lengths.cpp )
target_link_libraries( plot_histogram_of_intervals_lengths ${Boost_SYSTEM_LIBRARY})
-add_executable ( plot_persistence_Betti_numebrs plot_persistence_Betti_numebrs.cpp )
-target_link_libraries( plot_persistence_Betti_numebrs ${Boost_SYSTEM_LIBRARY})
+add_executable ( plot_persistence_Betti_numbers plot_persistence_Betti_numbers.cpp )
+target_link_libraries( plot_persistence_Betti_numbers ${Boost_SYSTEM_LIBRARY})
+
+if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1)
+add_executable ( compute_bottleneck_distance compute_bottleneck_distance.cpp )
+target_link_libraries( compute_bottleneck_distance ${Boost_SYSTEM_LIBRARY})
+if (TBB_FOUND)
+target_link_libraries(compute_bottleneck_distance ${TBB_LIBRARIES})
+endif(TBB_FOUND)
-#when we have bottleneck and wasserstein distance computations, add suitable programs here.
+endif (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1)
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 145040fe..426a9b7b 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
@@ -37,18 +37,20 @@ using namespace Gudhi::Gudhi_stat;
int main( int argc , char** argv )
{
- //std::cout << "This program compute minimum birth and the maximum death time for a collection of persistence intervals \n";
- //if ( argc != 2 )
- //{
- // std::cout << "To run this program, please provide the name of a file with persistence diagram \n";
- // return 1;
- //}
- //Persistence_intervals p( argv[1] );
- //std::pair<double,double> min_max_ = p.min_max();
- //std::cout << "Birth-death range : min: " << min_max_.first << ", max: " << min_max_.second << endl;
+ std::cout << "This program compute the range of birth and death times of persistence pairs in diagrams provided as an input. \n";
+ std::cout << "The first parameter of the program is the dimension of persistence to be used. If your file contains ";
+ std::cout << "the information about dimension of persistence pairs, please provide here the dimension of persistence pairs you want to use. If your input files consist only ";
+ std::cout << "of birth-death pairs, please set this first parameter to -1 \n";
+ std::cout << "The remaining parameters of the program are the names of files with persistence diagrams. \n";
+ int dim = atoi( argv[1] );
+ unsigned dimension = std::numeric_limits<unsigned>::max();
+ if ( (dim != -1) && (dim >= 0) )
+ {
+ dimension = (unsigned)dim;
+ }
std::vector< const char* > filenames;
- for ( int i = 1 ; i < argc ; ++i )
+ for ( int i = 2 ; i < argc ; ++i )
{
filenames.push_back( argv[i] );
}
@@ -59,7 +61,7 @@ int main( int argc , char** argv )
for ( size_t file_no = 0 ; file_no != filenames.size() ; ++file_no )
{
std::cout << "Creating diagram based on a file : " << filenames[file_no] << std::endl;
- Persistence_intervals p( filenames[file_no] );
+ Persistence_intervals p( filenames[file_no] , dimension );
std::pair<double,double> min_max_ = p.min_max();
if ( min_max_.first < min_ )min_ = min_max_.first;
if ( min_max_.second > max_ )max_ = min_max_.second;
diff --git a/src/Gudhi_stat/utilities/persistence_intervals/compute_bottleneck_distance.cpp b/src/Gudhi_stat/utilities/persistence_intervals/compute_bottleneck_distance.cpp
new file mode 100644
index 00000000..6f0ba635
--- /dev/null
+++ b/src/Gudhi_stat/utilities/persistence_intervals/compute_bottleneck_distance.cpp
@@ -0,0 +1,115 @@
+/* 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/persistence_representations/Persistence_intervals_with_distances.h>
+#include <gudhi/read_persistence_from_file.h>
+
+
+
+using namespace Gudhi;
+using namespace Gudhi::Gudhi_stat;
+
+#include <iostream>
+#include <sstream>
+
+
+int main( int argc , char** argv )
+{
+ std::cout << "This program compute the bottleneck distance of persistence diarams stored in a files. \n";
+ std::cout << "The first parameter of the program is the dimension of persistence to be used to construct persistence landscapes. If your file contains ";
+ std::cout << "the information about dimension of persistence pairs, please provide here the dimension of persistence pairs you want to use. If your input files consist only ";
+ std::cout << "of birth-death pairs, please set this first parameter to -1 \n";
+ std::cout << "The remaining parameters of this programs are names of files with persistence diagrams.\n";
+
+ if ( argc < 3 )
+ {
+ std::cout << "Wrong number of parameters, the program will now terminate \n";
+ return 1;
+ }
+
+ int dim = atoi(argv[1]);
+ unsigned dimension = std::numeric_limits<unsigned>::max();
+ if ( (dim != -1) && (dim >= 0) )
+ {
+ dimension = (unsigned)dim;
+ }
+
+
+ std::vector< const char* > filenames;
+ for ( int i = 2 ; i < argc ; ++i )
+ {
+ filenames.push_back( argv[i] );
+ }
+
+ //reading the persistence intervals:
+ std::vector< Persistence_intervals_with_distances > persistence_intervals;
+ for ( size_t i = 0 ; i != filenames.size() ; ++i )
+ {
+ Persistence_intervals_with_distances pers(filenames[i] , dimension );
+ std::cerr << "perss : " << pers << std::endl;
+ getchar();
+ persistence_intervals.push_back( pers );
+ }
+
+ //and now we will compute the scalar product of landscapes.
+
+ //first we prepare an array:
+ std::vector< std::vector< double > > distance( filenames.size() );
+ for ( size_t i = 0 ; i != filenames.size() ; ++i )
+ {
+ std::vector< double > v( filenames.size() , 0 );
+ distance[i] = v;
+ }
+
+ //and now we can compute the distances:
+ for ( size_t i = 0 ; i != persistence_intervals.size() ; ++i )
+ {
+ for ( size_t j = i+1 ; j != persistence_intervals.size() ; ++j )
+ {
+ distance[i][j] = distance[j][i] = persistence_intervals[i].distance( persistence_intervals[j] );
+ }
+ }
+
+ //and now output the result to the screen and a file:
+ std::ofstream out;
+ out.open( "distance" );
+ for ( size_t i = 0 ; i != distance.size() ; ++i )
+ {
+ for ( size_t j = 0 ; j != distance.size() ; ++j )
+ {
+ std::cout << distance[i][j] << " ";
+ out << distance[i][j] << " ";
+ }
+ std::cout << std::endl;
+ out << std::endl;
+ }
+ out.close();
+
+ return 0;
+}
+
+
+
+
+
+
+
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 eeda703a..0a7f7c2b 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
@@ -36,14 +36,19 @@ using namespace Gudhi::Gudhi_stat;
int main( int argc , char** argv )
{
std::cout << "This program compute the dominant intervals. A number of intervals to be displayed is a parameter of this program. \n";
- if ( argc != 3 )
+ if ( argc != 4 )
{
- std::cout << "To run this program, please provide the name of a file with persistence diagram and number of dominant intervals you would like to get \n";
+ std::cout << "To run this program, please provide the name of a file with persistence diagram, dimension of intervals that should be taken into account (if your file contains only persistence pairs in a single dimension, set it up to -1) and number of dominant intervals you would like to get \n";
return 1;
}
-
- Persistence_intervals p( argv[1] );
- std::vector< std::pair<double,double> > dominant_intervals = p.dominant_intervals( atoi( argv[2] ) );
+ int dim = atoi( argv[2] );
+ unsigned dimension = std::numeric_limits<unsigned>::max();
+ if ( (dim != -1) && (dim >= 0) )
+ {
+ dimension = (unsigned)dim;
+ }
+ Persistence_intervals p( argv[1] , dimension );
+ std::vector< std::pair<double,double> > dominant_intervals = p.dominant_intervals( atoi( argv[3] ) );
std::cout << "Here are the dominant intervals : " << std::endl;
for ( size_t i = 0 ; i != dominant_intervals.size() ; ++i )
{
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 db9c3f98..11876a0d 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
@@ -39,10 +39,21 @@ int main( int argc , char** argv )
if ( argc != 3 )
{
std::cout << "To run this program, please provide the name of a file with persistence diagram and number of dominant intervals you would like to get \n";
+ std::cout << "The second parameter of a program is the dimension of the persistence that is to be used. If your file contains only birth-death pairs, you can skip this parameter\n";
return 1;
}
+ unsigned dimension = std::numeric_limits<unsigned>::max();
+ int dim = -1;
+ if ( argc > 2 )
+ {
+ dim = atoi( argv[2] );
+ }
+ if ( (dim != -1) && (dim >= 0) )
+ {
+ dimension = (unsigned)dim;
+ }
- Persistence_intervals p( argv[1] );
+ Persistence_intervals p( argv[1] , dimension );
std::vector< std::pair<double,double> > dominant_intervals = p.dominant_intervals( atoi( argv[2] ) );
std::vector< size_t > histogram = p.histogram_of_lengths( 10 );
diff --git a/src/Gudhi_stat/utilities/persistence_intervals/plot_persistence_Betti_numebrs.cpp b/src/Gudhi_stat/utilities/persistence_intervals/plot_persistence_Betti_numbers.cpp
index cb89f6b9..09c6cc22 100644
--- a/src/Gudhi_stat/utilities/persistence_intervals/plot_persistence_Betti_numebrs.cpp
+++ b/src/Gudhi_stat/utilities/persistence_intervals/plot_persistence_Betti_numbers.cpp
@@ -36,12 +36,22 @@ using namespace Gudhi::Gudhi_stat;
int main( int argc , char** argv )
{
std::cout << "This program compute a plot of persistence Betti numbers. The input parameter is a file with persistence intervals. \n";
- if ( argc != 2 )
+ std::cout << "The second optional parameter of a program is the dimension of the persistence that is to be used. If your file contains only birth-death pairs, you can skip this parameter\n";
+ if ( argc < 2 )
{
std::cout << "To run this program, please provide the name of a file with persistence diagram and number of dominant intervals you would like to get \n";
return 1;
}
-
+ unsigned dimension = std::numeric_limits<unsigned>::max();
+ int dim = -1;
+ if ( argc > 2 )
+ {
+ dim = atoi( argv[2] );
+ }
+ if ( (dim != -1) && (dim >= 0) )
+ {
+ dimension = (unsigned)dim;
+ }
std::stringstream gnuplot_script;
@@ -49,7 +59,7 @@ int main( int argc , char** argv )
std::ofstream out;
out.open( gnuplot_script.str().c_str() );
- Persistence_intervals p( argv[1] );
+ Persistence_intervals p( argv[1] , dimension );
std::vector< std::pair< double , size_t > > pbns = p.compute_persistent_betti_numbers();
//set up the ranges so that we see the image well.
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 bc466bd3..4315abb9 100644
--- a/src/Gudhi_stat/utilities/persistence_intervals/plot_persistence_intervals.cpp
+++ b/src/Gudhi_stat/utilities/persistence_intervals/plot_persistence_intervals.cpp
@@ -42,9 +42,23 @@ int main( int argc , char** argv )
if ( argc != 2 )
{
std::cout << "To run this program, please provide the name of a file with persistence diagram \n";
+ std::cout << "The second optional parameter of a program is the dimension of the persistence that is to be used. If your file contains only birth-death pairs, you can skip this parameter\n";
return 1;
}
- std::vector< std::pair< double , double > > intervals = read_gudhi_persistence_file_in_one_dimension( argv[1] , 2 );
+ unsigned dimension = std::numeric_limits<unsigned>::max();
+ int dim = -1;
+ if ( argc > 2 )
+ {
+ dim = atoi( argv[2] );
+ }
+ if ( (dim != -1) && (dim >= 0) )
+ {
+ dimension = (unsigned)dim;
+ }
+
+
+
+ std::vector< std::pair< double , double > > intervals = read_persistence_intervals_in_one_dimension_from_file( argv[1] , dimension );
Persistence_intervals b( intervals );
b.plot( argv[1] );
return 0;
diff --git a/src/Gudhi_stat/utilities/persistence_landscapes/create_landscapes.cpp b/src/Gudhi_stat/utilities/persistence_landscapes/create_landscapes.cpp
index 5485bf2a..f36e313a 100644
--- a/src/Gudhi_stat/utilities/persistence_landscapes/create_landscapes.cpp
+++ b/src/Gudhi_stat/utilities/persistence_landscapes/create_landscapes.cpp
@@ -32,9 +32,19 @@ using namespace Gudhi::Gudhi_stat;
int main( int argc , char** argv )
{
- std::cout << "This program creates persistence landscapes of diagrams provided as an input. Please call this program with the names of files with persistence diagrams \n";
+ std::cout << "This program creates persistence landscapes of diagrams provided as an input. \n";
+ std::cout << "The first parameter of the program is the dimension of persistence to be used to construct persistence landscapes. If your file contains ";
+ std::cout << "the information about dimension of persistence pairs, please provide here the dimension of persistence pairs you want to use. If your input files consist only ";
+ std::cout << "of birth-death pairs, please set this first parameter to -1 \n";
+ std::cout << "The remaining parameters of the program are the names of files with persistence diagrams. \n";
std::vector< const char* > filenames;
- for ( int i = 1 ; i < argc ; ++i )
+ int dim = atoi(argv[1]);
+ unsigned dimension = std::numeric_limits<unsigned>::max();
+ if ( (dim != -1) && (dim >= 0) )
+ {
+ dimension = (unsigned)dim;
+ }
+ for ( int i = 2 ; i < argc ; ++i )
{
filenames.push_back( argv[i] );
}
@@ -42,8 +52,7 @@ int main( int argc , char** argv )
std::cout << "Creating persistence landscapes...\n";
for ( size_t i = 0 ; i != filenames.size() ; ++i )
{
- //std::vector< std::pair< double , double > > pers = read_standard_file( filename );
- Persistence_landscape l( filenames[i] , 1 );
+ Persistence_landscape l( filenames[i] , dimension );
std::stringstream ss;
ss << filenames[i] << ".land";
l.print_to_file( ss.str().c_str() );
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 4f36f02d..eb534bf1 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
@@ -36,9 +36,12 @@ int main( int argc , char** argv )
std::cout << "This program creates persistence landscape on grid of diagrams provided as an input.\n";
std::cout << "The first parameter of a program is an integer, a size of a grid.\n";
std::cout << "The second and third parameters are min and max of the grid. If you want those numbers to be computed based on the data, set them both to -1 \n";
+ std::cout << "The fourth parameter of the program is the dimension of persistence to be used to construct persistence landscape on a grid. If your file contains ";
+ std::cout << "the information about dimension of birth-death pairs, please provide here the dimension of intervals you want to use. If your input files consist only ";
+ std::cout << "of birth-death pairs, please set the fourth parameter to -1 \n";
std::cout << "The remaining parameters are the names of files with persistence diagrams. \n";
- if ( argc < 4 )
+ if ( argc < 5 )
{
std::cout << "Wrong parameter list, the program will now terminate \n";
return 1;
@@ -47,9 +50,15 @@ int main( int argc , char** argv )
size_t size_of_grid = (size_t)atoi( argv[1] );
double min_ = atof( argv[2] );
double max_ = atof( argv[3] );
+ int dim = atoi( argv[4] );
+ unsigned dimension = std::numeric_limits<unsigned>::max();
+ if ( (dim != -1) && (dim >= 0) )
+ {
+ dimension = (unsigned)dim;
+ }
std::vector< const char* > filenames;
- for ( int i = 4 ; i < argc ; ++i )
+ for ( int i = 5 ; i < argc ; ++i )
{
filenames.push_back( argv[i] );
}
@@ -61,12 +70,12 @@ int main( int argc , char** argv )
Persistence_landscape_on_grid l;
if ( (min_ != -1) || (max_ != -1) )
{
- l = Persistence_landscape_on_grid( filenames[i] , min_ , max_ , size_of_grid );
+ l = Persistence_landscape_on_grid( filenames[i] , min_ , max_ , size_of_grid , dimension );
}
else
{
//(min_ == -1) && (max_ == -1), in this case the program will find min_ and max_ based on the data.
- l = Persistence_landscape_on_grid( filenames[i] , size_of_grid );
+ l = Persistence_landscape_on_grid( filenames[i] , size_of_grid , dimension );
}
std::stringstream ss;
ss << filenames[i] << ".g_land";
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 fc434ba8..40f5e81f 100644
--- a/src/Gudhi_stat/utilities/persistence_vectors/create_persistence_vectors.cpp
+++ b/src/Gudhi_stat/utilities/persistence_vectors/create_persistence_vectors.cpp
@@ -33,9 +33,19 @@ using namespace Gudhi::Gudhi_stat;
int main( int argc , char** argv )
{
- std::cout << "This program creates persistence vectors of diagrams provided as an input. Please call this program with the names of files with persistence diagrams \n";
+ std::cout << "This program creates persistence vectors of diagrams provided as an input. The first parameter of this program is a dimension of persistence ";
+ std::cout << " that will be used in creation of the persistence vectors. If our input files contain persistence pairs of various dimension, as a second parameter of the ";
+ std::cout << " procedure please provide the dimension of persistence you want to use. If in your file there are only birth-death pairs of the same dimension, set the first parameter to -1." << std::endl;
+ std::cout << "The remaining parameters are the names of files with persistence diagrams. \n";
+ int dim = atoi( argv[1] );
+ unsigned dimension = std::numeric_limits<unsigned>::max();
+ if ( (dim != -1) && (dim >= 0) )
+ {
+ dimension = (unsigned)dim;
+ }
+
std::vector< const char* > filenames;
- for ( int i = 1 ; i < argc ; ++i )
+ for ( int i = 2 ; i < argc ; ++i )
{
filenames.push_back( argv[i] );
}
@@ -44,7 +54,7 @@ int main( int argc , char** argv )
{
std::cerr << "Creatign persistence vectors based on a file : " << filenames[i] << std::endl;
//std::vector< std::pair< double , double > > persistence_pairs = read_gudhi_persistence_file_in_one_dimension( filenames[i] , size_t dimension = 0 )
- Vector_distances_in_diagram< Euclidean_distance > l( filenames[i] , -1 );
+ Vector_distances_in_diagram< Euclidean_distance > l( filenames[i] , dimension );
std::stringstream ss;
ss << filenames[i] << ".vect";
l.print_to_file( ss.str().c_str() );