From d439da1345822fe25f58adb631f7d0cd9749ecfc Mon Sep 17 00:00:00 2001 From: skachano Date: Wed, 5 Oct 2016 17:06:15 +0000 Subject: Modified existing tests and examples git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/relaxed-witness@1647 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: cd187fe5bc9174403aa5dc96c74871c697b3a5e6 --- .../test/test_simple_witness_complex.cpp | 103 +++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 src/Witness_complex/test/test_simple_witness_complex.cpp (limited to 'src/Witness_complex/test/test_simple_witness_complex.cpp') diff --git a/src/Witness_complex/test/test_simple_witness_complex.cpp b/src/Witness_complex/test/test_simple_witness_complex.cpp new file mode 100644 index 00000000..abd0a0dd --- /dev/null +++ b/src/Witness_complex/test/test_simple_witness_complex.cpp @@ -0,0 +1,103 @@ +/* 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) 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 + * 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_TEST_DYN_LINK +#define BOOST_TEST_MODULE "simple_witness_complex" +#include +#include + +#include + +#include +#include +#include + +#include +#include +#include + +typedef Gudhi::Simplex_tree<> Simplex_tree; +typedef std::vector< Vertex_handle > typeVectorVertex; +typedef CGAL::Epick_d Kernel; +typedef typename Kernel::FT FT; +typedef typename Kernel::Point_d Point_d; +typedef Gudhi::witness_complex::Witness_complex WitnessComplex; +typedef Gudhi::witness_complex::Strong_witness_complex StrongWitnessComplex; + +/* All landmarks and witnesses are taken on the grid in the following manner. + LWLWL + WW.WW + L...L + WW.WW + LWLWL + + Witness complex consists of 8 vertices, 12 edges and 4 triangles + */ + +BOOST_AUTO_TEST_CASE(simple_witness_complex) { + Simplex_tree complex, relaxed_complex, strong_relaxed_complex; + + std::vector witnesses, landmarks; + + landmarks.push_back(Point_d(std::vector{-2,-2})); + landmarks.push_back(Point_d(std::vector{-2, 0})); + landmarks.push_back(Point_d(std::vector{-2, 2})); + landmarks.push_back(Point_d(std::vector{ 0,-2})); + landmarks.push_back(Point_d(std::vector{ 0, 2})); + landmarks.push_back(Point_d(std::vector{ 2,-2})); + landmarks.push_back(Point_d(std::vector{ 2, 0})); + landmarks.push_back(Point_d(std::vector{ 2, 2})); + witnesses.push_back(Point_d(std::vector{-2,-1})); + witnesses.push_back(Point_d(std::vector{-2, 1})); + witnesses.push_back(Point_d(std::vector{-1,-2})); + witnesses.push_back(Point_d(std::vector{-1,-1})); + witnesses.push_back(Point_d(std::vector{-1, 1})); + witnesses.push_back(Point_d(std::vector{-1, 2})); + witnesses.push_back(Point_d(std::vector{ 1,-2})); + witnesses.push_back(Point_d(std::vector{ 1,-1})); + witnesses.push_back(Point_d(std::vector{ 1, 1})); + witnesses.push_back(Point_d(std::vector{ 1, 2})); + witnesses.push_back(Point_d(std::vector{ 2,-1})); + witnesses.push_back(Point_d(std::vector{ 2, 1})); + + WitnessComplex witness_complex(landmarks.begin(), + landmarks.end(), + witnesses.begin(), + witnesses.end()); + witness_complex.create_complex(complex, 0); + + BOOST_CHECK(complex.num_simplices() == 24); + + witness_complex.create_complex(relaxed_complex, 8.01); + + BOOST_CHECK(relaxed_complex.num_simplices() == 239); + + StrongWitnessComplex strong_witness_complex(landmarks.begin(), + landmarks.end(), + witnesses.begin(), + witnesses.end()); + + strong_witness_complex.create_complex(strong_relaxed_complex, 9.1); + + BOOST_CHECK(strong_relaxed_complex.num_simplices() == 239); + +} -- cgit v1.2.3 From d1ec002edb5b3e1d72770418e55665cca58131c9 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Mon, 10 Oct 2016 11:02:15 +0000 Subject: Fix cmake issues git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/relaxed-witness@1682 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: e2570097e2fe1091b9beb5ef7e44d6dbd01d0ced --- src/Witness_complex/example/CMakeLists.txt | 15 +++++++++++++-- src/Witness_complex/test/test_simple_witness_complex.cpp | 3 +++ 2 files changed, 16 insertions(+), 2 deletions(-) (limited to 'src/Witness_complex/test/test_simple_witness_complex.cpp') diff --git a/src/Witness_complex/example/CMakeLists.txt b/src/Witness_complex/example/CMakeLists.txt index 38cfa821..848239b5 100644 --- a/src/Witness_complex/example/CMakeLists.txt +++ b/src/Witness_complex/example/CMakeLists.txt @@ -7,12 +7,23 @@ if(CGAL_FOUND) if (EIGEN3_FOUND) add_executable( Witness_complex_example_off example_witness_complex_off.cpp ) add_executable ( Witness_complex_example_sphere example_witness_complex_sphere.cpp ) + add_executable ( Witness_complex_example_witness_persistence example_witness_complex_persistence.cpp ) target_link_libraries(Witness_complex_example_witness_persistence ${Boost_PROGRAM_OPTIONS_LIBRARY}) - add_test(Witness_complex_test_torus_persistence src/Witness_complex/example/Witness_complex_example_witncess_complex_persistence ../data/points/tore3D_1307.off -l 20 -a 0.5) + add_executable ( Witness_complex_example_strong_witness_persistence example_strong_witness_persistence.cpp ) target_link_libraries(Witness_complex_example_strong_witness_persistence ${Boost_PROGRAM_OPTIONS_LIBRARY}) - add_test(Witness_complex_test_torus_persistence src/Witness_complex/example/Witness_complex_example_strong_witness_persistence ../data/points/tore3D_1307.off -l 20 -a 0.5) + if (TBB_FOUND) + target_link_libraries(Witness_complex_example_witness_persistence ${TBB_LIBRARIES}) + target_link_libraries(Witness_complex_example_strong_witness_persistence ${TBB_LIBRARIES}) + endif() + + add_test(Witness_complex_test_torus_persistence + ${CMAKE_CURRENT_BINARY_DIR}/Witness_complex_example_witness_persistence + ${CMAKE_SOURCE_DIR}/data/points/tore3D_1307.off -l 20 -a 0.5) + add_test(Witness_complex_test_torus_persistence + ${CMAKE_CURRENT_BINARY_DIR}/Witness_complex_example_strong_witness_persistence + ${CMAKE_SOURCE_DIR}/data/points/tore3D_1307.off -l 20 -a 0.5) endif(EIGEN3_FOUND) endif (NOT CGAL_VERSION VERSION_LESS 4.6.0) endif() diff --git a/src/Witness_complex/test/test_simple_witness_complex.cpp b/src/Witness_complex/test/test_simple_witness_complex.cpp index abd0a0dd..759ee14d 100644 --- a/src/Witness_complex/test/test_simple_witness_complex.cpp +++ b/src/Witness_complex/test/test_simple_witness_complex.cpp @@ -85,10 +85,12 @@ BOOST_AUTO_TEST_CASE(simple_witness_complex) { witnesses.end()); witness_complex.create_complex(complex, 0); + std::cout << "complex.num_simplices() = " << complex.num_simplices() << std::endl; BOOST_CHECK(complex.num_simplices() == 24); witness_complex.create_complex(relaxed_complex, 8.01); + std::cout << "relaxed_complex.num_simplices() = " << relaxed_complex.num_simplices() << std::endl; BOOST_CHECK(relaxed_complex.num_simplices() == 239); StrongWitnessComplex strong_witness_complex(landmarks.begin(), @@ -98,6 +100,7 @@ BOOST_AUTO_TEST_CASE(simple_witness_complex) { strong_witness_complex.create_complex(strong_relaxed_complex, 9.1); + std::cout << "strong_relaxed_complex.num_simplices() = " << strong_relaxed_complex.num_simplices() << std::endl; BOOST_CHECK(strong_relaxed_complex.num_simplices() == 239); } -- cgit v1.2.3 From 4473c9fd8d23097ed7b5570b800db245539e91d2 Mon Sep 17 00:00:00 2001 From: skachano Date: Tue, 18 Oct 2016 12:32:40 +0000 Subject: Removed Sophia Antipolis from copyrights git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/relaxed-witness@1731 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: f97758e943397259712ad76c4db117df3d3415b6 --- src/Witness_complex/example/example_strong_witness_persistence.cpp | 2 +- src/Witness_complex/example/example_witness_complex_off.cpp | 2 +- src/Witness_complex/example/example_witness_complex_persistence.cpp | 2 +- src/Witness_complex/example/example_witness_complex_sphere.cpp | 2 +- src/Witness_complex/include/gudhi/Active_witness/Active_witness.h | 2 +- .../include/gudhi/Active_witness/Active_witness_iterator.h | 2 +- src/Witness_complex/include/gudhi/Strong_witness_complex.h | 2 +- src/Witness_complex/include/gudhi/Witness_complex.h | 2 +- src/Witness_complex/test/test_simple_witness_complex.cpp | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) (limited to 'src/Witness_complex/test/test_simple_witness_complex.cpp') diff --git a/src/Witness_complex/example/example_strong_witness_persistence.cpp b/src/Witness_complex/example/example_strong_witness_persistence.cpp index 4e06867d..f43cba52 100644 --- a/src/Witness_complex/example/example_strong_witness_persistence.cpp +++ b/src/Witness_complex/example/example_strong_witness_persistence.cpp @@ -4,7 +4,7 @@ * * Author(s): Siargey Kachanovich * - * Copyright (C) 2016 INRIA Sophia Antipolis-Méditerranée (France) + * Copyright (C) 2016 INRIA (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/example/example_witness_complex_off.cpp b/src/Witness_complex/example/example_witness_complex_off.cpp index 37646faf..94088370 100644 --- a/src/Witness_complex/example/example_witness_complex_off.cpp +++ b/src/Witness_complex/example/example_witness_complex_off.cpp @@ -4,7 +4,7 @@ * * Author(s): Siargey Kachanovich * - * Copyright (C) 2015 INRIA Sophia Antipolis-Méditerranée (France) + * Copyright (C) 2015 INRIA (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/example/example_witness_complex_persistence.cpp b/src/Witness_complex/example/example_witness_complex_persistence.cpp index a4388047..b1b415fa 100644 --- a/src/Witness_complex/example/example_witness_complex_persistence.cpp +++ b/src/Witness_complex/example/example_witness_complex_persistence.cpp @@ -4,7 +4,7 @@ * * Author(s): Siargey Kachanovich * - * Copyright (C) 2016 INRIA Sophia Antipolis-Méditerranée (France) + * Copyright (C) 2016 INRIA (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/example/example_witness_complex_sphere.cpp b/src/Witness_complex/example/example_witness_complex_sphere.cpp index 8e2c5ff6..d21195fa 100644 --- a/src/Witness_complex/example/example_witness_complex_sphere.cpp +++ b/src/Witness_complex/example/example_witness_complex_sphere.cpp @@ -4,7 +4,7 @@ * * Author(s): Siargey Kachanovich * - * Copyright (C) 2015 INRIA Sophia Antipolis-Méditerranée (France) + * Copyright (C) 2015 INRIA (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/include/gudhi/Active_witness/Active_witness.h b/src/Witness_complex/include/gudhi/Active_witness/Active_witness.h index c6113442..fce7d3d1 100644 --- a/src/Witness_complex/include/gudhi/Active_witness/Active_witness.h +++ b/src/Witness_complex/include/gudhi/Active_witness/Active_witness.h @@ -4,7 +4,7 @@ * * Author(s): Siargey Kachanovich * - * Copyright (C) 2016 INRIA Sophia Antipolis-Méditerranée (France) + * Copyright (C) 2016 INRIA (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/include/gudhi/Active_witness/Active_witness_iterator.h b/src/Witness_complex/include/gudhi/Active_witness/Active_witness_iterator.h index 25897de6..ae051bea 100644 --- a/src/Witness_complex/include/gudhi/Active_witness/Active_witness_iterator.h +++ b/src/Witness_complex/include/gudhi/Active_witness/Active_witness_iterator.h @@ -4,7 +4,7 @@ * * Author(s): Siargey Kachanovich * - * Copyright (C) 2016 INRIA Sophia Antipolis-Méditerranée (France) + * Copyright (C) 2016 INRIA (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/include/gudhi/Strong_witness_complex.h b/src/Witness_complex/include/gudhi/Strong_witness_complex.h index 73de580d..7ef8d3e5 100644 --- a/src/Witness_complex/include/gudhi/Strong_witness_complex.h +++ b/src/Witness_complex/include/gudhi/Strong_witness_complex.h @@ -4,7 +4,7 @@ * * Author(s): Siargey Kachanovich * - * Copyright (C) 2015 INRIA Sophia Antipolis-Méditerranée (France) + * Copyright (C) 2015 INRIA (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/include/gudhi/Witness_complex.h b/src/Witness_complex/include/gudhi/Witness_complex.h index e336dc4f..ac0e8f66 100644 --- a/src/Witness_complex/include/gudhi/Witness_complex.h +++ b/src/Witness_complex/include/gudhi/Witness_complex.h @@ -4,7 +4,7 @@ * * Author(s): Siargey Kachanovich * - * Copyright (C) 2015 INRIA Sophia Antipolis-Méditerranée (France) + * Copyright (C) 2015 INRIA (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/test_simple_witness_complex.cpp b/src/Witness_complex/test/test_simple_witness_complex.cpp index 759ee14d..90b6cfa2 100644 --- a/src/Witness_complex/test/test_simple_witness_complex.cpp +++ b/src/Witness_complex/test/test_simple_witness_complex.cpp @@ -4,7 +4,7 @@ * * Author(s): Siargey Kachanovich * - * Copyright (C) 2016 INRIA Sophia Antipolis-Méditerranée (France) + * Copyright (C) 2016 INRIA (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 fe79f2dcfd8b1540485d8a81fa7cedd07f5c8fac Mon Sep 17 00:00:00 2001 From: skachano Date: Wed, 19 Oct 2016 08:19:49 +0000 Subject: Clément's remarks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/relaxed-witness@1735 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: c3bc66a081a0bc73874246e1e12ab98c6bf2a53e --- src/Witness_complex/doc/Witness_complex_doc.h | 10 +++++-- .../example/example_strong_witness_persistence.cpp | 28 ++---------------- .../example/example_witness_complex_off.cpp | 28 ++---------------- .../example_witness_complex_persistence.cpp | 28 ++---------------- .../example/example_witness_complex_sphere.cpp | 27 ++--------------- .../include/gudhi/Strong_witness_complex.h | 27 ++++++++--------- .../include/gudhi/Witness_complex.h | 32 +++++++------------- .../test/test_simple_witness_complex.cpp | 34 +++------------------- 8 files changed, 43 insertions(+), 171 deletions(-) (limited to 'src/Witness_complex/test/test_simple_witness_complex.cpp') diff --git a/src/Witness_complex/doc/Witness_complex_doc.h b/src/Witness_complex/doc/Witness_complex_doc.h index 4f3671e5..2831f107 100644 --- a/src/Witness_complex/doc/Witness_complex_doc.h +++ b/src/Witness_complex/doc/Witness_complex_doc.h @@ -17,7 +17,7 @@ Even though often the set of landmarks \f$L\f$ is a subset of the set of witnesses \f$ W\f$, it is not a requirement for the current implementation. - The simplices are based on landmarks + Landmarks are the vertices of the simplicial complex and witnesses help to decide on which simplices are inserted via a predicate "is witnessed". De Silva and Carlsson in their paper \cite de2004topological differentiate **weak witnessing** and **strong witnessing**: @@ -47,7 +47,13 @@ The constructors take on the step 1, while the function 'create_complex' executes the steps 2 and 3. - \section witnessexamples Examples + \section witnessexample1 Example 1: Constructing weak relaxed witness complex from an off file + + Let's start with a simple example, which reads an off point file and computes a weak witness complex. + + \include Witness_complex/example_witness_complex_off.cpp + + \section witnessexample2 Example2: Computing persistence using strong relaxed witness complex Here is an example of constructing a strong witness complex filtration and computing persistence on it: diff --git a/src/Witness_complex/example/example_strong_witness_persistence.cpp b/src/Witness_complex/example/example_strong_witness_persistence.cpp index f43cba52..a0563ee2 100644 --- a/src/Witness_complex/example/example_strong_witness_persistence.cpp +++ b/src/Witness_complex/example/example_strong_witness_persistence.cpp @@ -1,25 +1,3 @@ -/* 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) 2016 INRIA (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 @@ -81,10 +59,8 @@ int main(int argc, char * argv[]) { Gudhi::subsampling::pick_n_random_points(witnesses, nbL, std::back_inserter(landmarks)); // Compute witness complex - Strong_witness_complex strong_witness_complex(landmarks.begin(), - landmarks.end(), - witnesses.begin(), - witnesses.end()); + Strong_witness_complex strong_witness_complex(landmarks, + witnesses); strong_witness_complex.create_complex(simplex_tree, max_squared_alpha); diff --git a/src/Witness_complex/example/example_witness_complex_off.cpp b/src/Witness_complex/example/example_witness_complex_off.cpp index 94088370..2677499a 100644 --- a/src/Witness_complex/example/example_witness_complex_off.cpp +++ b/src/Witness_complex/example/example_witness_complex_off.cpp @@ -1,25 +1,3 @@ -/* 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 (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 @@ -72,10 +50,8 @@ int main(int argc, char * const argv[]) { // Compute witness complex start = clock(); - Witness_complex witness_complex(landmarks.begin(), - landmarks.end(), - point_vector.begin(), - point_vector.end()); + Witness_complex witness_complex(landmarks, + point_vector); witness_complex.create_complex(simplex_tree, alpha2, lim_dim); end = clock(); diff --git a/src/Witness_complex/example/example_witness_complex_persistence.cpp b/src/Witness_complex/example/example_witness_complex_persistence.cpp index b1b415fa..00f00aae 100644 --- a/src/Witness_complex/example/example_witness_complex_persistence.cpp +++ b/src/Witness_complex/example/example_witness_complex_persistence.cpp @@ -1,25 +1,3 @@ -/* 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) 2016 INRIA (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 @@ -81,10 +59,8 @@ int main(int argc, char * argv[]) { Gudhi::subsampling::pick_n_random_points(witnesses, nbL, std::back_inserter(landmarks)); // Compute witness complex - Witness_complex witness_complex(landmarks.begin(), - landmarks.end(), - witnesses.begin(), - witnesses.end()); + Witness_complex witness_complex(landmarks, + witnesses); witness_complex.create_complex(simplex_tree, max_squared_alpha); diff --git a/src/Witness_complex/example/example_witness_complex_sphere.cpp b/src/Witness_complex/example/example_witness_complex_sphere.cpp index d21195fa..42fb9f8d 100644 --- a/src/Witness_complex/example/example_witness_complex_sphere.cpp +++ b/src/Witness_complex/example/example_witness_complex_sphere.cpp @@ -1,24 +1,3 @@ -/* 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 (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 @@ -80,10 +59,8 @@ int main(int argc, char * const argv[]) { Gudhi::subsampling::pick_n_random_points(point_vector, number_of_landmarks, std::back_inserter(landmarks)); // Compute witness complex - Witness_complex witness_complex(landmarks.begin(), - landmarks.end(), - point_vector.begin(), - point_vector.end()); + Witness_complex witness_complex(landmarks, + point_vector); witness_complex.create_complex(simplex_tree, 0); end = clock(); double time = static_cast(end - start) / CLOCKS_PER_SEC; diff --git a/src/Witness_complex/include/gudhi/Strong_witness_complex.h b/src/Witness_complex/include/gudhi/Strong_witness_complex.h index 7ef8d3e5..c7b8c27b 100644 --- a/src/Witness_complex/include/gudhi/Strong_witness_complex.h +++ b/src/Witness_complex/include/gudhi/Strong_witness_complex.h @@ -94,22 +94,18 @@ private: /** * \brief Initializes member variables before constructing simplicial complex. - * \details Records landmarks from the range [landmarks_first, landmarks_last) into a - * table internally, as well as witnesses from the range [witnesses_first, witnesses_last). - * All iterator parameters should satisfy InputIterator - * C++ concept. + * \details Records landmarks from the range 'landmarks' into a + * table internally, as well as witnesses from the range 'witnesses'. */ - template< typename InputIteratorLandmarks, - typename InputIteratorWitnesses > - Strong_witness_complex(InputIteratorLandmarks landmarks_first, - InputIteratorLandmarks landmarks_last, - InputIteratorWitnesses witnesses_first, - InputIteratorWitnesses witnesses_last) - : witnesses_(witnesses_first, witnesses_last), landmarks_(landmarks_first, landmarks_last), landmark_tree_(landmarks_) + template< typename LandmarkRange, + typename WitnessRange > + Strong_witness_complex(const LandmarkRange & landmarks, + const WitnessRange & witnesses) + : witnesses_(witnesses), landmarks_(landmarks), landmark_tree_(landmarks_) { } + /** \brief Returns the point corresponding to the given vertex. */ template @@ -118,9 +114,10 @@ private: return landmarks_[vertex]; } - /** \brief Outputs the strong witness complex in a simplicial complex data structure. - * @param[out] complex Simplicial complex data structure compatible with 'find' and 'insert' operations. - * (Cf SimplicialComplexForWitness) + /** \brief Outputs the strong witness complex of relaxation 'max_alpha_square' + * in a simplicial complex data structure. + * @param[out] complex Simplicial complex data structure, which is a model of + * SimplicialComplexForWitness concept. * @param[in] max_alpha_square Maximal squared relaxation parameter. * @param[in] limit_dimension Represents the maximal dimension of the simplicial complex * (default value = no limit). diff --git a/src/Witness_complex/include/gudhi/Witness_complex.h b/src/Witness_complex/include/gudhi/Witness_complex.h index ac0e8f66..c1d402c6 100644 --- a/src/Witness_complex/include/gudhi/Witness_complex.h +++ b/src/Witness_complex/include/gudhi/Witness_complex.h @@ -46,12 +46,6 @@ namespace witness_complex { * \tparam Kernel_ requires a CGAL::Epick_d class, which * can be static if you know the ambiant dimension at compile-time, or dynamic if you don't. - * \tparam DimensionTag can be either Dimension_tag - * if you know the intrinsic dimension at compile-time, - * or CGAL::Dynamic_dimension_tag - * if you don't. */ template< class Kernel_ > class Witness_complex { @@ -94,19 +88,14 @@ private: /** * \brief Initializes member variables before constructing simplicial complex. - * \details Records landmarks from the range [landmarks_first, landmarks_last) into a - * table internally, as well as witnesses from the range [witnesses_first, witnesses_last). - * All iterator parameters should satisfy InputIterator - * C++ concept. + * \details Records landmarks from the range 'landmarks' into a + * table internally, as well as witnesses from the range 'witnesses'. */ - template< typename InputIteratorLandmarks, - typename InputIteratorWitnesses > - Witness_complex(InputIteratorLandmarks landmarks_first, - InputIteratorLandmarks landmarks_last, - InputIteratorWitnesses witnesses_first, - InputIteratorWitnesses witnesses_last) - : witnesses_(witnesses_first, witnesses_last), landmarks_(landmarks_first, landmarks_last), landmark_tree_(landmarks_) + template< typename LandmarkRange, + typename WitnessRange > + Witness_complex(const LandmarkRange & landmarks, + const WitnessRange & witnesses) + : witnesses_(witnesses), landmarks_(landmarks), landmark_tree_(landmarks_) { } @@ -118,9 +107,10 @@ private: return landmarks_[vertex]; } - /** \brief Outputs the (weak) witness complex in a simplicial complex data structure. - * @param[out] complex Simplicial complex data structure compatible with 'find' and 'insert' operations. - * (Cf SimplicialComplexForWitness) + /** \brief Outputs the (weak) witness complex of relaxation 'max_alpha_square' + * in a simplicial complex data structure. + * @param[out] complex Simplicial complex data structure compatible which is a model of + * SimplicialComplexForWitness concept. * @param[in] max_alpha_square Maximal squared relaxation parameter. * @param[in] limit_dimension Represents the maximal dimension of the simplicial complex * (default value = no limit). diff --git a/src/Witness_complex/test/test_simple_witness_complex.cpp b/src/Witness_complex/test/test_simple_witness_complex.cpp index 90b6cfa2..a0a1b36c 100644 --- a/src/Witness_complex/test/test_simple_witness_complex.cpp +++ b/src/Witness_complex/test/test_simple_witness_complex.cpp @@ -1,25 +1,3 @@ -/* 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) 2016 INRIA (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_TEST_DYN_LINK #define BOOST_TEST_MODULE "simple_witness_complex" #include @@ -79,10 +57,8 @@ BOOST_AUTO_TEST_CASE(simple_witness_complex) { witnesses.push_back(Point_d(std::vector{ 2,-1})); witnesses.push_back(Point_d(std::vector{ 2, 1})); - WitnessComplex witness_complex(landmarks.begin(), - landmarks.end(), - witnesses.begin(), - witnesses.end()); + WitnessComplex witness_complex(landmarks, + witnesses); witness_complex.create_complex(complex, 0); std::cout << "complex.num_simplices() = " << complex.num_simplices() << std::endl; @@ -93,10 +69,8 @@ BOOST_AUTO_TEST_CASE(simple_witness_complex) { std::cout << "relaxed_complex.num_simplices() = " << relaxed_complex.num_simplices() << std::endl; BOOST_CHECK(relaxed_complex.num_simplices() == 239); - StrongWitnessComplex strong_witness_complex(landmarks.begin(), - landmarks.end(), - witnesses.begin(), - witnesses.end()); + StrongWitnessComplex strong_witness_complex(landmarks, + witnesses); strong_witness_complex.create_complex(strong_relaxed_complex, 9.1); -- cgit v1.2.3 From e36bb3953817d9aa3b1baaa61e51cee4099787b9 Mon Sep 17 00:00:00 2001 From: skachano Date: Fri, 16 Dec 2016 08:42:13 +0000 Subject: memory access violation: here we go again git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/relaxed-witness@1892 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: fff0a693f83f8f0a0f93d2fe57640408e7b17c69 --- src/Witness_complex/include/gudhi/Strong_witness_complex.h | 13 +++++++------ src/Witness_complex/test/test_simple_witness_complex.cpp | 8 +++++--- 2 files changed, 12 insertions(+), 9 deletions(-) (limited to 'src/Witness_complex/test/test_simple_witness_complex.cpp') diff --git a/src/Witness_complex/include/gudhi/Strong_witness_complex.h b/src/Witness_complex/include/gudhi/Strong_witness_complex.h index 3803980b..5f9db5a4 100644 --- a/src/Witness_complex/include/gudhi/Strong_witness_complex.h +++ b/src/Witness_complex/include/gudhi/Strong_witness_complex.h @@ -162,7 +162,8 @@ private: // continue inserting limD-faces of the following simplices typeVectorVertex& vertices = simplex; //'simplex' now will be called vertices while (aw_it != aw.end() && aw_it->second < lim_dist2) { - add_all_faces_of_dimension(limD, vertices, vertices.begin(), aw_it, typeVectorVertex({}), complex); + typeVectorVertex facet = {}; + add_all_faces_of_dimension(limit_dimension, vertices, vertices.begin(), aw_it, facet, complex); vertices.push_back(aw_it->first); aw_it++; } @@ -181,17 +182,17 @@ private: * The landmark pointed by aw_it is added to all formed simplices. */ template < typename SimplicialComplexForWitness > - void add_all_faces_of_dimension(int dim, - std::vector& vertices, + void add_all_faces_of_dimension(Landmark_id dim, + typeVectorVertex& vertices, typename typeVectorVertex::iterator curr_it, typename ActiveWitness::iterator aw_it, - std::vector& simplex, + typeVectorVertex& simplex, SimplicialComplexForWitness& sc) { if (dim > 0) while (curr_it != vertices.end()) { - simplex.push_back(curr_it->first); - typename ActiveWitness::iterator next_it = curr_it++; + simplex.push_back(*curr_it); + typename typeVectorVertex::iterator next_it = curr_it++; add_all_faces_of_dimension(dim-1, vertices, next_it, diff --git a/src/Witness_complex/test/test_simple_witness_complex.cpp b/src/Witness_complex/test/test_simple_witness_complex.cpp index a0a1b36c..dc7f3175 100644 --- a/src/Witness_complex/test/test_simple_witness_complex.cpp +++ b/src/Witness_complex/test/test_simple_witness_complex.cpp @@ -32,7 +32,7 @@ typedef Gudhi::witness_complex::Strong_witness_complex StrongWitnessComp */ BOOST_AUTO_TEST_CASE(simple_witness_complex) { - Simplex_tree complex, relaxed_complex, strong_relaxed_complex; + Simplex_tree complex, relaxed_complex, strong_relaxed_complex, strong_relaxed_complex2; std::vector witnesses, landmarks; @@ -73,8 +73,10 @@ BOOST_AUTO_TEST_CASE(simple_witness_complex) { witnesses); strong_witness_complex.create_complex(strong_relaxed_complex, 9.1); - + strong_witness_complex.create_complex(strong_relaxed_complex2, 9.1, 2); + std::cout << "strong_relaxed_complex.num_simplices() = " << strong_relaxed_complex.num_simplices() << std::endl; BOOST_CHECK(strong_relaxed_complex.num_simplices() == 239); - + + std::cout << "strong_relaxed_complex2.num_simplices() = " << strong_relaxed_complex2.num_simplices() << std::endl; } -- cgit v1.2.3 From 7f5d6edb13f0c15bf85552984f3f6930fb810711 Mon Sep 17 00:00:00 2001 From: skachano Date: Fri, 16 Dec 2016 16:58:38 +0000 Subject: I'm almost there... git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/relaxed-witness@1908 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: a3f2a7ccf38672e51462d2ce42056d82b675d45a --- src/Witness_complex/include/gudhi/Strong_witness_complex.h | 4 ++-- src/Witness_complex/test/CMakeLists.txt | 1 + src/Witness_complex/test/test_simple_witness_complex.cpp | 8 +++++++- 3 files changed, 10 insertions(+), 3 deletions(-) (limited to 'src/Witness_complex/test/test_simple_witness_complex.cpp') diff --git a/src/Witness_complex/include/gudhi/Strong_witness_complex.h b/src/Witness_complex/include/gudhi/Strong_witness_complex.h index 5f9db5a4..4b39704e 100644 --- a/src/Witness_complex/include/gudhi/Strong_witness_complex.h +++ b/src/Witness_complex/include/gudhi/Strong_witness_complex.h @@ -192,7 +192,7 @@ private: if (dim > 0) while (curr_it != vertices.end()) { simplex.push_back(*curr_it); - typename typeVectorVertex::iterator next_it = curr_it++; + typename typeVectorVertex::iterator next_it = ++curr_it; add_all_faces_of_dimension(dim-1, vertices, next_it, @@ -209,7 +209,7 @@ private: } else if (dim == 0) { simplex.push_back(aw_it->first); - sc.insert_simplex(simplex, aw_it->second); + sc.insert_simplex_and_subfaces(simplex, aw_it->second); simplex.pop_back(); } } diff --git a/src/Witness_complex/test/CMakeLists.txt b/src/Witness_complex/test/CMakeLists.txt index 8d68ea1f..084761e2 100644 --- a/src/Witness_complex/test/CMakeLists.txt +++ b/src/Witness_complex/test/CMakeLists.txt @@ -12,6 +12,7 @@ endif() add_executable ( Witness_complex_test_simple_witness_complex test_simple_witness_complex.cpp ) target_link_libraries(Witness_complex_test_simple_witness_complex ${Boost_SYSTEM_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) +target_link_libraries(Witness_complex_test_simple_witness_complex ${TBB_LIBRARIES}) # Unitary tests definition and xml result file generation add_test(NAME simple_witness_complex diff --git a/src/Witness_complex/test/test_simple_witness_complex.cpp b/src/Witness_complex/test/test_simple_witness_complex.cpp index dc7f3175..299c7fd6 100644 --- a/src/Witness_complex/test/test_simple_witness_complex.cpp +++ b/src/Witness_complex/test/test_simple_witness_complex.cpp @@ -68,6 +68,10 @@ BOOST_AUTO_TEST_CASE(simple_witness_complex) { std::cout << "relaxed_complex.num_simplices() = " << relaxed_complex.num_simplices() << std::endl; BOOST_CHECK(relaxed_complex.num_simplices() == 239); + // All edges but big diagonals are present. + // + // Simplex count (number:dimension): + StrongWitnessComplex strong_witness_complex(landmarks, witnesses); @@ -78,5 +82,7 @@ BOOST_AUTO_TEST_CASE(simple_witness_complex) { std::cout << "strong_relaxed_complex.num_simplices() = " << strong_relaxed_complex.num_simplices() << std::endl; BOOST_CHECK(strong_relaxed_complex.num_simplices() == 239); - std::cout << "strong_relaxed_complex2.num_simplices() = " << strong_relaxed_complex2.num_simplices() << std::endl; + std::cout << "strong_relaxed_complex2.num_simplices() = " << strong_relaxed_complex2.num_simplices() << std::endl; + BOOST_CHECK(strong_relaxed_complex2.num_simplices() == 101); + std::cout << strong_relaxed_complex2 << std::endl; } -- cgit v1.2.3 From be4e9ebd24f48def07f6dfec1a46791321fbaee4 Mon Sep 17 00:00:00 2001 From: skachano Date: Fri, 16 Dec 2016 17:51:58 +0000 Subject: The bug with limit dimension in Strong witness is fixed git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/relaxed-witness@1912 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 2229381ca73da7ebe6a8b22d9a9a8eab70f65eb5 --- src/Witness_complex/include/gudhi/Strong_witness_complex.h | 2 +- src/Witness_complex/test/test_simple_witness_complex.cpp | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) (limited to 'src/Witness_complex/test/test_simple_witness_complex.cpp') diff --git a/src/Witness_complex/include/gudhi/Strong_witness_complex.h b/src/Witness_complex/include/gudhi/Strong_witness_complex.h index a3f88aae..3bb39c61 100644 --- a/src/Witness_complex/include/gudhi/Strong_witness_complex.h +++ b/src/Witness_complex/include/gudhi/Strong_witness_complex.h @@ -154,7 +154,7 @@ private: typeVectorVertex simplex; typename ActiveWitness::iterator aw_it = aw.begin(); float lim_dist2 = aw.begin()->second + max_alpha_square; - while ((Landmark_id)simplex.size() <= limit_dimension + 1 && aw_it != aw.end() && aw_it->second < lim_dist2) { + while ((Landmark_id)simplex.size() < limit_dimension + 1 && aw_it != aw.end() && aw_it->second < lim_dist2) { simplex.push_back(aw_it->first); complex.insert_simplex_and_subfaces(simplex, aw_it->second - aw.begin()->second); aw_it++; diff --git a/src/Witness_complex/test/test_simple_witness_complex.cpp b/src/Witness_complex/test/test_simple_witness_complex.cpp index 299c7fd6..aff6949e 100644 --- a/src/Witness_complex/test/test_simple_witness_complex.cpp +++ b/src/Witness_complex/test/test_simple_witness_complex.cpp @@ -68,9 +68,7 @@ BOOST_AUTO_TEST_CASE(simple_witness_complex) { std::cout << "relaxed_complex.num_simplices() = " << relaxed_complex.num_simplices() << std::endl; BOOST_CHECK(relaxed_complex.num_simplices() == 239); - // All edges but big diagonals are present. - // - // Simplex count (number:dimension): + // The corner simplex {0,2,5,7} and its cofaces are missing. StrongWitnessComplex strong_witness_complex(landmarks, @@ -83,6 +81,6 @@ BOOST_AUTO_TEST_CASE(simple_witness_complex) { BOOST_CHECK(strong_relaxed_complex.num_simplices() == 239); std::cout << "strong_relaxed_complex2.num_simplices() = " << strong_relaxed_complex2.num_simplices() << std::endl; - BOOST_CHECK(strong_relaxed_complex2.num_simplices() == 101); - std::cout << strong_relaxed_complex2 << std::endl; + BOOST_CHECK(strong_relaxed_complex2.num_simplices() == 92); + // 8 vertices, 28 edges, 56 triangles } -- cgit v1.2.3 From f6992f0e5eb53d67a567ee0f12d2c16099bcaf1b Mon Sep 17 00:00:00 2001 From: skachano Date: Tue, 17 Jan 2017 22:58:28 +0000 Subject: Added a non-Euclidean version of Witness. Compiles, but doesn't work git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/relaxed-witness@1943 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: a825e1ad183ae40170414038e70ce37d38e09689 --- .../include/gudhi/Witness_complex.h | 68 ++++++---------------- .../test/test_simple_witness_complex.cpp | 52 +++++++++++++---- 2 files changed, 61 insertions(+), 59 deletions(-) (limited to 'src/Witness_complex/test/test_simple_witness_complex.cpp') diff --git a/src/Witness_complex/include/gudhi/Witness_complex.h b/src/Witness_complex/include/gudhi/Witness_complex.h index 56ea8613..22f0f590 100644 --- a/src/Witness_complex/include/gudhi/Witness_complex.h +++ b/src/Witness_complex/include/gudhi/Witness_complex.h @@ -47,37 +47,22 @@ namespace witness_complex { * href="http://doc.cgal.org/latest/Kernel_d/classCGAL_1_1Epick__d.html">CGAL::Epick_d class, which * can be static if you know the ambiant dimension at compile-time, or dynamic if you don't. */ -template< class Kernel_ > +template< class Nearest_landmark_table_ > class Witness_complex { private: - typedef Kernel_ K; - typedef typename K::Point_d Point_d; - typedef typename K::FT FT; - typedef std::vector Point_range; - typedef gss::Kd_tree_search Kd_tree; - typedef typename Kd_tree::INS_range Nearest_landmark_range; - //typedef typename std::vector Nearest_landmark_table; - //typedef typename Nearest_landmark_range::iterator Nearest_landmark_row_iterator; - - typedef std::vector< double > Point_t; - typedef std::vector< Point_t > Point_Vector; - - typedef FT Filtration_value; - - - typedef std::size_t Witness_id; - typedef typename Nearest_landmark_range::Point_with_transformed_distance Id_distance_pair; - typedef typename Id_distance_pair::first_type Landmark_id; - typedef Active_witness ActiveWitness; - typedef std::list< ActiveWitness > ActiveWitnessList; - typedef std::vector< Landmark_id > typeVectorVertex; - typedef std::pair< typeVectorVertex, Filtration_value> typeSimplex; + typedef typename Nearest_landmark_table_::value_type Nearest_landmark_range; + typedef std::size_t Witness_id; + typedef std::size_t Landmark_id; + typedef std::pair Id_distance_pair; + typedef Active_witness ActiveWitness; + typedef std::list< ActiveWitness > ActiveWitnessList; + typedef std::vector< Landmark_id > typeVectorVertex; + typedef std::pair< typeVectorVertex, Filtration_value> typeSimplex; typedef Landmark_id Vertex_handle; private: - Point_range witnesses_, landmarks_; - Kd_tree landmark_tree_; + Nearest_landmark_table_& nearest_landmark_table_; public: ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -92,22 +77,13 @@ private: * table internally, as well as witnesses from the range 'witnesses'. * Both ranges should have value_type Kernel_::Point_d. */ - template< typename LandmarkRange, - typename WitnessRange > - Witness_complex(const LandmarkRange & landmarks, - const WitnessRange & witnesses) - : witnesses_(witnesses), landmarks_(landmarks), landmark_tree_(landmarks_) + + Witness_complex(Nearest_landmark_table_ & nearest_landmark_table) + : nearest_landmark_table_(nearest_landmark_table) { } - /** \brief Returns the point corresponding to the given vertex. - * @param[in] vertex Vertex handle of the point to retrieve. - */ - Point_d get_point( Vertex_handle vertex ) const - { - return landmarks_[vertex]; - } - + /** \brief Outputs the (weak) witness complex of relaxation 'max_alpha_square' * in a simplicial complex data structure. * \details The function returns true if the construction is successful and false otherwise. @@ -119,10 +95,10 @@ private: */ template < typename SimplicialComplexForWitness > bool create_complex(SimplicialComplexForWitness& complex, - FT max_alpha_square, + double max_alpha_square, Landmark_id limit_dimension = std::numeric_limits::max()) { - std::size_t nbL = landmarks_.size(); + // std::size_t nbL = landmarks_.size(); if (complex.num_vertices() > 0) { std::cerr << "Witness complex cannot create complex - complex is not empty.\n"; return false; @@ -137,15 +113,9 @@ private: } typeVectorVertex vv; ActiveWitnessList active_witnesses; - for (unsigned 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 - vv = {i}; - complex.insert_simplex(vv, Filtration_value(0.0)); - } - Landmark_id k = 1; /* current dimension in iterative construction */ - for (auto w: witnesses_) - active_witnesses.push_back(ActiveWitness(landmark_tree_.query_incremental_nearest_neighbors(w))); + Landmark_id k = 0; /* current dimension in iterative construction */ + for (auto w: nearest_landmark_table_) + active_witnesses.push_back(ActiveWitness(w)); ActiveWitness aw_copy(active_witnesses.front()); while (!active_witnesses.empty() && k <= limit_dimension ) { typename ActiveWitnessList::iterator aw_it = active_witnesses.begin(); diff --git a/src/Witness_complex/test/test_simple_witness_complex.cpp b/src/Witness_complex/test/test_simple_witness_complex.cpp index aff6949e..c50e829a 100644 --- a/src/Witness_complex/test/test_simple_witness_complex.cpp +++ b/src/Witness_complex/test/test_simple_witness_complex.cpp @@ -6,8 +6,13 @@ #include #include + #include +#include #include +#include + +#include #include #include @@ -18,8 +23,15 @@ typedef std::vector< Vertex_handle > typeVectorVertex; typedef CGAL::Epick_d Kernel; typedef typename Kernel::FT FT; typedef typename Kernel::Point_d Point_d; -typedef Gudhi::witness_complex::Witness_complex WitnessComplex; -typedef Gudhi::witness_complex::Strong_witness_complex StrongWitnessComplex; +typedef Gudhi::witness_complex::Euclidean_witness_complex EuclideanWitnessComplex; +typedef Gudhi::witness_complex::Euclidean_strong_witness_complex EuclideanStrongWitnessComplex; + +typedef std::vector Point_range; +typedef Gudhi::spatial_searching::Kd_tree_search Kd_tree; +typedef Kd_tree::INS_range Nearest_landmark_range; +typedef std::vector Nearest_landmark_table; +typedef Gudhi::witness_complex::Witness_complex WitnessComplex; + /* All landmarks and witnesses are taken on the grid in the following manner. LWLWL @@ -33,8 +45,9 @@ typedef Gudhi::witness_complex::Strong_witness_complex StrongWitnessComp BOOST_AUTO_TEST_CASE(simple_witness_complex) { Simplex_tree complex, relaxed_complex, strong_relaxed_complex, strong_relaxed_complex2; - - std::vector witnesses, landmarks; + Simplex_tree complex_ne, relaxed_complex_ne, strong_relaxed_complex_ne, strong_relaxed_complex2_ne; + + Point_range witnesses, landmarks; landmarks.push_back(Point_d(std::vector{-2,-2})); landmarks.push_back(Point_d(std::vector{-2, 0})); @@ -56,22 +69,41 @@ BOOST_AUTO_TEST_CASE(simple_witness_complex) { witnesses.push_back(Point_d(std::vector{ 1, 2})); witnesses.push_back(Point_d(std::vector{ 2,-1})); witnesses.push_back(Point_d(std::vector{ 2, 1})); - - WitnessComplex witness_complex(landmarks, - witnesses); - witness_complex.create_complex(complex, 0); + + Kd_tree landmark_tree(landmarks); + Nearest_landmark_table nearest_landmark_table; + for (auto w: witnesses) + nearest_landmark_table.push_back(landmark_tree.query_incremental_nearest_neighbors(w)); + + // Weak witness complex: Euclidean version + EuclideanWitnessComplex eucl_witness_complex(landmarks, + witnesses); + eucl_witness_complex.create_complex(complex, 0); std::cout << "complex.num_simplices() = " << complex.num_simplices() << std::endl; BOOST_CHECK(complex.num_simplices() == 24); - witness_complex.create_complex(relaxed_complex, 8.01); + eucl_witness_complex.create_complex(relaxed_complex, 8.01); std::cout << "relaxed_complex.num_simplices() = " << relaxed_complex.num_simplices() << std::endl; BOOST_CHECK(relaxed_complex.num_simplices() == 239); // The corner simplex {0,2,5,7} and its cofaces are missing. + // Weak witness complex: non-Euclidean version + WitnessComplex witness_complex(nearest_landmark_table); + witness_complex.create_complex(complex_ne, 0); + + std::cout << "complex.num_simplices() = " << complex_ne.num_simplices() << std::endl; + BOOST_CHECK(complex_ne.num_simplices() == 24); + + witness_complex.create_complex(relaxed_complex_ne, 8.01); + + std::cout << "relaxed_complex.num_simplices() = " << relaxed_complex_ne.num_simplices() << std::endl; + BOOST_CHECK(relaxed_complex_ne.num_simplices() == 239); + + - StrongWitnessComplex strong_witness_complex(landmarks, + EuclideanStrongWitnessComplex strong_witness_complex(landmarks, witnesses); strong_witness_complex.create_complex(strong_relaxed_complex, 9.1); -- cgit v1.2.3 From eed110f1e5ec3842553051a421a76dd9d47877fe Mon Sep 17 00:00:00 2001 From: skachano Date: Wed, 18 Jan 2017 10:04:19 +0000 Subject: Added a file + fixed the bug git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/relaxed-witness@1945 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: a5acd7e920dfba1857ed1b71bfc1b33e5522cfc3 --- .../include/gudhi/Strong_witness_complex.h | 65 +++++----------------- .../include/gudhi/Witness_complex.h | 1 - .../test/test_simple_witness_complex.cpp | 26 +++++++-- 3 files changed, 36 insertions(+), 56 deletions(-) (limited to 'src/Witness_complex/test/test_simple_witness_complex.cpp') diff --git a/src/Witness_complex/include/gudhi/Strong_witness_complex.h b/src/Witness_complex/include/gudhi/Strong_witness_complex.h index 3bb39c61..164d8ffe 100644 --- a/src/Witness_complex/include/gudhi/Strong_witness_complex.h +++ b/src/Witness_complex/include/gudhi/Strong_witness_complex.h @@ -53,37 +53,21 @@ namespace witness_complex { * href="http://doc.cgal.org/latest/Kernel_23/classCGAL_1_1Dynamic__dimension__tag.html">CGAL::Dynamic_dimension_tag * if you don't. */ -template< class Kernel_ > +template< class Nearest_landmark_table_ > class Strong_witness_complex { private: - typedef Kernel_ K; - typedef typename K::Point_d Point_d; - typedef typename K::FT FT; - typedef std::vector Point_range; - typedef gss::Kd_tree_search Kd_tree; - typedef typename Kd_tree::INS_range Nearest_landmark_range; - typedef typename std::vector Nearest_landmark_table; - typedef typename Nearest_landmark_range::iterator Nearest_landmark_row_iterator; + typedef typename Nearest_landmark_table_::value_type Nearest_landmark_range; + typedef std::size_t Witness_id; + typedef std::size_t Landmark_id; + typedef std::pair Id_distance_pair; + typedef Active_witness ActiveWitness; + typedef std::list< ActiveWitness > ActiveWitnessList; + typedef std::vector< Landmark_id > typeVectorVertex; - typedef std::vector< double > Point_t; - typedef std::vector< Point_t > Point_Vector; - - typedef FT Filtration_value; - - - typedef std::size_t Witness_id; - typedef typename Nearest_landmark_range::Point_with_transformed_distance Id_distance_pair; - typedef typename Id_distance_pair::first_type Landmark_id; - typedef Active_witness ActiveWitness; - typedef std::list< ActiveWitness > ActiveWitnessList; - typedef std::vector< Landmark_id > typeVectorVertex; - typedef std::pair< typeVectorVertex, Filtration_value> typeSimplex; - typedef Landmark_id Vertex_handle; private: - Point_range witnesses_, landmarks_; - Kd_tree landmark_tree_; + Nearest_landmark_table_& nearest_landmark_table_; public: ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -98,22 +82,10 @@ private: * table internally, as well as witnesses from the range 'witnesses'. * Both ranges should have value_type Kernel_::Point_d. */ - template< typename LandmarkRange, - typename WitnessRange > - Strong_witness_complex(const LandmarkRange & landmarks, - const WitnessRange & witnesses) - : witnesses_(witnesses), landmarks_(landmarks), landmark_tree_(landmarks_) + Strong_witness_complex(Nearest_landmark_table_ & nearest_landmark_table) + : nearest_landmark_table_(nearest_landmark_table) { } - - - /** \brief Returns the point corresponding to the given vertex. - */ - template - Point_d get_point( Vertex_handle vertex ) const - { - return landmarks_[vertex]; - } /** \brief Outputs the strong witness complex of relaxation 'max_alpha_square' * in a simplicial complex data structure. @@ -126,10 +98,9 @@ private: */ template < typename SimplicialComplexForWitness > bool create_complex(SimplicialComplexForWitness& complex, - FT max_alpha_square, + double max_alpha_square, Landmark_id limit_dimension = std::numeric_limits::max()-1) { - std::size_t nbL = landmarks_.size(); Landmark_id complex_dim = 0; if (complex.num_vertices() > 0) { std::cerr << "Strong witness complex cannot create complex - complex is not empty.\n"; @@ -143,14 +114,8 @@ private: std::cerr << "Strong witness complex cannot create complex - limit dimension must be non-negative.\n"; return false; } - typeVectorVertex vv; - for (unsigned i = 0; i != nbL; ++i) { - // initial fill of 0-dimensional simplices - vv = {i}; - complex.insert_simplex(vv, Filtration_value(0.0)); - } - for (auto w: witnesses_) { - ActiveWitness aw(landmark_tree_.query_incremental_nearest_neighbors(w)); + for (auto w: nearest_landmark_table_) { + ActiveWitness aw(w); typeVectorVertex simplex; typename ActiveWitness::iterator aw_it = aw.begin(); float lim_dist2 = aw.begin()->second + max_alpha_square; @@ -186,7 +151,7 @@ private: typeVectorVertex& vertices, typename typeVectorVertex::iterator curr_it, typename ActiveWitness::iterator aw_it, - FT filtration_value, + double filtration_value, typeVectorVertex& simplex, SimplicialComplexForWitness& sc) { diff --git a/src/Witness_complex/include/gudhi/Witness_complex.h b/src/Witness_complex/include/gudhi/Witness_complex.h index 73993900..2cd7a178 100644 --- a/src/Witness_complex/include/gudhi/Witness_complex.h +++ b/src/Witness_complex/include/gudhi/Witness_complex.h @@ -58,7 +58,6 @@ private: typedef Active_witness ActiveWitness; typedef std::list< ActiveWitness > ActiveWitnessList; typedef std::vector< Landmark_id > typeVectorVertex; - typedef std::pair< typeVectorVertex, Filtration_value> typeSimplex; typedef Landmark_id Vertex_handle; diff --git a/src/Witness_complex/test/test_simple_witness_complex.cpp b/src/Witness_complex/test/test_simple_witness_complex.cpp index c50e829a..2d4134f4 100644 --- a/src/Witness_complex/test/test_simple_witness_complex.cpp +++ b/src/Witness_complex/test/test_simple_witness_complex.cpp @@ -102,17 +102,33 @@ BOOST_AUTO_TEST_CASE(simple_witness_complex) { BOOST_CHECK(relaxed_complex_ne.num_simplices() == 239); - - EuclideanStrongWitnessComplex strong_witness_complex(landmarks, - witnesses); + // Strong complex : Euclidean version + EuclideanStrongWitnessComplex eucl_strong_witness_complex(landmarks, + witnesses); - strong_witness_complex.create_complex(strong_relaxed_complex, 9.1); - strong_witness_complex.create_complex(strong_relaxed_complex2, 9.1, 2); + eucl_strong_witness_complex.create_complex(strong_relaxed_complex, 9.1); + eucl_strong_witness_complex.create_complex(strong_relaxed_complex2, 9.1, 2); std::cout << "strong_relaxed_complex.num_simplices() = " << strong_relaxed_complex.num_simplices() << std::endl; BOOST_CHECK(strong_relaxed_complex.num_simplices() == 239); std::cout << "strong_relaxed_complex2.num_simplices() = " << strong_relaxed_complex2.num_simplices() << std::endl; BOOST_CHECK(strong_relaxed_complex2.num_simplices() == 92); + + + // Strong complex : non-Euclidean version + EuclideanStrongWitnessComplex strong_witness_complex(landmarks, + witnesses); + + strong_witness_complex.create_complex(strong_relaxed_complex_ne, 9.1); + strong_witness_complex.create_complex(strong_relaxed_complex2_ne, 9.1, 2); + + std::cout << "strong_relaxed_complex.num_simplices() = " << strong_relaxed_complex_ne.num_simplices() << std::endl; + BOOST_CHECK(strong_relaxed_complex_ne.num_simplices() == 239); + + std::cout << "strong_relaxed_complex2.num_simplices() = " << strong_relaxed_complex2_ne.num_simplices() << std::endl; + BOOST_CHECK(strong_relaxed_complex2_ne.num_simplices() == 92); + + // 8 vertices, 28 edges, 56 triangles } -- cgit v1.2.3 From db1398bcf173f372fc3ef7a410e4e72b0192f8cc Mon Sep 17 00:00:00 2001 From: skachano Date: Fri, 20 Jan 2017 15:24:36 +0000 Subject: non-Euclidean example works, but the test not anymore git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/relaxed-witness@1975 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 251638e6417f1059529d57a8a87364a17cf9f5a2 --- src/Witness_complex/example/example_nearest_landmark_table.cpp | 10 ++++------ .../include/gudhi/Active_witness/Active_witness.h | 2 +- .../include/gudhi/Active_witness/Active_witness_iterator.h | 5 +++-- src/Witness_complex/include/gudhi/Witness_complex.h | 2 +- src/Witness_complex/test/test_simple_witness_complex.cpp | 4 ++-- 5 files changed, 11 insertions(+), 12 deletions(-) (limited to 'src/Witness_complex/test/test_simple_witness_complex.cpp') diff --git a/src/Witness_complex/example/example_nearest_landmark_table.cpp b/src/Witness_complex/example/example_nearest_landmark_table.cpp index 00ec17e0..becf74e7 100644 --- a/src/Witness_complex/example/example_nearest_landmark_table.cpp +++ b/src/Witness_complex/example/example_nearest_landmark_table.cpp @@ -17,6 +17,7 @@ #include #include #include +#include int main(int argc, char * const argv[]) { typedef std::vector> Nearest_landmark_range; @@ -26,21 +27,18 @@ int main(int argc, char * const argv[]) { Gudhi::Simplex_tree<> simplex_tree; Nearest_landmark_table nlt; - // Example contains 10 witnesses and 5 landmarks + // Example contains 5 witnesses and 5 landmarks Nearest_landmark_range w0 = {std::make_pair(0,0), std::make_pair(1,1), std::make_pair(2,2), std::make_pair(3,3), std::make_pair(4,4)}; nlt.push_back(w0); Nearest_landmark_range w1 = {std::make_pair(1,0), std::make_pair(2,1), std::make_pair(3,2), std::make_pair(4,3), std::make_pair(0,4)}; nlt.push_back(w1); Nearest_landmark_range w2 = {std::make_pair(2,0), std::make_pair(3,1), std::make_pair(4,2), std::make_pair(0,3), std::make_pair(1,4)}; nlt.push_back(w2); Nearest_landmark_range w3 = {std::make_pair(3,0), std::make_pair(4,1), std::make_pair(0,2), std::make_pair(1,3), std::make_pair(2,4)}; nlt.push_back(w3); Nearest_landmark_range w4 = {std::make_pair(4,0), std::make_pair(0,1), std::make_pair(1,2), std::make_pair(2,3), std::make_pair(3,4)}; nlt.push_back(w4); - Nearest_landmark_range x0 = {std::make_pair(0,0), std::make_pair(4,1), std::make_pair(3,2), std::make_pair(2,3), std::make_pair(1,4)}; nlt.push_back(x0); - Nearest_landmark_range x1 = {std::make_pair(1,0), std::make_pair(0,1), std::make_pair(4,2), std::make_pair(3,3), std::make_pair(2,4)}; nlt.push_back(x1); - Nearest_landmark_range x2 = {std::make_pair(2,0), std::make_pair(1,1), std::make_pair(0,2), std::make_pair(4,3), std::make_pair(3,4)}; nlt.push_back(x2); - Nearest_landmark_range x3 = {std::make_pair(3,0), std::make_pair(2,1), std::make_pair(1,2), std::make_pair(0,3), std::make_pair(4,4)}; nlt.push_back(x3); - Nearest_landmark_range x4 = {std::make_pair(4,0), std::make_pair(3,1), std::make_pair(2,2), std::make_pair(1,3), std::make_pair(0,4)}; nlt.push_back(x4); Witness_complex witness_complex(nlt); witness_complex.create_complex(simplex_tree, 4.1); + std::cout << "Number of simplices: " << simplex_tree.num_simplices() << std::endl; + Gudhi::persistent_cohomology::Persistent_cohomology, Gudhi::persistent_cohomology::Field_Zp > pcoh(simplex_tree); // initializes the coefficient field for homology pcoh.init_coefficients(11); diff --git a/src/Witness_complex/include/gudhi/Active_witness/Active_witness.h b/src/Witness_complex/include/gudhi/Active_witness/Active_witness.h index debbd286..c3edc0b7 100644 --- a/src/Witness_complex/include/gudhi/Active_witness/Active_witness.h +++ b/src/Witness_complex/include/gudhi/Active_witness/Active_witness.h @@ -50,7 +50,7 @@ public: INS_iterator iterator_end_; Active_witness(INS_range search_range) - : search_range_(search_range), iterator_last_(search_range.begin()), iterator_end_(search_range.end()) + : search_range_(search_range), iterator_last_(search_range_.begin()), iterator_end_(search_range_.end()) { nearest_landmark_table_.push_back(*iterator_last_); } diff --git a/src/Witness_complex/include/gudhi/Active_witness/Active_witness_iterator.h b/src/Witness_complex/include/gudhi/Active_witness/Active_witness_iterator.h index 5b040914..b0a88662 100644 --- a/src/Witness_complex/include/gudhi/Active_witness/Active_witness_iterator.h +++ b/src/Witness_complex/include/gudhi/Active_witness/Active_witness_iterator.h @@ -86,12 +86,13 @@ private : // if the id of the current landmark is the same as the last one if (lh_->first == aw_->iterator_last_->first) { // if the next iterator is end, lh_it = end pointer - if (++(aw_->iterator_last_) == aw_->iterator_end_) { + INS_iterator next_it = aw_->iterator_last_; next_it++; + if (next_it == aw_->iterator_end_) { is_end_ = true; return; } else { - //aw_->iterator_last_ = ++(aw_->iterator_last_); + ++(aw_->iterator_last_); aw_->nearest_landmark_table_.push_back(*(aw_->iterator_last_)); } } diff --git a/src/Witness_complex/include/gudhi/Witness_complex.h b/src/Witness_complex/include/gudhi/Witness_complex.h index 3305a8e2..576b8b0d 100644 --- a/src/Witness_complex/include/gudhi/Witness_complex.h +++ b/src/Witness_complex/include/gudhi/Witness_complex.h @@ -62,7 +62,7 @@ private: typedef Landmark_id Vertex_handle; private: - Nearest_landmark_table_& nearest_landmark_table_; + Nearest_landmark_table_ nearest_landmark_table_; public: ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/Witness_complex/test/test_simple_witness_complex.cpp b/src/Witness_complex/test/test_simple_witness_complex.cpp index 2d4134f4..b47ebe4d 100644 --- a/src/Witness_complex/test/test_simple_witness_complex.cpp +++ b/src/Witness_complex/test/test_simple_witness_complex.cpp @@ -31,6 +31,7 @@ typedef Gudhi::spatial_searching::Kd_tree_search Kd_tree; typedef Kd_tree::INS_range Nearest_landmark_range; typedef std::vector Nearest_landmark_table; typedef Gudhi::witness_complex::Witness_complex WitnessComplex; +typedef Gudhi::witness_complex::Strong_witness_complex StrongWitnessComplex; /* All landmarks and witnesses are taken on the grid in the following manner. @@ -117,8 +118,7 @@ BOOST_AUTO_TEST_CASE(simple_witness_complex) { // Strong complex : non-Euclidean version - EuclideanStrongWitnessComplex strong_witness_complex(landmarks, - witnesses); + StrongWitnessComplex strong_witness_complex(nearest_landmark_table); strong_witness_complex.create_complex(strong_relaxed_complex_ne, 9.1); strong_witness_complex.create_complex(strong_relaxed_complex2_ne, 9.1, 2); -- cgit v1.2.3