summaryrefslogtreecommitdiff
path: root/src/Gudhi_stat/example
diff options
context:
space:
mode:
authorpdlotko <pdlotko@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2016-09-23 13:18:09 +0000
committerpdlotko <pdlotko@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2016-09-23 13:18:09 +0000
commit5719bcccd6b09eadcae8de8d9b8f1aa4983c56b3 (patch)
tree6547a06b76892416dcd7f1bf86f8605acd26e955 /src/Gudhi_stat/example
parent1df5ef4350bd17588bf431eb809fff6818bff93e (diff)
Finished adding utitilites. Note that they are still not tested!!!
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/gudhi_stat@1553 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 61243549302b6e87376c7c725240949be67d44ac
Diffstat (limited to 'src/Gudhi_stat/example')
-rw-r--r--src/Gudhi_stat/example/CMakeLists.txt49
-rw-r--r--src/Gudhi_stat/example/persistence_heat_maps.cpp8
-rw-r--r--src/Gudhi_stat/example/persistence_landscape.cpp2
-rw-r--r--src/Gudhi_stat/example/persistence_landscape_on_grid.cpp2
-rw-r--r--src/Gudhi_stat/example/utilities/persistence_heat_maps/average_persistence_heat_maps.cpp73
-rw-r--r--src/Gudhi_stat/example/utilities/persistence_heat_maps/compute_distance_of_persistence_heat_maps.cpp107
-rw-r--r--src/Gudhi_stat/example/utilities/persistence_heat_maps/compute_scalar_product_of_persistence_heat_maps.cpp91
-rw-r--r--src/Gudhi_stat/example/utilities/persistence_heat_maps/create_persistence_heat_maps.cpp76
-rw-r--r--src/Gudhi_stat/example/utilities/persistence_heat_maps/plot_persistence_heat_map.cpp50
-rw-r--r--src/Gudhi_stat/example/utilities/persistence_landscapes/average_landscapes.cpp2
-rw-r--r--src/Gudhi_stat/example/utilities/persistence_landscapes/create_landscapes.cpp2
-rw-r--r--src/Gudhi_stat/example/utilities/persistence_landscapes/plot_landscapes.cpp2
-rw-r--r--src/Gudhi_stat/example/utilities/persistence_landscapes_on_grid/average_landscapes_on_grid.cpp74
-rw-r--r--src/Gudhi_stat/example/utilities/persistence_landscapes_on_grid/compute_distance_of_landscapes_on_grid.cpp107
-rw-r--r--src/Gudhi_stat/example/utilities/persistence_landscapes_on_grid/compute_scalar_product_of_landscapes_on_grid.cpp91
-rw-r--r--src/Gudhi_stat/example/utilities/persistence_landscapes_on_grid/create_landscapes_on_grid.cpp79
-rw-r--r--src/Gudhi_stat/example/utilities/persistence_landscapes_on_grid/plot_landscapes_on_grid.cpp50
-rw-r--r--src/Gudhi_stat/example/utilities/persistence_vectors/average_persistence_vectors.cpp74
-rw-r--r--src/Gudhi_stat/example/utilities/persistence_vectors/compute_distance_of_persistence_vectors.cpp107
-rw-r--r--src/Gudhi_stat/example/utilities/persistence_vectors/compute_scalar_product_of_persistence_vectors.cpp97
-rw-r--r--src/Gudhi_stat/example/utilities/persistence_vectors/create_persistence_vectors.cpp56
-rw-r--r--src/Gudhi_stat/example/vector_representation.cpp1
22 files changed, 1189 insertions, 11 deletions
diff --git a/src/Gudhi_stat/example/CMakeLists.txt b/src/Gudhi_stat/example/CMakeLists.txt
index a0390875..0dd35dd6 100644
--- a/src/Gudhi_stat/example/CMakeLists.txt
+++ b/src/Gudhi_stat/example/CMakeLists.txt
@@ -48,8 +48,55 @@ target_link_libraries(utilities/persistence_landscapes/create_landscapes ${Boost
add_executable ( utilities/persistence_landscapes/plot_landscapes utilities/persistence_landscapes/plot_landscapes.cpp )
target_link_libraries(utilities/persistence_landscapes/plot_landscapes ${Boost_SYSTEM_LIBRARY})
+add_executable ( utilities/persistence_landscapes/compute_distance_of_landscapes utilities/persistence_landscapes/compute_distance_of_landscapes.cpp )
+target_link_libraries(utilities/persistence_landscapes/compute_distance_of_landscapes ${Boost_SYSTEM_LIBRARY})
+
+add_executable ( utilities/persistence_landscapes/compute_scalar_product_of_landscapes utilities/persistence_landscapes/compute_scalar_product_of_landscapes.cpp )
+target_link_libraries(utilities/persistence_landscapes/compute_scalar_product_of_landscapes ${Boost_SYSTEM_LIBRARY})
+
#persitence landscapes on a grid
+add_executable ( utilities/persistence_landscapes_on_grid/average_landscapes_on_grid utilities/persistence_landscapes_on_grid/average_landscapes_on_grid.cpp )
+target_link_libraries(utilities/persistence_landscapes_on_grid/average_landscapes_on_grid ${Boost_SYSTEM_LIBRARY})
+
+add_executable ( utilities/persistence_landscapes_on_grid/create_landscapes_on_grid utilities/persistence_landscapes_on_grid/create_landscapes_on_grid.cpp )
+target_link_libraries(utilities/persistence_landscapes_on_grid/create_landscapes_on_grid ${Boost_SYSTEM_LIBRARY})
+
+add_executable ( utilities/persistence_landscapes_on_grid/plot_landscapes_on_grid utilities/persistence_landscapes_on_grid/plot_landscapes_on_grid.cpp )
+target_link_libraries(utilities/persistence_landscapes_on_grid/plot_landscapes_on_grid ${Boost_SYSTEM_LIBRARY})
+
+add_executable ( utilities/persistence_landscapes_on_grid/compute_distance_of_landscapes_on_grid utilities/persistence_landscapes_on_grid/compute_distance_of_landscapes_on_grid.cpp )
+target_link_libraries(utilities/persistence_landscapes_on_grid/compute_distance_of_landscapes_on_grid ${Boost_SYSTEM_LIBRARY})
+
+add_executable ( utilities/persistence_landscapes_on_grid/compute_scalar_product_of_landscapes_on_grid utilities/persistence_landscapes_on_grid/compute_scalar_product_of_landscapes_on_grid.cpp )
+target_link_libraries(utilities/persistence_landscapes_on_grid/compute_scalar_product_of_landscapes_on_grid ${Boost_SYSTEM_LIBRARY})
+
+#persitence heat maps
+add_executable ( utilities/persistence_heat_maps/average_persistence_heat_maps utilities/persistence_heat_maps/average_persistence_heat_maps.cpp )
+target_link_libraries(utilities/persistence_heat_maps/average_persistence_heat_maps ${Boost_SYSTEM_LIBRARY})
+
+add_executable ( utilities/persistence_heat_maps/create_persistence_heat_maps utilities/persistence_heat_maps/create_persistence_heat_maps.cpp )
+target_link_libraries(utilities/persistence_heat_maps/create_persistence_heat_maps ${Boost_SYSTEM_LIBRARY})
-#persitence images
+add_executable ( utilities/persistence_heat_maps/plot_persistence_heat_map utilities/persistence_heat_maps/plot_persistence_heat_map.cpp )
+target_link_libraries(utilities/persistence_heat_maps/plot_persistence_heat_map ${Boost_SYSTEM_LIBRARY})
+
+add_executable ( utilities/persistence_heat_maps/compute_distance_of_persistence_heat_maps utilities/persistence_heat_maps/compute_distance_of_persistence_heat_maps.cpp )
+target_link_libraries(utilities/persistence_heat_maps/compute_distance_of_persistence_heat_maps ${Boost_SYSTEM_LIBRARY})
+
+add_executable ( utilities/persistence_heat_maps/compute_scalar_product_of_persistence_heat_maps utilities/persistence_heat_maps/compute_scalar_product_of_persistence_heat_maps.cpp )
+target_link_libraries(utilities/persistence_heat_maps/compute_scalar_product_of_persistence_heat_maps ${Boost_SYSTEM_LIBRARY})
#persitence vectors
+add_executable ( utilities/persistence_vectors/average_persistence_vectors utilities/persistence_vectors/average_persistence_vectors.cpp )
+target_link_libraries(utilities/persistence_vectors/average_persistence_vectors ${Boost_SYSTEM_LIBRARY})
+
+add_executable ( utilities/persistence_vectors/create_persistence_vectors utilities/persistence_vectors/create_persistence_vectors.cpp )
+target_link_libraries(utilities/persistence_vectors/create_persistence_vectors ${Boost_SYSTEM_LIBRARY})
+
+add_executable ( utilities/persistence_vectors/compute_distance_of_persistence_vectors utilities/persistence_vectors/compute_distance_of_persistence_vectors.cpp )
+target_link_libraries(utilities/persistence_vectors/compute_distance_of_persistence_vectors ${Boost_SYSTEM_LIBRARY})
+
+add_executable ( utilities/persistence_vectors/compute_scalar_product_of_persistence_vectors utilities/persistence_vectors/compute_scalar_product_of_persistence_vectors.cpp )
+target_link_libraries(utilities/persistence_vectors/compute_scalar_product_of_persistence_vectors ${Boost_SYSTEM_LIBRARY})
+
+
diff --git a/src/Gudhi_stat/example/persistence_heat_maps.cpp b/src/Gudhi_stat/example/persistence_heat_maps.cpp
index fc9e31a0..cd0c4113 100644
--- a/src/Gudhi_stat/example/persistence_heat_maps.cpp
+++ b/src/Gudhi_stat/example/persistence_heat_maps.cpp
@@ -83,7 +83,7 @@ int main( int argc , char** argv )
//test to construct persistence heat map:
std::vector< std::vector<double> > filter = create_Gaussian_filter(100,1);
Persistence_heat_maps p( "file_with_diagram" , filter , constant_function, false , 1000 , 0 , 1 );
- p.write_to_file( "persistence_heat_map_from_file_with_diagram" );
+ p.print_to_file( "persistence_heat_map_from_file_with_diagram" );
Persistence_heat_maps q;
q.load_from_file( "persistence_heat_map_from_file_with_diagram" );
@@ -126,7 +126,7 @@ int main( int argc , char** argv )
Persistence_heat_maps av;
av.compute_average( to_average );
- av.write_to_file( "template_average_of_heat_maps" );
+ av.print_to_file( "template_average_of_heat_maps" );
*/
/*
@@ -162,7 +162,7 @@ int main( int argc , char** argv )
Persistence_heat_maps median;
median.compute_median( to_compute_median );
- median.write_to_file( "template_median_of_heat_maps" );
+ median.print_to_file( "template_median_of_heat_maps" );
*/
@@ -179,7 +179,7 @@ int main( int argc , char** argv )
Persistence_heat_maps percentage_of_active;
percentage_of_active.compute_percentage_of_active( to_compute_percentage_of_active , 0.1 );
- percentage_of_active.write_to_file( "template_percentage_of_active_of_heat_maps" );
+ percentage_of_active.print_to_file( "template_percentage_of_active_of_heat_maps" );
//percentage_of_active.plot( "template_percentage_of_active_of_heat_maps" );
diff --git a/src/Gudhi_stat/example/persistence_landscape.cpp b/src/Gudhi_stat/example/persistence_landscape.cpp
index 7bd04b4d..ab58886a 100644
--- a/src/Gudhi_stat/example/persistence_landscape.cpp
+++ b/src/Gudhi_stat/example/persistence_landscape.cpp
@@ -23,7 +23,7 @@
#include <gudhi/abstract_classes/Abs_Topological_data.h>
-#include <gudhi/concretizations/Persistence_landscapes.h>
+#include <gudhi/concretizations/Persistence_landscape.h>
diff --git a/src/Gudhi_stat/example/persistence_landscape_on_grid.cpp b/src/Gudhi_stat/example/persistence_landscape_on_grid.cpp
index d5b0808b..7781493b 100644
--- a/src/Gudhi_stat/example/persistence_landscape_on_grid.cpp
+++ b/src/Gudhi_stat/example/persistence_landscape_on_grid.cpp
@@ -23,7 +23,7 @@
#include <gudhi/abstract_classes/Abs_Topological_data.h>
-#include <gudhi/concretizations/Persistence_landscapes_on_grid.h>
+#include <gudhi/concretizations/Persistence_landscape_on_grid.h>
diff --git a/src/Gudhi_stat/example/utilities/persistence_heat_maps/average_persistence_heat_maps.cpp b/src/Gudhi_stat/example/utilities/persistence_heat_maps/average_persistence_heat_maps.cpp
new file mode 100644
index 00000000..a7359a02
--- /dev/null
+++ b/src/Gudhi_stat/example/utilities/persistence_heat_maps/average_persistence_heat_maps.cpp
@@ -0,0 +1,73 @@
+/* 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 Sophia-Saclay (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/abstract_classes/Abs_Topological_data.h>
+#include <gudhi/concretizations/Persistence_heat_maps.h>
+
+
+
+using namespace Gudhi;
+using namespace Gudhi::Gudhi_stat;
+
+#include <iostream>
+
+
+int main( int argc , char** argv )
+{
+ std::cout << "This program computes average persistence landscape of persistence landscapes created based on persistence diagrams provided as an input. Please call this program with the names of files with persistence diagrams \n";
+ std::vector< const char* > filenames;
+
+ if ( argc == 1 )
+ {
+ std::cout << "No input files given, the program will now terminate \n";
+ return 1;
+ }
+
+ for ( int i = 1 ; i < argc ; ++i )
+ {
+ filenames.push_back( argv[i] );
+ }
+
+ std::cout << "Creating persistence landscapes...\n";
+ std::vector< Abs_Topological_data_with_averages* > 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 );
+ }
+
+ Persistence_heat_maps av;
+ av.compute_average( maps );
+
+ av.print_to_file( "average" );
+
+ for ( size_t i = 0 ; i != filenames.size() ; ++i )
+ {
+ delete maps[i];
+ }
+
+ std::cout << "Done \n";
+ return 0;
+}
diff --git a/src/Gudhi_stat/example/utilities/persistence_heat_maps/compute_distance_of_persistence_heat_maps.cpp b/src/Gudhi_stat/example/utilities/persistence_heat_maps/compute_distance_of_persistence_heat_maps.cpp
new file mode 100644
index 00000000..8164a93e
--- /dev/null
+++ b/src/Gudhi_stat/example/utilities/persistence_heat_maps/compute_distance_of_persistence_heat_maps.cpp
@@ -0,0 +1,107 @@
+/* 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 Sophia-Saclay (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/abstract_classes/Abs_Topological_data.h>
+#include <gudhi/concretizations/Persistence_heat_maps.h>
+
+
+
+using namespace Gudhi;
+using namespace Gudhi::Gudhi_stat;
+
+#include <iostream>
+#include <sstream>
+
+
+int main( int argc , char** argv )
+{
+ std::cout << "This program compute dsitance of persistence landscapes stored in a file (the file needs to be created beforehand). \n";
+ std::cout << "The first parameter of a program is an interger p. The program compute L^p distance of the two landscapes. For L^infty distance choose p = -1. \n";
+ std::cout << "The remaining parameters of this programs are names of files with persistence landscapes.";
+
+ if ( argc < 3 )
+ {
+ std::cout << "Wrong number of parameters, the program will now terminate \n";
+ return 1;
+ }
+
+ int p = atoi( argv[3] );
+
+ std::vector< const char* > filenames;
+ for ( int i = 2 ; i < argc ; ++i )
+ {
+ filenames.push_back( argv[i] );
+ }
+ std::vector< Abs_Topological_data_with_distances* > 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 );
+ }
+
+ //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 distnaces:
+ for ( size_t i = 0 ; i != filenames.size() ; ++i )
+ {
+ for ( size_t j = i ; j != filenames.size() ; ++j )
+ {
+ distance[i][j] = distance[j][i] = ((Persistence_heat_maps*)maps[i])->distance( maps[j] , p ) ;
+ }
+ }
+
+ //and now output the result to the screen and a file:
+ ofstream out;
+ out.open( "distance" );
+ for ( size_t i = 0 ; i != distance.size() ; ++i )
+ {
+ for ( size_t j = 0 ; j != distance.size() ; ++j )
+ {
+ cout << distance[i][j] << " ";
+ out << distance[i][j] << " ";
+ }
+ cout << endl;
+ out << endl;
+ }
+ out.close();
+
+ return 0;
+}
+
+
+
+
+
+
+
diff --git a/src/Gudhi_stat/example/utilities/persistence_heat_maps/compute_scalar_product_of_persistence_heat_maps.cpp b/src/Gudhi_stat/example/utilities/persistence_heat_maps/compute_scalar_product_of_persistence_heat_maps.cpp
new file mode 100644
index 00000000..82fe207e
--- /dev/null
+++ b/src/Gudhi_stat/example/utilities/persistence_heat_maps/compute_scalar_product_of_persistence_heat_maps.cpp
@@ -0,0 +1,91 @@
+/* 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 Sophia-Saclay (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/abstract_classes/Abs_Topological_data.h>
+#include <gudhi/concretizations/Persistence_heat_maps.h>
+
+
+
+using namespace Gudhi;
+using namespace Gudhi::Gudhi_stat;
+
+#include <iostream>
+#include <sstream>
+
+
+int main( int argc , char** argv )
+{
+ std::cout << "This program compute scalar product of persistence landscapes stored in a file (the file needs to be created beforehand). \n";
+ std::cout << "The parameters of this programs are names of files with persistence landscapes.";
+
+ std::vector< const char* > filenames;
+ for ( int i = 1 ; i < argc ; ++i )
+ {
+ filenames.push_back( argv[i] );
+ }
+ 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( l );
+ }
+
+ //and now we will compute the scalar product of landscapes.
+
+ //first we prepare an array:
+ std::vector< std::vector< double > > scalar_product( filenames.size() );
+ for ( size_t i = 0 ; i != filenames.size() ; ++i )
+ {
+ std::vector< double > v( filenames.size() , 0 );
+ scalar_product[i] = v;
+ }
+
+ //and now we can compute the scalar product:
+ for ( size_t i = 0 ; i != maps.size() ; ++i )
+ {
+ 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] ) ;
+ }
+ }
+
+ //and now output the result to the screen and a file:
+ ofstream out;
+ out.open( "scalar_product" );
+ for ( size_t i = 0 ; i != scalar_product.size() ; ++i )
+ {
+ for ( size_t j = 0 ; j != scalar_product.size() ; ++j )
+ {
+ cout << scalar_product[i][j] << " ";
+ out << scalar_product[i][j] << " ";
+ }
+ cout << endl;
+ out << endl;
+ }
+ out.close();
+
+ return 0;
+}
diff --git a/src/Gudhi_stat/example/utilities/persistence_heat_maps/create_persistence_heat_maps.cpp b/src/Gudhi_stat/example/utilities/persistence_heat_maps/create_persistence_heat_maps.cpp
new file mode 100644
index 00000000..152a1616
--- /dev/null
+++ b/src/Gudhi_stat/example/utilities/persistence_heat_maps/create_persistence_heat_maps.cpp
@@ -0,0 +1,76 @@
+/* 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 Sophia-Saclay (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/abstract_classes/Abs_Topological_data.h>
+#include <gudhi/concretizations/Persistence_heat_maps.h>
+
+
+
+using namespace Gudhi;
+using namespace Gudhi::Gudhi_stat;
+
+#include <iostream>
+#include <sstream>
+
+
+
+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 remoaning parameters are the names of files with persistence diagrams. \n";
+
+ if ( argc < 4 )
+ {
+ 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] );
+
+ std::vector< const char* > filenames;
+ for ( int i = 4 ; i < argc ; ++i )
+ {
+ filenames.push_back( argv[i] );
+ }
+
+
+
+
+ std::cout << "Creating persistence heat maps...\n";
+ std::vector< std::vector<double> > filter = create_Gaussian_filter(10,1);
+
+ for ( size_t i = 0 ; i != filenames.size() ; ++i )
+ {
+ Persistence_heat_maps l( filenames[i] , filter, constant_function, false , size_of_grid , min_ , max_ );
+ std::stringstream ss;
+ ss << filenames[i] << ".land";
+ l.print_to_file( ss.str().c_str() );
+ }
+ std::cout << "Done \n";
+ return 0;
+}
diff --git a/src/Gudhi_stat/example/utilities/persistence_heat_maps/plot_persistence_heat_map.cpp b/src/Gudhi_stat/example/utilities/persistence_heat_maps/plot_persistence_heat_map.cpp
new file mode 100644
index 00000000..d163aba6
--- /dev/null
+++ b/src/Gudhi_stat/example/utilities/persistence_heat_maps/plot_persistence_heat_map.cpp
@@ -0,0 +1,50 @@
+/* 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 Sophia-Saclay (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/abstract_classes/Abs_Topological_data.h>
+#include <gudhi/concretizations/Persistence_heat_maps.h>
+
+
+
+using namespace Gudhi;
+using namespace Gudhi::Gudhi_stat;
+
+#include <iostream>
+#include <sstream>
+
+
+int main( int argc , char** argv )
+{
+ std::cout << "This program plot persistence landscape stored in a file (the file needs to be created beforehand). Please call the code with the name of a landsape file \n";
+ Persistence_heat_maps l;
+ l.load_from_file( argv[1] );
+
+ std::stringstream ss;
+ ss << argv[1] << "_gnuplot_script";
+ l.plot( ss.str().c_str() );
+
+ std::cout << "Done \n";
+
+ return 0;
+}
diff --git a/src/Gudhi_stat/example/utilities/persistence_landscapes/average_landscapes.cpp b/src/Gudhi_stat/example/utilities/persistence_landscapes/average_landscapes.cpp
index ac3b6432..47c3f150 100644
--- a/src/Gudhi_stat/example/utilities/persistence_landscapes/average_landscapes.cpp
+++ b/src/Gudhi_stat/example/utilities/persistence_landscapes/average_landscapes.cpp
@@ -23,7 +23,7 @@
#include <gudhi/abstract_classes/Abs_Topological_data.h>
-#include <gudhi/concretizations/Persistence_landscapes.h>
+#include <gudhi/concretizations/Persistence_landscape.h>
diff --git a/src/Gudhi_stat/example/utilities/persistence_landscapes/create_landscapes.cpp b/src/Gudhi_stat/example/utilities/persistence_landscapes/create_landscapes.cpp
index 0a5df3b9..5152a033 100644
--- a/src/Gudhi_stat/example/utilities/persistence_landscapes/create_landscapes.cpp
+++ b/src/Gudhi_stat/example/utilities/persistence_landscapes/create_landscapes.cpp
@@ -23,7 +23,7 @@
#include <gudhi/abstract_classes/Abs_Topological_data.h>
-#include <gudhi/concretizations/Persistence_landscapes.h>
+#include <gudhi/concretizations/Persistence_landscape.h>
diff --git a/src/Gudhi_stat/example/utilities/persistence_landscapes/plot_landscapes.cpp b/src/Gudhi_stat/example/utilities/persistence_landscapes/plot_landscapes.cpp
index 55575b97..559fc096 100644
--- a/src/Gudhi_stat/example/utilities/persistence_landscapes/plot_landscapes.cpp
+++ b/src/Gudhi_stat/example/utilities/persistence_landscapes/plot_landscapes.cpp
@@ -23,7 +23,7 @@
#include <gudhi/abstract_classes/Abs_Topological_data.h>
-#include <gudhi/concretizations/Persistence_landscapes.h>
+#include <gudhi/concretizations/Persistence_landscape.h>
diff --git a/src/Gudhi_stat/example/utilities/persistence_landscapes_on_grid/average_landscapes_on_grid.cpp b/src/Gudhi_stat/example/utilities/persistence_landscapes_on_grid/average_landscapes_on_grid.cpp
new file mode 100644
index 00000000..497e2c7c
--- /dev/null
+++ b/src/Gudhi_stat/example/utilities/persistence_landscapes_on_grid/average_landscapes_on_grid.cpp
@@ -0,0 +1,74 @@
+/* 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 Sophia-Saclay (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/abstract_classes/Abs_Topological_data.h>
+#include <gudhi/concretizations/Persistence_landscape_on_grid.h>
+
+
+
+using namespace Gudhi;
+using namespace Gudhi::Gudhi_stat;
+
+#include <iostream>
+
+
+int main( int argc , char** argv )
+{
+ std::cout << "This program computes average persistence landscape on grid of persistence landscapes on grid created based on persistence diagrams provided as an input. Please call this program with the names of files with persistence diagrams \n";
+ std::vector< const char* > filenames;
+
+ if ( argc == 1 )
+ {
+ std::cout << "No input files given, the program will now terminate \n";
+ return 1;
+ }
+
+ for ( int i = 1 ; i < argc ; ++i )
+ {
+ filenames.push_back( argv[i] );
+ }
+
+ std::cout << "Creating persistence landscapes...\n";
+ std::vector< Abs_Topological_data_with_averages* > 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 );
+ }
+
+ Persistence_landscape_on_grid av;
+ av.compute_average( lands );
+
+ av.print_to_file( "average" );
+
+ for ( size_t i = 0 ; i != filenames.size() ; ++i )
+ {
+ delete lands[i];
+ }
+
+ std::cout << "Done \n";
+
+ return 0;
+}
diff --git a/src/Gudhi_stat/example/utilities/persistence_landscapes_on_grid/compute_distance_of_landscapes_on_grid.cpp b/src/Gudhi_stat/example/utilities/persistence_landscapes_on_grid/compute_distance_of_landscapes_on_grid.cpp
new file mode 100644
index 00000000..355b7976
--- /dev/null
+++ b/src/Gudhi_stat/example/utilities/persistence_landscapes_on_grid/compute_distance_of_landscapes_on_grid.cpp
@@ -0,0 +1,107 @@
+/* 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 Sophia-Saclay (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/abstract_classes/Abs_Topological_data.h>
+#include <gudhi/concretizations/Persistence_landscape_on_grid.h>
+
+
+
+using namespace Gudhi;
+using namespace Gudhi::Gudhi_stat;
+
+#include <iostream>
+#include <sstream>
+
+
+int main( int argc , char** argv )
+{
+ std::cout << "This program compute dsitance of persistence landscapes on grid stored in a file (the file needs to be created beforehand). \n";
+ std::cout << "The first parameter of a program is an interger p. The program compute L^p distance of the two landscapes on grid. For L^infty distance choose p = -1. \n";
+ std::cout << "The remaining parameters of this programs are names of files with persistence landscapes on grid.";
+
+ if ( argc < 3 )
+ {
+ std::cout << "Wrong number of parameters, the program will now terminate \n";
+ return 1;
+ }
+
+ int p = atoi( argv[3] );
+
+ std::vector< const char* > filenames;
+ for ( int i = 2 ; i < argc ; ++i )
+ {
+ filenames.push_back( argv[i] );
+ }
+ std::vector< Persistence_landscape_on_grid > landscaspes;
+ landscaspes.reserve( filenames.size() );
+ for ( size_t file_no = 0 ; file_no != filenames.size() ; ++file_no )
+ {
+ Persistence_landscape_on_grid l;
+ l.load_landscape_from_file( filenames[file_no] );
+ landscaspes.push_back( l );
+ }
+
+ //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 scalar product:
+ for ( size_t i = 0 ; i != landscaspes.size() ; ++i )
+ {
+ for ( size_t j = i ; j != landscaspes.size() ; ++j )
+ {
+ distance[i][j] = distance[j][i] = compute_discance_of_landscapes_on_grid( landscaspes[i], landscaspes[j] , p ) ;
+ }
+ }
+
+ //and now output the result to the screen and a file:
+ ofstream out;
+ out.open( "distance" );
+ for ( size_t i = 0 ; i != distance.size() ; ++i )
+ {
+ for ( size_t j = 0 ; j != distance.size() ; ++j )
+ {
+ cout << distance[i][j] << " ";
+ out << distance[i][j] << " ";
+ }
+ cout << endl;
+ out << endl;
+ }
+ out.close();
+
+ return 0;
+}
+
+
+
+
+
+
+
diff --git a/src/Gudhi_stat/example/utilities/persistence_landscapes_on_grid/compute_scalar_product_of_landscapes_on_grid.cpp b/src/Gudhi_stat/example/utilities/persistence_landscapes_on_grid/compute_scalar_product_of_landscapes_on_grid.cpp
new file mode 100644
index 00000000..4f6f2f5a
--- /dev/null
+++ b/src/Gudhi_stat/example/utilities/persistence_landscapes_on_grid/compute_scalar_product_of_landscapes_on_grid.cpp
@@ -0,0 +1,91 @@
+/* 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 Sophia-Saclay (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/abstract_classes/Abs_Topological_data.h>
+#include <gudhi/concretizations/Persistence_landscape_on_grid.h>
+
+
+
+using namespace Gudhi;
+using namespace Gudhi::Gudhi_stat;
+
+#include <iostream>
+#include <sstream>
+
+
+int main( int argc , char** argv )
+{
+ std::cout << "This program compute scalar product of persistence landscapes on grid stored in a file (the file needs to be created beforehand). \n";
+ std::cout << "The parameters of this programs are names of files with persistence landscapes on grid.";
+
+ std::vector< const char* > filenames;
+ for ( int i = 1 ; i < argc ; ++i )
+ {
+ filenames.push_back( argv[i] );
+ }
+ std::vector< Persistence_landscape_on_grid > landscaspes;
+ landscaspes.reserve( filenames.size() );
+ for ( size_t file_no = 0 ; file_no != filenames.size() ; ++file_no )
+ {
+ Persistence_landscape_on_grid l;
+ l.load_landscape_from_file( filenames[file_no] );
+ landscaspes.push_back( l );
+ }
+
+ //and now we will compute the scalar product of landscapes.
+
+ //first we prepare an array:
+ std::vector< std::vector< double > > scalar_product( filenames.size() );
+ for ( size_t i = 0 ; i != filenames.size() ; ++i )
+ {
+ std::vector< double > v( filenames.size() , 0 );
+ scalar_product[i] = v;
+ }
+
+ //and now we can compute the scalar product:
+ for ( size_t i = 0 ; i != landscaspes.size() ; ++i )
+ {
+ for ( size_t j = i ; j != landscaspes.size() ; ++j )
+ {
+ scalar_product[i][j] = scalar_product[j][i] = compute_inner_product( landscaspes[i], landscaspes[j] ) ;
+ }
+ }
+
+ //and now output the result to the screen and a file:
+ ofstream out;
+ out.open( "scalar_product" );
+ for ( size_t i = 0 ; i != scalar_product.size() ; ++i )
+ {
+ for ( size_t j = 0 ; j != scalar_product.size() ; ++j )
+ {
+ cout << scalar_product[i][j] << " ";
+ out << scalar_product[i][j] << " ";
+ }
+ cout << endl;
+ out << endl;
+ }
+ out.close();
+
+ return 0;
+}
diff --git a/src/Gudhi_stat/example/utilities/persistence_landscapes_on_grid/create_landscapes_on_grid.cpp b/src/Gudhi_stat/example/utilities/persistence_landscapes_on_grid/create_landscapes_on_grid.cpp
new file mode 100644
index 00000000..096f1036
--- /dev/null
+++ b/src/Gudhi_stat/example/utilities/persistence_landscapes_on_grid/create_landscapes_on_grid.cpp
@@ -0,0 +1,79 @@
+/* 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 Sophia-Saclay (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/abstract_classes/Abs_Topological_data.h>
+#include <gudhi/concretizations/Persistence_landscape_on_grid.h>
+
+
+
+using namespace Gudhi;
+using namespace Gudhi::Gudhi_stat;
+
+#include <iostream>
+#include <sstream>
+
+
+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 remoaning parameters are the names of files with persistence diagrams. \n";
+
+ if ( argc < 4 )
+ {
+ 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] );
+
+ std::vector< const char* > filenames;
+ for ( int i = 4 ; i < argc ; ++i )
+ {
+ filenames.push_back( argv[i] );
+ }
+
+ std::cout << "Creating persistence landscapes...\n";
+ for ( size_t i = 0 ; i != filenames.size() ; ++i )
+ {
+ Persistence_landscape_on_grid l;
+ if ( (min_ != -1) || (max_ != -1) )
+ {
+ l = Persistence_landscape_on_grid( filenames[i] , min_ , max_ , size_of_grid );
+ }
+ 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 );
+ }
+ std::stringstream ss;
+ ss << filenames[i] << ".land";
+ l.print_to_file( ss.str().c_str() );
+ }
+ std::cout << "Done \n";
+ return 0;
+}
diff --git a/src/Gudhi_stat/example/utilities/persistence_landscapes_on_grid/plot_landscapes_on_grid.cpp b/src/Gudhi_stat/example/utilities/persistence_landscapes_on_grid/plot_landscapes_on_grid.cpp
new file mode 100644
index 00000000..21d2c014
--- /dev/null
+++ b/src/Gudhi_stat/example/utilities/persistence_landscapes_on_grid/plot_landscapes_on_grid.cpp
@@ -0,0 +1,50 @@
+/* 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 Sophia-Saclay (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/abstract_classes/Abs_Topological_data.h>
+#include <gudhi/concretizations/Persistence_landscape_on_grid.h>
+
+
+
+using namespace Gudhi;
+using namespace Gudhi::Gudhi_stat;
+
+#include <iostream>
+#include <sstream>
+
+
+int main( int argc , char** argv )
+{
+ std::cout << "This program plot persistence landscape on grid stored in a file (the file needs to be created beforehand). Please call the code with the name of a landsape on grid file \n";
+ Persistence_landscape_on_grid l;
+ l.load_landscape_from_file( argv[1] );
+
+ std::stringstream ss;
+ ss << argv[1] << "_gnuplot_script";
+ l.plot( ss.str().c_str() );
+
+ std::cout << "Done \n";
+
+ return 0;
+}
diff --git a/src/Gudhi_stat/example/utilities/persistence_vectors/average_persistence_vectors.cpp b/src/Gudhi_stat/example/utilities/persistence_vectors/average_persistence_vectors.cpp
new file mode 100644
index 00000000..f0c0ba61
--- /dev/null
+++ b/src/Gudhi_stat/example/utilities/persistence_vectors/average_persistence_vectors.cpp
@@ -0,0 +1,74 @@
+/* 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 Sophia-Saclay (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/abstract_classes/Abs_Topological_data.h>
+#include <gudhi/concretizations/Vector_distances_in_diagram.h>
+
+
+
+using namespace Gudhi;
+using namespace Gudhi::Gudhi_stat;
+
+#include <iostream>
+
+
+int main( int argc , char** argv )
+{
+ std::cout << "This program computes average persistence landscape of persistence landscapes created based on persistence diagrams provided as an input. Please call this program with the names of files with persistence diagrams \n";
+ std::vector< const char* > filenames;
+
+ if ( argc == 1 )
+ {
+ std::cout << "No input files given, the program will now terminate \n";
+ return 1;
+ }
+
+ for ( int i = 1 ; i < argc ; ++i )
+ {
+ filenames.push_back( argv[i] );
+ }
+
+ std::cout << "Creating persistence landscapes...\n";
+ std::vector< Abs_Topological_data_with_averages* > 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 );
+ }
+
+ Vector_distances_in_diagram< euclidean_distance<double> > av;
+ av.compute_average( lands );
+
+ av.print_to_file( "average" );
+
+ for ( size_t i = 0 ; i != filenames.size() ; ++i )
+ {
+ delete lands[i];
+ }
+
+ std::cout << "Done \n";
+
+ return 0;
+}
diff --git a/src/Gudhi_stat/example/utilities/persistence_vectors/compute_distance_of_persistence_vectors.cpp b/src/Gudhi_stat/example/utilities/persistence_vectors/compute_distance_of_persistence_vectors.cpp
new file mode 100644
index 00000000..f93c910a
--- /dev/null
+++ b/src/Gudhi_stat/example/utilities/persistence_vectors/compute_distance_of_persistence_vectors.cpp
@@ -0,0 +1,107 @@
+/* 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 Sophia-Saclay (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/abstract_classes/Abs_Topological_data.h>
+#include <gudhi/concretizations/Vector_distances_in_diagram.h>
+
+
+
+using namespace Gudhi;
+using namespace Gudhi::Gudhi_stat;
+
+#include <iostream>
+#include <sstream>
+
+
+int main( int argc , char** argv )
+{
+ std::cout << "This program compute dsitance of persistence vectors stored in a file (the file needs to be created beforehand). \n";
+ std::cout << "The first parameter of a program is an interger p. The program compute l^p distance of the vectors. For L^infty distance choose p = -1. \n";
+ std::cout << "The remaining parameters of this programs are names of files with persistence vectors.";
+
+ if ( argc < 3 )
+ {
+ std::cout << "Wrong number of parameters, the program will now terminate \n";
+ return 1;
+ }
+
+ int p = atoi( argv[3] );
+
+ std::vector< const char* > filenames;
+ for ( int i = 2 ; i < argc ; ++i )
+ {
+ filenames.push_back( argv[i] );
+ }
+ 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] );
+ vectors.push_back( l );
+ }
+
+ //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 != vectors.size() ; ++i )
+ {
+ for ( size_t j = i ; j != vectors.size() ; ++j )
+ {
+ distance[i][j] = distance[j][i] = ((Vector_distances_in_diagram< euclidean_distance<double> >*)vectors[i])->distance( vectors[j] , p ) ;
+ }
+ }
+
+ //and now output the result to the screen and a file:
+ ofstream out;
+ out.open( "distance" );
+ for ( size_t i = 0 ; i != distance.size() ; ++i )
+ {
+ for ( size_t j = 0 ; j != distance.size() ; ++j )
+ {
+ cout << distance[i][j] << " ";
+ out << distance[i][j] << " ";
+ }
+ cout << endl;
+ out << endl;
+ }
+ out.close();
+
+ return 0;
+}
+
+
+
+
+
+
+
diff --git a/src/Gudhi_stat/example/utilities/persistence_vectors/compute_scalar_product_of_persistence_vectors.cpp b/src/Gudhi_stat/example/utilities/persistence_vectors/compute_scalar_product_of_persistence_vectors.cpp
new file mode 100644
index 00000000..c886d076
--- /dev/null
+++ b/src/Gudhi_stat/example/utilities/persistence_vectors/compute_scalar_product_of_persistence_vectors.cpp
@@ -0,0 +1,97 @@
+/* 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 Sophia-Saclay (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/abstract_classes/Abs_Topological_data.h>
+#include <gudhi/concretizations/Vector_distances_in_diagram.h>
+
+
+
+using namespace Gudhi;
+using namespace Gudhi::Gudhi_stat;
+
+#include <iostream>
+#include <sstream>
+
+
+int main( int argc , char** argv )
+{
+ std::cout << "This program compute scalar product of persistence vectors stored in a file (the file needs to be created beforehand). \n";
+ std::cout << "The parameters of this programs are names of files with persistence vectors.";
+
+ std::vector< const char* > filenames;
+ for ( int i = 1 ; i < argc ; ++i )
+ {
+ filenames.push_back( argv[i] );
+ }
+ 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] );
+ vectors.push_back( l );
+ }
+
+ //and now we will compute the scalar product of landscapes.
+
+ //first we prepare an array:
+ std::vector< std::vector< double > > scalar_product( filenames.size() );
+ for ( size_t i = 0 ; i != filenames.size() ; ++i )
+ {
+ std::vector< double > v( filenames.size() , 0 );
+ scalar_product[i] = v;
+ }
+
+ //and now we can compute the scalar product:
+ for ( size_t i = 0 ; i != vectors.size() ; ++i )
+ {
+ 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] ) ;
+ }
+ }
+
+ //and now output the result to the screen and a file:
+ ofstream out;
+ out.open( "scalar_product" );
+ for ( size_t i = 0 ; i != scalar_product.size() ; ++i )
+ {
+ for ( size_t j = 0 ; j != scalar_product.size() ; ++j )
+ {
+ cout << scalar_product[i][j] << " ";
+ out << scalar_product[i][j] << " ";
+ }
+ cout << endl;
+ out << endl;
+ }
+ out.close();
+
+ //cleaning up
+ for ( size_t i = 0 ; i != vectors.size() ; ++i )
+ {
+ delete vectors[i];
+ }
+
+ return 0;
+}
diff --git a/src/Gudhi_stat/example/utilities/persistence_vectors/create_persistence_vectors.cpp b/src/Gudhi_stat/example/utilities/persistence_vectors/create_persistence_vectors.cpp
new file mode 100644
index 00000000..b800c872
--- /dev/null
+++ b/src/Gudhi_stat/example/utilities/persistence_vectors/create_persistence_vectors.cpp
@@ -0,0 +1,56 @@
+/* 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 Sophia-Saclay (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/abstract_classes/Abs_Topological_data.h>
+#include <gudhi/concretizations/Vector_distances_in_diagram.h>
+
+
+
+using namespace Gudhi;
+using namespace Gudhi::Gudhi_stat;
+
+#include <iostream>
+#include <sstream>
+
+
+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::vector< const char* > filenames;
+ for ( int i = 1 ; i < argc ; ++i )
+ {
+ filenames.push_back( argv[i] );
+ }
+
+ std::cout << "Creating persistence vectors...\n";
+ for ( size_t i = 0 ; i != filenames.size() ; ++i )
+ {
+ Vector_distances_in_diagram< euclidean_distance<double> > l( filenames[i] , -1 );
+ std::stringstream ss;
+ ss << filenames[i] << ".vect";
+ l.print_to_file( ss.str().c_str() );
+ }
+ std::cout << "Done \n";
+ return 0;
+}
diff --git a/src/Gudhi_stat/example/vector_representation.cpp b/src/Gudhi_stat/example/vector_representation.cpp
index 4e9cd1a6..358de1b0 100644
--- a/src/Gudhi_stat/example/vector_representation.cpp
+++ b/src/Gudhi_stat/example/vector_representation.cpp
@@ -50,7 +50,6 @@ int main( int argc , char** argv )
}
Vector_distances_in_diagram< euclidean_distance<double> > p( argv[1] , 100 );
-
cout << "This is a vector corresponding to the input persistence diagram : \n";
cout << p << endl;