summaryrefslogtreecommitdiff
path: root/src/Bottleneck_distance/example
diff options
context:
space:
mode:
authorvrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2017-01-04 08:39:18 +0000
committervrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2017-01-04 08:39:18 +0000
commit64dd2a2b0eec1374ed23ca079f86b312125d03f7 (patch)
treef22c13edb5f6d2980c0af4ec21a6a9b8910990de /src/Bottleneck_distance/example
parent67c34d7b506efe6445a24380b3ad0743e09ef334 (diff)
Move bottleneck_chrono in benchmark
Add test in cmake for basic example Move CGAL gudhi patches for bottleneck in dedicated directory Fix cpplint syntax issue git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/bottleneck_integration@1920 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 24671facf791de93dc6fd94bb39ca7362bb22959
Diffstat (limited to 'src/Bottleneck_distance/example')
-rw-r--r--src/Bottleneck_distance/example/CMakeLists.txt2
-rw-r--r--src/Bottleneck_distance/example/bottleneck_basic_example.cpp26
-rw-r--r--src/Bottleneck_distance/example/bottleneck_read_file_example.cpp71
3 files changed, 47 insertions, 52 deletions
diff --git a/src/Bottleneck_distance/example/CMakeLists.txt b/src/Bottleneck_distance/example/CMakeLists.txt
index cd53ccfc..c66623e9 100644
--- a/src/Bottleneck_distance/example/CMakeLists.txt
+++ b/src/Bottleneck_distance/example/CMakeLists.txt
@@ -8,6 +8,8 @@ if(CGAL_FOUND)
if (EIGEN3_FOUND)
add_executable (bottleneck_read_file_example bottleneck_read_file_example.cpp)
add_executable (bottleneck_basic_example bottleneck_basic_example.cpp)
+
+ add_test(bottleneck_basic_example ${CMAKE_CURRENT_BINARY_DIR}/bottleneck_basic_example)
endif()
endif ()
endif()
diff --git a/src/Bottleneck_distance/example/bottleneck_basic_example.cpp b/src/Bottleneck_distance/example/bottleneck_basic_example.cpp
index 78e00e57..91a7302f 100644
--- a/src/Bottleneck_distance/example/bottleneck_basic_example.cpp
+++ b/src/Bottleneck_distance/example/bottleneck_basic_example.cpp
@@ -4,7 +4,7 @@
*
* Authors: Francois Godi, small modifications by Pawel Dlotko
*
- * Copyright (C) 2015 INRIA (France)
+ * Copyright (C) 2015 INRIA
*
* 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
@@ -25,24 +25,24 @@
int main() {
- std::vector< std::pair<double, double> > v1, v2;
+ std::vector< std::pair<double, double> > v1, v2;
- v1.emplace_back(2.7, 3.7);
- v1.emplace_back(9.6, 14.);
- v1.emplace_back(34.2, 34.974);
- v1.emplace_back(3., std::numeric_limits<double>::infinity());
+ v1.emplace_back(2.7, 3.7);
+ v1.emplace_back(9.6, 14.);
+ v1.emplace_back(34.2, 34.974);
+ v1.emplace_back(3., std::numeric_limits<double>::infinity());
- v2.emplace_back(2.8, 4.45);
- v2.emplace_back(9.5, 14.1);
- v2.emplace_back(3.2, std::numeric_limits<double>::infinity());
+ v2.emplace_back(2.8, 4.45);
+ v2.emplace_back(9.5, 14.1);
+ v2.emplace_back(3.2, std::numeric_limits<double>::infinity());
- double b = Gudhi::persistence_diagram::bottleneck_distance(v1, v2);
+ double b = Gudhi::persistence_diagram::bottleneck_distance(v1, v2);
- std::cout << "Bottleneck distance = " << b << std::endl;
+ std::cout << "Bottleneck distance = " << b << std::endl;
- b = Gudhi::persistence_diagram::bottleneck_distance(v1, v2, 0.1);
+ b = Gudhi::persistence_diagram::bottleneck_distance(v1, v2, 0.1);
- std::cout << "Approx bottleneck distance = " << b << std::endl;
+ std::cout << "Approx bottleneck distance = " << b << std::endl;
}
diff --git a/src/Bottleneck_distance/example/bottleneck_read_file_example.cpp b/src/Bottleneck_distance/example/bottleneck_read_file_example.cpp
index ceedccc5..4c74b66e 100644
--- a/src/Bottleneck_distance/example/bottleneck_read_file_example.cpp
+++ b/src/Bottleneck_distance/example/bottleneck_read_file_example.cpp
@@ -4,7 +4,7 @@
*
* Authors: Francois Godi, small modifications by Pawel Dlotko
*
- * Copyright (C) 2015 INRIA (France)
+ * Copyright (C) 2015 INRIA
*
* 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
@@ -28,49 +28,42 @@
#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::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 ) );
- }
+ 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
+ }
+ in.close();
+ return result;
+} // read_diagram_from_file
-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";
+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::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] );
+ 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.;
- if ( argc == 4 )
- {
- tolerance = atof( argv[3] );
+ 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;