summaryrefslogtreecommitdiff
path: root/example/Bitmap_cubical_complex
diff options
context:
space:
mode:
Diffstat (limited to 'example/Bitmap_cubical_complex')
-rw-r--r--example/Bitmap_cubical_complex/Bitmap_cubical_complex.cpp24
-rw-r--r--example/Bitmap_cubical_complex/Bitmap_cubical_complex_periodic_boundary_conditions.cpp22
-rw-r--r--example/Bitmap_cubical_complex/CMakeLists.txt7
3 files changed, 35 insertions, 18 deletions
diff --git a/example/Bitmap_cubical_complex/Bitmap_cubical_complex.cpp b/example/Bitmap_cubical_complex/Bitmap_cubical_complex.cpp
index e6bc6648..67735ba1 100644
--- a/example/Bitmap_cubical_complex/Bitmap_cubical_complex.cpp
+++ b/example/Bitmap_cubical_complex/Bitmap_cubical_complex.cpp
@@ -27,8 +27,9 @@
// standard stuff
#include <iostream>
-#include <sstream>
+#include <string>
#include <vector>
+#include <cstddef>
int main(int argc, char** argv) {
std::cout << "This program computes persistent homology, by using bitmap_cubical_complex class, of cubical " <<
@@ -38,9 +39,6 @@ int main(int argc, char** argv) {
"filtrations of top dimensional cells. We assume that the cells are in the lexicographical order. See " <<
"CubicalOneSphere.txt or CubicalTwoSphere.txt for example.\n" << std::endl;
- int p = 2;
- double min_persistence = 0;
-
if (argc != 2) {
std::cerr << "Wrong number of parameters. Please provide the name of a file with a Perseus style bitmap at " <<
"the input. The program will now terminate.\n";
@@ -56,16 +54,26 @@ int main(int argc, char** argv) {
// Compute the persistence diagram of the complex
Persistent_cohomology pcoh(b);
+ int p = 2;
+ double min_persistence = 0;
+
pcoh.init_coefficients(p); // initializes the coefficient field for homology
pcoh.compute_persistent_cohomology(min_persistence);
- std::stringstream ss;
- ss << argv[1] << "_persistence";
- std::ofstream out(ss.str().c_str());
+ std::string output_file_name(argv[1]);
+ output_file_name += "_persistence";
+
+ std::size_t last_in_path = output_file_name.find_last_of("/\\");
+
+ if (last_in_path != std::string::npos) {
+ output_file_name = output_file_name.substr(last_in_path+1);
+ }
+
+ std::ofstream out(output_file_name.c_str());
pcoh.output_diagram(out);
out.close();
- std::cout << "Result in file: " << ss.str().c_str() << "\n";
+ std::cout << "Result in file: " << output_file_name << "\n";
return 0;
}
diff --git a/example/Bitmap_cubical_complex/Bitmap_cubical_complex_periodic_boundary_conditions.cpp b/example/Bitmap_cubical_complex/Bitmap_cubical_complex_periodic_boundary_conditions.cpp
index 839a4c89..122160a2 100644
--- a/example/Bitmap_cubical_complex/Bitmap_cubical_complex_periodic_boundary_conditions.cpp
+++ b/example/Bitmap_cubical_complex/Bitmap_cubical_complex_periodic_boundary_conditions.cpp
@@ -30,6 +30,7 @@
#include <iostream>
#include <sstream>
#include <vector>
+#include <string>
int main(int argc, char** argv) {
std::cout << "This program computes persistent homology, by using " <<
@@ -40,9 +41,6 @@ int main(int argc, char** argv) {
"assume that the cells are in the lexicographical order. See CubicalOneSphere.txt or CubicalTwoSphere.txt for" <<
" example.\n" << std::endl;
- int p = 2;
- double min_persistence = 0;
-
if (argc != 2) {
std::cerr << "Wrong number of parameters. Please provide the name of a file with a Perseus style bitmap at " <<
"the input. The program will now terminate.\n";
@@ -58,16 +56,26 @@ int main(int argc, char** argv) {
typedef Gudhi::persistent_cohomology::Persistent_cohomology<Bitmap_cubical_complex, Field_Zp> Persistent_cohomology;
// Compute the persistence diagram of the complex
Persistent_cohomology pcoh(b, true);
+
+ int p = 2;
+ double min_persistence = 0;
pcoh.init_coefficients(p); // initializes the coefficient field for homology
pcoh.compute_persistent_cohomology(min_persistence);
- std::stringstream ss;
- ss << argv[1] << "_persistence";
- std::ofstream out(ss.str().c_str());
+ std::string output_file_name(argv[1]);
+ output_file_name += "_persistence";
+
+ std::size_t last_in_path = output_file_name.find_last_of("/\\");
+
+ if (last_in_path != std::string::npos) {
+ output_file_name = output_file_name.substr(last_in_path+1);
+ }
+
+ std::ofstream out(output_file_name.c_str());
pcoh.output_diagram(out);
out.close();
- std::cout << "Result in file: " << ss.str().c_str() << "\n";
+ std::cout << "Result in file: " << output_file_name << "\n";
return 0;
}
diff --git a/example/Bitmap_cubical_complex/CMakeLists.txt b/example/Bitmap_cubical_complex/CMakeLists.txt
index 241a11e5..a0401619 100644
--- a/example/Bitmap_cubical_complex/CMakeLists.txt
+++ b/example/Bitmap_cubical_complex/CMakeLists.txt
@@ -2,7 +2,6 @@ cmake_minimum_required(VERSION 2.6)
project(Bitmap_cubical_complex_examples)
add_executable ( Bitmap_cubical_complex Bitmap_cubical_complex.cpp )
-target_link_libraries(Bitmap_cubical_complex ${Boost_SYSTEM_LIBRARY})
if (TBB_FOUND)
target_link_libraries(Bitmap_cubical_complex ${TBB_LIBRARIES})
endif()
@@ -14,7 +13,6 @@ add_test(NAME Bitmap_cubical_complex_example_persistence_two_sphere COMMAND $<TA
"${CMAKE_SOURCE_DIR}/data/bitmap/CubicalTwoSphere.txt")
add_executable ( Random_bitmap_cubical_complex Random_bitmap_cubical_complex.cpp )
-target_link_libraries(Random_bitmap_cubical_complex ${Boost_SYSTEM_LIBRARY})
if (TBB_FOUND)
target_link_libraries(Random_bitmap_cubical_complex ${TBB_LIBRARIES})
endif()
@@ -22,7 +20,6 @@ add_test(NAME Bitmap_cubical_complex_example_random COMMAND $<TARGET_FILE:Random
"2" "100" "100")
add_executable ( Bitmap_cubical_complex_periodic_boundary_conditions Bitmap_cubical_complex_periodic_boundary_conditions.cpp )
-target_link_libraries(Bitmap_cubical_complex_periodic_boundary_conditions ${Boost_SYSTEM_LIBRARY})
if (TBB_FOUND)
target_link_libraries(Bitmap_cubical_complex_periodic_boundary_conditions ${TBB_LIBRARIES})
endif()
@@ -34,3 +31,7 @@ add_test(NAME Bitmap_cubical_complex_example_periodic_boundary_conditions_2d_tor
add_test(NAME Bitmap_cubical_complex_example_periodic_boundary_conditions_3d_torus
COMMAND $<TARGET_FILE:Bitmap_cubical_complex_periodic_boundary_conditions>
"${CMAKE_SOURCE_DIR}/data/bitmap/3d_torus.txt")
+
+install(TARGETS Bitmap_cubical_complex DESTINATION bin)
+install(TARGETS Random_bitmap_cubical_complex DESTINATION bin)
+install(TARGETS Bitmap_cubical_complex_periodic_boundary_conditions DESTINATION bin)