summaryrefslogtreecommitdiff
path: root/src/Witness_complex/include/gudhi/Landmark_choice_by_random_point.h
diff options
context:
space:
mode:
authorskachano <skachano@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2015-12-10 09:29:52 +0000
committerskachano <skachano@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2015-12-10 09:29:52 +0000
commitf3fa597138156c3b925ac970555f8482e964c968 (patch)
treeb54d3337b473f96c029814a8e8228108d304b36a /src/Witness_complex/include/gudhi/Landmark_choice_by_random_point.h
parent8f54c437e0b895368c6151584811ce7df1575ea0 (diff)
Added things
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/witness@937 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 4f0ae39ee1f68d8cce565ad0855edb3bff1e7f3f
Diffstat (limited to 'src/Witness_complex/include/gudhi/Landmark_choice_by_random_point.h')
-rw-r--r--src/Witness_complex/include/gudhi/Landmark_choice_by_random_point.h16
1 files changed, 9 insertions, 7 deletions
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 bc3e72d9..fa822591 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
@@ -33,18 +33,19 @@
class Landmark_choice_by_random_point {
-
+public:
+
/** \brief Landmark choice strategy by taking random vertices for landmarks.
- * It takes a random access range points and outputs a matrix {witness}*{closest landmarks}
- * in knn.
+ * \details It chooses nbL distinct landmarks from a random access range `points`
+ * and outputs a matrix {witness}*{closest landmarks} in knn.
*/
template <typename KNearestNeighbours,
typename Point_random_access_range>
- void landmark_choice_by_random_points(Point_random_access_range &points, KNearestNeighbours &knn)
+ Landmark_choice_by_random_point(Point_random_access_range &points, int nbL, KNearestNeighbours &knn)
{
int nbP = points.end() - points.begin();
- std::set<int> &landmarks;
+ std::set<int> landmarks;
int current_number_of_landmarks=0; // counter for landmarks
int chosen_landmark = rand()%nbP;
@@ -55,9 +56,10 @@ class Landmark_choice_by_random_point {
landmarks.insert(chosen_landmark);
}
- int D = points.begin().size();
+ int dim = points.begin()->size();
typedef std::pair<double,int> dist_i;
typedef bool (*comp)(dist_i,dist_i);
+ knn = KNearestNeighbours(nbP);
for (int points_i = 0; points_i < nbP; points_i++)
{
std::priority_queue<dist_i, std::vector<dist_i>, comp> l_heap([&](dist_i j1, dist_i j2){return j1.first > j2.first;});
@@ -68,7 +70,7 @@ class Landmark_choice_by_random_point {
dist_i dist = std::make_pair(euclidean_distance(points[points_i],points[*landmarks_it]), landmarks_i);
l_heap.push(dist);
}
- for (int i = 0; i < D+1; i++)
+ for (int i = 0; i < dim+1; i++)
{
dist_i dist = l_heap.top();
knn[points_i].push_back(dist.second);