diff options
author | vrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2016-10-03 15:17:04 +0000 |
---|---|---|
committer | vrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2016-10-03 15:17:04 +0000 |
commit | 5ce7c7c8ec1378439cdc02dc94ac2a7e14e9ca04 (patch) | |
tree | e5dab0473590126a3a5864fe7ebc11720c26bd26 /src/Rips_complex | |
parent | 29499b02d1b6eafcc6419a0b6b4469152ea20a09 (diff) |
Fix euclidean distance for rips
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/rips_complex_module@1610 636b058d-ea47-450e-bf9e-a15bfbe3eedb
Former-commit-id: a07dfd4ffe3f17bf242ffb5b57058e99171a8016
Diffstat (limited to 'src/Rips_complex')
3 files changed, 13 insertions, 9 deletions
diff --git a/src/Rips_complex/example/example_one_skeleton_rips_from_points.cpp b/src/Rips_complex/example/example_one_skeleton_rips_from_points.cpp index db41b425..2e63d9a6 100644 --- a/src/Rips_complex/example/example_one_skeleton_rips_from_points.cpp +++ b/src/Rips_complex/example/example_one_skeleton_rips_from_points.cpp @@ -23,8 +23,9 @@ int main(int argc, char **argv) { // Type definitions using Point = std::vector<double>; - using Simplex_tree = Gudhi::Simplex_tree<>; - using Rips_complex = Gudhi::rips_complex::Rips_complex<Simplex_tree::Filtration_value>; + using Simplex_tree = Gudhi::Simplex_tree<Gudhi::Simplex_tree_options_fast_persistence>; + using Filtration_value = Simplex_tree::Filtration_value; + using Rips_complex = Gudhi::rips_complex::Rips_complex<Filtration_value>; std::vector<Point> points; points.push_back({1.0, 1.0}); @@ -38,10 +39,10 @@ int main(int argc, char **argv) { // ---------------------------------------------------------------------------- // Init of a rips complex from points // ---------------------------------------------------------------------------- - Rips_complex rips_complex_from_file(points, threshold, euclidean_distance<Point>); + Rips_complex rips_complex_from_points(points, threshold, euclidean_distance<Filtration_value, Point>); Simplex_tree simplex; - if (rips_complex_from_file.create_complex(simplex, 1)) { + if (rips_complex_from_points.create_complex(simplex, 1)) { // ---------------------------------------------------------------------------- // Display information about the one skeleton rips complex // ---------------------------------------------------------------------------- diff --git a/src/Rips_complex/example/example_rips_complex_from_off_file.cpp b/src/Rips_complex/example/example_rips_complex_from_off_file.cpp index 82baa68e..60050cea 100644 --- a/src/Rips_complex/example/example_rips_complex_from_off_file.cpp +++ b/src/Rips_complex/example/example_rips_complex_from_off_file.cpp @@ -25,14 +25,15 @@ int main(int argc, char **argv) { // Type definitions using Point = std::vector<float>; using Simplex_tree = Gudhi::Simplex_tree<>; - using Rips_complex = Gudhi::rips_complex::Rips_complex<Simplex_tree::Filtration_value>; + using Filtration_value = Simplex_tree::Filtration_value; + using Rips_complex = Gudhi::rips_complex::Rips_complex<Filtration_value>; // ---------------------------------------------------------------------------- // Init of a rips complex from an OFF file // ---------------------------------------------------------------------------- Gudhi::Points_off_reader<Point> off_reader(off_file_name); Rips_complex rips_complex_from_file(off_reader.get_point_cloud(), threshold, - euclidean_distance<Point>); + euclidean_distance<Filtration_value, Point>); std::streambuf* streambufffer; std::ofstream ouput_file_stream; diff --git a/src/Rips_complex/test/test_rips_complex.cpp b/src/Rips_complex/test/test_rips_complex.cpp index 5f129160..f8be9748 100644 --- a/src/Rips_complex/test/test_rips_complex.cpp +++ b/src/Rips_complex/test/test_rips_complex.cpp @@ -40,6 +40,7 @@ // Type definitions using Point = std::vector<double>; using Simplex_tree = Gudhi::Simplex_tree<>; +using Filtration_value = Simplex_tree::Filtration_value; using Rips_complex = Gudhi::rips_complex::Rips_complex<Simplex_tree::Filtration_value>; bool are_almost_the_same(float a, float b) { @@ -58,7 +59,8 @@ BOOST_AUTO_TEST_CASE(RIPS_DOC_OFF_file) { rips_threshold << "==========" << std::endl; Gudhi::Points_off_reader<Point> off_reader(off_file_name); - Rips_complex rips_complex_from_file(off_reader.get_point_cloud(), rips_threshold, euclidean_distance<Point>); + Rips_complex rips_complex_from_file(off_reader.get_point_cloud(), rips_threshold, + euclidean_distance<Filtration_value, Point>); const int DIMENSION_1 = 1; Simplex_tree st; @@ -87,10 +89,10 @@ BOOST_AUTO_TEST_CASE(RIPS_DOC_OFF_file) { std::cout << vertex << ","; vp.push_back(off_reader.get_point_cloud().at(vertex)); } - std::cout << ") - distance =" << euclidean_distance(vp.at(0), vp.at(1)) << + std::cout << ") - distance =" << euclidean_distance<double>(vp.at(0), vp.at(1)) << " - filtration =" << st.filtration(f_simplex) << std::endl; BOOST_CHECK(vp.size() == 2); - BOOST_CHECK(are_almost_the_same(st.filtration(f_simplex), euclidean_distance(vp.at(0), vp.at(1)))); + BOOST_CHECK(are_almost_the_same(st.filtration(f_simplex), euclidean_distance<double>(vp.at(0), vp.at(1)))); } } |