From d3cef9245dcff1ea585142ef0b711bb35b6f9338 Mon Sep 17 00:00:00 2001 From: skachano Date: Wed, 15 Apr 2015 13:48:51 +0000 Subject: Landmark selection: now it's faster git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/witness@567 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 24292a17b98074b7aff4693630829b636ba3d67a --- .../include/gudhi/Witness_complex.h | 25 ++++++++++++---------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/Witness_complex/include/gudhi/Witness_complex.h b/src/Witness_complex/include/gudhi/Witness_complex.h index e2dcdf79..c633691b 100644 --- a/src/Witness_complex/include/gudhi/Witness_complex.h +++ b/src/Witness_complex/include/gudhi/Witness_complex.h @@ -510,22 +510,25 @@ private: //std::cout << "Push't back\n"; j = current_number_of_landmarks; //std::cout << "First half complete\n"; - while (j > 0 && wit_land_dist[i][j-1] > wit_land_dist[i][j]) - { - // sort the closest landmark vector for every witness - temp_swap_int = WL[i][j]; - WL[i][j] = WL[i][j-1]; - WL[i][j-1] = temp_swap_int; - temp_swap_double = wit_land_dist[i][j]; - wit_land_dist[i][j] = wit_land_dist[i][j-1]; - wit_land_dist[i][j-1] = temp_swap_double; - --j; - } //std::cout << "result WL="; print_vvector(WL); //std::cout << "result WLD="; print_vvector(wit_land_dist); //std::cout << "End loop\n"; } } + for (int i = 0; i < nbP; i++) + { + // sort the closest landmark vector for every witness + sort(WL[i].begin(), WL[i].end(), [&](int j1, int j2){return wit_land_dist[i][j1] < wit_land_dist[i][j2];}); + /* + temp_swap_int = WL[i][j]; + WL[i][j] = WL[i][j-1]; + WL[i][j-1] = temp_swap_int; + temp_swap_double = wit_land_dist[i][j]; + wit_land_dist[i][j] = wit_land_dist[i][j-1]; + wit_land_dist[i][j-1] = temp_swap_double; + --j; + */ + } //std::cout << endl; } -- cgit v1.2.3