summaryrefslogtreecommitdiff
path: root/src/Cech_complex/test/test_cech_complex.cpp
diff options
context:
space:
mode:
authorvrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2018-02-22 23:16:55 +0000
committervrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2018-02-22 23:16:55 +0000
commit3cd1e01f0b0d4fdb46f49ec640c389374ca2fe70 (patch)
treeafe2bec947f098942d021e62d62546d56b9acabd /src/Cech_complex/test/test_cech_complex.cpp
parentd57e3dfbf15f8aaa3afa097a4e3ed49cd23d26ea (diff)
Fix Cech with radius distance
Add a meta generation script for off_file_generator git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/cechcomplex_vincent@3256 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: fb13baa124ddc97c0dc61835ab0c72595d666155
Diffstat (limited to 'src/Cech_complex/test/test_cech_complex.cpp')
-rw-r--r--src/Cech_complex/test/test_cech_complex.cpp38
1 files changed, 20 insertions, 18 deletions
diff --git a/src/Cech_complex/test/test_cech_complex.cpp b/src/Cech_complex/test/test_cech_complex.cpp
index aa42d322..626f1d82 100644
--- a/src/Cech_complex/test/test_cech_complex.cpp
+++ b/src/Cech_complex/test/test_cech_complex.cpp
@@ -58,14 +58,15 @@ BOOST_AUTO_TEST_CASE(Cech_complex_from_file) {
//
// ----------------------------------------------------------------------------
std::string off_file_name("alphacomplexdoc.off");
- double threshold = 12.0;
- std::cout << "========== OFF FILE NAME = " << off_file_name << " - Cech threshold=" <<
- threshold << "==========" << std::endl;
+ double max_radius = 12.0;
+ std::cout << "========== OFF FILE NAME = " << off_file_name << " - Cech max_radius=" <<
+ max_radius << "==========" << std::endl;
Points_off_reader off_reader(off_file_name);
Point_cloud point_cloud = off_reader.get_point_cloud();
- Cech_complex cech_complex_from_file(point_cloud, threshold, Gudhi::Euclidean_distance());
+ Cech_complex cech_complex_from_file(point_cloud, max_radius);
+ GUDHI_TEST_FLOAT_EQUALITY_CHECK(cech_complex_from_file.max_radius(), max_radius);
std::size_t i = 0;
for (; i < point_cloud.size(); i++) {
BOOST_CHECK(point_cloud[i] == *(cech_complex_from_file.point_iterator(i)));
@@ -101,10 +102,10 @@ BOOST_AUTO_TEST_CASE(Cech_complex_from_file) {
std::cout << vertex << ",";
vp.push_back(off_reader.get_point_cloud().at(vertex));
}
- std::cout << ") - distance =" << Gudhi::Euclidean_distance()(vp.at(0), vp.at(1)) <<
+ std::cout << ") - distance =" << Gudhi::Radius_distance()(vp.at(0), vp.at(1)) <<
" - filtration =" << st.filtration(f_simplex) << std::endl;
BOOST_CHECK(vp.size() == 2);
- GUDHI_TEST_FLOAT_EQUALITY_CHECK(st.filtration(f_simplex), Gudhi::Euclidean_distance()(vp.at(0), vp.at(1)));
+ GUDHI_TEST_FLOAT_EQUALITY_CHECK(st.filtration(f_simplex), Gudhi::Radius_distance()(vp.at(0), vp.at(1)));
}
}
@@ -125,7 +126,8 @@ BOOST_AUTO_TEST_CASE(Cech_complex_from_file) {
points012.push_back(Point(cech_complex_from_file.point_iterator(vertex)->begin(),
cech_complex_from_file.point_iterator(vertex)->end()));
}
- Min_sphere ms012(cech_complex_from_file.dimension(), points012.begin(),points012.end());
+ std::size_t dimension = point_cloud[0].end() - point_cloud[0].begin();
+ Min_sphere ms012(dimension, points012.begin(),points012.end());
Simplex_tree::Filtration_value f012 = st2.filtration(st2.find({0, 1, 2}));
std::cout << "f012= " << f012 << " | ms012_radius= " << std::sqrt(ms012.squared_radius()) << std::endl;
@@ -137,7 +139,7 @@ BOOST_AUTO_TEST_CASE(Cech_complex_from_file) {
points456.push_back(Point(cech_complex_from_file.point_iterator(vertex)->begin(),
cech_complex_from_file.point_iterator(vertex)->end()));
}
- Min_sphere ms456(cech_complex_from_file.dimension(), points456.begin(),points456.end());
+ Min_sphere ms456(dimension, points456.begin(),points456.end());
Simplex_tree::Filtration_value f456 = st2.filtration(st2.find({4, 5, 6}));
std::cout << "f456= " << f456 << " | ms456_radius= " << std::sqrt(ms456.squared_radius()) << std::endl;
@@ -161,7 +163,7 @@ BOOST_AUTO_TEST_CASE(Cech_complex_from_file) {
points0123.push_back(Point(cech_complex_from_file.point_iterator(vertex)->begin(),
cech_complex_from_file.point_iterator(vertex)->end()));
}
- Min_sphere ms0123(cech_complex_from_file.dimension(), points0123.begin(),points0123.end());
+ Min_sphere ms0123(dimension, points0123.begin(),points0123.end());
Simplex_tree::Filtration_value f0123 = st3.filtration(st3.find({0, 1, 2, 3}));
std::cout << "f0123= " << f0123 << " | ms0123_radius= " << std::sqrt(ms0123.squared_radius()) << std::endl;
@@ -175,7 +177,7 @@ BOOST_AUTO_TEST_CASE(Cech_complex_from_file) {
points01.push_back(Point(cech_complex_from_file.point_iterator(vertex)->begin(),
cech_complex_from_file.point_iterator(vertex)->end()));
}
- Min_sphere ms01(cech_complex_from_file.dimension(), points01.begin(),points01.end());
+ Min_sphere ms01(dimension, points01.begin(),points01.end());
Simplex_tree::Filtration_value f01 = st2.filtration(st2.find({0, 1}));
std::cout << "f01= " << f01 << " | ms01_radius= " << std::sqrt(ms01.squared_radius()) << std::endl;
@@ -199,7 +201,7 @@ BOOST_AUTO_TEST_CASE(Cech_complex_from_points) {
// ----------------------------------------------------------------------------
// Init of a Cech complex from the list of points
// ----------------------------------------------------------------------------
- Cech_complex cech_complex_from_points(points, 2.0, Gudhi::Euclidean_distance());
+ Cech_complex cech_complex_from_points(points, 2.0);
std::cout << "========== cech_complex_from_points ==========" << std::endl;
Simplex_tree st;
@@ -234,13 +236,13 @@ BOOST_AUTO_TEST_CASE(Cech_complex_from_points) {
GUDHI_TEST_FLOAT_EQUALITY_CHECK(st.filtration(f_simplex), 0.0);
break;
case 1:
- GUDHI_TEST_FLOAT_EQUALITY_CHECK(st.filtration(f_simplex), 1.41421, .00001);
+ GUDHI_TEST_FLOAT_EQUALITY_CHECK(st.filtration(f_simplex), 0.5);
break;
case 2:
- GUDHI_TEST_FLOAT_EQUALITY_CHECK(st.filtration(f_simplex), 0.816497, .00001);
+ GUDHI_TEST_FLOAT_EQUALITY_CHECK(st.filtration(f_simplex), 0.666667, .00001);
break;
case 3:
- GUDHI_TEST_FLOAT_EQUALITY_CHECK(st.filtration(f_simplex), 0.866025, .00001);
+ GUDHI_TEST_FLOAT_EQUALITY_CHECK(st.filtration(f_simplex), 0.75);
break;
default:
BOOST_CHECK(false); // Shall not happen
@@ -257,12 +259,12 @@ BOOST_AUTO_TEST_CASE(Cech_create_complex_throw) {
//
// ----------------------------------------------------------------------------
std::string off_file_name("alphacomplexdoc.off");
- double threshold = 12.0;
- std::cout << "========== OFF FILE NAME = " << off_file_name << " - Cech threshold=" <<
- threshold << "==========" << std::endl;
+ double max_radius = 12.0;
+ std::cout << "========== OFF FILE NAME = " << off_file_name << " - Cech max_radius=" <<
+ max_radius << "==========" << std::endl;
Gudhi::Points_off_reader<Point> off_reader(off_file_name);
- Cech_complex cech_complex_from_file(off_reader.get_point_cloud(), threshold, Gudhi::Euclidean_distance());
+ Cech_complex cech_complex_from_file(off_reader.get_point_cloud(), max_radius);
Simplex_tree stree;
std::vector<int> simplex = {0, 1, 2};