summaryrefslogtreecommitdiff
path: root/src/Witness_complex/include
diff options
context:
space:
mode:
authorglisse <glisse@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2016-03-20 13:04:38 +0000
committerglisse <glisse@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2016-03-20 13:04:38 +0000
commitc19dafdee66ca80c5bf5e71129d9cca9b9243c92 (patch)
tree2fcd7eda4e7cf8af89aac147e02d188787ec2962 /src/Witness_complex/include
parent8feab25e21b6f8f5702c035be6aadc63d7c9b422 (diff)
Let the witness code match its doc better.
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@1057 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 99dc557a03f1ea85730ce286b80e384257ab2a77
Diffstat (limited to 'src/Witness_complex/include')
-rw-r--r--src/Witness_complex/include/gudhi/Landmark_choice_by_furthest_point.h14
-rw-r--r--src/Witness_complex/include/gudhi/Landmark_choice_by_random_point.h7
-rw-r--r--src/Witness_complex/include/gudhi/Witness_complex.h5
3 files changed, 16 insertions, 10 deletions
diff --git a/src/Witness_complex/include/gudhi/Landmark_choice_by_furthest_point.h b/src/Witness_complex/include/gudhi/Landmark_choice_by_furthest_point.h
index 86d8ac61..df93155b 100644
--- a/src/Witness_complex/include/gudhi/Landmark_choice_by_furthest_point.h
+++ b/src/Witness_complex/include/gudhi/Landmark_choice_by_furthest_point.h
@@ -23,7 +23,10 @@
#ifndef LANDMARK_CHOICE_BY_FURTHEST_POINT_H_
#define LANDMARK_CHOICE_BY_FURTHEST_POINT_H_
+#include <boost/range/size.hpp>
+
#include <limits> // for numeric_limits<>
+#include <iterator>
#include <algorithm> // for sort
#include <vector>
@@ -51,7 +54,7 @@ namespace witness_complex {
void landmark_choice_by_furthest_point(Point_random_access_range const &points,
int nbL,
KNearestNeighbours &knn) {
- int nb_points = points.end() - points.begin();
+ int nb_points = boost::size(points);
assert(nb_points >= nbL);
// distance matrix witness x landmarks
std::vector<std::vector<double>> wit_land_dist(nb_points, std::vector<double>());
@@ -65,6 +68,7 @@ namespace witness_complex {
std::vector< double > dist_to_L(nb_points, infty); // vector of current distances to L from points
// TODO(SK) Consider using rand_r(...) instead of rand(...) for improved thread safety
+ // or better yet std::uniform_int_distribution
int rand_int = rand() % nb_points;
int curr_max_w = rand_int; // For testing purposes a pseudo-random number is used here
@@ -73,7 +77,7 @@ namespace witness_complex {
chosen_landmarks.push_back(curr_max_w);
unsigned i = 0;
for (auto& p : points) {
- double curr_dist = euclidean_distance(p, *(points.begin() + chosen_landmarks[current_number_of_landmarks]));
+ double curr_dist = euclidean_distance(p, *(std::begin(points) + chosen_landmarks[current_number_of_landmarks]));
wit_land_dist[i].push_back(curr_dist);
knn[i].push_back(current_number_of_landmarks);
if (curr_dist < dist_to_L[i])
@@ -87,9 +91,9 @@ namespace witness_complex {
curr_max_w = i;
}
}
- for (unsigned i = 0; i < nb_points; ++i)
- std::sort(knn[i].begin(),
- knn[i].end(),
+ for (int i = 0; i < nb_points; ++i)
+ std::sort(std::begin(knn[i]),
+ std::end(knn[i]),
[&wit_land_dist, i](int a, int b) {
return wit_land_dist[i][a] < wit_land_dist[i][b]; });
}
diff --git a/src/Witness_complex/include/gudhi/Landmark_choice_by_random_point.h b/src/Witness_complex/include/gudhi/Landmark_choice_by_random_point.h
index a73c04ac..ebf6aad1 100644
--- a/src/Witness_complex/include/gudhi/Landmark_choice_by_random_point.h
+++ b/src/Witness_complex/include/gudhi/Landmark_choice_by_random_point.h
@@ -23,8 +23,11 @@
#ifndef LANDMARK_CHOICE_BY_RANDOM_POINT_H_
#define LANDMARK_CHOICE_BY_RANDOM_POINT_H_
+#include <boost/range/size.hpp>
+
#include <queue> // for priority_queue<>
#include <utility> // for pair<>
+#include <iterator>
#include <vector>
#include <set>
@@ -50,7 +53,7 @@ namespace witness_complex {
void landmark_choice_by_random_point(Point_random_access_range const &points,
int nbL,
KNearestNeighbours &knn) {
- int nbP = points.end() - points.begin();
+ int nbP = boost::size(points);
assert(nbP >= nbL);
std::set<int> landmarks;
int current_number_of_landmarks = 0; // counter for landmarks
@@ -63,7 +66,7 @@ namespace witness_complex {
landmarks.insert(chosen_landmark);
}
- int dim = points.begin()->size();
+ int dim = boost::size(*std::begin(points));
typedef std::pair<double, int> dist_i;
typedef bool (*comp)(dist_i, dist_i);
knn = KNearestNeighbours(nbP);
diff --git a/src/Witness_complex/include/gudhi/Witness_complex.h b/src/Witness_complex/include/gudhi/Witness_complex.h
index 52f374f3..489cdf11 100644
--- a/src/Witness_complex/include/gudhi/Witness_complex.h
+++ b/src/Witness_complex/include/gudhi/Witness_complex.h
@@ -28,8 +28,7 @@
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/connected_components.hpp>
-#include <boost/container/flat_map.hpp>
-#include <boost/iterator/transform_iterator.hpp>
+#include <boost/range/size.hpp>
#include <gudhi/distance_functions.h>
@@ -113,7 +112,7 @@ class Witness_complex {
int dim,
SimplicialComplex & sc) : nbL_(nbL), sc_(sc) {
// Construction of the active witness list
- int nbW = knn.size();
+ int nbW = boost::size(knn);
typeVectorVertex vv;
int counter = 0;
/* The list of still useful witnesses