From 7e40efa04f1cc528f49da82df1502af85feb78d1 Mon Sep 17 00:00:00 2001 From: skachano Date: Wed, 13 Jan 2016 19:08:03 +0000 Subject: Added a test, moved the old test from example git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/witness@964 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 5744fdd3d30735cebdbd7442f023585a70bf0fca --- .../test/simple_witness_complex.cpp | 55 +++++++++++++++++++ .../test/witness_complex_points.cpp | 64 ++++++++++++++++++++++ 2 files changed, 119 insertions(+) create mode 100644 src/Witness_complex/test/simple_witness_complex.cpp create mode 100644 src/Witness_complex/test/witness_complex_points.cpp (limited to 'src/Witness_complex/test') diff --git a/src/Witness_complex/test/simple_witness_complex.cpp b/src/Witness_complex/test/simple_witness_complex.cpp new file mode 100644 index 00000000..c7d85a4d --- /dev/null +++ b/src/Witness_complex/test/simple_witness_complex.cpp @@ -0,0 +1,55 @@ +/* This file is part of the Gudhi Library. The Gudhi library + * (Geometric Understanding in Higher Dimensions) is a generic C++ + * library for computational topology. + * + * Author(s): Vincent Rouvreau + * + * Copyright (C) 2014 INRIA Sophia Antipolis-Méditerranée (France) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include +//#include "gudhi/graph_simplicial_complex.h" +#include "gudhi/Simplex_tree.h" +#include "gudhi/Witness_complex.h" + +using namespace Gudhi; + +typedef std::vector< Vertex_handle > typeVectorVertex; +typedef Witness_complex> WitnessComplex; +//typedef std::pair typeSimplex; +//typedef std::pair< Simplex_tree<>::Simplex_handle, bool > typePairSimplexBool; + +int main (int argc, char * const argv[]) +{ + Simplex_tree<> complex; + std::vector< typeVectorVertex > knn; + typeVectorVertex witness0 = {1,0,5,2,6,3,4}; knn.push_back(witness0 ); + typeVectorVertex witness1 = {2,6,4,5,0,1,3}; knn.push_back(witness1 ); + typeVectorVertex witness2 = {3,4,2,1,5,6,0}; knn.push_back(witness2 ); + typeVectorVertex witness3 = {4,2,1,3,5,6,0}; knn.push_back(witness3 ); + typeVectorVertex witness4 = {5,1,6,0,2,3,4}; knn.push_back(witness4 ); + typeVectorVertex witness5 = {6,0,5,2,1,3,4}; knn.push_back(witness5 ); + typeVectorVertex witness6 = {0,5,6,1,2,3,4}; knn.push_back(witness6 ); + typeVectorVertex witness7 = {2,6,4,5,3,1,0}; knn.push_back(witness7 ); + typeVectorVertex witness8 = {1,2,5,4,3,6,0}; knn.push_back(witness8 ); + typeVectorVertex witness9 = {3,4,0,6,5,1,2}; knn.push_back(witness9 ); + typeVectorVertex witness10 = {5,0,1,3,6,2,4}; knn.push_back(witness10); + typeVectorVertex witness11 = {5,6,1,0,2,3,4}; knn.push_back(witness11); + typeVectorVertex witness12 = {1,6,0,5,2,3,4}; knn.push_back(witness12); + WitnessComplex witnessComplex(knn, complex, 7, 7); + assert(witnessComplex.is_witness_complex(knn, true)); +} diff --git a/src/Witness_complex/test/witness_complex_points.cpp b/src/Witness_complex/test/witness_complex_points.cpp new file mode 100644 index 00000000..f9680874 --- /dev/null +++ b/src/Witness_complex/test/witness_complex_points.cpp @@ -0,0 +1,64 @@ +/* This file is part of the Gudhi Library. The Gudhi library + * (Geometric Understanding in Higher Dimensions) is a generic C++ + * library for computational topology. + * + * Author(s): Vincent Rouvreau + * + * Copyright (C) 2014 INRIA Sophia Antipolis-Méditerranée (France) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include +//#include "gudhi/graph_simplicial_complex.h" +#include "gudhi/Simplex_tree.h" +#include "gudhi/Witness_complex.h" +#include "gudhi/Landmark_choice_by_random_point.h" +#include "gudhi/Landmark_choice_by_furthest_point.h" + + +using namespace Gudhi; + +typedef std::vector< Vertex_handle > typeVectorVertex; +typedef Witness_complex> WitnessComplex; +typedef std::vector Point; +//typedef std::pair typeSimplex; +//typedef std::pair< Simplex_tree<>::Simplex_handle, bool > typePairSimplexBool; + +int main (int argc, char * const argv[]) +{ + std::vector< typeVectorVertex > knn; + std::vector< Point > points; + // Add grid points as witnesses + for (double i = 0; i < 10; i += 1.0) + for (double j = 0; j < 10; j += 1.0) + for (double k = 0; k < 10; k += 1.0) + points.push_back(Point({i,j,k})); + + bool b_print_output = true; + // First test: random choice + Simplex_tree<> complex1; + Landmark_choice_by_random_point lcrp(points, 100, knn); + assert(!knn.empty()); + WitnessComplex witnessComplex1(knn, complex1, 100, 3); + assert(witnessComplex1.is_witness_complex(knn, b_print_output)); + + // Second test: furthest choice + knn.clear(); + Simplex_tree<> complex2; + Landmark_choice_by_furthest_point lcfp(points, 100, knn); + WitnessComplex witnessComplex2(knn, complex2, 100, 3); + assert(witnessComplex2.is_witness_complex(knn, b_print_output)); +} -- cgit v1.2.3 From e9f91fe2787f41dd7791c055592ade552ce8df8a Mon Sep 17 00:00:00 2001 From: skachano Date: Wed, 13 Jan 2016 19:08:48 +0000 Subject: Oh, forgot the CMakeList in test folder git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/witness@965 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: d4a5301e5a48a27050bec9a43c35980a98d8837b --- src/Witness_complex/test/CMakeLists.txt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/Witness_complex/test/CMakeLists.txt (limited to 'src/Witness_complex/test') diff --git a/src/Witness_complex/test/CMakeLists.txt b/src/Witness_complex/test/CMakeLists.txt new file mode 100644 index 00000000..a13fd94a --- /dev/null +++ b/src/Witness_complex/test/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 2.6) +project(GUDHITestWitnessComplex) + +#if(NOT MSVC) +# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage") +# set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} --coverage") +# set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} --coverage") +#endif() + +add_executable ( simple_witness_complex simple_witness_complex.cpp ) +add_test(test ${CMAKE_CURRENT_BINARY_DIR}/simple_witness_complex) + +add_executable ( witness_complex_points witness_complex_points.cpp ) +add_test(test ${CMAKE_CURRENT_BINARY_DIR}/witness_complex_points) + +#cpplint_add_tests("${CMAKE_SOURCE_DIR}/src/Simplex_tree/include/gudhi") -- cgit v1.2.3 From 309699bf1dfd0582e671c730aee6bdf0f5031a1a Mon Sep 17 00:00:00 2001 From: skachano Date: Thu, 14 Jan 2016 10:37:35 +0000 Subject: 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 --- .../include/gudhi/Landmark_choice_by_furthest_point.h | 16 ++++++---------- src/Witness_complex/test/witness_complex_points.cpp | 2 +- 2 files changed, 7 insertions(+), 11 deletions(-) (limited to 'src/Witness_complex/test') 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::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); -- cgit v1.2.3 From f44d72644fc31bc863d0c81d0ae80630ebc506e5 Mon Sep 17 00:00:00 2001 From: skachano Date: Thu, 14 Jan 2016 16:17:51 +0000 Subject: Added example stuff git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/witness@968 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: a769b41f7d2d784a2740c149da08dac8124e3df9 --- src/Witness_complex/example/CMakeLists.txt | 11 +- src/Witness_complex/example/generators.h | 134 +++++++++++++++++++++ .../example/witness_complex_sphere.cpp | 126 +++++++++++++++++++ .../include/gudhi/Witness_complex.h | 2 +- .../test/simple_witness_complex.cpp | 5 +- .../test/witness_complex_points.cpp | 9 +- 6 files changed, 271 insertions(+), 16 deletions(-) create mode 100644 src/Witness_complex/example/generators.h create mode 100644 src/Witness_complex/example/witness_complex_sphere.cpp (limited to 'src/Witness_complex/test') diff --git a/src/Witness_complex/example/CMakeLists.txt b/src/Witness_complex/example/CMakeLists.txt index 4473078a..b5770ba6 100644 --- a/src/Witness_complex/example/CMakeLists.txt +++ b/src/Witness_complex/example/CMakeLists.txt @@ -4,9 +4,6 @@ project(GUDHIWitnessComplex) # A simple example add_executable( witness_complex_from_file witness_complex_from_file.cpp ) add_test( witness_complex_from_bunny &{CMAKE_CURRENT_BINARY_DIR}/witness_complex_from_file ${CMAKE_SOURCE_DIR}/data/points/bunny_5000 100) - - add_executable( witness_complex_bench witness_complex_bench.cpp ) - add_test( witness_complex_bench_from_bunny &{CMAKE_CURRENT_BINARY_DIR}/witness_complex_bench ${CMAKE_SOURCE_DIR}/data/points/bunny_5000 100) if(CGAL_FOUND) if (NOT CGAL_VERSION VERSION_LESS 4.6.0) @@ -21,12 +18,12 @@ if(CGAL_FOUND) message(STATUS "Eigen3 use file: ${EIGEN3_USE_FILE}.") include_directories (BEFORE "../../include") - add_executable ( witness_complex_bench2 witness_complex_bench2.cpp ) - target_link_libraries(witness_complex_bench2 ${Boost_SYSTEM_LIBRARY} ${CGAL_LIBRARY}) + add_executable ( witness_complex_sphere witness_complex_sphere.cpp ) + target_link_libraries(witness_complex_sphere ${Boost_SYSTEM_LIBRARY} ${CGAL_LIBRARY}) else() - message(WARNING "Eigen3 not found. Version 3.1.0 is required for Alpha shapes feature.") + message(WARNING "Eigen3 not found. Version 3.1.0 is required for witness_complex_sphere example.") endif() else() - message(WARNING "CGAL version: ${CGAL_VERSION} is too old to compile Alpha shapes feature. Version 4.6.0 is required.") + message(WARNING "CGAL version: ${CGAL_VERSION} is too old to compile witness_complex_sphere example. Version 4.6.0 is required.") endif () endif() diff --git a/src/Witness_complex/example/generators.h b/src/Witness_complex/example/generators.h new file mode 100644 index 00000000..0d42cda2 --- /dev/null +++ b/src/Witness_complex/example/generators.h @@ -0,0 +1,134 @@ +#ifndef GENERATORS_H +#define GENERATORS_H + +#include + +#include +#include + +typedef CGAL::Epick_d K; +typedef K::FT FT; +typedef K::Point_d Point_d; +typedef std::vector Point_Vector; +typedef CGAL::Random_points_in_cube_d Random_cube_iterator; +typedef CGAL::Random_points_in_ball_d Random_point_iterator; + +/** + * \brief Rock age method of reading off file + * + */ +inline void +off_reader_cust ( std::string file_name , std::vector & points) +{ + std::ifstream in_file (file_name.c_str(),std::ios::in); + if(!in_file.is_open()) + { + std::cerr << "Unable to open file " << file_name << std::endl; + return; + } + std::string line; + double x; + // Line OFF. No need in it + if (!getline(in_file, line)) + { + std::cerr << "No line OFF\n"; + return; + } + // Line with 3 numbers. No need + if (!getline(in_file, line)) + { + std::cerr << "No line with 3 numbers\n"; + return; + } + // Reading points + while( getline ( in_file , line ) ) + { + std::vector< double > point; + std::istringstream iss( line ); + while(iss >> x) { point.push_back(x); } + points.push_back(Point_d(point)); + } + in_file.close(); +} + +/** + * \brief Customized version of read_points + * which takes into account a possible nbP first line + * + */ +inline void +read_points_cust ( std::string file_name , Point_Vector & points) +{ + std::ifstream in_file (file_name.c_str(),std::ios::in); + if(!in_file.is_open()) + { + std::cerr << "Unable to open file " << file_name << std::endl; + return; + } + std::string line; + double x; + while( getline ( in_file , line ) ) + { + std::vector< double > point; + std::istringstream iss( line ); + while(iss >> x) { point.push_back(x); } + Point_d p(point.begin(), point.end()); + if (point.size() != 1) + points.push_back(p); + } + in_file.close(); +} + +/** \brief Generate points on a grid in a cube of side 2 + * having {+-1}^D as vertices and insert them in W. + * The grid has "width" points on each side. + * If torus is true then it is supposed that the cube represents + * a flat torus, hence the opposite borders are associated. + * The points on border in this case are not placed twice. + */ +void generate_points_grid(Point_Vector& W, int width, int D, bool torus) +{ + int nb_points = 1; + for (int i = 0; i < D; ++i) + nb_points *= width; + for (int i = 0; i < nb_points; ++i) + { + std::vector point; + int cell_i = i; + for (int l = 0; l < D; ++l) + { + if (torus) + point.push_back(-1+(2.0/(width-1))*(cell_i%width)); + else + point.push_back(-1+(2.0/width)*(cell_i%width)); + //attention: the bottom and the right are covered too! + cell_i /= width; + } + W.push_back(point); + } +} + +/** \brief Generate nbP points uniformly in a cube of side 2 + * having {+-1}^dim as its vertices and insert them in W. + */ +void generate_points_random_box(Point_Vector& W, int nbP, int dim) +{ + Random_cube_iterator rp(dim, 1.0); + for (int i = 0; i < nbP; i++) + { + W.push_back(*rp++); + } +} + +/** \brief Generate nbP points uniformly on a (dim-1)-sphere + * and insert them in W. + */ +void generate_points_sphere(Point_Vector& W, int nbP, int dim) +{ + CGAL::Random_points_on_sphere_d rp(dim,1); + for (int i = 0; i < nbP; i++) + W.push_back(*rp++); +} + + +#endif diff --git a/src/Witness_complex/example/witness_complex_sphere.cpp b/src/Witness_complex/example/witness_complex_sphere.cpp new file mode 100644 index 00000000..1fa0fc42 --- /dev/null +++ b/src/Witness_complex/example/witness_complex_sphere.cpp @@ -0,0 +1,126 @@ +/* This file is part of the Gudhi Library. The Gudhi library + * (Geometric Understanding in Higher Dimensions) is a generic C++ + * library for computational topology. + * + * Author(s): Siargey Kachanovich + * + * Copyright (C) 2015 INRIA Sophia Antipolis-Méditerranée (France) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#define BOOST_PARAMETER_MAX_ARITY 12 + + +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include + +#include "generators.h" + +using namespace Gudhi; + +typedef std::vector< Vertex_handle > typeVectorVertex; +//typedef std::vector< std::vector > Point_Vector; + +typedef Witness_complex< Simplex_tree<> > WitnessComplex; + +/** + * \brief Customized version of read_points + * which takes into account a possible nbP first line + * + */ +inline void +read_points_cust ( std::string file_name , std::vector< std::vector< double > > & points) +{ + std::ifstream in_file (file_name.c_str(),std::ios::in); + if(!in_file.is_open()) + { + std::cerr << "Unable to open file " << file_name << std::endl; + return; + } + std::string line; + double x; + while( getline ( in_file , line ) ) + { + std::vector< double > point; + std::istringstream iss( line ); + while(iss >> x) { point.push_back(x); } + if (point.size() != 1) + points.push_back(point); + } + in_file.close(); +} + +/** Write a gnuplot readable file. + * Data range is a random access range of pairs (arg, value) + */ +template < typename Data_range > +void write_data( Data_range & data, std::string filename ) +{ + std::ofstream ofs(filename, std::ofstream::out); + for (auto entry: data) + ofs << entry.first << ", " << entry.second << "\n"; + ofs.close(); +} + +int main (int argc, char * const argv[]) +{ + if (argc != 3) + { + std::cerr << "Usage: " << argv[0] + << " path_to_point_file nbL \n"; + return 0; + } + + std::string file_name = argv[1]; + int nbL = atoi(argv[2]); + clock_t start, end; + + // Construct the Simplex Tree + Simplex_tree<> simplex_tree; + + std::vector< std::pair > l_time; + + // Read the point file + for (int nbP = 500; nbP < 10000; nbP += 500) + { + Point_Vector point_vector; + generate_points_sphere(point_vector, nbP, 4); + std::cout << "Successfully generated " << point_vector.size() << " points.\n"; + std::cout << "Ambient dimension is " << point_vector[0].size() << ".\n"; + + // Choose landmarks + start = clock(); + std::vector > knn; + Landmark_choice_by_random_point(point_vector, nbL, knn); + + // Compute witness complex + WitnessComplex(knn, simplex_tree, nbL, point_vector[0].size()); + end = clock(); + double time = (double)(end-start)/CLOCKS_PER_SEC; + std::cout << "Witness complex for " << nbL << " landmarks took " + << time << " s. \n"; + l_time.push_back(std::make_pair(nbP,time)); + } + write_data(l_time, "w_time.dat"); +} diff --git a/src/Witness_complex/include/gudhi/Witness_complex.h b/src/Witness_complex/include/gudhi/Witness_complex.h index 791d0e45..915e445c 100644 --- a/src/Witness_complex/include/gudhi/Witness_complex.h +++ b/src/Witness_complex/include/gudhi/Witness_complex.h @@ -27,7 +27,7 @@ #include #include #include -#include "gudhi/distance_functions.h" +#include #include #include #include diff --git a/src/Witness_complex/test/simple_witness_complex.cpp b/src/Witness_complex/test/simple_witness_complex.cpp index c7d85a4d..ea38b5c0 100644 --- a/src/Witness_complex/test/simple_witness_complex.cpp +++ b/src/Witness_complex/test/simple_witness_complex.cpp @@ -22,9 +22,8 @@ #include #include -//#include "gudhi/graph_simplicial_complex.h" -#include "gudhi/Simplex_tree.h" -#include "gudhi/Witness_complex.h" +#include +#include using namespace Gudhi; diff --git a/src/Witness_complex/test/witness_complex_points.cpp b/src/Witness_complex/test/witness_complex_points.cpp index a86bf493..0a50101d 100644 --- a/src/Witness_complex/test/witness_complex_points.cpp +++ b/src/Witness_complex/test/witness_complex_points.cpp @@ -22,11 +22,10 @@ #include #include -//#include "gudhi/graph_simplicial_complex.h" -#include "gudhi/Simplex_tree.h" -#include "gudhi/Witness_complex.h" -#include "gudhi/Landmark_choice_by_random_point.h" -#include "gudhi/Landmark_choice_by_furthest_point.h" +#include +#include +#include +#include using namespace Gudhi; -- cgit v1.2.3 From 500d18704bc26166983ea005278bd187e2d3020c Mon Sep 17 00:00:00 2001 From: skachano Date: Fri, 15 Jan 2016 08:53:03 +0000 Subject: Fixed namespaces git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/witness@970 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: f71d4840583611d3829d8c4f1049e5d2b01ce71d --- src/Witness_complex/example/witness_complex_from_file.cpp | 1 + src/Witness_complex/example/witness_complex_sphere.cpp | 1 + .../include/gudhi/Landmark_choice_by_furthest_point.h | 8 ++++++++ .../include/gudhi/Landmark_choice_by_random_point.h | 8 ++++++++ src/Witness_complex/include/gudhi/Witness_complex.h | 9 +++++---- src/Witness_complex/test/simple_witness_complex.cpp | 5 ++--- src/Witness_complex/test/witness_complex_points.cpp | 1 + 7 files changed, 26 insertions(+), 7 deletions(-) (limited to 'src/Witness_complex/test') diff --git a/src/Witness_complex/example/witness_complex_from_file.cpp b/src/Witness_complex/example/witness_complex_from_file.cpp index 6add4e0a..72caf30b 100644 --- a/src/Witness_complex/example/witness_complex_from_file.cpp +++ b/src/Witness_complex/example/witness_complex_from_file.cpp @@ -33,6 +33,7 @@ #include "gudhi/reader_utils.h" using namespace Gudhi; +using namespace Gudhi::witness_complex; typedef std::vector< Vertex_handle > typeVectorVertex; typedef std::vector< std::vector > Point_Vector; diff --git a/src/Witness_complex/example/witness_complex_sphere.cpp b/src/Witness_complex/example/witness_complex_sphere.cpp index 1fa0fc42..d73445b9 100644 --- a/src/Witness_complex/example/witness_complex_sphere.cpp +++ b/src/Witness_complex/example/witness_complex_sphere.cpp @@ -38,6 +38,7 @@ #include "generators.h" using namespace Gudhi; +using namespace Gudhi::witness_complex; typedef std::vector< Vertex_handle > typeVectorVertex; //typedef std::vector< std::vector > Point_Vector; 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 6ac59ae9..050286f2 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,6 +23,10 @@ #ifndef GUDHI_LANDMARK_CHOICE_BY_FURTHEST_POINT_H_ #define GUDHI_LANDMARK_CHOICE_BY_FURTHEST_POINT_H_ +namespace Gudhi { + +namespace witness_complex { + /** * \class Landmark_choice_by_furthest_point * \brief The class `Landmark_choice_by_furthest_point` allows to construct the matrix @@ -96,4 +100,8 @@ public: }; +} + +} + #endif 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 fa822591..038deff6 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,6 +23,10 @@ #ifndef GUDHI_LANDMARK_CHOICE_BY_RANDOM_POINT_H_ #define GUDHI_LANDMARK_CHOICE_BY_RANDOM_POINT_H_ +namespace Gudhi { + +namespace witness_complex { + /** * \class Landmark_choice_by_random_point * \brief The class `Landmark_choice_by_random_point` allows to construct the matrix @@ -81,4 +85,8 @@ public: }; +} + +} + #endif diff --git a/src/Witness_complex/include/gudhi/Witness_complex.h b/src/Witness_complex/include/gudhi/Witness_complex.h index 915e445c..8938e59d 100644 --- a/src/Witness_complex/include/gudhi/Witness_complex.h +++ b/src/Witness_complex/include/gudhi/Witness_complex.h @@ -44,7 +44,8 @@ namespace Gudhi { - + namespace witness_complex { + /** \class Witness_complex \brief Constructs the witness complex for the given set of witnesses and landmarks. @@ -256,13 +257,13 @@ namespace Gudhi { return false; } } - return true; // Arrive here if the not_witnessed check failed all the time + return true; } -}; //class Witness_complex - + }; //class Witness_complex + } //namespace witness_complex } // namespace Guhdi diff --git a/src/Witness_complex/test/simple_witness_complex.cpp b/src/Witness_complex/test/simple_witness_complex.cpp index ea38b5c0..86f5bcd1 100644 --- a/src/Witness_complex/test/simple_witness_complex.cpp +++ b/src/Witness_complex/test/simple_witness_complex.cpp @@ -26,11 +26,10 @@ #include using namespace Gudhi; +using namespace Gudhi::witness_complex; typedef std::vector< Vertex_handle > typeVectorVertex; typedef Witness_complex> WitnessComplex; -//typedef std::pair typeSimplex; -//typedef std::pair< Simplex_tree<>::Simplex_handle, bool > typePairSimplexBool; int main (int argc, char * const argv[]) { @@ -50,5 +49,5 @@ int main (int argc, char * const argv[]) typeVectorVertex witness11 = {5,6,1,0,2,3,4}; knn.push_back(witness11); typeVectorVertex witness12 = {1,6,0,5,2,3,4}; knn.push_back(witness12); WitnessComplex witnessComplex(knn, complex, 7, 7); - assert(witnessComplex.is_witness_complex(knn, true)); + assert(witnessComplex.is_witness_complex(knn, false)); } diff --git a/src/Witness_complex/test/witness_complex_points.cpp b/src/Witness_complex/test/witness_complex_points.cpp index 0a50101d..e9fac9b8 100644 --- a/src/Witness_complex/test/witness_complex_points.cpp +++ b/src/Witness_complex/test/witness_complex_points.cpp @@ -29,6 +29,7 @@ using namespace Gudhi; +using namespace Gudhi::witness_complex; typedef std::vector< Vertex_handle > typeVectorVertex; typedef Witness_complex> WitnessComplex; -- cgit v1.2.3 From d13a8867ca368b1f56be3ba151d2042728fb4754 Mon Sep 17 00:00:00 2001 From: skachano Date: Wed, 20 Jan 2016 10:43:59 +0000 Subject: Almost all Vincent's remarks git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/witness@982 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 32564e3521e0807e26bd2c07d682751a3d47e6da --- .../example/witness_complex_sphere.cpp | 34 ++-------------------- .../test/simple_witness_complex.cpp | 4 +-- .../test/witness_complex_points.cpp | 4 +-- 3 files changed, 7 insertions(+), 35 deletions(-) (limited to 'src/Witness_complex/test') diff --git a/src/Witness_complex/example/witness_complex_sphere.cpp b/src/Witness_complex/example/witness_complex_sphere.cpp index d73445b9..9dc458d4 100644 --- a/src/Witness_complex/example/witness_complex_sphere.cpp +++ b/src/Witness_complex/example/witness_complex_sphere.cpp @@ -41,36 +41,9 @@ using namespace Gudhi; using namespace Gudhi::witness_complex; typedef std::vector< Vertex_handle > typeVectorVertex; -//typedef std::vector< std::vector > Point_Vector; typedef Witness_complex< Simplex_tree<> > WitnessComplex; -/** - * \brief Customized version of read_points - * which takes into account a possible nbP first line - * - */ -inline void -read_points_cust ( std::string file_name , std::vector< std::vector< double > > & points) -{ - std::ifstream in_file (file_name.c_str(),std::ios::in); - if(!in_file.is_open()) - { - std::cerr << "Unable to open file " << file_name << std::endl; - return; - } - std::string line; - double x; - while( getline ( in_file , line ) ) - { - std::vector< double > point; - std::istringstream iss( line ); - while(iss >> x) { point.push_back(x); } - if (point.size() != 1) - points.push_back(point); - } - in_file.close(); -} /** Write a gnuplot readable file. * Data range is a random access range of pairs (arg, value) @@ -86,15 +59,14 @@ void write_data( Data_range & data, std::string filename ) int main (int argc, char * const argv[]) { - if (argc != 3) + if (argc != 2) { std::cerr << "Usage: " << argv[0] - << " path_to_point_file nbL \n"; + << " nbL \n"; return 0; } - std::string file_name = argv[1]; - int nbL = atoi(argv[2]); + int nbL = atoi(argv[1]); clock_t start, end; // Construct the Simplex Tree diff --git a/src/Witness_complex/test/simple_witness_complex.cpp b/src/Witness_complex/test/simple_witness_complex.cpp index 86f5bcd1..7735ca6f 100644 --- a/src/Witness_complex/test/simple_witness_complex.cpp +++ b/src/Witness_complex/test/simple_witness_complex.cpp @@ -2,9 +2,9 @@ * (Geometric Understanding in Higher Dimensions) is a generic C++ * library for computational topology. * - * Author(s): Vincent Rouvreau + * Author(s): Siargey Kachanovich * - * Copyright (C) 2014 INRIA Sophia Antipolis-Méditerranée (France) + * Copyright (C) 2016 INRIA Sophia Antipolis-Méditerranée (France) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/Witness_complex/test/witness_complex_points.cpp b/src/Witness_complex/test/witness_complex_points.cpp index e9fac9b8..3850bd82 100644 --- a/src/Witness_complex/test/witness_complex_points.cpp +++ b/src/Witness_complex/test/witness_complex_points.cpp @@ -2,9 +2,9 @@ * (Geometric Understanding in Higher Dimensions) is a generic C++ * library for computational topology. * - * Author(s): Vincent Rouvreau + * Author(s): Siargey Kachanovich * - * Copyright (C) 2014 INRIA Sophia Antipolis-Méditerranée (France) + * Copyright (C) 2016 INRIA Sophia Antipolis-Méditerranée (France) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by -- cgit v1.2.3 From 945a98537205d4f3e3f7c3c652f373af89723731 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Thu, 21 Jan 2016 21:41:33 +0000 Subject: Warning fix - if not BOOST_CHECK, variable b_print_output seen as not used. git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/VR_witness@986 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 171f360b478c98edd9e177808e2c0b8410bfbd37 --- src/Witness_complex/test/witness_complex_points.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/Witness_complex/test') diff --git a/src/Witness_complex/test/witness_complex_points.cpp b/src/Witness_complex/test/witness_complex_points.cpp index 78f01e08..300b2ac5 100644 --- a/src/Witness_complex/test/witness_complex_points.cpp +++ b/src/Witness_complex/test/witness_complex_points.cpp @@ -55,12 +55,12 @@ BOOST_AUTO_TEST_CASE(witness_complex_points) { Landmark_choice_by_random_point lcrp(points, 100, knn); assert(!knn.empty()); WitnessComplex witnessComplex1(knn, complex1, 100, 3); - assert(witnessComplex1.is_witness_complex(knn, b_print_output)); + BOOST_CHECK(witnessComplex1.is_witness_complex(knn, b_print_output)); // Second test: furthest choice knn.clear(); Simplex_tree complex2; Landmark_choice_by_furthest_point lcfp(points, 100, knn); WitnessComplex witnessComplex2(knn, complex2, 100, 3); - assert(witnessComplex2.is_witness_complex(knn, b_print_output)); + BOOST_CHECK(witnessComplex2.is_witness_complex(knn, b_print_output)); } -- cgit v1.2.3 From 7e667b71d937f83b82240afbf90b8cde7225eb8a Mon Sep 17 00:00:00 2001 From: skachano Date: Tue, 2 Feb 2016 14:49:56 +0000 Subject: landmark choice functions are now static git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/witness@994 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: f83d337feab944e2c823b8e127f1a8d612d0a1bd --- .../example/witness_complex_from_file.cpp | 2 +- .../example/witness_complex_sphere.cpp | 2 +- .../gudhi/Landmark_choice_by_furthest_point.h | 22 +++++---------------- .../gudhi/Landmark_choice_by_random_point.h | 23 ++++++---------------- .../test/witness_complex_points.cpp | 6 ++---- 5 files changed, 15 insertions(+), 40 deletions(-) (limited to 'src/Witness_complex/test') diff --git a/src/Witness_complex/example/witness_complex_from_file.cpp b/src/Witness_complex/example/witness_complex_from_file.cpp index d94502b1..77109512 100644 --- a/src/Witness_complex/example/witness_complex_from_file.cpp +++ b/src/Witness_complex/example/witness_complex_from_file.cpp @@ -102,7 +102,7 @@ int main(int argc, char * const argv[]) { // Choose landmarks start = clock(); std::vector > knn; - Landmark_choice_by_random_point(point_vector, nbL, knn); + Gudhi::witness_complex::landmark_choice_by_random_point(point_vector, nbL, knn); end = clock(); std::cout << "Landmark choice for " << nbL << " landmarks took " << static_cast(end - start) / CLOCKS_PER_SEC << " s. \n"; diff --git a/src/Witness_complex/example/witness_complex_sphere.cpp b/src/Witness_complex/example/witness_complex_sphere.cpp index 36f63437..1ff35bff 100644 --- a/src/Witness_complex/example/witness_complex_sphere.cpp +++ b/src/Witness_complex/example/witness_complex_sphere.cpp @@ -82,7 +82,7 @@ int main(int argc, char * const argv[]) { // Choose landmarks start = clock(); std::vector > knn; - Landmark_choice_by_random_point(point_vector, nbL, knn); + Gudhi::witness_complex::landmark_choice_by_random_point(point_vector, nbL, knn); // Compute witness complex WitnessComplex(knn, simplex_tree, nbL, point_vector[0].size()); 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 bb7e87f5..47cd888d 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 @@ -31,20 +31,9 @@ namespace Gudhi { namespace witness_complex { -/** - * \class Landmark_choice_by_furthest_point - * \brief The class `Landmark_choice_by_furthest_point` allows to construct the matrix - * of closest landmarks per witness by iteratively choosing the furthest witness - * from the set of already chosen landmarks as the new landmark. - * \ingroup witness_complex - */ - -class Landmark_choice_by_furthest_point { - private: - typedef std::vector typeVectorVertex; + typedef std::vector typeVectorVertex; - public: - /** + /** * \brief Landmark choice strategy by iteratively adding the furthest witness from the * current landmark set as the new landmark. * \details It chooses nbL landmarks from a random access range `points` and @@ -53,9 +42,9 @@ class Landmark_choice_by_furthest_point { template - Landmark_choice_by_furthest_point(Point_random_access_range const &points, - int nbL, - KNearestNeighbours &knn) { + void landmark_choice_by_furthest_point(Point_random_access_range const &points, + int nbL, + KNearestNeighbours &knn) { int nb_points = points.end() - points.begin(); assert(nb_points >= nbL); // distance matrix witness x landmarks @@ -98,7 +87,6 @@ class Landmark_choice_by_furthest_point { [&wit_land_dist, i](int a, int b) { return wit_land_dist[i][a] < wit_land_dist[i][b]; }); } -}; } // namespace witness_complex 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 4747dd73..dc364007 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 @@ -32,26 +32,16 @@ namespace Gudhi { namespace witness_complex { -/** - * \class Landmark_choice_by_random_point - * \brief The class `Landmark_choice_by_random_point` allows to construct the matrix - * of closest landmarks per witness by iteratively choosing a random non-chosen witness - * as a new landmark. - * \ingroup witness_complex - */ - -class Landmark_choice_by_random_point { - public: /** \brief Landmark choice strategy by taking random vertices for landmarks. * \details It chooses nbL distinct landmarks from a random access range `points` * and outputs a matrix {witness}*{closest landmarks} in knn. */ template - Landmark_choice_by_random_point(Point_random_access_range const &points, - int nbL, - KNearestNeighbours &knn) { + typename Point_random_access_range> + void landmark_choice_by_random_point(Point_random_access_range const &points, + int nbL, + KNearestNeighbours &knn) { int nbP = points.end() - points.begin(); assert(nbP >= nbL); std::set landmarks; @@ -71,8 +61,8 @@ class Landmark_choice_by_random_point { knn = KNearestNeighbours(nbP); for (int points_i = 0; points_i < nbP; points_i++) { std::priority_queue, comp> l_heap([&](dist_i j1, dist_i j2) { - return j1.first > j2.first; - }); + return j1.first > j2.first; + }); std::set::iterator landmarks_it; int landmarks_i = 0; for (landmarks_it = landmarks.begin(), landmarks_i = 0; landmarks_it != landmarks.end(); @@ -87,7 +77,6 @@ class Landmark_choice_by_random_point { } } } -}; } // namespace witness_complex diff --git a/src/Witness_complex/test/witness_complex_points.cpp b/src/Witness_complex/test/witness_complex_points.cpp index 300b2ac5..cb1639e1 100644 --- a/src/Witness_complex/test/witness_complex_points.cpp +++ b/src/Witness_complex/test/witness_complex_points.cpp @@ -37,8 +37,6 @@ typedef std::vector Point; typedef std::vector< Vertex_handle > typeVectorVertex; typedef Gudhi::Simplex_tree<> Simplex_tree; typedef Gudhi::witness_complex::Witness_complex WitnessComplex; -typedef Gudhi::witness_complex::Landmark_choice_by_random_point Landmark_choice_by_random_point; -typedef Gudhi::witness_complex::Landmark_choice_by_furthest_point Landmark_choice_by_furthest_point; BOOST_AUTO_TEST_CASE(witness_complex_points) { std::vector< typeVectorVertex > knn; @@ -52,7 +50,7 @@ BOOST_AUTO_TEST_CASE(witness_complex_points) { bool b_print_output = false; // First test: random choice Simplex_tree complex1; - Landmark_choice_by_random_point lcrp(points, 100, knn); + Gudhi::witness_complex::landmark_choice_by_random_point(points, 100, knn); assert(!knn.empty()); WitnessComplex witnessComplex1(knn, complex1, 100, 3); BOOST_CHECK(witnessComplex1.is_witness_complex(knn, b_print_output)); @@ -60,7 +58,7 @@ BOOST_AUTO_TEST_CASE(witness_complex_points) { // Second test: furthest choice knn.clear(); Simplex_tree complex2; - Landmark_choice_by_furthest_point lcfp(points, 100, knn); + Gudhi::witness_complex::landmark_choice_by_furthest_point(points, 100, knn); WitnessComplex witnessComplex2(knn, complex2, 100, 3); BOOST_CHECK(witnessComplex2.is_witness_complex(knn, b_print_output)); } -- cgit v1.2.3 From b7796215d4eac6b4c43ad70998c3737a6527eebb Mon Sep 17 00:00:00 2001 From: skachano Date: Thu, 11 Feb 2016 16:05:15 +0000 Subject: Commited Marc's remarks git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/witness@1017 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: d87eb82f60f4f943f59622f33521bcdce7873091 --- src/Witness_complex/concept/Simplicial_complex.h | 11 ++--------- .../example/witness_complex_from_file.cpp | 13 +------------ src/Witness_complex/example/witness_complex_sphere.cpp | 10 +++++----- .../include/gudhi/Landmark_choice_by_random_point.h | 6 ++++++ src/Witness_complex/include/gudhi/Witness_complex.h | 18 ++++++------------ src/Witness_complex/test/simple_witness_complex.cpp | 2 +- src/Witness_complex/test/witness_complex_points.cpp | 4 ++-- 7 files changed, 23 insertions(+), 41 deletions(-) (limited to 'src/Witness_complex/test') diff --git a/src/Witness_complex/concept/Simplicial_complex.h b/src/Witness_complex/concept/Simplicial_complex.h index d7f3496d..9e9f2ff8 100644 --- a/src/Witness_complex/concept/Simplicial_complex.h +++ b/src/Witness_complex/concept/Simplicial_complex.h @@ -40,16 +40,11 @@ struct Simplicial_complex { /** Returns a Simplex_hanlde that is different from all simplex handles * of the simplices. */ Simplex_handle null_simplex(); - /** \brief Returns the number of simplices in the complex. - * - * Does not count the empty simplex. */ - size_t num_simplices(); /** \brief Iterator over the simplices of the complex, * in an arbitrary order. * * 'value_type' must be 'Simplex_handle'.*/ - typedef unspecified Complex_simplex_iterator; typedef unspecified Complex_simplex_range; /** @@ -71,19 +66,17 @@ struct Simplicial_complex { */ typedef unspecified Insertion_result_type; - /** \brief Input range of vertices. - * 'value_type' must be 'Vertex_handle'. */ - typedef unspecified Input_vertex_range; - /** \brief Inserts a simplex with vertices from a given range * 'vertex_range' in the simplicial complex. * */ + template< typedef Input_vertex_range > Insertion_result_type insert_simplex(Input_vertex_range const & vertex_range); /** \brief Finds a simplex with vertices given by a range * * If a simplex exists, its Simplex_handle is returned. * Otherwise null_simplex() is returned. */ + template< typedef Input_vertex_range > Simplex_handle find(Input_vertex_range const & vertex_range); }; diff --git a/src/Witness_complex/example/witness_complex_from_file.cpp b/src/Witness_complex/example/witness_complex_from_file.cpp index 77109512..98d1fe9c 100644 --- a/src/Witness_complex/example/witness_complex_from_file.cpp +++ b/src/Witness_complex/example/witness_complex_from_file.cpp @@ -68,17 +68,6 @@ read_points_cust(std::string file_name, std::vector< std::vector< double > > & p in_file.close(); } -/** Write a gnuplot readable file. - * Data range is a random access range of pairs (arg, value) - */ -template < typename Data_range > -void write_data(Data_range & data, std::string filename) { - std::ofstream ofs(filename, std::ofstream::out); - for (auto entry : data) - ofs << entry.first << ", " << entry.second << "\n"; - ofs.close(); -} - int main(int argc, char * const argv[]) { if (argc != 3) { std::cerr << "Usage: " << argv[0] @@ -109,7 +98,7 @@ int main(int argc, char * const argv[]) { // Compute witness complex start = clock(); - WitnessComplex(knn, simplex_tree, nbL, point_vector[0].size()); + WitnessComplex(knn, nbL, point_vector[0].size(), simplex_tree); end = clock(); std::cout << "Witness complex took " << static_cast(end - start) / CLOCKS_PER_SEC << " s. \n"; diff --git a/src/Witness_complex/example/witness_complex_sphere.cpp b/src/Witness_complex/example/witness_complex_sphere.cpp index f9d0b5a2..fae80d67 100644 --- a/src/Witness_complex/example/witness_complex_sphere.cpp +++ b/src/Witness_complex/example/witness_complex_sphere.cpp @@ -60,11 +60,11 @@ void write_data(Data_range & data, std::string filename) { int main(int argc, char * const argv[]) { if (argc != 2) { std::cerr << "Usage: " << argv[0] - << " nbL \n"; + << " number_of_landmarks \n"; return 0; } - int nbL = atoi(argv[1]); + int number_of_landmarks = atoi(argv[1]); clock_t start, end; // Construct the Simplex Tree @@ -82,13 +82,13 @@ int main(int argc, char * const argv[]) { // Choose landmarks start = clock(); std::vector > knn; - Gudhi::witness_complex::landmark_choice_by_random_point(point_vector, nbL, knn); + Gudhi::witness_complex::landmark_choice_by_random_point(point_vector, number_of_landmarks, knn); // Compute witness complex - WitnessComplex(knn, simplex_tree, nbL, point_vector[0].size()); + WitnessComplex(knn, number_of_landmarks, point_vector[0].size(), simplex_tree); end = clock(); double time = static_cast(end - start) / CLOCKS_PER_SEC; - std::cout << "Witness complex for " << nbL << " landmarks took " + std::cout << "Witness complex for " << number_of_landmarks << " landmarks took " << time << " s. \n"; std::cout << "Number of simplices is: " << simplex_tree.num_simplices() << "\n"; l_time.push_back(std::make_pair(nbP, time)); 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 dc364007..617c0258 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 @@ -35,6 +35,12 @@ namespace witness_complex { /** \brief Landmark choice strategy by taking random vertices for landmarks. * \details It chooses nbL distinct landmarks from a random access range `points` * and outputs a matrix {witness}*{closest landmarks} in knn. + * + * The type KNearestNeighbors can be seen as + * Witness_range>, where + * Witness_range and Closest_landmark_range are random access ranges and + * Vertex_handle is the label type of a vertex in a simplicial complex. + * Closest_landmark_range needs to have push_back operation. */ template Point_t; typedef std::vector< Point_t > Point_Vector; - // typedef typename Simplicial_complex::Filtration_value Filtration_value; typedef std::vector< Vertex_handle > typeVectorVertex; typedef std::pair< typeVectorVertex, Filtration_value> typeSimplex; typedef std::pair< Simplex_handle, bool > typePairSimplexBool; @@ -109,9 +108,9 @@ class Witness_complex { */ template< typename KNearestNeighbors > Witness_complex(KNearestNeighbors const & knn, - Simplicial_complex & sc_, int nbL_, - int dim) : nbL(nbL_), sc(sc_) { + int dim, + Simplicial_complex & sc_) : nbL(nbL_), sc(sc_) { // Construction of the active witness list int nbW = knn.size(); typeVectorVertex vv; @@ -120,7 +119,7 @@ class Witness_complex { * it will diminuish in the course of iterations */ ActiveWitnessList active_w; // = new ActiveWitnessList(); - for (int i = 0; i != nbL; ++i) { + for (Vertex_handle i = 0; i != nbL; ++i) { // initial fill of 0-dimensional simplices // by doing it we don't assume that landmarks are necessarily witnesses themselves anymore counter++; @@ -131,9 +130,7 @@ class Witness_complex { int k = 1; /* current dimension in iterative construction */ for (int i = 0; i != nbW; ++i) active_w.push_back(i); - // std::cout << "Successfully added edges" << std::endl; while (!active_w.empty() && k < dim) { - // std::cout << "Started the step k=" << k << std::endl; typename ActiveWitnessList::iterator it = active_w.begin(); while (it != active_w.end()) { typeVectorVertex simplex_vector; @@ -142,7 +139,7 @@ class Witness_complex { if (ok) { for (int i = 0; i != k + 1; ++i) simplex_vector.push_back(knn[*it][i]); - sc.insert_simplex(simplex_vector, 0.0); + sc.insert_simplex(simplex_vector); // TODO(SK) Error if not inserted : normally no need here though it++; } else { @@ -162,9 +159,7 @@ class Witness_complex { */ template bool all_faces_in(KNearestNeighbors const &knn, int witness_id, int k) { - // std::cout << "All face in with the landmark " << inserted_vertex << std::endl; std::vector< Vertex_handle > facet; - // Vertex_handle curr_vh = curr_sh->first; // CHECK ALL THE FACETS for (int i = 0; i != k + 1; ++i) { facet = {}; @@ -175,7 +170,6 @@ class Witness_complex { } // endfor if (sc.find(facet) == sc.null_simplex()) return false; - // std::cout << "++++ finished loop safely\n"; } // endfor return true; } @@ -206,12 +200,12 @@ class Witness_complex { bool is_witnessed = false; typeVectorVertex simplex; int nbV = 0; // number of verticed in the simplex - for (int v : sc.simplex_vertex_range(sh)) + for (Vertex_handle v : sc.simplex_vertex_range(sh)) simplex.push_back(v); nbV = simplex.size(); for (typeVectorVertex w : knn) { bool has_vertices = true; - for (int v : simplex) + for (Vertex_handle v : simplex) if (std::find(w.begin(), w.begin() + nbV, v) == w.begin() + nbV) { has_vertices = false; // break; diff --git a/src/Witness_complex/test/simple_witness_complex.cpp b/src/Witness_complex/test/simple_witness_complex.cpp index 7d44b90c..03df78ee 100644 --- a/src/Witness_complex/test/simple_witness_complex.cpp +++ b/src/Witness_complex/test/simple_witness_complex.cpp @@ -53,7 +53,7 @@ BOOST_AUTO_TEST_CASE(simple_witness_complex) { knn.push_back({5, 0, 1, 3, 6, 2, 4}); knn.push_back({5, 6, 1, 0, 2, 3, 4}); knn.push_back({1, 6, 0, 5, 2, 3, 4}); - WitnessComplex witnessComplex(knn, complex, 7, 7); + WitnessComplex witnessComplex(knn, 7, 7, complex); BOOST_CHECK(witnessComplex.is_witness_complex(knn, false)); } diff --git a/src/Witness_complex/test/witness_complex_points.cpp b/src/Witness_complex/test/witness_complex_points.cpp index cb1639e1..bd3df604 100644 --- a/src/Witness_complex/test/witness_complex_points.cpp +++ b/src/Witness_complex/test/witness_complex_points.cpp @@ -52,13 +52,13 @@ BOOST_AUTO_TEST_CASE(witness_complex_points) { Simplex_tree complex1; Gudhi::witness_complex::landmark_choice_by_random_point(points, 100, knn); assert(!knn.empty()); - WitnessComplex witnessComplex1(knn, complex1, 100, 3); + WitnessComplex witnessComplex1(knn, 100, 3, complex1); BOOST_CHECK(witnessComplex1.is_witness_complex(knn, b_print_output)); // Second test: furthest choice knn.clear(); Simplex_tree complex2; Gudhi::witness_complex::landmark_choice_by_furthest_point(points, 100, knn); - WitnessComplex witnessComplex2(knn, complex2, 100, 3); + WitnessComplex witnessComplex2(knn, 100, 3, complex2); BOOST_CHECK(witnessComplex2.is_witness_complex(knn, b_print_output)); } -- cgit v1.2.3 From 607fc8aa10122089aa2b3debf36e48250e2dfb5b Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Fri, 8 Apr 2016 13:34:12 +0000 Subject: Modification on CMakeLists.txt for code coverage were not propagated on these 2 test files git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@1109 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 8dc143d808040f903ac9c5e0b967fcf3fc4c9ba4 --- src/Bitmap_cubical_complex/test/CMakeLists.txt | 4 ---- src/Witness_complex/test/CMakeLists.txt | 4 ---- 2 files changed, 8 deletions(-) (limited to 'src/Witness_complex/test') diff --git a/src/Bitmap_cubical_complex/test/CMakeLists.txt b/src/Bitmap_cubical_complex/test/CMakeLists.txt index 97c374e6..b6fc8a3b 100644 --- a/src/Bitmap_cubical_complex/test/CMakeLists.txt +++ b/src/Bitmap_cubical_complex/test/CMakeLists.txt @@ -4,14 +4,10 @@ project(GUDHIBitmapCCUT) if (GCOVR_PATH) # for gcovr to make coverage reports - Corbera Jenkins plugin set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage") - set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage") - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fprofile-arcs -ftest-coverage") endif() if (GPROF_PATH) # for gprof to make coverage reports - Jenkins set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg") - set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -pg") - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -pg") endif() add_executable ( BitmapCCUT Bitmap_test.cpp ) diff --git a/src/Witness_complex/test/CMakeLists.txt b/src/Witness_complex/test/CMakeLists.txt index 9422c152..37bef2d0 100644 --- a/src/Witness_complex/test/CMakeLists.txt +++ b/src/Witness_complex/test/CMakeLists.txt @@ -4,14 +4,10 @@ project(GUDHIWitnessComplexUT) if (GCOVR_PATH) # for gcovr to make coverage reports - Corbera Jenkins plugin set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage") - set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage") - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fprofile-arcs -ftest-coverage") endif() if (GPROF_PATH) # for gprof to make coverage reports - Jenkins set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg") - set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -pg") - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -pg") endif() add_executable ( simple_witness_complexUT simple_witness_complex.cpp ) -- cgit v1.2.3