summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHind-M <hind.montassif@gmail.com>2022-04-26 16:52:26 +0200
committerHind-M <hind.montassif@gmail.com>2022-04-26 16:52:26 +0200
commitaec7ab1737a5284f4b7c2d1f7fe3eb7977df7537 (patch)
treebf39e07ea9d38fbae2a9c0c6e412954ae66d16a7
parenta3d8a052e260c501d2feee2e63d3699b71baf549 (diff)
Modify cech doc
Use Filtration_value instead of double for casting Use a templated range of points instead of vector in cech constructor Capitalize sphere_circumradius.h file name and make it private in doc
-rw-r--r--src/Cech_complex/include/gudhi/Cech_complex.h19
-rw-r--r--src/Cech_complex/include/gudhi/Cech_complex_blocker.h18
-rw-r--r--src/Cech_complex/include/gudhi/Sphere_circumradius.h (renamed from src/Cech_complex/include/gudhi/sphere_circumradius.h)2
-rw-r--r--src/Cech_complex/test/test_cech_complex.cpp15
-rw-r--r--src/Cech_complex/utilities/cech_persistence.cpp1
5 files changed, 27 insertions, 28 deletions
diff --git a/src/Cech_complex/include/gudhi/Cech_complex.h b/src/Cech_complex/include/gudhi/Cech_complex.h
index 375be1d2..fc39f75b 100644
--- a/src/Cech_complex/include/gudhi/Cech_complex.h
+++ b/src/Cech_complex/include/gudhi/Cech_complex.h
@@ -11,7 +11,7 @@
#ifndef CECH_COMPLEX_H_
#define CECH_COMPLEX_H_
-#include <gudhi/sphere_circumradius.h> // for Gudhi::cech_complex::Sphere_circumradius
+#include <gudhi/Sphere_circumradius.h> // for Gudhi::cech_complex::Sphere_circumradius
#include <gudhi/graph_simplicial_complex.h> // for Gudhi::Proximity_graph
#include <gudhi/Debug_utils.h> // for GUDHI_CHECK
#include <gudhi/Cech_complex_blocker.h> // for Gudhi::cech_complex::Cech_blocker
@@ -25,15 +25,15 @@ namespace cech_complex {
/**
* \class Cech_complex
- * \brief Cech complex data structure.
+ * \brief Cech complex class.
*
* \ingroup cech_complex
*
* \details
- * The data structure is a proximity graph, containing edges when the edge length is less or equal
- * to a given max_radius. Edge length is computed from `Gudhi::cech_complex::Sphere_circumradius` distance function.
+ * Cech complex is a simplicial complex constructed from a proximity graph, where the set of all simplices is filtered
+ * by the radius of their minimal enclosing ball and bounded by the given max_radius.
*
- * \tparam Kernel CGAL kernel.
+ * \tparam Kernel CGAL kernel: either Epick_d or Epeck_d.
*
* \tparam SimplicialComplexForCechComplex furnishes `Vertex_handle` and `Filtration_value` type definition required
* by `Gudhi::Proximity_graph` and Cech blocker.
@@ -58,15 +58,16 @@ class Cech_complex {
using Sphere = typename cech_blocker::Sphere;
public:
- /** \brief Cech_complex constructor from a list of points.
+ /** \brief Cech_complex constructor from a range of points.
*
- * @param[in] points Vector of points where each point is defined as `kernel::Point_d`.
+ * @param[in] points Range of points where each point is defined as `kernel::Point_d`.
* @param[in] max_radius Maximal radius value.
*
*/
- Cech_complex(const Point_cloud & points, Filtration_value max_radius) : max_radius_(max_radius) {
+ template<typename InputPointRange >
+ Cech_complex(const InputPointRange & points, Filtration_value max_radius) : max_radius_(max_radius) {
- point_cloud_.assign(points.begin(), points.end());
+ point_cloud_.assign(std::begin(points), std::end(points));
cech_skeleton_graph_ = Gudhi::compute_proximity_graph<SimplicialComplexForCechComplex>(
point_cloud_, max_radius_, Sphere_circumradius<Kernel>());
diff --git a/src/Cech_complex/include/gudhi/Cech_complex_blocker.h b/src/Cech_complex/include/gudhi/Cech_complex_blocker.h
index 1a696422..1a09f7e1 100644
--- a/src/Cech_complex/include/gudhi/Cech_complex_blocker.h
+++ b/src/Cech_complex/include/gudhi/Cech_complex_blocker.h
@@ -11,7 +11,7 @@
#ifndef CECH_COMPLEX_BLOCKER_H_
#define CECH_COMPLEX_BLOCKER_H_
-#include <CGAL/NT_converter.h> // for casting from FT to double
+#include <CGAL/NT_converter.h> // for casting from FT to Filtration_value and double to FT
#include <iostream>
#include <vector>
@@ -36,7 +36,7 @@ namespace cech_complex {
*
* \tparam Cech_complex is required by the blocker.
*
- * \tparam Kernel CGAL kernel.
+ * \tparam Kernel CGAL kernel: either Epick_d or Epeck_d.
*/
template <typename SimplicialComplexForCech, typename Cech_complex, typename Kernel>
class Cech_blocker {
@@ -69,8 +69,8 @@ class Cech_blocker {
* \return true if the simplex radius is greater than the Cech_complex max_radius*/
bool operator()(Simplex_handle sh) {
using Point_cloud = std::vector<Point_d>;
- CGAL::NT_converter<FT, double> cast_to_double;
- Filtration_value radius = 0.;
+ CGAL::NT_converter<FT, Filtration_value> cast_to_fv;
+ Filtration_value radius = 0;
// for each face of simplex sh, test outsider point is indeed inside enclosing ball, if yes, take it and exit loop, otherwise, new sphere is circumsphere of all vertices
Sphere min_enclos_ball;
@@ -105,18 +105,18 @@ class Cech_blocker {
face_points.clear();
if (kernel_.squared_distance_d_object()(sph.first, cc_ptr_->get_point(extra)) <= sph.second) {
- radius = std::sqrt(cast_to_double(sph.second));
+ radius = std::sqrt(cast_to_fv(sph.second));
#ifdef DEBUG_TRACES
std::clog << "center: " << sph.first << ", radius: " << radius << std::endl;
#endif // DEBUG_TRACES
- if (cast_to_double(sph.second) < cast_to_double(min_enclos_ball.second))
+ if (sph.second < min_enclos_ball.second)
min_enclos_ball = sph;
break;
}
}
// Get the minimal radius of all faces enclosing balls if exists
- if(cast_to_double(min_enclos_ball.second) != std::numeric_limits<double>::max()) {
- radius = std::sqrt(cast_to_double(min_enclos_ball.second));
+ if(min_enclos_ball.second != std::numeric_limits<double>::max()) {
+ radius = std::sqrt(cast_to_fv(min_enclos_ball.second));
sc_ptr_->assign_key(sh, cc_ptr_->get_cache().size());
cc_ptr_->get_cache().push_back(min_enclos_ball);
@@ -128,7 +128,7 @@ class Cech_blocker {
points.push_back(cc_ptr_->get_point(vertex));
}
Sphere sph = get_sphere(points.cbegin(), points.cend());
- radius = std::sqrt(cast_to_double(sph.second));
+ radius = std::sqrt(cast_to_fv(sph.second));
sc_ptr_->assign_key(sh, cc_ptr_->get_cache().size());
cc_ptr_->get_cache().push_back(sph);
diff --git a/src/Cech_complex/include/gudhi/sphere_circumradius.h b/src/Cech_complex/include/gudhi/Sphere_circumradius.h
index a6dec3dc..b0d9f7cc 100644
--- a/src/Cech_complex/include/gudhi/sphere_circumradius.h
+++ b/src/Cech_complex/include/gudhi/Sphere_circumradius.h
@@ -20,7 +20,7 @@ namespace Gudhi {
namespace cech_complex {
-/** @brief Compute the circumradius of the sphere passing through points given by a range of coordinates.
+/** \private @brief Compute the circumradius of the sphere passing through points given by a range of coordinates.
* The points are assumed to have the same dimension. */
template<typename Kernel>
class Sphere_circumradius {
diff --git a/src/Cech_complex/test/test_cech_complex.cpp b/src/Cech_complex/test/test_cech_complex.cpp
index 4cf8b68f..ea32f596 100644
--- a/src/Cech_complex/test/test_cech_complex.cpp
+++ b/src/Cech_complex/test/test_cech_complex.cpp
@@ -22,7 +22,6 @@
// to construct Cech_complex from a OFF file of points
#include <gudhi/Points_off_io.h>
#include <gudhi/Simplex_tree.h>
-#include <gudhi/sphere_circumradius.h>
#include <gudhi/Unitary_tests_utils.h>
#include <CGAL/Epeck_d.h> // For EXACT or SAFE version
@@ -139,18 +138,18 @@ BOOST_AUTO_TEST_CASE(Cech_complex_for_documentation) {
}
Kernel kern;
- Simplex_tree::Filtration_value f012 = st2.filtration(st2.find({0, 1, 2}));
+ Filtration_value f012 = st2.filtration(st2.find({0, 1, 2}));
std::clog << "f012= " << f012 << std::endl;
- CGAL::NT_converter<FT, double> cast_to_double;
- GUDHI_TEST_FLOAT_EQUALITY_CHECK(f012, std::sqrt(cast_to_double(kern.compute_squared_radius_d_object()(points012.begin(), points012.end()))));
+ CGAL::NT_converter<FT, Filtration_value> cast_to_fv;
+ GUDHI_TEST_FLOAT_EQUALITY_CHECK(f012, std::sqrt(cast_to_fv(kern.compute_squared_radius_d_object()(points012.begin(), points012.end()))));
Point_cloud points1410;
points1410.push_back(cech_complex_for_doc.get_point(1));
points1410.push_back(cech_complex_for_doc.get_point(4));
points1410.push_back(cech_complex_for_doc.get_point(10));
- Simplex_tree::Filtration_value f1410 = st2.filtration(st2.find({1, 4, 10}));
+ Filtration_value f1410 = st2.filtration(st2.find({1, 4, 10}));
std::clog << "f1410= " << f1410 << std::endl;
// In this case, the computed circumsphere using CGAL kernel does not match the minimal enclosing ball; the filtration value check is therefore done against a hardcoded value
@@ -161,10 +160,10 @@ BOOST_AUTO_TEST_CASE(Cech_complex_for_documentation) {
points469.push_back(cech_complex_for_doc.get_point(6));
points469.push_back(cech_complex_for_doc.get_point(9));
- Simplex_tree::Filtration_value f469 = st2.filtration(st2.find({4, 6, 9}));
+ Filtration_value f469 = st2.filtration(st2.find({4, 6, 9}));
std::clog << "f469= " << f469 << std::endl;
- GUDHI_TEST_FLOAT_EQUALITY_CHECK(f469, std::sqrt(cast_to_double(kern.compute_squared_radius_d_object()(points469.begin(), points469.end()))));
+ GUDHI_TEST_FLOAT_EQUALITY_CHECK(f469, std::sqrt(cast_to_fv(kern.compute_squared_radius_d_object()(points469.begin(), points469.end()))));
BOOST_CHECK((st2.find({6, 7, 8}) == st2.null_simplex()));
BOOST_CHECK((st2.find({3, 5, 7}) == st2.null_simplex()));
@@ -246,7 +245,7 @@ BOOST_AUTO_TEST_CASE(Cech_create_complex_throw) {
//
// ----------------------------------------------------------------------------
std::string off_file_name("alphacomplexdoc.off");
- double max_radius = 12.0;
+ Filtration_value max_radius = 12.0;
std::clog << "========== OFF FILE NAME = " << off_file_name << " - Cech max_radius=" << max_radius
<< "==========" << std::endl;
diff --git a/src/Cech_complex/utilities/cech_persistence.cpp b/src/Cech_complex/utilities/cech_persistence.cpp
index 82992f2d..75d10c0f 100644
--- a/src/Cech_complex/utilities/cech_persistence.cpp
+++ b/src/Cech_complex/utilities/cech_persistence.cpp
@@ -9,7 +9,6 @@
*/
#include <gudhi/Cech_complex.h>
-#include <gudhi/sphere_circumradius.h>
#include <gudhi/Simplex_tree.h>
#include <gudhi/Persistent_cohomology.h>
#include <gudhi/Points_off_io.h>