summaryrefslogtreecommitdiff
path: root/src/Witness_complex
diff options
context:
space:
mode:
authorskachano <skachano@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2016-01-14 10:37:35 +0000
committerskachano <skachano@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2016-01-14 10:37:35 +0000
commit309699bf1dfd0582e671c730aee6bdf0f5031a1a (patch)
tree14f9758c37f4378e0afeb71149a302ecd28e366b /src/Witness_complex
parente9f91fe2787f41dd7791c055592ade552ce8df8a (diff)
Fixed the bug in Landmark_selection_by_furthest_point
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/witness@966 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: cbda37a8c267348800fe04e82c58c4021744292e
Diffstat (limited to 'src/Witness_complex')
-rw-r--r--src/Witness_complex/include/gudhi/Landmark_choice_by_furthest_point.h16
-rw-r--r--src/Witness_complex/test/witness_complex_points.cpp2
2 files changed, 7 insertions, 11 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 ebee96ad..6ac59ae9 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
@@ -60,7 +60,7 @@ public:
double curr_max_dist = 0; // used for defining the furhest point from L
const double infty = std::numeric_limits<double>::infinity(); // infinity (see next entry)
std::vector< double > dist_to_L(nb_points,infty); // vector of current distances to L from points
- int dim = points.begin()->size();
+ //int dim = points.begin()->size();
int rand_int = rand() % nb_points;
int curr_max_w = rand_int; //For testing purposes a pseudo-random number is used here
@@ -69,8 +69,6 @@ public:
{
//curr_max_w at this point is the next landmark
chosen_landmarks.push_back(curr_max_w);
- for (auto& v: knn)
- v.push_back(current_number_of_landmarks);
unsigned i = 0;
for (auto& p: points)
{
@@ -79,13 +77,6 @@ public:
knn[i].push_back(current_number_of_landmarks);
if (curr_dist < dist_to_L[i])
dist_to_L[i] = curr_dist;
- int j = current_number_of_landmarks;
- while (j > 0 && wit_land_dist[i][j-1] > wit_land_dist[i][j])
- {
- std::swap(knn[i][j], knn[i][j-1]);
- std::swap(wit_land_dist[i][j-1], wit_land_dist[i][j-1]);
- --j;
- }
++i;
}
curr_max_dist = 0;
@@ -96,6 +87,11 @@ public:
curr_max_w = i;
}
}
+ for (unsigned i = 0; i < points.size(); ++i)
+ std::sort(knn[i].begin(),
+ knn[i].end(),
+ [&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/test/witness_complex_points.cpp b/src/Witness_complex/test/witness_complex_points.cpp
index f9680874..a86bf493 100644
--- a/src/Witness_complex/test/witness_complex_points.cpp
+++ b/src/Witness_complex/test/witness_complex_points.cpp
@@ -47,7 +47,7 @@ int main (int argc, char * const argv[])
for (double k = 0; k < 10; k += 1.0)
points.push_back(Point({i,j,k}));
- bool b_print_output = true;
+ bool b_print_output = false;
// First test: random choice
Simplex_tree<> complex1;
Landmark_choice_by_random_point lcrp(points, 100, knn);