summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/persistence_diagram/simple_diagram.txt4
-rw-r--r--src/Persistence_representations/example/CMakeLists.txt4
-rw-r--r--src/Persistence_representations/include/gudhi/Persistence_intervals.h12
-rw-r--r--src/Persistence_representations/include/gudhi/Persistence_intervals_with_distances.h2
-rw-r--r--src/Persistence_representations/utilities/CMakeLists.txt9
-rw-r--r--src/Persistence_representations/utilities/persistence_heat_maps/simple_diagram.txt.mps11
-rw-r--r--src/Persistence_representations/utilities/persistence_intervals/CMakeLists.txt38
-rw-r--r--src/Persistence_representations/utilities/persistence_intervals/compute_birth_death_range_in_persistence_diagram.cpp22
-rw-r--r--src/Persistence_representations/utilities/persistence_intervals/compute_bottleneck_distance.cpp20
-rw-r--r--src/Persistence_representations/utilities/persistence_intervals/compute_number_of_dominant_intervals.cpp1
-rw-r--r--src/Persistence_representations/utilities/persistence_intervals/plot_histogram_of_intervals_lengths.cpp39
-rw-r--r--src/Persistence_representations/utilities/persistence_intervals/plot_persistence_Betti_numbers.cpp30
-rw-r--r--src/Persistence_representations/utilities/persistence_intervals/plot_persistence_intervals.cpp13
-rw-r--r--src/Persistence_representations/utilities/persistence_landscapes/simple_diagram.txt.land13
-rw-r--r--src/Persistence_representations/utilities/persistence_landscapes_on_grid/simple_diagram.txt.g_land104
-rw-r--r--src/Persistence_representations/utilities/persistence_vectors/simple_diagram.txt.vect1
16 files changed, 94 insertions, 229 deletions
diff --git a/data/persistence_diagram/simple_diagram.txt b/data/persistence_diagram/simple_diagram.txt
deleted file mode 100644
index 2f199fd4..00000000
--- a/data/persistence_diagram/simple_diagram.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-1 2
-3 4
-5 6
-7 8 \ No newline at end of file
diff --git a/src/Persistence_representations/example/CMakeLists.txt b/src/Persistence_representations/example/CMakeLists.txt
index 7788b603..3a6696b7 100644
--- a/src/Persistence_representations/example/CMakeLists.txt
+++ b/src/Persistence_representations/example/CMakeLists.txt
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 2.6)
project(Persistence_representations_example)
-file(COPY "${CMAKE_SOURCE_DIR}/data/persistence_diagram/simple_diagram.txt" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/")
+#file(COPY "${CMAKE_SOURCE_DIR}/data/persistence_diagram/simple_diagram.txt" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/")
add_executable ( Persistence_representations_example_landscape_on_grid persistence_landscape_on_grid.cpp )
target_link_libraries(Persistence_representations_example_landscape_on_grid ${Boost_SYSTEM_LIBRARY})
@@ -17,7 +17,7 @@ add_executable ( Persistence_representations_example_intervals persistence_inter
target_link_libraries(Persistence_representations_example_intervals ${Boost_SYSTEM_LIBRARY})
add_test(NAME Persistence_representations_example_intervals
COMMAND $<TARGET_FILE:Persistence_representations_example_intervals>
- "${CMAKE_CURRENT_BINARY_DIR}/simple_diagram.txt")
+ "${CMAKE_SOURCE_DIR}/data/persistence_diagram/first.pers")
add_executable ( Persistence_representations_example_vectors persistence_vectors.cpp )
target_link_libraries(Persistence_representations_example_vectors ${Boost_SYSTEM_LIBRARY})
diff --git a/src/Persistence_representations/include/gudhi/Persistence_intervals.h b/src/Persistence_representations/include/gudhi/Persistence_intervals.h
index 525d58a3..1ed97882 100644
--- a/src/Persistence_representations/include/gudhi/Persistence_intervals.h
+++ b/src/Persistence_representations/include/gudhi/Persistence_intervals.h
@@ -167,10 +167,10 @@ class Persistence_intervals {
// this program create a gnuplot script file that allows to plot persistence diagram.
std::ofstream out;
- std::ostringstream nameSS;
- nameSS << filename << "_GnuplotScript";
- std::string nameStr = nameSS.str();
- out.open(nameStr);
+ std::stringstream gnuplot_script;
+ gnuplot_script << filename << "_GnuplotScript";
+
+ out.open(gnuplot_script.str().c_str());
std::pair<double, double> min_max_values = this->get_x_range();
if (min_x == max_x) {
@@ -195,8 +195,8 @@ class Persistence_intervals {
out.close();
- std::cout << "Gnuplot script to visualize persistence diagram written to the file: " << nameStr << ". Type load '"
- << nameStr << "' in gnuplot to visualize." << std::endl;
+ std::cout << "To visualize, install gnuplot and type the command: gnuplot -persist -e \"load \'"
+ << gnuplot_script.str().c_str() << "\'\"" << std::endl;
}
/**
diff --git a/src/Persistence_representations/include/gudhi/Persistence_intervals_with_distances.h b/src/Persistence_representations/include/gudhi/Persistence_intervals_with_distances.h
index d5ab04b4..2a3858bf 100644
--- a/src/Persistence_representations/include/gudhi/Persistence_intervals_with_distances.h
+++ b/src/Persistence_representations/include/gudhi/Persistence_intervals_with_distances.h
@@ -47,7 +47,7 @@ class Persistence_intervals_with_distances : public Persistence_intervals {
* The last parameter, tolerance, it is an additiv error of the approimation, set by default to zero.
**/
double distance(const Persistence_intervals_with_distances& second, double power = std::numeric_limits<double>::max(),
- double tolerance = 0) const {
+ double tolerance = (std::numeric_limits<double>::min)()) const {
if (power >= std::numeric_limits<double>::max()) {
return Gudhi::persistence_diagram::bottleneck_distance(this->intervals, second.intervals, tolerance);
} else {
diff --git a/src/Persistence_representations/utilities/CMakeLists.txt b/src/Persistence_representations/utilities/CMakeLists.txt
index d0d93f9d..137eb0c1 100644
--- a/src/Persistence_representations/utilities/CMakeLists.txt
+++ b/src/Persistence_representations/utilities/CMakeLists.txt
@@ -18,13 +18,13 @@ function(add_persistence_representation_plot_utility plot_utility tool_extension
# as the function is called in a subdirectory level, need to '../' to find persistence heat maps files
add_test(NAME Persistence_representation_utilities_${plot_utility}_first COMMAND $<TARGET_FILE:${plot_utility}>
"${CMAKE_CURRENT_BINARY_DIR}/../first.pers${tool_extension}")
- add_test(NAME Persistence_representation_utilities_${plot_utility}_second COMMAND $<TARGET_FILE:${plot_utility}>
- "${CMAKE_CURRENT_BINARY_DIR}/../second.pers${tool_extension}")
+ #add_test(NAME Persistence_representation_utilities_${plot_utility}_second COMMAND $<TARGET_FILE:${plot_utility}>
+ # "${CMAKE_CURRENT_BINARY_DIR}/../second.pers${tool_extension}")
if(GNUPLOT_PATH)
add_test(NAME Persistence_representation_utilities_${plot_utility}_first_gnuplot COMMAND ${GNUPLOT_PATH}
"-e" "load '${CMAKE_CURRENT_BINARY_DIR}/../first.pers${tool_extension}_GnuplotScript'")
- add_test(NAME Persistence_representation_utilities_${plot_utility}_second_gnuplot COMMAND ${GNUPLOT_PATH}
- "-e" "load '${CMAKE_CURRENT_BINARY_DIR}/../second.pers${tool_extension}_GnuplotScript'")
+ #add_test(NAME Persistence_representation_utilities_${plot_utility}_second_gnuplot COMMAND ${GNUPLOT_PATH}
+ # "-e" "load '${CMAKE_CURRENT_BINARY_DIR}/../second.pers${tool_extension}_GnuplotScript'")
endif()
endfunction(add_persistence_representation_plot_utility)
@@ -51,4 +51,3 @@ add_subdirectory(persistence_intervals)
add_subdirectory(persistence_landscapes)
add_subdirectory(persistence_landscapes_on_grid)
add_subdirectory(persistence_vectors)
-
diff --git a/src/Persistence_representations/utilities/persistence_heat_maps/simple_diagram.txt.mps b/src/Persistence_representations/utilities/persistence_heat_maps/simple_diagram.txt.mps
deleted file mode 100644
index b7643887..00000000
--- a/src/Persistence_representations/utilities/persistence_heat_maps/simple_diagram.txt.mps
+++ /dev/null
@@ -1,11 +0,0 @@
-0.93 8.0707
-0.0492104 0.03889 0.0190956 0.00603584 0.00131569 0.000120934 2.10152e-05 0 0 0
-0.0650745 0.0539306 0.0296488 0.011745 0.00357642 0.000695928 0.000120934 0 0 0
-0.0572665 0.0559446 0.0409942 0.0230905 0.00937173 0.00242903 0.000422102 0 0 0
-0.0409942 0.0559656 0.0573874 0.0408475 0.0192639 0.00628964 0.00178718 0.000422102 0.000120934 2.10152e-05
-0.0296488 0.0540515 0.0657704 0.0519133 0.0283092 0.0132056 0.00628964 0.00242903 0.000695928 0.000120934
-0.0190956 0.0393121 0.0516395 0.0465955 0.0359385 0.0283092 0.0192639 0.00937173 0.00357642 0.00131569
-0.00847814 0.0188418 0.0281882 0.0358964 0.0465955 0.0519133 0.0408475 0.0230905 0.011745 0.00603584
-0.00242903 0.00628964 0.0132056 0.0281882 0.0516395 0.0657704 0.0573874 0.0409942 0.0296488 0.0190956
-0.000422102 0.00178718 0.00628964 0.0188418 0.0393121 0.0540515 0.0559656 0.0559446 0.0539306 0.03889
-0 0.000422102 0.00242903 0.00847814 0.0190956 0.0296488 0.0409942 0.0572665 0.0650745 0.0492104
diff --git a/src/Persistence_representations/utilities/persistence_intervals/CMakeLists.txt b/src/Persistence_representations/utilities/persistence_intervals/CMakeLists.txt
index 2ba6efe5..897e12a3 100644
--- a/src/Persistence_representations/utilities/persistence_intervals/CMakeLists.txt
+++ b/src/Persistence_representations/utilities/persistence_intervals/CMakeLists.txt
@@ -1,40 +1,32 @@
cmake_minimum_required(VERSION 2.6)
project(Persistence_representations_intervals_utilities)
-file(COPY "${CMAKE_SOURCE_DIR}/data/persistence_diagram/simple_diagram.txt" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/")
-add_executable ( plot_persistence_intervals plot_persistence_intervals.cpp )
-
-add_test(NAME plot_persistence_intervals COMMAND $<TARGET_FILE:plot_persistence_intervals>
- "${CMAKE_CURRENT_BINARY_DIR}/simple_diagram.txt")
-
-add_executable ( compute_birth_death_range_in_persistence_diagram compute_birth_death_range_in_persistence_diagram.cpp )
-
-add_test(NAME compute_birth_death_range_in_persistence_diagram COMMAND $<TARGET_FILE:compute_birth_death_range_in_persistence_diagram>
- "-1" "${CMAKE_CURRENT_BINARY_DIR}/simple_diagram.txt")
+add_executable ( plot_histogram_of_intervals_lengths plot_histogram_of_intervals_lengths.cpp )
-add_executable ( compute_number_of_dominant_intervals compute_number_of_dominant_intervals.cpp )
+add_test(NAME plot_histogram_of_intervals_lengths COMMAND $<TARGET_FILE:plot_histogram_of_intervals_lengths>
+ "${CMAKE_CURRENT_BINARY_DIR}/../first.pers" "-1")
-add_test(NAME compute_number_of_dominant_intervals COMMAND $<TARGET_FILE:compute_number_of_dominant_intervals>
- "${CMAKE_CURRENT_BINARY_DIR}/simple_diagram.txt" "-1" "2")
+add_persistence_representation_plot_utility(plot_persistence_intervals "")
+add_persistence_representation_plot_utility(plot_persistence_Betti_numbers "")
-add_executable ( plot_histogram_of_intervals_lengths plot_histogram_of_intervals_lengths.cpp )
+add_persistence_representation_creation_utility(compute_birth_death_range_in_persistence_diagram "-1")
-add_test(NAME plot_histogram_of_intervals_lengths COMMAND $<TARGET_FILE:plot_histogram_of_intervals_lengths>
- "${CMAKE_CURRENT_BINARY_DIR}/simple_diagram.txt" "2")
-add_executable ( plot_persistence_Betti_numbers plot_persistence_Betti_numbers.cpp )
+add_executable ( compute_number_of_dominant_intervals compute_number_of_dominant_intervals.cpp )
+add_test(NAME Persistence_representation_utilities_compute_number_of_dominant_intervals
+ COMMAND $<TARGET_FILE:compute_number_of_dominant_intervals>
+ "${CMAKE_CURRENT_BINARY_DIR}/../first.pers" "-1" "2")
-add_test(NAME plot_persistence_Betti_numbers COMMAND $<TARGET_FILE:plot_persistence_Betti_numbers>
- "${CMAKE_CURRENT_BINARY_DIR}/simple_diagram.txt")
if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1)
add_executable ( compute_bottleneck_distance compute_bottleneck_distance.cpp )
if (TBB_FOUND)
target_link_libraries(compute_bottleneck_distance ${TBB_LIBRARIES})
endif(TBB_FOUND)
-
- add_test(NAME compute_bottleneck_distance COMMAND $<TARGET_FILE:compute_bottleneck_distance>
- "${CMAKE_CURRENT_BINARY_DIR}/simple_diagram.txt"
- "${CMAKE_CURRENT_BINARY_DIR}/simple_diagram.txt")
+ add_test(NAME Persistence_representation_utilities_compute_bottleneck_distance
+ COMMAND $<TARGET_FILE:compute_bottleneck_distance>
+ "-1"
+ "${CMAKE_CURRENT_BINARY_DIR}/../first.pers"
+ "${CMAKE_CURRENT_BINARY_DIR}/../second.pers")
endif (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1)
diff --git a/src/Persistence_representations/utilities/persistence_intervals/compute_birth_death_range_in_persistence_diagram.cpp b/src/Persistence_representations/utilities/persistence_intervals/compute_birth_death_range_in_persistence_diagram.cpp
index 66fa31ca..9102da79 100644
--- a/src/Persistence_representations/utilities/persistence_intervals/compute_birth_death_range_in_persistence_diagram.cpp
+++ b/src/Persistence_representations/utilities/persistence_intervals/compute_birth_death_range_in_persistence_diagram.cpp
@@ -20,7 +20,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <gudhi/reader_utils.h>
#include <gudhi/Persistence_intervals.h>
#include <iostream>
@@ -31,16 +30,21 @@
using Persistence_intervals = Gudhi::Persistence_representations::Persistence_intervals;
int main(int argc, char** argv) {
- 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";
+ std::cout << "This program computes the range of birth and death times of persistence pairs in diagrams provided as "
+ << "an input.\n"
+ << "The first parameter is the dimension of persistence to be used to create persistence intervals. "
+ << "If your file contains 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 of birth-death pairs, please set this first parameter to -1.\n"
+ << "The remaining parameters of the program are the names of files with persistence diagrams.\n";
+
+ if (argc < 3) {
+ std::cout << "Wrong parameter list, the program will now terminate \n";
+ return 1;
+ }
- int dim = atoi(argv[1]);
unsigned dimension = std::numeric_limits<unsigned>::max();
+ int dim = atoi(argv[1]);
if (dim >= 0) {
dimension = (unsigned)dim;
}
diff --git a/src/Persistence_representations/utilities/persistence_intervals/compute_bottleneck_distance.cpp b/src/Persistence_representations/utilities/persistence_intervals/compute_bottleneck_distance.cpp
index 0b1b526d..c8290845 100644
--- a/src/Persistence_representations/utilities/persistence_intervals/compute_bottleneck_distance.cpp
+++ b/src/Persistence_representations/utilities/persistence_intervals/compute_bottleneck_distance.cpp
@@ -21,7 +21,6 @@
*/
#include <gudhi/Persistence_intervals_with_distances.h>
-#include <gudhi/read_persistence_from_file.h>
#include <iostream>
#include <sstream>
@@ -31,21 +30,21 @@
using Persistence_intervals_with_distances = Gudhi::Persistence_representations::Persistence_intervals_with_distances;
int main(int argc, char** argv) {
- std::cout << "This program compute the bottleneck distance of persistence diagrams 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";
+ std::cout << "This program computes the bottleneck distance of persistence pairs in diagrams provided as "
+ << "an input.\n"
+ << "The first parameter is the dimension of persistence to be used to create persistence intervals. "
+ << "If your file contains 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 of birth-death pairs, please set this first parameter to -1.\n"
+ << "The remaining parameters of the program are the 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();
+ int dim = atoi(argv[1]);
if (dim >= 0) {
dimension = (unsigned)dim;
}
@@ -80,7 +79,7 @@ int main(int argc, char** argv) {
// and now output the result to the screen and a file:
std::ofstream out;
- out.open("distance");
+ out.open("distance.itv");
for (size_t i = 0; i != distance.size(); ++i) {
for (size_t j = 0; j != distance.size(); ++j) {
std::cout << distance[i][j] << " ";
@@ -91,5 +90,6 @@ int main(int argc, char** argv) {
}
out.close();
+ std::cout << "Distance can be found in 'distance.itv' file\n";
return 0;
}
diff --git a/src/Persistence_representations/utilities/persistence_intervals/compute_number_of_dominant_intervals.cpp b/src/Persistence_representations/utilities/persistence_intervals/compute_number_of_dominant_intervals.cpp
index 1286ca57..b3d126f0 100644
--- a/src/Persistence_representations/utilities/persistence_intervals/compute_number_of_dominant_intervals.cpp
+++ b/src/Persistence_representations/utilities/persistence_intervals/compute_number_of_dominant_intervals.cpp
@@ -20,7 +20,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <gudhi/reader_utils.h>
#include <gudhi/Persistence_intervals.h>
#include <iostream>
diff --git a/src/Persistence_representations/utilities/persistence_intervals/plot_histogram_of_intervals_lengths.cpp b/src/Persistence_representations/utilities/persistence_intervals/plot_histogram_of_intervals_lengths.cpp
index d68f4584..ccb5b645 100644
--- a/src/Persistence_representations/utilities/persistence_intervals/plot_histogram_of_intervals_lengths.cpp
+++ b/src/Persistence_representations/utilities/persistence_intervals/plot_histogram_of_intervals_lengths.cpp
@@ -20,7 +20,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <gudhi/reader_utils.h>
#include <gudhi/Persistence_intervals.h>
#include <iostream>
@@ -31,30 +30,34 @@
using Persistence_intervals = Gudhi::Persistence_representations::Persistence_intervals;
int main(int argc, char** argv) {
- std::cout << "This program compute a histogram of barcode's length. A number of bins in the histogram is a parameter "
- "of this program. \n";
- if (argc != 3) {
+ std::cout << "This program computes a histogram of barcode's length. A number of bins in the histogram is a "
+ << "parameter of this program. \n";
+ if ((argc != 3) && (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 << "The third 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";
+ << "dominant intervals you would like to get. Set a negative number dominant intervals value "
+ << "If your file contains only birth-death pairs.\n"
+ << "The third parameter 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]);
+
+ unsigned dominant_interval_number = std::numeric_limits<unsigned>::max();
+ int nbr = atoi(argv[2]);
+ if (nbr >= 0) {
+ dominant_interval_number = static_cast<unsigned>(nbr);
}
- if (dim >= 0) {
- dimension = (unsigned)dim;
+
+ int persistence_dimension = -1;
+ if (argc == 4) {
+ persistence_dimension = atoi(argv[3]);
}
- Persistence_intervals p(argv[1], dimension);
- std::vector<std::pair<double, double> > dominant_intervals = p.dominant_intervals(atoi(argv[2]));
+ Persistence_intervals p(argv[1], dominant_interval_number);
+ std::vector<std::pair<double, double> > dominant_intervals = p.dominant_intervals(persistence_dimension);
std::vector<size_t> histogram = p.histogram_of_lengths(10);
std::stringstream gnuplot_script;
- gnuplot_script << argv[1] << "_Gnuplot_script";
+ gnuplot_script << argv[1] << "_GnuplotScript";
std::ofstream out;
out.open(gnuplot_script.str().c_str());
@@ -66,7 +69,9 @@ int main(int argc, char** argv) {
out << histogram[i] << std::endl;
}
out << std::endl;
- std::cout << "To visualize, open gnuplot and type: load \'" << gnuplot_script.str().c_str() << "\'" << std::endl;
out.close();
+
+ std::cout << "To visualize, install gnuplot and type the command: gnuplot -persist -e \"load \'"
+ << gnuplot_script.str().c_str() << "\'\"" << std::endl;
return 0;
}
diff --git a/src/Persistence_representations/utilities/persistence_intervals/plot_persistence_Betti_numbers.cpp b/src/Persistence_representations/utilities/persistence_intervals/plot_persistence_Betti_numbers.cpp
index da2b9319..b433c2b3 100644
--- a/src/Persistence_representations/utilities/persistence_intervals/plot_persistence_Betti_numbers.cpp
+++ b/src/Persistence_representations/utilities/persistence_intervals/plot_persistence_Betti_numbers.cpp
@@ -20,7 +20,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <gudhi/reader_utils.h>
#include <gudhi/Persistence_intervals.h>
#include <iostream>
@@ -31,29 +30,24 @@
using Persistence_intervals = Gudhi::Persistence_representations::Persistence_intervals;
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";
- 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";
+ if ((argc != 3) && (argc != 2)) {
+ std::cout << "This program creates a gnuplot script of Betti numbers from a single persistence diagram file"
+ << "(*.pers).\n"
+ << "To run this program, please provide the name of a file with persistence diagram.\n"
+ << "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;
}
+
unsigned dimension = std::numeric_limits<unsigned>::max();
int dim = -1;
- if (argc > 2) {
+ if (argc == 3) {
dim = atoi(argv[2]);
}
if (dim >= 0) {
dimension = (unsigned)dim;
}
- std::stringstream gnuplot_script;
- gnuplot_script << argv[1] << "_Gnuplot_script";
- std::ofstream out;
- out.open(gnuplot_script.str().c_str());
-
Persistence_intervals p(argv[1], dimension);
std::vector<std::pair<double, size_t> > pbns = p.compute_persistent_betti_numbers();
@@ -69,6 +63,11 @@ int main(int argc, char** argv) {
xRangeEnd += (xRangeEnd - xRangeBegin) / 100.0;
yRangeEnd += yRangeEnd / 100;
+ std::stringstream gnuplot_script;
+ gnuplot_script << argv[1] << "_GnuplotScript";
+ std::ofstream out;
+ out.open(gnuplot_script.str().c_str());
+
out << "set xrange [" << xRangeBegin << " : " << xRangeEnd << "]" << std::endl;
out << "set yrange [" << yRangeBegin << " : " << yRangeEnd << "]" << std::endl;
out << "plot '-' using 1:2 notitle with lp " << std::endl;
@@ -81,7 +80,8 @@ int main(int argc, char** argv) {
out << std::endl;
out.close();
- std::cout << "To visualize, open gnuplot and type: load \'" << gnuplot_script.str().c_str() << "\'" << std::endl;
+ std::cout << "To visualize, install gnuplot and type the command: gnuplot -persist -e \"load \'"
+ << gnuplot_script.str().c_str() << "\'\"" << std::endl;
return 0;
}
diff --git a/src/Persistence_representations/utilities/persistence_intervals/plot_persistence_intervals.cpp b/src/Persistence_representations/utilities/persistence_intervals/plot_persistence_intervals.cpp
index e7d29e84..33387802 100644
--- a/src/Persistence_representations/utilities/persistence_intervals/plot_persistence_intervals.cpp
+++ b/src/Persistence_representations/utilities/persistence_intervals/plot_persistence_intervals.cpp
@@ -20,9 +20,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <gudhi/reader_utils.h>
#include <gudhi/Persistence_intervals.h>
-#include <gudhi/read_persistence_from_file.h>
#include <iostream>
#include <limits>
@@ -32,15 +30,16 @@
using Persistence_intervals = Gudhi::Persistence_representations::Persistence_intervals;
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";
+ if ((argc != 3) && (argc != 2)) {
+ std::cout << "This program creates a gnuplot script from a single persistence diagram file (*.pers).\n"
+ << "To run this program, please provide the name of a file with persistence diagram.\n"
+ << "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;
}
unsigned dimension = std::numeric_limits<unsigned>::max();
int dim = -1;
- if (argc > 2) {
+ if (argc == 3) {
dim = atoi(argv[2]);
}
if (dim >= 0) {
diff --git a/src/Persistence_representations/utilities/persistence_landscapes/simple_diagram.txt.land b/src/Persistence_representations/utilities/persistence_landscapes/simple_diagram.txt.land
deleted file mode 100644
index b99d2f62..00000000
--- a/src/Persistence_representations/utilities/persistence_landscapes/simple_diagram.txt.land
+++ /dev/null
@@ -1,13 +0,0 @@
-#lambda_0
-1 0
-1.5 0.5
-2 0
-3 0
-3.5 0.5
-4 0
-5 0
-5.5 0.5
-6 0
-7 0
-7.5 0.5
-8 0
diff --git a/src/Persistence_representations/utilities/persistence_landscapes_on_grid/simple_diagram.txt.g_land b/src/Persistence_representations/utilities/persistence_landscapes_on_grid/simple_diagram.txt.g_land
deleted file mode 100644
index dc53b932..00000000
--- a/src/Persistence_representations/utilities/persistence_landscapes_on_grid/simple_diagram.txt.g_land
+++ /dev/null
@@ -1,104 +0,0 @@
-1
-8
-101
-
-0.07
-0.14
-0.21
-0.28
-0.35
-0.42
-0.49
-0.42
-0.35
-0.28
-0.21
-0.14
-0.07
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-0.07
-0.14
-0.21
-0.28
-0.35
-0.42
-0.49
-0.42
-0.35
-0.28
-0.21
-0.14
-0.07
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-0.07
-0.14
-0.21
-0.28
-0.35
-0.42
-0.49
-0.42
-0.35
-0.28
-0.21
-0.14
-0.07
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-0.07
-0.14
-0.21
-0.28
-0.35
-0.42
-0.49
-0.42
-0.35
-0.28
-0.21
-0.14
-0.07
-
-
diff --git a/src/Persistence_representations/utilities/persistence_vectors/simple_diagram.txt.vect b/src/Persistence_representations/utilities/persistence_vectors/simple_diagram.txt.vect
deleted file mode 100644
index 1d4eeaaf..00000000
--- a/src/Persistence_representations/utilities/persistence_vectors/simple_diagram.txt.vect
+++ /dev/null
@@ -1 +0,0 @@
-0.707107 0.707107 0.707107 0.707107 0.707107 0.707107 0.707107 0.707107 0.707107 0.707107 \ No newline at end of file