summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Alpha_complex/include/gudhi/Alpha_complex.h2
-rw-r--r--src/Alpha_complex/utilities/CMakeLists.txt2
-rw-r--r--src/Alpha_complex/utilities/alpha_complex_3d_helper.h8
-rw-r--r--src/Alpha_complex/utilities/alpha_complex_3d_persistence.cpp50
-rw-r--r--src/Alpha_complex/utilities/exact_alpha_complex_3d_persistence.cpp33
-rw-r--r--src/Alpha_complex/utilities/periodic_alpha_complex_3d_persistence.cpp47
-rw-r--r--src/Alpha_complex/utilities/weighted_alpha_complex_3d_persistence.cpp33
-rw-r--r--src/Alpha_complex/utilities/weighted_periodic_alpha_complex_3d_persistence.cpp85
-rw-r--r--src/Bottleneck_distance/include/gudhi/Neighbors_finder.h2
-rw-r--r--src/Doxyfile2
-rw-r--r--src/Persistence_representations/include/gudhi/PSSK.h8
-rw-r--r--src/Persistence_representations/include/gudhi/Persistence_heat_maps.h11
-rw-r--r--src/Persistence_representations/include/gudhi/Persistence_intervals.h5
-rw-r--r--src/Persistence_representations/include/gudhi/Persistence_intervals_with_distances.h1
-rw-r--r--src/Persistence_representations/include/gudhi/Persistence_landscape.h119
-rw-r--r--src/Persistence_representations/include/gudhi/Persistence_vectors.h4
-rw-r--r--src/Persistence_representations/include/gudhi/read_persistence_from_file.h128
-rw-r--r--src/Persistence_representations/test/persistence_lanscapes_test.cpp4
-rw-r--r--src/Persistent_cohomology/doc/Intro_persistent_cohomology.h31
-rw-r--r--src/Simplex_tree/include/gudhi/Simplex_tree.h103
-rw-r--r--src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_iterators.h32
-rw-r--r--src/Subsampling/include/gudhi/choose_n_farthest_points.h4
-rw-r--r--src/cmake/modules/GUDHI_third_party_libraries.cmake2
-rw-r--r--src/common/doc/main_page.h4
-rw-r--r--src/common/include/gudhi/Debug_utils.h2
-rw-r--r--src/cython/cython/simplex_tree.pyx11
-rw-r--r--src/cython/doc/witness_complex_user.rst2
-rw-r--r--src/cython/include/Tangential_complex_interface.h2
28 files changed, 347 insertions, 390 deletions
diff --git a/src/Alpha_complex/include/gudhi/Alpha_complex.h b/src/Alpha_complex/include/gudhi/Alpha_complex.h
index 5f7d7622..63c6675c 100644
--- a/src/Alpha_complex/include/gudhi/Alpha_complex.h
+++ b/src/Alpha_complex/include/gudhi/Alpha_complex.h
@@ -175,7 +175,7 @@ class Alpha_complex {
*
* @return The number of vertices.
*/
- const std::size_t number_of_vertices() const {
+ std::size_t number_of_vertices() const {
return vertex_handle_to_iterator_.size();
}
diff --git a/src/Alpha_complex/utilities/CMakeLists.txt b/src/Alpha_complex/utilities/CMakeLists.txt
index 79d9e7dd..a2dfac20 100644
--- a/src/Alpha_complex/utilities/CMakeLists.txt
+++ b/src/Alpha_complex/utilities/CMakeLists.txt
@@ -54,7 +54,7 @@ if(CGAL_FOUND)
target_link_libraries(weighted_periodic_alpha_complex_3d_persistence ${TBB_LIBRARIES})
endif(TBB_FOUND)
- add_test(NAME Persistent_cohomology_example_weigted_periodic_alpha_complex_3d COMMAND $<TARGET_FILE:weighted_periodic_alpha_complex_3d_persistence>
+ add_test(NAME Alpha_complex_utilities_weigted_periodic_alpha_complex_3d COMMAND $<TARGET_FILE:weighted_periodic_alpha_complex_3d_persistence>
"${CMAKE_SOURCE_DIR}/data/points/grid_10_10_10_in_0_1.off" "${CMAKE_SOURCE_DIR}/data/points/grid_10_10_10_in_0_1.weights"
"${CMAKE_SOURCE_DIR}/data/points/iso_cuboid_3_in_0_1.txt" "3" "1.0")
diff --git a/src/Alpha_complex/utilities/alpha_complex_3d_helper.h b/src/Alpha_complex/utilities/alpha_complex_3d_helper.h
index 6b3b7d5d..3747923f 100644
--- a/src/Alpha_complex/utilities/alpha_complex_3d_helper.h
+++ b/src/Alpha_complex/utilities/alpha_complex_3d_helper.h
@@ -52,13 +52,11 @@ Vertex_list from_facet(const Facet& fct) {
template <class Vertex_list, class Edge_3>
Vertex_list from_edge(const Edge_3& edg) {
Vertex_list the_list;
- for (auto i = 0; i < 4; i++) {
- if ((edg.second == i) || (edg.third == i)) {
+ for (auto i : { edg.second, edg.third }) {
#ifdef DEBUG_TRACES
- std::cout << "from edge[" << i << "]=" << edg.first->vertex(i)->point() << std::endl;
+ std::cout << "from edge[" << i << "]=" << edg.first->vertex(i)->point() << std::endl;
#endif // DEBUG_TRACES
- the_list.push_back(edg.first->vertex(i));
- }
+ the_list.push_back(edg.first->vertex(i));
}
return the_list;
}
diff --git a/src/Alpha_complex/utilities/alpha_complex_3d_persistence.cpp b/src/Alpha_complex/utilities/alpha_complex_3d_persistence.cpp
index 0a021a0f..1070d17b 100644
--- a/src/Alpha_complex/utilities/alpha_complex_3d_persistence.cpp
+++ b/src/Alpha_complex/utilities/alpha_complex_3d_persistence.cpp
@@ -20,9 +20,14 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <boost/version.hpp>
#include <boost/program_options.hpp>
#include <boost/variant.hpp>
+#if BOOST_VERSION >= 105400
+#include <boost/container/static_vector.hpp>
+#endif
+
#include <gudhi/Simplex_tree.h>
#include <gudhi/Persistent_cohomology.h>
#include <gudhi/Points_3D_off_io.h>
@@ -38,7 +43,6 @@
#include <tuple>
#include <map>
#include <utility>
-#include <list>
#include <vector>
#include <cstdlib>
@@ -66,14 +70,18 @@ using Cell_handle = Alpha_shape_3::Cell_handle;
using Facet = Alpha_shape_3::Facet;
using Edge_3 = Alpha_shape_3::Edge;
using Vertex_handle = Alpha_shape_3::Vertex_handle;
-using Vertex_list = std::list<Alpha_shape_3::Vertex_handle>;
+
+#if BOOST_VERSION >= 105400
+using Vertex_list = boost::container::static_vector<Alpha_shape_3::Vertex_handle, 4>;
+#else
+using Vertex_list = std::vector<Alpha_shape_3::Vertex_handle>;
+#endif
// gudhi type definition
using ST = Gudhi::Simplex_tree<Gudhi::Simplex_tree_options_fast_persistence>;
using Filtration_value = ST::Filtration_value;
using Simplex_tree_vertex = ST::Vertex_handle;
using Alpha_shape_simplex_tree_map = std::map<Alpha_shape_3::Vertex_handle, Simplex_tree_vertex>;
-using Alpha_shape_simplex_tree_pair = std::pair<Alpha_shape_3::Vertex_handle, Simplex_tree_vertex>;
using Simplex_tree_vector_vertex = std::vector<Simplex_tree_vertex>;
using Persistent_cohomology =
Gudhi::persistent_cohomology::Persistent_cohomology<ST, Gudhi::persistent_cohomology::Field_Zp>;
@@ -97,7 +105,7 @@ int main(int argc, char **argv) {
exit(-1);
}
- // Retrieve the triangulation
+ // Retrieve the points
std::vector<Point_3> lp = off_reader.get_point_cloud();
// alpha shape construction from points. CGAL has a strange behavior in REGULARIZED mode.
@@ -128,37 +136,23 @@ int main(int argc, char **argv) {
ST simplex_tree;
Alpha_shape_simplex_tree_map map_cgal_simplex_tree;
std::vector<Alpha_value_type>::iterator the_alpha_value_iterator = the_alpha_values.begin();
- int dim_max = 0;
- Filtration_value filtration_max = 0.0;
for (auto object_iterator : the_objects) {
// Retrieve Alpha shape vertex list from object
if (const Cell_handle* cell = CGAL::object_cast<Cell_handle>(&object_iterator)) {
vertex_list = from_cell<Vertex_list, Cell_handle>(*cell);
count_cells++;
- if (dim_max < 3) {
- // Cell is of dim 3
- dim_max = 3;
- }
} else if (const Facet* facet = CGAL::object_cast<Facet>(&object_iterator)) {
vertex_list = from_facet<Vertex_list, Facet>(*facet);
count_facets++;
- if (dim_max < 2) {
- // Facet is of dim 2
- dim_max = 2;
- }
} else if (const Edge_3* edge = CGAL::object_cast<Edge_3>(&object_iterator)) {
vertex_list = from_edge<Vertex_list, Edge_3>(*edge);
count_edges++;
- if (dim_max < 1) {
- // Edge_3 is of dim 1
- dim_max = 1;
- }
} else if (const Vertex_handle* vertex = CGAL::object_cast<Vertex_handle>(&object_iterator)) {
count_vertices++;
vertex_list = from_vertex<Vertex_list, Vertex_handle>(*vertex);
}
// Construction of the vector of simplex_tree vertex from list of alpha_shapes vertex
- Simplex_tree_vector_vertex the_simplex_tree;
+ Simplex_tree_vector_vertex the_simplex;
for (auto the_alpha_shape_vertex : vertex_list) {
Alpha_shape_simplex_tree_map::iterator the_map_iterator = map_cgal_simplex_tree.find(the_alpha_shape_vertex);
if (the_map_iterator == map_cgal_simplex_tree.end()) {
@@ -167,15 +161,15 @@ int main(int argc, char **argv) {
#ifdef DEBUG_TRACES
std::cout << "vertex [" << the_alpha_shape_vertex->point() << "] not found - insert " << vertex << std::endl;
#endif // DEBUG_TRACES
- the_simplex_tree.push_back(vertex);
- map_cgal_simplex_tree.insert(Alpha_shape_simplex_tree_pair(the_alpha_shape_vertex, vertex));
+ the_simplex.push_back(vertex);
+ map_cgal_simplex_tree.emplace(the_alpha_shape_vertex, vertex);
} else {
// alpha shape found
Simplex_tree_vertex vertex = the_map_iterator->second;
#ifdef DEBUG_TRACES
std::cout << "vertex [" << the_alpha_shape_vertex->point() << "] found in " << vertex << std::endl;
#endif // DEBUG_TRACES
- the_simplex_tree.push_back(vertex);
+ the_simplex.push_back(vertex);
}
}
// Construction of the simplex_tree
@@ -183,14 +177,10 @@ int main(int argc, char **argv) {
#ifdef DEBUG_TRACES
std::cout << "filtration = " << filtr << std::endl;
#endif // DEBUG_TRACES
- if (filtr > filtration_max) {
- filtration_max = filtr;
- }
- simplex_tree.insert_simplex(the_simplex_tree, filtr);
- if (the_alpha_value_iterator != the_alpha_values.end())
- ++the_alpha_value_iterator;
- else
- std::cout << "This shall not happen" << std::endl;
+ simplex_tree.insert_simplex(the_simplex, filtr);
+ GUDHI_CHECK(the_alpha_value_iterator != the_alpha_values.end(),
+ "CGAL provided more simplices than values");
+ ++the_alpha_value_iterator;
}
#ifdef DEBUG_TRACES
diff --git a/src/Alpha_complex/utilities/exact_alpha_complex_3d_persistence.cpp b/src/Alpha_complex/utilities/exact_alpha_complex_3d_persistence.cpp
index 9a266418..3b9a2ae0 100644
--- a/src/Alpha_complex/utilities/exact_alpha_complex_3d_persistence.cpp
+++ b/src/Alpha_complex/utilities/exact_alpha_complex_3d_persistence.cpp
@@ -38,7 +38,6 @@
#include <tuple>
#include <map>
#include <utility>
-#include <list>
#include <vector>
#include <cstdlib>
@@ -67,14 +66,13 @@ using Cell_handle = Alpha_shape_3::Cell_handle;
using Facet = Alpha_shape_3::Facet;
using Edge_3 = Alpha_shape_3::Edge;
using Vertex_handle = Alpha_shape_3::Vertex_handle;
-using Vertex_list = std::list<Vertex_handle>;
+using Vertex_list = std::vector<Vertex_handle>;
// gudhi type definition
using ST = Gudhi::Simplex_tree<Gudhi::Simplex_tree_options_fast_persistence>;
using Filtration_value = ST::Filtration_value;
using Simplex_tree_vertex = ST::Vertex_handle;
using Alpha_shape_simplex_tree_map = std::map<Alpha_shape_3::Vertex_handle, Simplex_tree_vertex>;
-using Alpha_shape_simplex_tree_pair = std::pair<Alpha_shape_3::Vertex_handle, Simplex_tree_vertex>;
using Simplex_tree_vector_vertex = std::vector<Simplex_tree_vertex>;
using Persistent_cohomology =
Gudhi::persistent_cohomology::Persistent_cohomology<ST, Gudhi::persistent_cohomology::Field_Zp>;
@@ -98,7 +96,7 @@ int main(int argc, char **argv) {
exit(-1);
}
- // Retrieve the triangulation
+ // Retrieve the points
std::vector<Point_3> lp = off_reader.get_point_cloud();
// alpha shape construction from points. CGAL has a strange behavior in REGULARIZED mode.
@@ -129,37 +127,23 @@ int main(int argc, char **argv) {
ST simplex_tree;
Alpha_shape_simplex_tree_map map_cgal_simplex_tree;
std::vector<Alpha_value_type>::iterator the_alpha_value_iterator = the_alpha_values.begin();
- int dim_max = 0;
- Filtration_value filtration_max = 0.0;
for (auto object_iterator : the_objects) {
// Retrieve Alpha shape vertex list from object
if (const Cell_handle* cell = CGAL::object_cast<Cell_handle>(&object_iterator)) {
vertex_list = from_cell<Vertex_list, Cell_handle>(*cell);
count_cells++;
- if (dim_max < 3) {
- // Cell is of dim 3
- dim_max = 3;
- }
} else if (const Facet* facet = CGAL::object_cast<Facet>(&object_iterator)) {
vertex_list = from_facet<Vertex_list, Facet>(*facet);
count_facets++;
- if (dim_max < 2) {
- // Facet is of dim 2
- dim_max = 2;
- }
} else if (const Edge_3* edge = CGAL::object_cast<Edge_3>(&object_iterator)) {
vertex_list = from_edge<Vertex_list, Edge_3>(*edge);
count_edges++;
- if (dim_max < 1) {
- // Edge_3 is of dim 1
- dim_max = 1;
- }
} else if (const Vertex_handle* vertex = CGAL::object_cast<Vertex_handle>(&object_iterator)) {
count_vertices++;
vertex_list = from_vertex<Vertex_list, Vertex_handle>(*vertex);
}
// Construction of the vector of simplex_tree vertex from list of alpha_shapes vertex
- Simplex_tree_vector_vertex the_simplex_tree;
+ Simplex_tree_vector_vertex the_simplex;
for (auto the_alpha_shape_vertex : vertex_list) {
Alpha_shape_simplex_tree_map::iterator the_map_iterator = map_cgal_simplex_tree.find(the_alpha_shape_vertex);
if (the_map_iterator == map_cgal_simplex_tree.end()) {
@@ -168,15 +152,15 @@ int main(int argc, char **argv) {
#ifdef DEBUG_TRACES
std::cout << "vertex [" << the_alpha_shape_vertex->point() << "] not found - insert " << vertex << std::endl;
#endif // DEBUG_TRACES
- the_simplex_tree.push_back(vertex);
- map_cgal_simplex_tree.insert(Alpha_shape_simplex_tree_pair(the_alpha_shape_vertex, vertex));
+ the_simplex.push_back(vertex);
+ map_cgal_simplex_tree.emplace(the_alpha_shape_vertex, vertex);
} else {
// alpha shape found
Simplex_tree_vertex vertex = the_map_iterator->second;
#ifdef DEBUG_TRACES
std::cout << "vertex [" << the_alpha_shape_vertex->point() << "] found in " << vertex << std::endl;
#endif // DEBUG_TRACES
- the_simplex_tree.push_back(vertex);
+ the_simplex.push_back(vertex);
}
}
// Construction of the simplex_tree
@@ -185,10 +169,7 @@ int main(int argc, char **argv) {
#ifdef DEBUG_TRACES
std::cout << "filtration = " << filtr << std::endl;
#endif // DEBUG_TRACES
- if (filtr > filtration_max) {
- filtration_max = filtr;
- }
- simplex_tree.insert_simplex(the_simplex_tree, filtr);
+ simplex_tree.insert_simplex(the_simplex, filtr);
if (the_alpha_value_iterator != the_alpha_values.end())
++the_alpha_value_iterator;
else
diff --git a/src/Alpha_complex/utilities/periodic_alpha_complex_3d_persistence.cpp b/src/Alpha_complex/utilities/periodic_alpha_complex_3d_persistence.cpp
index 186a58f8..ac72dcc4 100644
--- a/src/Alpha_complex/utilities/periodic_alpha_complex_3d_persistence.cpp
+++ b/src/Alpha_complex/utilities/periodic_alpha_complex_3d_persistence.cpp
@@ -3,6 +3,7 @@
* library for computational topology.
*
* Author(s): Vincent Rouvreau
+ * Pawel Dlotko - 2017 - Swansea University, UK
*
* Copyright (C) 2014 INRIA
*
@@ -39,7 +40,6 @@
#include <tuple>
#include <map>
#include <utility>
-#include <list>
#include <vector>
#include <cstdlib>
@@ -72,14 +72,13 @@ using Cell_handle = Alpha_shape_3::Cell_handle;
using Facet = Alpha_shape_3::Facet;
using Edge_3 = Alpha_shape_3::Edge;
using Vertex_handle = Alpha_shape_3::Vertex_handle;
-using Vertex_list = std::list<Alpha_shape_3::Vertex_handle>;
+using Vertex_list = std::vector<Alpha_shape_3::Vertex_handle>;
// gudhi type definition
using ST = Gudhi::Simplex_tree<Gudhi::Simplex_tree_options_fast_persistence>;
using Filtration_value = ST::Filtration_value;
using Simplex_tree_vertex = ST::Vertex_handle;
using Alpha_shape_simplex_tree_map = std::map<Alpha_shape_3::Vertex_handle, Simplex_tree_vertex>;
-using Alpha_shape_simplex_tree_pair = std::pair<Alpha_shape_3::Vertex_handle, Simplex_tree_vertex>;
using Simplex_tree_vector_vertex = std::vector<Simplex_tree_vertex>;
using Persistent_cohomology =
Gudhi::persistent_cohomology::Persistent_cohomology<ST, Gudhi::persistent_cohomology::Field_Zp>;
@@ -114,8 +113,14 @@ int main(int argc, char **argv) {
std::cerr << "Unable to read file " << cuboid_file << std::endl;
exit(-1);
}
+ //Checking if the cuboid is the same in x,y and z direction. If not, CGAL will not process it.
+ if ((x_max-x_min != y_max-y_min) || (x_max-x_min != z_max-z_min) || (z_max-z_min != y_max-y_min))
+ {
+ std::cerr << "The size of the cuboid in every directions is not the same." << std::endl;
+ exit(-1);
+ }
- // Retrieve the triangulation
+ // Retrieve the points
std::vector<Point_3> lp = off_reader.get_point_cloud();
// Define the periodic cube
@@ -123,7 +128,12 @@ int main(int argc, char **argv) {
// Heuristic for inserting large point sets (if pts is reasonably large)
pdt.insert(lp.begin(), lp.end(), true);
// As pdt won't be modified anymore switch to 1-sheeted cover if possible
- if (pdt.is_triangulation_in_1_sheet()) pdt.convert_to_1_sheeted_covering();
+ if (pdt.is_triangulation_in_1_sheet()) {
+ pdt.convert_to_1_sheeted_covering();
+ } else {
+ std::cerr << "ERROR: we were not able to construct a triangulation within a single periodic domain." << std::endl;
+ exit(-1);
+ }
std::cout << "Periodic Delaunay computed." << std::endl;
// alpha shape construction from points. CGAL has a strange behavior in REGULARIZED mode. This is the default mode
@@ -152,37 +162,23 @@ int main(int argc, char **argv) {
ST simplex_tree;
Alpha_shape_simplex_tree_map map_cgal_simplex_tree;
std::vector<Alpha_value_type>::iterator the_alpha_value_iterator = the_alpha_values.begin();
- int dim_max = 0;
- Filtration_value filtration_max = 0.0;
for (auto object_iterator : the_objects) {
// Retrieve Alpha shape vertex list from object
if (const Cell_handle* cell = CGAL::object_cast<Cell_handle>(&object_iterator)) {
vertex_list = from_cell<Vertex_list, Cell_handle>(*cell);
count_cells++;
- if (dim_max < 3) {
- // Cell is of dim 3
- dim_max = 3;
- }
} else if (const Facet* facet = CGAL::object_cast<Facet>(&object_iterator)) {
vertex_list = from_facet<Vertex_list, Facet>(*facet);
count_facets++;
- if (dim_max < 2) {
- // Facet is of dim 2
- dim_max = 2;
- }
} else if (const Edge_3* edge = CGAL::object_cast<Edge_3>(&object_iterator)) {
vertex_list = from_edge<Vertex_list, Edge_3>(*edge);
count_edges++;
- if (dim_max < 1) {
- // Edge_3 is of dim 1
- dim_max = 1;
- }
} else if (const Vertex_handle* vertex = CGAL::object_cast<Vertex_handle>(&object_iterator)) {
count_vertices++;
vertex_list = from_vertex<Vertex_list, Vertex_handle>(*vertex);
}
// Construction of the vector of simplex_tree vertex from list of alpha_shapes vertex
- Simplex_tree_vector_vertex the_simplex_tree;
+ Simplex_tree_vector_vertex the_simplex;
for (auto the_alpha_shape_vertex : vertex_list) {
Alpha_shape_simplex_tree_map::iterator the_map_iterator = map_cgal_simplex_tree.find(the_alpha_shape_vertex);
if (the_map_iterator == map_cgal_simplex_tree.end()) {
@@ -191,15 +187,15 @@ int main(int argc, char **argv) {
#ifdef DEBUG_TRACES
std::cout << "vertex [" << the_alpha_shape_vertex->point() << "] not found - insert " << vertex << std::endl;
#endif // DEBUG_TRACES
- the_simplex_tree.push_back(vertex);
- map_cgal_simplex_tree.insert(Alpha_shape_simplex_tree_pair(the_alpha_shape_vertex, vertex));
+ the_simplex.push_back(vertex);
+ map_cgal_simplex_tree.emplace(the_alpha_shape_vertex, vertex);
} else {
// alpha shape found
Simplex_tree_vertex vertex = the_map_iterator->second;
#ifdef DEBUG_TRACES
std::cout << "vertex [" << the_alpha_shape_vertex->point() << "] found in " << vertex << std::endl;
#endif // DEBUG_TRACES
- the_simplex_tree.push_back(vertex);
+ the_simplex.push_back(vertex);
}
}
// Construction of the simplex_tree
@@ -207,10 +203,7 @@ int main(int argc, char **argv) {
#ifdef DEBUG_TRACES
std::cout << "filtration = " << filtr << std::endl;
#endif // DEBUG_TRACES
- if (filtr > filtration_max) {
- filtration_max = filtr;
- }
- simplex_tree.insert_simplex(the_simplex_tree, filtr);
+ simplex_tree.insert_simplex(the_simplex, filtr);
if (the_alpha_value_iterator != the_alpha_values.end())
++the_alpha_value_iterator;
else
diff --git a/src/Alpha_complex/utilities/weighted_alpha_complex_3d_persistence.cpp b/src/Alpha_complex/utilities/weighted_alpha_complex_3d_persistence.cpp
index 0e73a99b..f46f1a58 100644
--- a/src/Alpha_complex/utilities/weighted_alpha_complex_3d_persistence.cpp
+++ b/src/Alpha_complex/utilities/weighted_alpha_complex_3d_persistence.cpp
@@ -44,7 +44,6 @@
#include <tuple>
#include <map>
#include <utility>
-#include <list>
#include <vector>
#include <cstdlib>
@@ -92,14 +91,13 @@ using Cell_handle = Alpha_shape_3::Cell_handle;
using Facet = Alpha_shape_3::Facet;
using Edge_3 = Alpha_shape_3::Edge;
using Vertex_handle = Alpha_shape_3::Vertex_handle;
-using Vertex_list = std::list<Alpha_shape_3::Vertex_handle>;
+using Vertex_list = std::vector<Alpha_shape_3::Vertex_handle>;
// gudhi type definition
using ST = Gudhi::Simplex_tree<Gudhi::Simplex_tree_options_fast_persistence>;
using Filtration_value = ST::Filtration_value;
using Simplex_tree_vertex = ST::Vertex_handle;
using Alpha_shape_simplex_tree_map = std::map<Alpha_shape_3::Vertex_handle, Simplex_tree_vertex>;
-using Alpha_shape_simplex_tree_pair = std::pair<Alpha_shape_3::Vertex_handle, Simplex_tree_vertex>;
using Simplex_tree_vector_vertex = std::vector<Simplex_tree_vertex>;
using Persistent_cohomology =
Gudhi::persistent_cohomology::Persistent_cohomology<ST, Gudhi::persistent_cohomology::Field_Zp>;
@@ -125,7 +123,7 @@ int main(int argc, char **argv) {
exit(-1);
}
- // Retrieve the triangulation
+ // Retrieve the points
std::vector<Point_3> lp = off_reader.get_point_cloud();
// Read weights information from file
@@ -177,37 +175,23 @@ int main(int argc, char **argv) {
ST simplex_tree;
Alpha_shape_simplex_tree_map map_cgal_simplex_tree;
std::vector<Alpha_value_type>::iterator the_alpha_value_iterator = the_alpha_values.begin();
- int dim_max = 0;
- Filtration_value filtration_max = 0.0;
for (auto object_iterator : the_objects) {
// Retrieve Alpha shape vertex list from object
if (const Cell_handle* cell = CGAL::object_cast<Cell_handle>(&object_iterator)) {
vertex_list = from_cell<Vertex_list, Cell_handle>(*cell);
count_cells++;
- if (dim_max < 3) {
- // Cell is of dim 3
- dim_max = 3;
- }
} else if (const Facet* facet = CGAL::object_cast<Facet>(&object_iterator)) {
vertex_list = from_facet<Vertex_list, Facet>(*facet);
count_facets++;
- if (dim_max < 2) {
- // Facet is of dim 2
- dim_max = 2;
- }
} else if (const Edge_3* edge = CGAL::object_cast<Edge_3>(&object_iterator)) {
vertex_list = from_edge<Vertex_list, Edge_3>(*edge);
count_edges++;
- if (dim_max < 1) {
- // Edge_3 is of dim 1
- dim_max = 1;
- }
} else if (const Vertex_handle* vertex = CGAL::object_cast<Vertex_handle>(&object_iterator)) {
count_vertices++;
vertex_list = from_vertex<Vertex_list, Vertex_handle>(*vertex);
}
// Construction of the vector of simplex_tree vertex from list of alpha_shapes vertex
- Simplex_tree_vector_vertex the_simplex_tree;
+ Simplex_tree_vector_vertex the_simplex;
for (auto the_alpha_shape_vertex : vertex_list) {
Alpha_shape_simplex_tree_map::iterator the_map_iterator = map_cgal_simplex_tree.find(the_alpha_shape_vertex);
if (the_map_iterator == map_cgal_simplex_tree.end()) {
@@ -216,15 +200,15 @@ int main(int argc, char **argv) {
#ifdef DEBUG_TRACES
std::cout << "vertex [" << the_alpha_shape_vertex->point() << "] not found - insert " << vertex << std::endl;
#endif // DEBUG_TRACES
- the_simplex_tree.push_back(vertex);
- map_cgal_simplex_tree.insert(Alpha_shape_simplex_tree_pair(the_alpha_shape_vertex, vertex));
+ the_simplex.push_back(vertex);
+ map_cgal_simplex_tree.emplace(the_alpha_shape_vertex, vertex);
} else {
// alpha shape found
Simplex_tree_vertex vertex = the_map_iterator->second;
#ifdef DEBUG_TRACES
std::cout << "vertex [" << the_alpha_shape_vertex->point() << "] found in " << vertex << std::endl;
#endif // DEBUG_TRACES
- the_simplex_tree.push_back(vertex);
+ the_simplex.push_back(vertex);
}
}
// Construction of the simplex_tree
@@ -232,10 +216,7 @@ int main(int argc, char **argv) {
#ifdef DEBUG_TRACES
std::cout << "filtration = " << filtr << std::endl;
#endif // DEBUG_TRACES
- if (filtr > filtration_max) {
- filtration_max = filtr;
- }
- simplex_tree.insert_simplex(the_simplex_tree, filtr);
+ simplex_tree.insert_simplex(the_simplex, filtr);
if (the_alpha_value_iterator != the_alpha_values.end())
++the_alpha_value_iterator;
else
diff --git a/src/Alpha_complex/utilities/weighted_periodic_alpha_complex_3d_persistence.cpp b/src/Alpha_complex/utilities/weighted_periodic_alpha_complex_3d_persistence.cpp
index 13634ff7..0fe8931f 100644
--- a/src/Alpha_complex/utilities/weighted_periodic_alpha_complex_3d_persistence.cpp
+++ b/src/Alpha_complex/utilities/weighted_periodic_alpha_complex_3d_persistence.cpp
@@ -3,6 +3,7 @@
* library for computational topology.
*
* Author(s): Vincent Rouvreau
+ * Pawel Dlotko - 2017 - Swansea University, UK
*
* Copyright (C) 2014 INRIA
*
@@ -38,7 +39,6 @@
#include <tuple>
#include <map>
#include <utility>
-#include <list>
#include <vector>
#include <cstdlib>
@@ -74,14 +74,13 @@ using Cell_handle = Alpha_shape_3::Cell_handle;
using Facet = Alpha_shape_3::Facet;
using Edge_3 = Alpha_shape_3::Edge;
using Vertex_handle = Alpha_shape_3::Vertex_handle;
-using Vertex_list = std::list<Alpha_shape_3::Vertex_handle>;
+using Vertex_list = std::vector<Alpha_shape_3::Vertex_handle>;
// gudhi type definition
using ST = Gudhi::Simplex_tree<Gudhi::Simplex_tree_options_fast_persistence>;
using Filtration_value = ST::Filtration_value;
using Simplex_tree_vertex = ST::Vertex_handle;
using Alpha_shape_simplex_tree_map = std::map<Alpha_shape_3::Vertex_handle, Simplex_tree_vertex>;
-using Alpha_shape_simplex_tree_pair = std::pair<Alpha_shape_3::Vertex_handle, Simplex_tree_vertex>;
using Simplex_tree_vector_vertex = std::vector<Simplex_tree_vertex>;
using Persistent_cohomology =
Gudhi::persistent_cohomology::Persistent_cohomology<ST, Gudhi::persistent_cohomology::Field_Zp>;
@@ -112,18 +111,48 @@ int main(int argc, char* const argv[]) {
usage(argv[0]);
}
- // Retrieve the triangulation
+ // Retrieve the points
std::vector<Point_3> lp = off_reader.get_point_cloud();
+ // Read iso_cuboid_3 information from file
+ std::ifstream iso_cuboid_str(argv[3]);
+ double x_min, y_min, z_min, x_max, y_max, z_max;
+ if (iso_cuboid_str.is_open()) {
+ if (!(iso_cuboid_str >> x_min >> y_min >> z_min >> x_max >> y_max >> z_max)) {
+ std::cerr << argv[3] << " - Bad file format." << std::endl;
+ usage(argv[0]);
+ }
+
+ } else {
+ std::cerr << "Unable to read file " << argv[3] << std::endl;
+ usage(argv[0]);
+ }
+ //Checking if the cuboid is the same in x,y and z direction. If not, CGAL will not process it.
+ if ((x_max-x_min != y_max-y_min) || (x_max-x_min != z_max-z_min) || (z_max-z_min != y_max-y_min))
+ {
+ std::cerr << "The size of the cuboid in every directions is not the same." << std::endl;
+ exit(-1);
+ }
+
+ double maximal_possible_weight = 0.015625 * (x_max-x_min) * (x_max-x_min);
+
// Read weights information from file
std::ifstream weights_ifstr(argv[2]);
std::vector<Weighted_point_3> wp;
- if (weights_ifstr.good()) {
+ if (weights_ifstr.is_open()) {
double weight = 0.0;
std::size_t index = 0;
wp.reserve(lp.size());
// Attempt read the weight in a double format, return false if it fails
while ((weights_ifstr >> weight) && (index < lp.size())) {
+ if ((weight >= maximal_possible_weight) || (weight < 0))
+ {
+ std::cerr << "At line " << (index + 1) << ", the weight (" << weight
+ << ") is negative or more than or equal to maximal possible weight (" << maximal_possible_weight
+ << ") = 1/64*cuboid length squared, which is not an acceptable input." << std::endl;
+ exit(-1);
+ }
+
wp.push_back(Weighted_point_3(lp[index], weight));
index++;
}
@@ -136,23 +165,18 @@ int main(int argc, char* const argv[]) {
usage(argv[0]);
}
- // Read iso_cuboid_3 information from file
- std::ifstream iso_cuboid_str(argv[3]);
- double x_min, y_min, z_min, x_max, y_max, z_max;
- if (iso_cuboid_str.good()) {
- iso_cuboid_str >> x_min >> y_min >> z_min >> x_max >> y_max >> z_max;
- } else {
- std::cerr << "Unable to read file " << argv[3] << std::endl;
- usage(argv[0]);
- }
-
// Define the periodic cube
P3RT3 prt(PK::Iso_cuboid_3(x_min, y_min, z_min, x_max, y_max, z_max));
// Heuristic for inserting large point sets (if pts is reasonably large)
prt.insert(wp.begin(), wp.end(), true);
// As prt won't be modified anymore switch to 1-sheeted cover if possible
- if (prt.is_triangulation_in_1_sheet()) prt.convert_to_1_sheeted_covering();
- std::cout << "Periodic Delaunay computed." << std::endl;
+ if (prt.is_triangulation_in_1_sheet()) {
+ prt.convert_to_1_sheeted_covering();
+ } else {
+ std::cerr << "ERROR: we were not able to construct a triangulation within a single periodic domain." << std::endl;
+ exit(-1);
+ }
+ std::cout << "Weighted Periodic Delaunay computed." << std::endl;
// alpha shape construction from points. CGAL has a strange behavior in REGULARIZED mode. This is the default mode
// Maybe need to set it to GENERAL mode
@@ -180,37 +204,23 @@ int main(int argc, char* const argv[]) {
ST simplex_tree;
Alpha_shape_simplex_tree_map map_cgal_simplex_tree;
std::vector<Alpha_value_type>::iterator the_alpha_value_iterator = the_alpha_values.begin();
- int dim_max = 0;
- Filtration_value filtration_max = 0.0;
for (auto object_iterator : the_objects) {
// Retrieve Alpha shape vertex list from object
if (const Cell_handle* cell = CGAL::object_cast<Cell_handle>(&object_iterator)) {
vertex_list = from_cell<Vertex_list, Cell_handle>(*cell);
count_cells++;
- if (dim_max < 3) {
- // Cell is of dim 3
- dim_max = 3;
- }
} else if (const Facet* facet = CGAL::object_cast<Facet>(&object_iterator)) {
vertex_list = from_facet<Vertex_list, Facet>(*facet);
count_facets++;
- if (dim_max < 2) {
- // Facet is of dim 2
- dim_max = 2;
- }
} else if (const Edge_3* edge = CGAL::object_cast<Edge_3>(&object_iterator)) {
vertex_list = from_edge<Vertex_list, Edge_3>(*edge);
count_edges++;
- if (dim_max < 1) {
- // Edge_3 is of dim 1
- dim_max = 1;
- }
} else if (const Vertex_handle* vertex = CGAL::object_cast<Vertex_handle>(&object_iterator)) {
count_vertices++;
vertex_list = from_vertex<Vertex_list, Vertex_handle>(*vertex);
}
// Construction of the vector of simplex_tree vertex from list of alpha_shapes vertex
- Simplex_tree_vector_vertex the_simplex_tree;
+ Simplex_tree_vector_vertex the_simplex;
for (auto the_alpha_shape_vertex : vertex_list) {
Alpha_shape_simplex_tree_map::iterator the_map_iterator = map_cgal_simplex_tree.find(the_alpha_shape_vertex);
if (the_map_iterator == map_cgal_simplex_tree.end()) {
@@ -219,15 +229,15 @@ int main(int argc, char* const argv[]) {
#ifdef DEBUG_TRACES
std::cout << "vertex [" << the_alpha_shape_vertex->point() << "] not found - insert " << vertex << std::endl;
#endif // DEBUG_TRACES
- the_simplex_tree.push_back(vertex);
- map_cgal_simplex_tree.insert(Alpha_shape_simplex_tree_pair(the_alpha_shape_vertex, vertex));
+ the_simplex.push_back(vertex);
+ map_cgal_simplex_tree.emplace(the_alpha_shape_vertex, vertex);
} else {
// alpha shape found
Simplex_tree_vertex vertex = the_map_iterator->second;
#ifdef DEBUG_TRACES
std::cout << "vertex [" << the_alpha_shape_vertex->point() << "] found in " << vertex << std::endl;
#endif // DEBUG_TRACES
- the_simplex_tree.push_back(vertex);
+ the_simplex.push_back(vertex);
}
}
// Construction of the simplex_tree
@@ -235,10 +245,7 @@ int main(int argc, char* const argv[]) {
#ifdef DEBUG_TRACES
std::cout << "filtration = " << filtr << std::endl;
#endif // DEBUG_TRACES
- if (filtr > filtration_max) {
- filtration_max = filtr;
- }
- simplex_tree.insert_simplex(the_simplex_tree, filtr);
+ simplex_tree.insert_simplex(the_simplex, filtr);
if (the_alpha_value_iterator != the_alpha_values.end())
++the_alpha_value_iterator;
else
diff --git a/src/Bottleneck_distance/include/gudhi/Neighbors_finder.h b/src/Bottleneck_distance/include/gudhi/Neighbors_finder.h
index a6b9b021..dc804630 100644
--- a/src/Bottleneck_distance/include/gudhi/Neighbors_finder.h
+++ b/src/Bottleneck_distance/include/gudhi/Neighbors_finder.h
@@ -44,7 +44,7 @@ struct Square_query {
typedef Internal_point Point_d;
typedef double FT;
bool contains(Point_d p) const {
- return std::abs(p.x()-c.x()) <= size && std::abs(p.y()-c.y()) <= size;
+ return std::max(std::abs(p.x()-c.x()), std::abs(p.y()-c.y())) <= size;
}
bool inner_range_intersects(CGAL::Kd_tree_rectangle<FT, D> const&r) const {
return
diff --git a/src/Doxyfile b/src/Doxyfile
index 429bf6a1..2d5adea1 100644
--- a/src/Doxyfile
+++ b/src/Doxyfile
@@ -38,7 +38,7 @@ PROJECT_NAME = "GUDHI"
# could be handy for archiving the generated documentation or if some version
# control system is used.
-PROJECT_NUMBER = "2.0.1"
+PROJECT_NUMBER = "2.1.0.rc1"
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
diff --git a/src/Persistence_representations/include/gudhi/PSSK.h b/src/Persistence_representations/include/gudhi/PSSK.h
index e2d4225e..630f5623 100644
--- a/src/Persistence_representations/include/gudhi/PSSK.h
+++ b/src/Persistence_representations/include/gudhi/PSSK.h
@@ -121,10 +121,10 @@ void PSSK::construct(const std::vector<std::pair<double, double> >& intervals_,
for (size_t pt_nr = 0; pt_nr != intervals_.size(); ++pt_nr) {
// compute the value of intervals_[pt_nr] in the grid:
- int x_grid = static_cast<int>((intervals_[pt_nr].first - this->min_) /
- (this->max_ - this->min_) * number_of_pixels);
- int y_grid = static_cast<int>((intervals_[pt_nr].second - this->min_) /
- (this->max_ - this->min_) * number_of_pixels);
+ int x_grid =
+ static_cast<int>((intervals_[pt_nr].first - this->min_) / (this->max_ - this->min_) * number_of_pixels);
+ int y_grid =
+ static_cast<int>((intervals_[pt_nr].second - this->min_) / (this->max_ - this->min_) * number_of_pixels);
if (dbg) {
std::cerr << "point : " << intervals_[pt_nr].first << " , " << intervals_[pt_nr].second << std::endl;
diff --git a/src/Persistence_representations/include/gudhi/Persistence_heat_maps.h b/src/Persistence_representations/include/gudhi/Persistence_heat_maps.h
index ae1740a7..a80c3c40 100644
--- a/src/Persistence_representations/include/gudhi/Persistence_heat_maps.h
+++ b/src/Persistence_representations/include/gudhi/Persistence_heat_maps.h
@@ -582,10 +582,10 @@ void Persistence_heat_maps<Scalling_of_kernels>::construct(const std::vector<std
for (size_t pt_nr = 0; pt_nr != intervals_.size(); ++pt_nr) {
// compute the value of intervals_[pt_nr] in the grid:
- int x_grid = static_cast<int>((intervals_[pt_nr].first - this->min_) /
- (this->max_ - this->min_) * number_of_pixels);
- int y_grid = static_cast<int>((intervals_[pt_nr].second - this->min_) /
- (this->max_ - this->min_) * number_of_pixels);
+ int x_grid =
+ static_cast<int>((intervals_[pt_nr].first - this->min_) / (this->max_ - this->min_) * number_of_pixels);
+ int y_grid =
+ static_cast<int>((intervals_[pt_nr].second - this->min_) / (this->max_ - this->min_) * number_of_pixels);
if (dbg) {
std::cerr << "point : " << intervals_[pt_nr].first << " , " << intervals_[pt_nr].second << std::endl;
@@ -797,8 +797,7 @@ void Persistence_heat_maps<Scalling_of_kernels>::load_from_file(const char* file
std::string temp;
std::getline(in, temp);
-
- while (!in.eof()) {
+ while (in.good()) {
std::getline(in, temp);
std::stringstream lineSS;
lineSS << temp;
diff --git a/src/Persistence_representations/include/gudhi/Persistence_intervals.h b/src/Persistence_representations/include/gudhi/Persistence_intervals.h
index 1ed97882..3d04d8b7 100644
--- a/src/Persistence_representations/include/gudhi/Persistence_intervals.h
+++ b/src/Persistence_representations/include/gudhi/Persistence_intervals.h
@@ -402,9 +402,8 @@ std::vector<double> Persistence_intervals::characteristic_function_of_diagram(do
}
for (size_t pos = beginIt; pos != endIt; ++pos) {
- result[pos] +=
- ((x_max - x_min) / static_cast<double>(number_of_bins)) *
- (this->intervals[i].second - this->intervals[i].first);
+ result[pos] += ((x_max - x_min) / static_cast<double>(number_of_bins)) *
+ (this->intervals[i].second - this->intervals[i].first);
}
if (dbg) {
std::cerr << "Result at this stage \n";
diff --git a/src/Persistence_representations/include/gudhi/Persistence_intervals_with_distances.h b/src/Persistence_representations/include/gudhi/Persistence_intervals_with_distances.h
index 2a3858bf..79908883 100644
--- a/src/Persistence_representations/include/gudhi/Persistence_intervals_with_distances.h
+++ b/src/Persistence_representations/include/gudhi/Persistence_intervals_with_distances.h
@@ -26,7 +26,6 @@
#include <gudhi/Persistence_intervals.h>
#include <gudhi/Bottleneck.h>
-
#include <limits>
namespace Gudhi {
diff --git a/src/Persistence_representations/include/gudhi/Persistence_landscape.h b/src/Persistence_representations/include/gudhi/Persistence_landscape.h
index 72498edf..c5aa7867 100644
--- a/src/Persistence_representations/include/gudhi/Persistence_landscape.h
+++ b/src/Persistence_representations/include/gudhi/Persistence_landscape.h
@@ -79,14 +79,16 @@ class Persistence_landscape {
/**
* Constructor that takes as an input a vector of birth-death pairs.
**/
- Persistence_landscape(const std::vector<std::pair<double, double> >& p, size_t number_of_levels = std::numeric_limits<size_t>::max() );
+ Persistence_landscape(const std::vector<std::pair<double, double> >& p,
+ size_t number_of_levels = std::numeric_limits<size_t>::max());
/**
* Constructor that reads persistence intervals from file and creates persistence landscape. The format of the
*input file is the following: in each line we put birth-death pair. Last line is assumed
* to be empty. Even if the points within a line are not ordered, they will be ordered while the input is read.
**/
- Persistence_landscape(const char* filename, size_t dimension = std::numeric_limits<unsigned>::max() , size_t number_of_levels = std::numeric_limits<size_t>::max() );
+ Persistence_landscape(const char* filename, size_t dimension = std::numeric_limits<unsigned>::max(),
+ size_t number_of_levels = std::numeric_limits<size_t>::max());
/**
* This procedure loads a landscape from file. It erase all the data that was previously stored in this landscape.
@@ -285,7 +287,7 @@ class Persistence_landscape {
*distance, we need to take its absolute value. This is the purpose of this procedure.
**/
Persistence_landscape abs();
-
+
Persistence_landscape* new_abs();
/**
@@ -453,7 +455,8 @@ class Persistence_landscape {
size_t number_of_functions_for_vectorization;
size_t number_of_functions_for_projections_to_reals;
- void construct_persistence_landscape_from_barcode(const std::vector<std::pair<double, double> >& p , size_t number_of_levels = std::numeric_limits<size_t>::max());
+ void construct_persistence_landscape_from_barcode(const std::vector<std::pair<double, double> >& p,
+ size_t number_of_levels = std::numeric_limits<size_t>::max());
Persistence_landscape multiply_lanscape_by_real_number_not_overwrite(double x) const;
void multiply_lanscape_by_real_number_overwrite(double x);
friend double compute_maximal_distance_non_symmetric(const Persistence_landscape& pl1,
@@ -473,7 +476,7 @@ Persistence_landscape::Persistence_landscape(const char* filename, size_t dimens
} else {
barcode = read_persistence_intervals_in_one_dimension_from_file(filename);
}
- this->construct_persistence_landscape_from_barcode(barcode,number_of_levels);
+ this->construct_persistence_landscape_from_barcode(barcode, number_of_levels);
this->set_up_numbers_of_functions_for_vectorization_and_projections_to_reals();
}
@@ -506,14 +509,14 @@ bool Persistence_landscape::operator==(const Persistence_landscape& rhs) const {
return true;
}
-Persistence_landscape::Persistence_landscape(const std::vector<std::pair<double, double> >& p,size_t number_of_levels) {
- this->construct_persistence_landscape_from_barcode(p,number_of_levels);
+Persistence_landscape::Persistence_landscape(const std::vector<std::pair<double, double> >& p,
+ size_t number_of_levels) {
+ this->construct_persistence_landscape_from_barcode(p, number_of_levels);
this->set_up_numbers_of_functions_for_vectorization_and_projections_to_reals();
}
void Persistence_landscape::construct_persistence_landscape_from_barcode(
- const std::vector<std::pair<double, double> >& p, size_t number_of_levels)
- {
+ const std::vector<std::pair<double, double> >& p, size_t number_of_levels) {
bool dbg = false;
if (dbg) {
std::cerr << "Persistence_landscape::Persistence_landscape( const std::vector< std::pair< double , double > >& p )"
@@ -648,12 +651,11 @@ void Persistence_landscape::construct_persistence_landscape_from_barcode(
lambda_n.erase(std::unique(lambda_n.begin(), lambda_n.end()), lambda_n.end());
this->land.push_back(lambda_n);
-
+
++number_of_levels_in_the_landscape;
- if ( number_of_levels == number_of_levels_in_the_landscape )
- {
- break;
- }
+ if (number_of_levels == number_of_levels_in_the_landscape) {
+ break;
+ }
}
}
@@ -857,58 +859,47 @@ Persistence_landscape Persistence_landscape::abs() {
return result;
}
+Persistence_landscape* Persistence_landscape::new_abs() {
+ Persistence_landscape* result = new Persistence_landscape(*this);
+ for (size_t level = 0; level != this->land.size(); ++level) {
+ if (AbsDbg) {
+ std::cout << "level: " << level << std::endl;
+ }
+ std::vector<std::pair<double, double> > lambda_n;
+ lambda_n.push_back(std::make_pair(-std::numeric_limits<int>::max(), 0));
+ for (size_t i = 1; i != this->land[level].size(); ++i) {
+ if (AbsDbg) {
+ std::cout << "this->land[" << level << "][" << i << "] : " << this->land[level][i].first << " "
+ << this->land[level][i].second << std::endl;
+ }
+ // if a line segment between this->land[level][i-1] and this->land[level][i] crosses the x-axis, then we have to
+ // add one landscape point t o result
+ if ((this->land[level][i - 1].second) * (this->land[level][i].second) < 0) {
+ double zero =
+ find_zero_of_a_line_segment_between_those_two_points(this->land[level][i - 1], this->land[level][i]);
-Persistence_landscape* Persistence_landscape::new_abs()
-{
- Persistence_landscape* result = new Persistence_landscape(*this);
- for (size_t level = 0; level != this->land.size(); ++level)
- {
- if (AbsDbg)
- {
- std::cout << "level: " << level << std::endl;
- }
- std::vector<std::pair<double, double> > lambda_n;
- lambda_n.push_back(std::make_pair(-std::numeric_limits<int>::max(), 0));
- for (size_t i = 1; i != this->land[level].size(); ++i)
- {
- if (AbsDbg)
- {
- std::cout << "this->land[" << level << "][" << i << "] : " << this->land[level][i].first << " "
- << this->land[level][i].second << std::endl;
- }
- // if a line segment between this->land[level][i-1] and this->land[level][i] crosses the x-axis, then we have to
- // add one landscape point t o result
- if ((this->land[level][i - 1].second) * (this->land[level][i].second) < 0) {
- double zero =
- find_zero_of_a_line_segment_between_those_two_points(this->land[level][i - 1], this->land[level][i]);
-
- lambda_n.push_back(std::make_pair(zero, 0));
- lambda_n.push_back(std::make_pair(this->land[level][i].first, fabs(this->land[level][i].second)));
- if (AbsDbg)
- {
- std::cout << "Adding pair : (" << zero << ",0)" << std::endl;
- std::cout << "In the same step adding pair : (" << this->land[level][i].first << ","
- << fabs(this->land[level][i].second) << ") " << std::endl;
- std::cin.ignore();
- }
- }
- else
- {
- lambda_n.push_back(std::make_pair(this->land[level][i].first, fabs(this->land[level][i].second)));
- if (AbsDbg)
- {
- std::cout << "Adding pair : (" << this->land[level][i].first << "," << fabs(this->land[level][i].second)
- << ") " << std::endl;
- std::cin.ignore();
- }
- }
- }
- result->land.push_back(lambda_n);
- }
- return result;
+ lambda_n.push_back(std::make_pair(zero, 0));
+ lambda_n.push_back(std::make_pair(this->land[level][i].first, fabs(this->land[level][i].second)));
+ if (AbsDbg) {
+ std::cout << "Adding pair : (" << zero << ",0)" << std::endl;
+ std::cout << "In the same step adding pair : (" << this->land[level][i].first << ","
+ << fabs(this->land[level][i].second) << ") " << std::endl;
+ std::cin.ignore();
+ }
+ } else {
+ lambda_n.push_back(std::make_pair(this->land[level][i].first, fabs(this->land[level][i].second)));
+ if (AbsDbg) {
+ std::cout << "Adding pair : (" << this->land[level][i].first << "," << fabs(this->land[level][i].second)
+ << ") " << std::endl;
+ std::cin.ignore();
+ }
+ }
+ }
+ result->land.push_back(lambda_n);
+ }
+ return result;
}
-
Persistence_landscape Persistence_landscape::multiply_lanscape_by_real_number_not_overwrite(double x) const {
std::vector<std::vector<std::pair<double, double> > > result(this->land.size());
for (size_t dim = 0; dim != this->land.size(); ++dim) {
@@ -954,7 +945,7 @@ void Persistence_landscape::load_landscape_from_file(const char* filename) {
std::vector<std::pair<double, double> > landscapeAtThisLevel;
bool isThisAFirsLine = true;
- while (!in.eof()) {
+ while (in.good()) {
getline(in, line);
if (!(line.length() == 0 || line[0] == '#')) {
std::stringstream lineSS;
diff --git a/src/Persistence_representations/include/gudhi/Persistence_vectors.h b/src/Persistence_representations/include/gudhi/Persistence_vectors.h
index 39df37e0..63577e46 100644
--- a/src/Persistence_representations/include/gudhi/Persistence_vectors.h
+++ b/src/Persistence_representations/include/gudhi/Persistence_vectors.h
@@ -618,9 +618,7 @@ void Vector_distances_in_diagram<F>::load_from_file(const char* filename) {
}
double number;
- while (true) {
- in >> number;
- if (in.eof()) break;
+ while (in >> number) {
this->sorted_vector_of_distances.push_back(number);
}
in.close();
diff --git a/src/Persistence_representations/include/gudhi/read_persistence_from_file.h b/src/Persistence_representations/include/gudhi/read_persistence_from_file.h
index 770da15b..450c223c 100644
--- a/src/Persistence_representations/include/gudhi/read_persistence_from_file.h
+++ b/src/Persistence_representations/include/gudhi/read_persistence_from_file.h
@@ -50,81 +50,73 @@ namespace Persistence_representations {
* The procedure returns vector of persistence pairs.
**/
std::vector<std::pair<double, double> > read_persistence_intervals_in_one_dimension_from_file(
- std::string const& filename, int dimension = -1, double what_to_substitute_for_infinite_bar = -1) {
+ std::string const& filename, int dimension = -1, double what_to_substitute_for_infinite_bar = -1) {
bool dbg = false;
std::string line;
- std::vector<std::pair<double, double> > barcode_initial = read_persistence_intervals_in_dimension(filename,(int)dimension);
+ std::vector<std::pair<double, double> > barcode_initial =
+ read_persistence_intervals_in_dimension(filename, (int)dimension);
std::vector<std::pair<double, double> > final_barcode;
- final_barcode.reserve( barcode_initial.size() );
-
- if ( dbg )
- {
- std::cerr << "Here are the intervals that we read from the file : \n";
- for ( size_t i = 0 ; i != barcode_initial.size() ; ++i )
- {
- std::cout << barcode_initial[i].first << " " << barcode_initial[i].second << std::endl;
- }
- getchar();
+ final_barcode.reserve(barcode_initial.size());
+
+ if (dbg) {
+ std::cerr << "Here are the intervals that we read from the file : \n";
+ for (size_t i = 0; i != barcode_initial.size(); ++i) {
+ std::cout << barcode_initial[i].first << " " << barcode_initial[i].second << std::endl;
+ }
+ getchar();
}
-
- for ( size_t i = 0 ; i != barcode_initial.size() ; ++i )
- {
- if ( dbg )
- {
- std::cout << "COnsidering interval : " << barcode_initial[i].first << " " << barcode_initial[i].second << std::endl;
- }
- // if ( barcode_initial[i].first == barcode_initial[i].second )
- //{
- // if ( dbg )std::cout << "It has zero length \n";
- // continue;//zero length intervals are not relevant, so we skip all of them.
- //}
-
- if ( barcode_initial[i].first > barcode_initial[i].second )//note that in this case barcode_initial[i].second != std::numeric_limits<double>::infinity()
- {
- if ( dbg )std::cout << "Swap and enter \n";
- //swap them to make sure that birth < death
- final_barcode.push_back( std::pair<double,double>( barcode_initial[i].second , barcode_initial[i].first ) );
- continue;
- }
- else
- {
- if ( barcode_initial[i].second != std::numeric_limits<double>::infinity() )
- {
- if ( dbg )std::cout << "Simply enters\n";
- //in this case, due to the previous conditions we know that barcode_initial[i].first < barcode_initial[i].second, so we put them as they are
- final_barcode.push_back( std::pair<double,double>( barcode_initial[i].first , barcode_initial[i].second ) );
- }
- }
-
- if ( (barcode_initial[i].second == std::numeric_limits<double>::infinity() ) && ( what_to_substitute_for_infinite_bar != -1 ) )
- {
- if ( barcode_initial[i].first < what_to_substitute_for_infinite_bar )//if only birth < death.
- {
- final_barcode.push_back( std::pair<double,double>( barcode_initial[i].first , what_to_substitute_for_infinite_bar ) );
- }
- }
- else
- {
- //if the variable what_to_substitute_for_infinite_bar is not set, then we ignore all the infinite bars.
- }
+
+ for (size_t i = 0; i != barcode_initial.size(); ++i) {
+ if (dbg) {
+ std::cout << "COnsidering interval : " << barcode_initial[i].first << " " << barcode_initial[i].second
+ << std::endl;
+ }
+ // if ( barcode_initial[i].first == barcode_initial[i].second )
+ //{
+ // if ( dbg )std::cout << "It has zero length \n";
+ // continue;//zero length intervals are not relevant, so we skip all of them.
+ //}
+
+ if (barcode_initial[i].first >
+ barcode_initial[i]
+ .second) // note that in this case barcode_initial[i].second != std::numeric_limits<double>::infinity()
+ {
+ if (dbg) std::cout << "Swap and enter \n";
+ // swap them to make sure that birth < death
+ final_barcode.push_back(std::pair<double, double>(barcode_initial[i].second, barcode_initial[i].first));
+ continue;
+ } else {
+ if (barcode_initial[i].second != std::numeric_limits<double>::infinity()) {
+ if (dbg) std::cout << "Simply enters\n";
+ // in this case, due to the previous conditions we know that barcode_initial[i].first <
+ // barcode_initial[i].second, so we put them as they are
+ final_barcode.push_back(std::pair<double, double>(barcode_initial[i].first, barcode_initial[i].second));
+ }
+ }
+
+ if ((barcode_initial[i].second == std::numeric_limits<double>::infinity()) &&
+ (what_to_substitute_for_infinite_bar != -1)) {
+ if (barcode_initial[i].first < what_to_substitute_for_infinite_bar) // if only birth < death.
+ {
+ final_barcode.push_back(
+ std::pair<double, double>(barcode_initial[i].first, what_to_substitute_for_infinite_bar));
+ }
+ } else {
+ // if the variable what_to_substitute_for_infinite_bar is not set, then we ignore all the infinite bars.
+ }
}
-
-
- if ( dbg )
- {
- std::cerr << "Here are the final bars that we are sending further : \n";
- for ( size_t i = 0 ; i != final_barcode.size() ; ++i )
- {
- std::cout << final_barcode[i].first << " " << final_barcode[i].second << std::endl;
- }
- std::cerr << "final_barcode.size() : " << final_barcode.size() << std::endl;
- getchar();
+
+ if (dbg) {
+ std::cerr << "Here are the final bars that we are sending further : \n";
+ for (size_t i = 0; i != final_barcode.size(); ++i) {
+ std::cout << final_barcode[i].first << " " << final_barcode[i].second << std::endl;
+ }
+ std::cerr << "final_barcode.size() : " << final_barcode.size() << std::endl;
+ getchar();
}
-
-
-
- return final_barcode;
+
+ return final_barcode;
} // read_persistence_intervals_in_one_dimension_from_file
} // namespace Persistence_representations
diff --git a/src/Persistence_representations/test/persistence_lanscapes_test.cpp b/src/Persistence_representations/test/persistence_lanscapes_test.cpp
index 47737784..e7267bec 100644
--- a/src/Persistence_representations/test/persistence_lanscapes_test.cpp
+++ b/src/Persistence_representations/test/persistence_lanscapes_test.cpp
@@ -58,8 +58,6 @@ BOOST_AUTO_TEST_CASE(check_computations_of_integrals) {
std::vector<std::pair<double, double> > diag =
read_persistence_intervals_in_one_dimension_from_file("data/file_with_diagram");
Persistence_landscape p(diag);
- //double integral = p.compute_integral_of_landscape();
- //BOOST_CHECK(fabs(integral - 2.34992) <= 0.00001);
GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.compute_integral_of_landscape(), 2.34992, epsilon);
}
@@ -97,10 +95,8 @@ BOOST_AUTO_TEST_CASE(check_computations_of_integrals_for_each_level_separatelly)
integrals_for_different_levels.push_back(0.000195296);
for (size_t level = 0; level != p.size(); ++level) {
- //double integral = p.compute_integral_of_a_level_of_a_landscape(level);
GUDHI_TEST_FLOAT_EQUALITY_CHECK(p.compute_integral_of_a_level_of_a_landscape(level),
integrals_for_different_levels[level], epsilon);
- //BOOST_CHECK(fabs(integral - integrals_for_different_levels[level]) <= 0.00001);
}
}
diff --git a/src/Persistent_cohomology/doc/Intro_persistent_cohomology.h b/src/Persistent_cohomology/doc/Intro_persistent_cohomology.h
index 62bbbfc5..ceaea505 100644
--- a/src/Persistent_cohomology/doc/Intro_persistent_cohomology.h
+++ b/src/Persistent_cohomology/doc/Intro_persistent_cohomology.h
@@ -165,7 +165,7 @@ outputs its persistence diagram.
\li <a href="_alpha_complex_2alpha_complex_3d_persistence_8cpp-example.html">
Alpha_complex/alpha_complex_3d_persistence.cpp</a> computes the persistent homology with
\f$\mathbb{Z}/2\mathbb{Z}\f$ coefficients of the alpha complex on points sampling from an OFF file.
-\code $> ./alpha_complex_3d_persistence ../../data/points/tore3D_300.off 2 0.45 \endcode
+\code $> ./alpha_complex_3d_persistence ../../data/points/tore3D_300.off -p 2 -m 0.45 \endcode
\code Simplex_tree dim: 3
2 0 0 inf
2 1 0.0682162 1.0001
@@ -177,7 +177,7 @@ Alpha_complex/exact_alpha_complex_3d_persistence.cpp</a> computes the persistent
\f$\mathbb{Z}/2\mathbb{Z}\f$ coefficients of the alpha complex on points sampling from an OFF file.
Here, as CGAL computes the exact values, it is slower, but it is necessary when points are on a grid
for instance.
-\code $> ./exact_alpha_complex_3d_persistence ../../data/points/sphere3D_pts_on_grid.off 2 0.1 \endcode
+\code $> ./exact_alpha_complex_3d_persistence ../../data/points/sphere3D_pts_on_grid.off -p 2 -m 0.1 \endcode
\code Simplex_tree dim: 3
2 0 0 inf
2 2 0.0002 0.2028 \endcode
@@ -187,7 +187,7 @@ Alpha_complex/weighted_alpha_complex_3d_persistence.cpp</a> computes the persist
\f$\mathbb{Z}/2\mathbb{Z}\f$ coefficients of the weighted alpha complex on points sampling from an OFF file
and a weights file.
\code $> ./weighted_alpha_complex_3d_persistence ../../data/points/tore3D_300.off
-../../data/points/tore3D_300.weights 2 0.45 \endcode
+../../data/points/tore3D_300.weights -p 2 -m 0.45 \endcode
\code Simplex_tree dim: 3
2 0 -1 inf
2 1 -0.931784 0.000103311
@@ -208,8 +208,10 @@ Simplex_tree dim: 3
\li <a href="_alpha_complex_2periodic_alpha_complex_3d_persistence_8cpp-example.html">
Alpha_complex/periodic_alpha_complex_3d_persistence.cpp</a> computes the persistent homology with
\f$\mathbb{Z}/2\mathbb{Z}\f$ coefficients of the periodic alpha complex on points sampling from an OFF file.
+The second parameter is a \ref FileFormatsIsoCuboid file with coordinates of the periodic cuboid.
+Note that the lengths of the sides of the periodic cuboid have to be the same.
\code $> ./periodic_alpha_complex_3d_persistence ../../data/points/grid_10_10_10_in_0_1.off
-../../data/points/iso_cuboid_3_in_0_1.txt 3 1.0 \endcode
+../../data/points/iso_cuboid_3_in_0_1.txt -p 3 -m 1.0 \endcode
\code Periodic Delaunay computed.
Simplex_tree dim: 3
3 0 0 inf
@@ -221,6 +223,27 @@ Simplex_tree dim: 3
3 2 0.005 inf
3 3 0.0075 inf \endcode
+\li <a href="_persistent_cohomology_2weighted_periodic_alpha_complex_3d_persistence_8cpp-example.html">
+Persistent_cohomology/weighted_periodic_alpha_complex_3d_persistence.cpp</a> computes the persistent homology with
+\f$\mathbb{Z}/2\mathbb{Z}\f$ coefficients of the periodic alpha complex on weighted points from an OFF file. The
+additional parameters of this program are:<br>
+(a) The file with the weights of points. The file consist of a sequence of numbers (as many as points).
+Note that the weight of each single point have to be bounded by 1/64 times the square of the cuboid edge length.<br>
+(b) A \ref FileFormatsIsoCuboid file with coordinates of the periodic cuboid.
+Note that the lengths of the sides of the periodic cuboid have to be the same.<br>
+\code $> ./weighted_periodic_alpha_complex_3d_persistence ../../data/points/shifted_sphere.off
+../../data/points/shifted_sphere.weights ../../data/points/iso_cuboid_3_in_0_10.txt 3 1.0 \endcode
+\code Weighted Periodic Delaunay computed.
+Simplex_tree dim: 3
+3 0 -0.0001 inf
+3 1 16.0264 inf
+3 1 16.0273 inf
+3 1 16.0303 inf
+3 2 36.8635 inf
+3 2 36.8704 inf
+3 2 36.8838 inf
+3 3 58.6783 inf \endcode
+
\li <a href="_persistent_cohomology_2plain_homology_8cpp-example.html">
Persistent_cohomology/plain_homology.cpp</a> computes the plain homology of a simple simplicial complex without
filtration values.
diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h
index cb6ab309..4094af25 100644
--- a/src/Simplex_tree/include/gudhi/Simplex_tree.h
+++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h
@@ -106,8 +106,9 @@ class Simplex_tree {
};
struct Key_simplex_base_dummy {
Key_simplex_base_dummy() {}
- void assign_key(Simplex_key) { }
- Simplex_key key() const { assert(false); return -1; }
+ // Undefined so it will not link
+ void assign_key(Simplex_key);
+ Simplex_key key() const;
};
typedef typename std::conditional<Options::store_key, Key_simplex_base_real, Key_simplex_base_dummy>::type
Key_simplex_base;
@@ -121,7 +122,7 @@ class Simplex_tree {
};
struct Filtration_simplex_base_dummy {
Filtration_simplex_base_dummy() {}
- void assign_filtration(Filtration_value f) { assert(f == 0); }
+ void assign_filtration(Filtration_value GUDHI_CHECK_code(f)) { GUDHI_CHECK(f == 0, "filtration value specified for a complex that does not store them"); }
Filtration_value filtration() const { return 0; }
};
typedef typename std::conditional<Options::store_filtration, Filtration_simplex_base_real,
@@ -664,71 +665,63 @@ class Simplex_tree {
*/
template<class InputVertexRange = std::initializer_list<Vertex_handle>>
std::pair<Simplex_handle, bool> insert_simplex_and_subfaces(const InputVertexRange& Nsimplex,
- Filtration_value filtration = 0) {
+ Filtration_value filtration = 0) {
auto first = std::begin(Nsimplex);
auto last = std::end(Nsimplex);
if (first == last)
- return std::pair<Simplex_handle, bool>(null_simplex(), true); // ----->>
+ return { null_simplex(), true }; // ----->>
// Copy before sorting
- std::vector<Vertex_handle> copy(first, last);
+ thread_local std::vector<Vertex_handle> copy;
+ copy.clear();
+ copy.insert(copy.end(), first, last);
std::sort(std::begin(copy), std::end(copy));
- std::vector<std::vector<Vertex_handle>> to_be_inserted;
- std::vector<std::vector<Vertex_handle>> to_be_propagated;
- return rec_insert_simplex_and_subfaces(copy, to_be_inserted, to_be_propagated, filtration);
+ return insert_simplex_and_subfaces_sorted(copy, filtration);
}
private:
- std::pair<Simplex_handle, bool> rec_insert_simplex_and_subfaces(std::vector<Vertex_handle>& the_simplex,
- std::vector<std::vector<Vertex_handle>>& to_be_inserted,
- std::vector<std::vector<Vertex_handle>>& to_be_propagated,
- Filtration_value filtration = 0.0) {
- std::pair<Simplex_handle, bool> insert_result;
- if (the_simplex.size() > 1) {
- // Get and remove last vertex
- Vertex_handle last_vertex = the_simplex.back();
- the_simplex.pop_back();
- // Recursive call after last vertex removal
- insert_result = rec_insert_simplex_and_subfaces(the_simplex, to_be_inserted, to_be_propagated, filtration);
-
- // Concatenation of to_be_inserted and to_be_propagated
- to_be_inserted.insert(to_be_inserted.begin(), to_be_propagated.begin(), to_be_propagated.end());
- to_be_propagated = to_be_inserted;
-
- // to_be_inserted treatment
- for (auto& simplex_tbi : to_be_inserted) {
- simplex_tbi.push_back(last_vertex);
- }
- std::vector<Vertex_handle> last_simplex(1, last_vertex);
- to_be_inserted.insert(to_be_inserted.begin(), last_simplex);
- // i.e. (0,1,2) =>
- // [to_be_inserted | to_be_propagated] = [(1) (0,1) | (0)]
- // [to_be_inserted | to_be_propagated] = [(2) (0,2) (1,2) (0,1,2) | (0) (1) (0,1)]
- // N.B. : it is important the last inserted to be the highest in dimension
- // in order to return the "last" insert_simplex result
-
- // insert all to_be_inserted
- for (auto& simplex_tbi : to_be_inserted) {
- insert_result = insert_vertex_vector(simplex_tbi, filtration);
- }
- } else if (the_simplex.size() == 1) {
- // When reaching the end of recursivity, vector of simplices shall be empty and filled on back recursive
- if ((to_be_inserted.size() != 0) || (to_be_propagated.size() != 0)) {
- std::cerr << "Simplex_tree::rec_insert_simplex_and_subfaces - Error vector not empty\n";
- exit(-1);
+ /// Same as insert_simplex_and_subfaces but assumes that the range of vertices is sorted
+ template<class ForwardVertexRange = std::initializer_list<Vertex_handle>>
+ std::pair<Simplex_handle, bool> insert_simplex_and_subfaces_sorted(const ForwardVertexRange& Nsimplex, Filtration_value filt = 0) {
+ auto first = std::begin(Nsimplex);
+ auto last = std::end(Nsimplex);
+ if (first == last)
+ return { null_simplex(), true }; // FIXME: false would make more sense to me.
+ GUDHI_CHECK(std::is_sorted(first, last), "simplex vertices listed in unsorted order");
+ // Update dimension if needed. We could wait to see if the insertion succeeds, but I doubt there is much to gain.
+ dimension_ = std::max(dimension_, static_cast<int>(std::distance(first, last)) - 1);
+ return rec_insert_simplex_and_subfaces_sorted(root(), first, last, filt);
+ }
+ // To insert {1,2,3,4}, we insert {2,3,4} twice, once at the root, and once below 1.
+ template<class ForwardVertexIterator>
+ std::pair<Simplex_handle, bool> rec_insert_simplex_and_subfaces_sorted(Siblings* sib, ForwardVertexIterator first, ForwardVertexIterator last, Filtration_value filt) {
+ // An alternative strategy would be:
+ // - try to find the complete simplex, if found (and low filtration) exit
+ // - insert all the vertices at once in sib
+ // - loop over those (new or not) simplices, with a recursive call(++first, last)
+ Vertex_handle vertex_one = *first;
+ auto&& dict = sib->members();
+ auto insertion_result = dict.emplace(vertex_one, Node(sib, filt));
+ Simplex_handle simplex_one = insertion_result.first;
+ bool one_is_new = insertion_result.second;
+ if (!one_is_new) {
+ if (filtration(simplex_one) > filt) {
+ assign_filtration(simplex_one, filt);
+ } else {
+ // FIXME: this interface makes no sense, and it doesn't seem to be tested.
+ insertion_result.first = null_simplex();
}
- std::vector<Vertex_handle> first_simplex(1, the_simplex.back());
- // i.e. (0,1,2) => [to_be_inserted | to_be_propagated] = [(0) | ]
- to_be_inserted.push_back(first_simplex);
-
- insert_result = insert_vertex_vector(first_simplex, filtration);
- } else {
- std::cerr << "Simplex_tree::rec_insert_simplex_and_subfaces - Recursivity error\n";
- exit(-1);
}
- return insert_result;
+ if (++first == last) return insertion_result;
+ if (!has_children(simplex_one))
+ // TODO: have special code here, we know we are building the whole subtree from scratch.
+ simplex_one->second.assign_children(new Siblings(sib, vertex_one));
+ auto res = rec_insert_simplex_and_subfaces_sorted(simplex_one->second.children(), first, last, filt);
+ // No need to continue if the full simplex was already there with a low enough filtration value.
+ if (res.first != null_simplex()) rec_insert_simplex_and_subfaces_sorted(sib, first, last, filt);
+ return res;
}
public:
diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_iterators.h b/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_iterators.h
index 7e0a454d..ab7346d4 100644
--- a/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_iterators.h
+++ b/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_iterators.h
@@ -23,6 +23,8 @@
#ifndef SIMPLEX_TREE_SIMPLEX_TREE_ITERATORS_H_
#define SIMPLEX_TREE_SIMPLEX_TREE_ITERATORS_H_
+#include <gudhi/Debug_utils.h>
+
#include <boost/iterator/iterator_facade.hpp>
#include <boost/version.hpp>
#if BOOST_VERSION >= 105600
@@ -109,11 +111,18 @@ class Simplex_tree_boundary_simplex_iterator : public boost::iterator_facade<
: last_(sh->first),
sib_(nullptr),
st_(st) {
+ // Only check once at the beginning instead of for every increment, as this is expensive.
+ if (SimplexTree::Options::contiguous_vertices)
+ GUDHI_CHECK(st_->contiguous_vertices(), "The set of vertices is not { 0, ..., n } without holes");
Siblings * sib = st->self_siblings(sh);
next_ = sib->parent();
sib_ = sib->oncles();
if (sib_ != nullptr) {
- sh_ = sib_->find(next_);
+ if (SimplexTree::Options::contiguous_vertices && sib_->oncles() == nullptr)
+ // Only relevant for edges
+ sh_ = sib_->members_.begin()+next_;
+ else
+ sh_ = sib_->find(next_);
} else {
sh_ = st->null_simplex();
} // vertex: == end()
@@ -140,14 +149,19 @@ class Simplex_tree_boundary_simplex_iterator : public boost::iterator_facade<
Siblings * for_sib = sib_;
Siblings * new_sib = sib_->oncles();
auto rit = suffix_.rbegin();
- if (SimplexTree::Options::contiguous_vertices && new_sib == nullptr && rit != suffix_.rend()) {
- // We reached the root, use a short-cut to find a vertex. We could also
- // optimize finding the second vertex of a segment, but people are
- // expected to call endpoints().
- assert(st_->contiguous_vertices());
- sh_ = for_sib->members_.begin()+*rit;
- for_sib = sh_->second.children();
- ++rit;
+ if (SimplexTree::Options::contiguous_vertices && new_sib == nullptr) {
+ // We reached the root, use a short-cut to find a vertex.
+ if (rit == suffix_.rend()) {
+ // Segment, this vertex is the last boundary simplex
+ sh_ = for_sib->members_.begin()+last_;
+ sib_ = nullptr;
+ return;
+ } else {
+ // Dim >= 2, initial step of the descent
+ sh_ = for_sib->members_.begin()+*rit;
+ for_sib = sh_->second.children();
+ ++rit;
+ }
}
for (; rit != suffix_.rend(); ++rit) {
sh_ = for_sib->find(*rit);
diff --git a/src/Subsampling/include/gudhi/choose_n_farthest_points.h b/src/Subsampling/include/gudhi/choose_n_farthest_points.h
index 86500b28..8390b4c9 100644
--- a/src/Subsampling/include/gudhi/choose_n_farthest_points.h
+++ b/src/Subsampling/include/gudhi/choose_n_farthest_points.h
@@ -93,7 +93,7 @@ void choose_n_farthest_points(Kernel const &k,
// Choose randomly the first landmark
std::random_device rd;
std::mt19937 gen(rd());
- std::uniform_int_distribution<std::size_t> dis(0, (input_pts.size() - 1));
+ std::uniform_int_distribution<std::size_t> dis(0, nb_points - 1);
starting_point = dis(gen);
}
@@ -110,7 +110,7 @@ void choose_n_farthest_points(Kernel const &k,
*output_it++ = input_pts[curr_max_w];
*dist_it++ = dist_to_L[curr_max_w];
std::size_t i = 0;
- for (auto& p : input_pts) {
+ for (auto&& p : input_pts) {
double curr_dist = sqdist(p, *(std::begin(input_pts) + curr_max_w));
if (curr_dist < dist_to_L[i])
dist_to_L[i] = curr_dist;
diff --git a/src/cmake/modules/GUDHI_third_party_libraries.cmake b/src/cmake/modules/GUDHI_third_party_libraries.cmake
index e44bbe04..419c2581 100644
--- a/src/cmake/modules/GUDHI_third_party_libraries.cmake
+++ b/src/cmake/modules/GUDHI_third_party_libraries.cmake
@@ -1,6 +1,6 @@
# This files manage third party libraries required by GUDHI
-find_package(Boost REQUIRED COMPONENTS system filesystem unit_test_framework program_options thread)
+find_package(Boost 1.48.0 REQUIRED COMPONENTS system filesystem unit_test_framework program_options thread)
if(NOT Boost_FOUND)
message(FATAL_ERROR "NOTICE: This program requires Boost and will not be compiled.")
diff --git a/src/common/doc/main_page.h b/src/common/doc/main_page.h
index 108cf6e3..148ee670 100644
--- a/src/common/doc/main_page.h
+++ b/src/common/doc/main_page.h
@@ -99,7 +99,7 @@
<tr>
<td width="25%">
<b>Author:</b> Mathieu Carri&egrave;re<br>
- <b>Introduced in:</b> GUDHI 2.0.1<br>
+ <b>Introduced in:</b> GUDHI 2.1.0<br>
<b>Copyright:</b> GPL v3<br>
</td>
<td width="75%">
@@ -551,4 +551,4 @@ make doxygen
* @example Witness_complex/weak_witness_persistence.cpp
* @example Witness_complex/strong_witness_persistence.cpp
*/
- \ No newline at end of file
+
diff --git a/src/common/include/gudhi/Debug_utils.h b/src/common/include/gudhi/Debug_utils.h
index f9d9c50c..90d3cf47 100644
--- a/src/common/include/gudhi/Debug_utils.h
+++ b/src/common/include/gudhi/Debug_utils.h
@@ -32,7 +32,7 @@
// GUDHI_CHECK throw an exception if expression is false in debug mode, but does nothing in release mode
// Could assert in release mode, but cmake sets NDEBUG (for "NO DEBUG") in this mode, means assert does nothing.
#ifdef GUDHI_DEBUG
- #define GUDHI_CHECK(expression, excpt) if ((expression) == 0) throw excpt
+ #define GUDHI_CHECK(expression, excpt) ((expression) ? (void) 0 : (throw excpt))
#define GUDHI_CHECK_code(CODE) CODE
#else
#define GUDHI_CHECK(expression, excpt) (void) 0
diff --git a/src/cython/cython/simplex_tree.pyx b/src/cython/cython/simplex_tree.pyx
index 8a436619..0cb575d2 100644
--- a/src/cython/cython/simplex_tree.pyx
+++ b/src/cython/cython/simplex_tree.pyx
@@ -106,8 +106,8 @@ cdef class SimplexTree:
return self.pcohptr != NULL
def filtration(self, simplex):
- """This function returns the simplicial complex filtration value for a
- given N-simplex.
+ """This function returns the filtration value for a given N-simplex in
+ this simplicial complex, or +infinity if it is not in the complex.
:param simplex: The N-simplex, represented by a list of vertex.
:type simplex: list of int.
@@ -222,14 +222,17 @@ cdef class SimplexTree:
def insert(self, simplex, filtration=0.0):
"""This function inserts the given N-simplex and its subfaces with the
- given filtration value (default value is '0.0').
+ given filtration value (default value is '0.0'). If some of those
+ simplices are already present with a higher filtration value, their
+ filtration value is lowered.
:param simplex: The N-simplex to insert, represented by a list of
vertex.
:type simplex: list of int.
:param filtration: The filtration value of the simplex.
:type filtration: float.
- :returns: true if the simplex was found, false otherwise.
+ :returns: true if the simplex was not yet in the complex, false
+ otherwise (whatever its original filtration value).
:rtype: bool
"""
cdef vector[int] csimplex
diff --git a/src/cython/doc/witness_complex_user.rst b/src/cython/doc/witness_complex_user.rst
index 29413269..99be5185 100644
--- a/src/cython/doc/witness_complex_user.rst
+++ b/src/cython/doc/witness_complex_user.rst
@@ -121,7 +121,7 @@ Example2: Computing persistence using strong relaxed witness complex
Here is an example of constructing a strong witness complex filtration and computing persistence on it:
-* :download:`euclidean_strong_witness_complex_diagram_persistence_from_off_file_example.py <../example/periodic_cubical_complex_barcode_persistence_from_perseus_file_example.py>`
+* :download:`euclidean_strong_witness_complex_diagram_persistence_from_off_file_example.py <../example/euclidean_strong_witness_complex_diagram_persistence_from_off_file_example.py>`
Bibliography
============
diff --git a/src/cython/include/Tangential_complex_interface.h b/src/cython/include/Tangential_complex_interface.h
index ecf014b3..0c3a510e 100644
--- a/src/cython/include/Tangential_complex_interface.h
+++ b/src/cython/include/Tangential_complex_interface.h
@@ -105,7 +105,7 @@ class Tangential_complex_interface {
}
void create_simplex_tree(Simplex_tree<>* simplex_tree) {
- int max_dim = tangential_complex_->create_complex<Gudhi::Simplex_tree<Gudhi::Simplex_tree_options_full_featured>>(*simplex_tree);
+ tangential_complex_->create_complex<Gudhi::Simplex_tree<Gudhi::Simplex_tree_options_full_featured>>(*simplex_tree);
simplex_tree->initialize_filtration();
}