diff options
author | cjamin <cjamin@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2017-09-29 15:59:03 +0000 |
---|---|---|
committer | cjamin <cjamin@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2017-09-29 15:59:03 +0000 |
commit | f45959484fb85299d9ac60c43de9325e5c06e730 (patch) | |
tree | 64055685e3e2d1b1bb8db82db57bd1c45d7657ea /src/Bottleneck_distance/example | |
parent | 0a66874247cb6ab10a2d96e22ecd5009113291d2 (diff) | |
parent | 768c70aa382a7b0b561ea842720f5963a412b88e (diff) |
Merge from trunk
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/add_utils_in_gudhi_v2@2732 636b058d-ea47-450e-bf9e-a15bfbe3eedb
Former-commit-id: 7872aa224ee471c05e9213b81192d304254e608a
Diffstat (limited to 'src/Bottleneck_distance/example')
-rw-r--r-- | src/Bottleneck_distance/example/CMakeLists.txt | 6 | ||||
-rw-r--r-- | src/Bottleneck_distance/example/bottleneck_read_file_example.cpp | 48 |
2 files changed, 17 insertions, 37 deletions
diff --git a/src/Bottleneck_distance/example/CMakeLists.txt b/src/Bottleneck_distance/example/CMakeLists.txt index 93eb7b2f..b37555f9 100644 --- a/src/Bottleneck_distance/example/CMakeLists.txt +++ b/src/Bottleneck_distance/example/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 2.6) project(Bottleneck_distance_examples) -if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1) +if (NOT CGAL_VERSION VERSION_LESS 4.8.1) add_executable (bottleneck_read_file_example bottleneck_read_file_example.cpp) add_executable (bottleneck_basic_example bottleneck_basic_example.cpp) @@ -9,5 +9,7 @@ if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1) install(TARGETS bottleneck_read_file_example DESTINATION bin) install(TARGETS bottleneck_basic_example DESTINATION bin) - + if (TBB_FOUND) + target_link_libraries(alpha_rips_persistence_bottleneck_distance ${TBB_LIBRARIES}) + endif(TBB_FOUND) endif (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.8.1) diff --git a/src/Bottleneck_distance/example/bottleneck_read_file_example.cpp b/src/Bottleneck_distance/example/bottleneck_read_file_example.cpp index bde05825..24d73c57 100644 --- a/src/Bottleneck_distance/example/bottleneck_read_file_example.cpp +++ b/src/Bottleneck_distance/example/bottleneck_read_file_example.cpp @@ -20,53 +20,31 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#define CGAL_HAS_THREADS - #include <gudhi/Bottleneck.h> +#include <gudhi/reader_utils.h> #include <iostream> #include <vector> #include <utility> // for pair -#include <fstream> -#include <sstream> #include <string> - -std::vector< std::pair<double, double> > read_diagram_from_file(const char* filename) { - std::ifstream in; - in.open(filename); - std::vector< std::pair<double, double> > result; - if (!in.is_open()) { - std::cerr << "File : " << filename << " do not exist. The program will now terminate \n"; - throw "File do not exist \n"; - } - - std::string line; - while (!in.eof()) { - getline(in, line); - if (line.length() != 0) { - std::stringstream lineSS; - lineSS << line; - double beginn, endd; - lineSS >> beginn; - lineSS >> endd; - result.push_back(std::make_pair(beginn, endd)); - } - } - in.close(); - return result; -} // read_diagram_from_file +#include <limits> // for numeric_limits int main(int argc, char** argv) { if (argc < 3) { - std::cout << "To run this program please provide as an input two files with persistence diagrams. Each file " << - "should contain a birth-death pair per line. Third, optional parameter is an error bound on a bottleneck" << - " distance (set by default to zero). The program will now terminate \n"; + std::cout << "To run this program please provide as an input two files with persistence diagrams. Each file" << + " should contain a birth-death pair per line. Third, optional parameter is an error bound on a bottleneck" << + " distance (set by default to the smallest positive double value). If you set the error bound to 0, be" << + " aware this version is exact but expensive. The program will now terminate \n"; + return -1; } - std::vector< std::pair< double, double > > diag1 = read_diagram_from_file(argv[1]); - std::vector< std::pair< double, double > > diag2 = read_diagram_from_file(argv[2]); - double tolerance = 0.; + std::vector<std::pair<double, double>> diag1 = Gudhi::read_persistence_intervals_in_dimension(argv[1]); + std::vector<std::pair<double, double>> diag2 = Gudhi::read_persistence_intervals_in_dimension(argv[2]); + + double tolerance = std::numeric_limits<double>::min(); if (argc == 4) { tolerance = atof(argv[3]); } double b = Gudhi::persistence_diagram::bottleneck_distance(diag1, diag2, tolerance); std::cout << "The distance between the diagrams is : " << b << ". The tolerance is : " << tolerance << std::endl; + + return 0; } |