summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2016-12-16 16:11:45 +0000
committervrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2016-12-16 16:11:45 +0000
commitde0bdf55c16de11d47809dc6f347773b10cc3673 (patch)
tree5ef252df624dfdeb9ea2fc6e30f2c29f56801866
parentc8dbfc68cca3c5462226e5d953f721143fc645f0 (diff)
Warning fixes
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@1905 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 7b7222ebe65fd01fde30f8ba527ebaee633fc87e
-rw-r--r--src/Contraction/example/Garland_heckbert.cpp12
-rw-r--r--src/GudhUI/utils/Critical_points.h2
-rw-r--r--src/GudhUI/utils/Is_manifold.h1
-rw-r--r--src/GudhUI/utils/Vertex_collapsor.h1
-rw-r--r--src/Subsampling/include/gudhi/choose_n_farthest_points.h3
-rw-r--r--src/Subsampling/include/gudhi/pick_n_random_points.h4
-rw-r--r--src/Subsampling/test/test_choose_n_farthest_points.cpp55
-rw-r--r--src/Tangential_complex/include/gudhi/Tangential_complex.h10
-rw-r--r--src/Tangential_complex/test/test_tangential_complex.cpp2
-rw-r--r--src/common/include/gudhi/random_point_generators.h7
10 files changed, 63 insertions, 34 deletions
diff --git a/src/Contraction/example/Garland_heckbert.cpp b/src/Contraction/example/Garland_heckbert.cpp
index 5347830c..4689519f 100644
--- a/src/Contraction/example/Garland_heckbert.cpp
+++ b/src/Contraction/example/Garland_heckbert.cpp
@@ -63,12 +63,10 @@ typedef Skeleton_blocker_contractor<Complex> Complex_contractor;
* the point minimizing the cost of the quadric.
*/
class GH_placement : public Gudhi::contraction::Placement_policy<EdgeProfile> {
- Complex& complex_;
-
public:
typedef Gudhi::contraction::Placement_policy<EdgeProfile>::Placement_type Placement_type;
- GH_placement(Complex& complex) : complex_(complex) { }
+ GH_placement(Complex& complex) { }
Placement_type operator()(const EdgeProfile& profile) const override {
auto sum_quad(profile.v0().quadric);
@@ -87,12 +85,10 @@ class GH_placement : public Gudhi::contraction::Placement_policy<EdgeProfile> {
* which expresses a squared distances with triangles planes.
*/
class GH_cost : public Gudhi::contraction::Cost_policy<EdgeProfile> {
- Complex& complex_;
-
public:
typedef Gudhi::contraction::Cost_policy<EdgeProfile>::Cost_type Cost_type;
- GH_cost(Complex& complex) : complex_(complex) { }
+ GH_cost(Complex& complex) { }
Cost_type operator()(EdgeProfile const& profile, boost::optional<Point> const& new_point) const override {
Cost_type res;
@@ -111,10 +107,8 @@ class GH_cost : public Gudhi::contraction::Cost_policy<EdgeProfile> {
* and we update them when contracting an edge (the quadric become the sum of both quadrics).
*/
class GH_visitor : public Gudhi::contraction::Contraction_visitor<EdgeProfile> {
- Complex& complex_;
-
public:
- GH_visitor(Complex& complex) : complex_(complex) { }
+ GH_visitor(Complex& complex) { }
// Compute quadrics for every vertex v
// The quadric of v consists in the sum of quadric
diff --git a/src/GudhUI/utils/Critical_points.h b/src/GudhUI/utils/Critical_points.h
index 3021a5fe..b88293e9 100644
--- a/src/GudhUI/utils/Critical_points.h
+++ b/src/GudhUI/utils/Critical_points.h
@@ -105,8 +105,6 @@ template<typename SkBlComplex> class Critical_points {
if (link.empty())
return 0;
- Edge_contractor<Complex> contractor(link, link.num_vertices() - 1);
-
if (link.num_connected_components() > 1)
// one than more CC -> not contractible
return 0;
diff --git a/src/GudhUI/utils/Is_manifold.h b/src/GudhUI/utils/Is_manifold.h
index 0640ea47..6dd7898e 100644
--- a/src/GudhUI/utils/Is_manifold.h
+++ b/src/GudhUI/utils/Is_manifold.h
@@ -76,7 +76,6 @@ template<typename SkBlComplex> class Is_manifold {
bool is_k_sphere(Vertex_handle v, int k) {
auto link = input_complex_.link(v);
- Edge_contractor<Complex> contractor(link, link.num_vertices() - 1);
return (is_sphere_simplex(link) == k);
}
diff --git a/src/GudhUI/utils/Vertex_collapsor.h b/src/GudhUI/utils/Vertex_collapsor.h
index 2b36cb3a..3f0e7ffd 100644
--- a/src/GudhUI/utils/Vertex_collapsor.h
+++ b/src/GudhUI/utils/Vertex_collapsor.h
@@ -80,7 +80,6 @@ template<typename SkBlComplex> class Vertex_collapsor {
if (link.empty()) return false;
if (link.is_cone()) return true;
if (link.num_connected_components() > 1) return false;
- Edge_contractor<Complex> contractor(link, link.num_vertices() - 1);
return (link.num_vertices() == 1);
}
};
diff --git a/src/Subsampling/include/gudhi/choose_n_farthest_points.h b/src/Subsampling/include/gudhi/choose_n_farthest_points.h
index ea387bf9..5e908090 100644
--- a/src/Subsampling/include/gudhi/choose_n_farthest_points.h
+++ b/src/Subsampling/include/gudhi/choose_n_farthest_points.h
@@ -145,7 +145,8 @@ void choose_n_farthest_points(Kernel const& k,
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_int_distribution<> dis(0, (input_pts.size() - 1));
- int starting_point = dis(gen);
+ std::size_t starting_point = dis(gen);
+
choose_n_farthest_points(k, input_pts, final_size, starting_point, output_it);
}
diff --git a/src/Subsampling/include/gudhi/pick_n_random_points.h b/src/Subsampling/include/gudhi/pick_n_random_points.h
index e89b2b2d..f0e3f1f1 100644
--- a/src/Subsampling/include/gudhi/pick_n_random_points.h
+++ b/src/Subsampling/include/gudhi/pick_n_random_points.h
@@ -57,7 +57,9 @@ void pick_n_random_points(Point_container const &points,
#endif
std::size_t nbP = boost::size(points);
- assert(nbP >= final_size);
+ if (final_size > nbP)
+ final_size = nbP;
+
std::vector<int> landmarks(nbP);
std::iota(landmarks.begin(), landmarks.end(), 0);
diff --git a/src/Subsampling/test/test_choose_n_farthest_points.cpp b/src/Subsampling/test/test_choose_n_farthest_points.cpp
index d064899a..0bc0dff4 100644
--- a/src/Subsampling/test/test_choose_n_farthest_points.cpp
+++ b/src/Subsampling/test/test_choose_n_farthest_points.cpp
@@ -39,18 +39,65 @@ typedef CGAL::Epick_d<CGAL::Dynamic_dimension_tag> K;
typedef typename K::FT FT;
typedef typename K::Point_d Point_d;
-BOOST_AUTO_TEST_CASE(test_choose_farthest_point) {
+typedef boost::mpl::list<CGAL::Epick_d<CGAL::Dynamic_dimension_tag>, CGAL::Epick_d<CGAL::Dimension_tag<4>>> list_of_tested_kernels;
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(test_choose_farthest_point, Kernel, list_of_tested_kernels) {
+ typedef typename Kernel::FT FT;
+ typedef typename Kernel::Point_d Point_d;
std::vector< Point_d > points, landmarks;
// Add grid points (625 points)
for (FT i = 0; i < 5; i += 1.0)
for (FT j = 0; j < 5; j += 1.0)
for (FT k = 0; k < 5; k += 1.0)
- for (FT l = 0; l < 5; l += 1.0)
- points.push_back(Point_d(std::vector<FT>({i, j, k, l})));
+ for (FT l = 0; l < 5; l += 1.0) {
+ std::vector<FT> point({i, j, k, l});
+ points.push_back(Point_d(point.begin(), point.end()));
+ }
landmarks.clear();
- K k;
+ Kernel k;
Gudhi::subsampling::choose_n_farthest_points(k, points, 100, std::back_inserter(landmarks));
BOOST_CHECK(landmarks.size() == 100);
+ for (auto landmark : landmarks)
+ {
+ // Check all landmarks are in points
+ BOOST_CHECK(std::find (points.begin(), points.end(), landmark) != points.end());
+ }
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(test_choose_farthest_point_limits, Kernel, list_of_tested_kernels) {
+ typedef typename Kernel::FT FT;
+ typedef typename Kernel::Point_d Point_d;
+ std::vector< Point_d > points, landmarks;
+ landmarks.clear();
+ Kernel k;
+ // Choose -1 farthest points in an empty point cloud
+ Gudhi::subsampling::choose_n_farthest_points(k, points, -1, std::back_inserter(landmarks));
+ BOOST_CHECK(landmarks.size() == 0);
+ landmarks.clear();
+ // Choose 0 farthest points in an empty point cloud
+ Gudhi::subsampling::choose_n_farthest_points(k, points, 0, std::back_inserter(landmarks));
+ BOOST_CHECK(landmarks.size() == 0);
+ landmarks.clear();
+ // Choose 1 farthest points in an empty point cloud
+ Gudhi::subsampling::choose_n_farthest_points(k, points, 1, std::back_inserter(landmarks));
+ BOOST_CHECK(landmarks.size() == 0);
+ landmarks.clear();
+
+ std::vector<FT> point({0.0, 0.0, 0.0, 0.0});
+ points.push_back(Point_d(point.begin(), point.end()));
+ // Choose -1 farthest points in an empty point cloud
+ Gudhi::subsampling::choose_n_farthest_points(k, points, -1, std::back_inserter(landmarks));
+ BOOST_CHECK(landmarks.size() == 1);
+ landmarks.clear();
+ // Choose 0 farthest points in a one point cloud
+ Gudhi::subsampling::choose_n_farthest_points(k, points, 0, std::back_inserter(landmarks));
+ BOOST_CHECK(landmarks.size() == 0);
+ landmarks.clear();
+ // Choose 1 farthest points in a one point cloud
+ Gudhi::subsampling::choose_n_farthest_points(k, points, 1, std::back_inserter(landmarks));
+ BOOST_CHECK(landmarks.size() == 1);
+ landmarks.clear();
+
}
diff --git a/src/Tangential_complex/include/gudhi/Tangential_complex.h b/src/Tangential_complex/include/gudhi/Tangential_complex.h
index 65de2743..cfc82eb1 100644
--- a/src/Tangential_complex/include/gudhi/Tangential_complex.h
+++ b/src/Tangential_complex/include/gudhi/Tangential_complex.h
@@ -1314,14 +1314,6 @@ class Tangential_complex {
m_k.construct_vector_d_object();
typename K::Compute_coordinate_d coord =
m_k.compute_coordinate_d_object();
- typename K::Squared_length_d sqlen =
- m_k.squared_length_d_object();
- typename K::Scaled_vector_d scaled_vec =
- m_k.scaled_vector_d_object();
- typename K::Scalar_product_d scalar_pdct =
- m_k.scalar_product_d_object();
- typename K::Difference_of_vectors_d diff_vec =
- m_k.difference_of_vectors_d_object();
#ifdef GUDHI_TC_USE_ANOTHER_POINT_SET_FOR_TANGENT_SPACE_ESTIM
KNS_range kns_range = m_points_ds_for_tse.query_k_nearest_neighbors(
@@ -2159,7 +2151,7 @@ class Tangential_complex {
typedef std::vector<Simplex> Triangles;
Triangles triangles;
- std::size_t num_vertices = c.size();
+ int num_vertices = static_cast<int>(c.size());
// Do not export smaller dimension simplices
if (num_vertices < m_intrinsic_dim + 1)
continue;
diff --git a/src/Tangential_complex/test/test_tangential_complex.cpp b/src/Tangential_complex/test/test_tangential_complex.cpp
index ebe5cdb4..48156440 100644
--- a/src/Tangential_complex/test/test_tangential_complex.cpp
+++ b/src/Tangential_complex/test/test_tangential_complex.cpp
@@ -71,9 +71,7 @@ BOOST_AUTO_TEST_CASE(test_Spatial_tree_data_structure) {
BOOST_AUTO_TEST_CASE(test_mini_tangential) {
typedef CGAL::Epick_d<CGAL::Dynamic_dimension_tag> Kernel;
- typedef Kernel::FT FT;
typedef Kernel::Point_d Point;
- typedef Kernel::Vector_d Vector;
typedef tc::Tangential_complex<Kernel, CGAL::Dynamic_dimension_tag, CGAL::Parallel_tag> TC;
diff --git a/src/common/include/gudhi/random_point_generators.h b/src/common/include/gudhi/random_point_generators.h
index c643a1e3..2ec465ef 100644
--- a/src/common/include/gudhi/random_point_generators.h
+++ b/src/common/include/gudhi/random_point_generators.h
@@ -192,10 +192,9 @@ static void generate_uniform_points_on_torus_d(const Kernel &k, int dim, std::si
double radius_noise_percentage = 0.,
std::vector<typename Kernel::FT> current_point = std::vector<typename Kernel::FT>()) {
CGAL::Random rng;
- if (current_point.size() == 2 * dim) {
- *out++ = k.construct_point_d_object()(
- static_cast<int> (current_point.size()),
- current_point.begin(), current_point.end());
+ int point_size = static_cast<int>(current_point.size());
+ if (point_size == 2 * dim) {
+ *out++ = k.construct_point_d_object()(point_size, current_point.begin(), current_point.end());
} else {
for (std::size_t slice_idx = 0; slice_idx < num_slices; ++slice_idx) {
double radius_noise_ratio = 1.;