From 2814e25cbc70160e57f426ec708f6d99180ef5fd Mon Sep 17 00:00:00 2001 From: glisse Date: Sun, 25 Oct 2015 21:41:01 +0000 Subject: Example to compute persistence of a Rips filtration "in parallel". On a machine with a gazillion cores, it gains a factor >2 at the expense of some memory. At this point, construction of the Rips graph and expansion are not negligible anymore and could use some parallelism. git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/tbb@875 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 53d6a74338f1346bd7d1ca018ec15dd1ee8287e8 --- .../example/parallel_rips_persistence.cpp | 180 +++++++++++++++++++++ 1 file changed, 180 insertions(+) create mode 100644 src/Persistent_cohomology/example/parallel_rips_persistence.cpp (limited to 'src/Persistent_cohomology') diff --git a/src/Persistent_cohomology/example/parallel_rips_persistence.cpp b/src/Persistent_cohomology/example/parallel_rips_persistence.cpp new file mode 100644 index 00000000..425a5b2c --- /dev/null +++ b/src/Persistent_cohomology/example/parallel_rips_persistence.cpp @@ -0,0 +1,180 @@ +/* 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): Clément Maria, Marc Glisse + * + * Copyright (C) 2014 INRIA Sophia Antipolis-Méditerranée (France), + * 2015 INRIA Saclay Île de 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 +#include +#include +#include "gudhi/Hasse_complex.h" + +#include + +#ifdef GUDHI_USE_TBB +#include +#endif + +#include +#include + +//////////////////////////////////////////////////////////////// +// // +// WARNING: persistence computation itself is not parallel, // +// and this uses more memory than rips_persistence. // +// // +//////////////////////////////////////////////////////////////// + +using namespace Gudhi; +using namespace Gudhi::persistent_cohomology; + +typedef int Vertex_handle; +typedef double Filtration_value; + +void program_options(int argc, char * argv[] + , std::string & filepoints + , std::string & filediag + , Filtration_value & threshold + , int & dim_max + , int & p + , Filtration_value & min_persistence); + +int main(int argc, char * argv[]) { + std::string filepoints; + std::string filediag; + Filtration_value threshold; + int dim_max; + int p; + Filtration_value min_persistence; + + program_options(argc, argv, filepoints, filediag, threshold, dim_max, p, min_persistence); + + // Extract the points from the file filepoints + typedef std::vector Point_t; + std::vector< Point_t > points; + read_points(filepoints, points); + + // Compute the proximity graph of the points + Graph_t prox_graph = compute_proximity_graph(points, threshold + , euclidean_distance); + + // Construct the Rips complex in a Simplex Tree + Simplex_tree<>& st = *new Simplex_tree<>; + // insert the proximity graph in the simplex tree + st.insert_graph(prox_graph); + // expand the graph until dimension dim_max + st.expansion(dim_max); + + std::cout << "The complex contains " << st.num_simplices() << " simplices \n"; + std::cout << " and has dimension " << st.dimension() << " \n"; + +#ifdef GUDHI_USE_TBB + // Unnecessary, but clarifies which operations are parallel. + tbb::task_scheduler_init ts; +#endif + + // Sort the simplices in the order of the filtration + st.initialize_filtration(); + int count = 0; + for (auto sh : st.filtration_simplex_range()) + st.assign_key(sh, count++); + + // Convert to a more convenient representation. + Hasse_complex<> hcpx(st); + +#ifdef GUDHI_USE_TBB + ts.terminate(); +#endif + + // Free some space. + delete &st; + + // Compute the persistence diagram of the complex + persistent_cohomology::Persistent_cohomology< Hasse_complex<>, Field_Zp > pcoh(hcpx); + // initializes the coefficient field for homology + pcoh.init_coefficients(p); + + pcoh.compute_persistent_cohomology(min_persistence); + + // Output the diagram in filediag + if (filediag.empty()) { + pcoh.output_diagram(); + } else { + std::ofstream out(filediag); + pcoh.output_diagram(out); + out.close(); + } +} + +void program_options(int argc, char * argv[] + , std::string & filepoints + , std::string & filediag + , Filtration_value & threshold + , int & dim_max + , int & p + , Filtration_value & min_persistence) { + namespace po = boost::program_options; + po::options_description hidden("Hidden options"); + hidden.add_options() + ("input-file", po::value(&filepoints), + "Name of file containing a point set. Format is one point per line: X1 ... Xd "); + + po::options_description visible("Allowed options", 100); + visible.add_options() + ("help,h", "produce help message") + ("output-file,o", po::value(&filediag)->default_value(std::string()), + "Name of file in which the persistence diagram is written. Default print in std::cout") + ("max-edge-length,r", po::value(&threshold)->default_value(0), + "Maximal length of an edge for the Rips complex construction.") + ("cpx-dimension,d", po::value(&dim_max)->default_value(1), + "Maximal dimension of the Rips complex we want to compute.") + ("field-charac,p", po::value(&p)->default_value(11), + "Characteristic p of the coefficient field Z/pZ for computing homology.") + ("min-persistence,m", po::value(&min_persistence), + "Minimal lifetime of homology feature to be recorded. Default is 0. Enter a negative value to see zero length intervals"); + + po::positional_options_description pos; + pos.add("input-file", 1); + + po::options_description all; + all.add(visible).add(hidden); + + po::variables_map vm; + po::store(po::command_line_parser(argc, argv). + options(all).positional(pos).run(), vm); + po::notify(vm); + + if (vm.count("help") || !vm.count("input-file")) { + std::cout << std::endl; + std::cout << "Compute the persistent homology with coefficient field Z/pZ \n"; + std::cout << "of a Rips complex defined on a set of input points.\n \n"; + std::cout << "The output diagram contains one bar per line, written with the convention: \n"; + std::cout << " p dim b d \n"; + std::cout << "where dim is the dimension of the homological feature,\n"; + std::cout << "b and d are respectively the birth and death of the feature and \n"; + std::cout << "p is the characteristic of the field Z/pZ used for homology coefficients." << std::endl << std::endl; + + std::cout << "Usage: " << argv[0] << " [options] input-file" << std::endl << std::endl; + std::cout << visible << std::endl; + std::abort(); + } +} -- cgit v1.2.3 From a57e87727ea3cbf73ac8e4ce0fe65a19de1fe2d9 Mon Sep 17 00:00:00 2001 From: glisse Date: Mon, 9 Nov 2015 16:54:45 +0000 Subject: New Simplex_tree_options_fast_persistence, while Simplex_tree_options_full_featured switches to the safe default of allowing non-contiguous vertices. git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/contiguous_vertices@896 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 60bc11a90027ed17233903d22a6494198f30eeb1 --- .../example/performance_rips_persistence.cpp | 2 +- .../example/rips_multifield_persistence.cpp | 5 +-- .../example/rips_persistence.cpp | 5 +-- src/Simplex_tree/include/gudhi/Simplex_tree.h | 36 ++++++++++++++++------ src/Simplex_tree/test/simplex_tree_unit_test.cpp | 2 +- 5 files changed, 34 insertions(+), 16 deletions(-) (limited to 'src/Persistent_cohomology') diff --git a/src/Persistent_cohomology/example/performance_rips_persistence.cpp b/src/Persistent_cohomology/example/performance_rips_persistence.cpp index 0e912d57..b0366c6c 100644 --- a/src/Persistent_cohomology/example/performance_rips_persistence.cpp +++ b/src/Persistent_cohomology/example/performance_rips_persistence.cpp @@ -85,7 +85,7 @@ int main(int argc, char * argv[]) { std::cout << "Compute Rips graph in " << enlapsed_sec << " sec.\n"; // Construct the Rips complex in a Simplex Tree - Simplex_tree<> st; + Simplex_tree st; start = std::chrono::system_clock::now(); // insert the proximity graph in the simplex tree diff --git a/src/Persistent_cohomology/example/rips_multifield_persistence.cpp b/src/Persistent_cohomology/example/rips_multifield_persistence.cpp index 5277bf7a..c5cd775d 100644 --- a/src/Persistent_cohomology/example/rips_multifield_persistence.cpp +++ b/src/Persistent_cohomology/example/rips_multifield_persistence.cpp @@ -68,7 +68,8 @@ int main(int argc, char * argv[]) { , euclidean_distance); // Construct the Rips complex in a Simplex Tree - Simplex_tree<> st; + typedef Simplex_tree ST; + ST st; // insert the proximity graph in the simplex tree st.insert_graph(prox_graph); // expand the graph until dimension dim_max @@ -78,7 +79,7 @@ int main(int argc, char * argv[]) { st.initialize_filtration(); // Compute the persistence diagram of the complex - Persistent_cohomology< Simplex_tree<>, Multi_field > pcoh(st); + Persistent_cohomology pcoh(st); // initializes the coefficient field for homology pcoh.init_coefficients(min_p, max_p); // compute persistent homology, disgarding persistent features of life shorter than min_persistence diff --git a/src/Persistent_cohomology/example/rips_persistence.cpp b/src/Persistent_cohomology/example/rips_persistence.cpp index 9b1ef42f..2d926a0d 100644 --- a/src/Persistent_cohomology/example/rips_persistence.cpp +++ b/src/Persistent_cohomology/example/rips_persistence.cpp @@ -65,7 +65,8 @@ int main(int argc, char * argv[]) { , euclidean_distance); // Construct the Rips complex in a Simplex Tree - Simplex_tree<> st; + typedef Simplex_tree ST; + ST st; // insert the proximity graph in the simplex tree st.insert_graph(prox_graph); // expand the graph until dimension dim_max @@ -78,7 +79,7 @@ int main(int argc, char * argv[]) { st.initialize_filtration(); // Compute the persistence diagram of the complex - persistent_cohomology::Persistent_cohomology< Simplex_tree<>, Field_Zp > pcoh(st); + persistent_cohomology::Persistent_cohomology pcoh(st); // initializes the coefficient field for homology pcoh.init_coefficients(p); diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index 74ae1713..b9c2a245 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -77,16 +77,7 @@ namespace Gudhi { * @{ */ -/// Model of SimplexTreeOptions. -struct Simplex_tree_options_full_featured { - typedef linear_indexing_tag Indexing_tag; - typedef int Vertex_handle; - typedef double Filtration_value; - typedef int Simplex_key; - static const bool store_key = true; - static const bool store_filtration = true; - static const bool contiguous_vertices = true; -}; +struct Simplex_tree_options_full_featured; /** * \brief Simplex Tree data structure for representing simplicial complexes. @@ -1159,6 +1150,31 @@ std::istream& operator>>(std::istream & is, Simplex_tree & st) { return is; } + +/// Model of SimplexTreeOptions. +struct Simplex_tree_options_full_featured { + typedef linear_indexing_tag Indexing_tag; + typedef int Vertex_handle; + typedef double Filtration_value; + typedef int Simplex_key; + static const bool store_key = true; + static const bool store_filtration = true; + static const bool contiguous_vertices = false; +}; + +/** Model of SimplexTreeOptions, faster than + `Simplex_tree_options_full_featured` but note the unsafe + `contiguous_vertices` option. */ +struct Simplex_tree_options_fast_persistence { + typedef linear_indexing_tag Indexing_tag; + typedef int Vertex_handle; + typedef float Filtration_value; + typedef int Simplex_key; + static const bool store_key = true; + static const bool store_filtration = true; + static const bool contiguous_vertices = true; +}; + /** @} */ // end defgroup simplex_tree } // namespace Gudhi diff --git a/src/Simplex_tree/test/simplex_tree_unit_test.cpp b/src/Simplex_tree/test/simplex_tree_unit_test.cpp index fff00d77..c2e214c0 100644 --- a/src/Simplex_tree/test/simplex_tree_unit_test.cpp +++ b/src/Simplex_tree/test/simplex_tree_unit_test.cpp @@ -509,7 +509,7 @@ BOOST_AUTO_TEST_CASE(NSimplexAndSubfaces_tree_insertion) { // Find in the simplex_tree // ------------------------------------------------------------------------------------------------------------------ typeVectorVertex simpleSimplexVector{1}; - Simplex_tree<>::Simplex_handle simplexFound = st.find(simpleSimplexVector); + typeST::Simplex_handle simplexFound = st.find(simpleSimplexVector); std::cout << "**************IS THE SIMPLEX {1} IN THE SIMPLEX TREE ?\n"; if (simplexFound != st.null_simplex()) std::cout << "***+ YES IT IS!\n"; -- cgit v1.2.3 From 416b251a88afb83d05d4fb891863e8b99afdab2b Mon Sep 17 00:00:00 2001 From: glisse Date: Tue, 10 Nov 2015 16:30:43 +0000 Subject: Use Simplex_tree_options_fast_persistence in one more place. git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/contiguous_vertices@899 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: b22785182c0140dd36d1a4876c240aa4deabef75 --- src/Persistent_cohomology/example/alpha_shapes_persistence.cpp | 7 ++++--- src/Persistent_cohomology/example/persistence_from_file.cpp | 2 +- src/Simplex_tree/example/simplex_tree_from_alpha_shapes_3.cpp | 5 +++-- 3 files changed, 8 insertions(+), 6 deletions(-) (limited to 'src/Persistent_cohomology') diff --git a/src/Persistent_cohomology/example/alpha_shapes_persistence.cpp b/src/Persistent_cohomology/example/alpha_shapes_persistence.cpp index 6d5eebcf..92c0b065 100644 --- a/src/Persistent_cohomology/example/alpha_shapes_persistence.cpp +++ b/src/Persistent_cohomology/example/alpha_shapes_persistence.cpp @@ -66,7 +66,8 @@ typedef Alpha_shape_3::Edge Edge_3; typedef std::list Vertex_list; // gudhi type definition -typedef Simplex_tree<>::Vertex_handle Simplex_tree_vertex; +typedef Simplex_tree ST; +typedef ST::Vertex_handle Simplex_tree_vertex; typedef std::map Alpha_shape_simplex_tree_map; typedef std::pair Alpha_shape_simplex_tree_pair; typedef std::vector< Simplex_tree_vertex > Simplex_tree_vector_vertex; @@ -184,7 +185,7 @@ int main(int argc, char * const argv[]) { // Loop on objects vector Vertex_list vertex_list; - Simplex_tree<> simplex_tree; + ST simplex_tree; Alpha_shape_simplex_tree_map map_cgal_simplex_tree; std::vector::iterator the_alpha_value_iterator = the_alpha_values.begin(); int dim_max = 0; @@ -281,7 +282,7 @@ int main(int argc, char * const argv[]) { std::cout << "Simplex_tree dim: " << simplex_tree.dimension() << std::endl; // Compute the persistence diagram of the complex - Persistent_cohomology< Simplex_tree<>, Field_Zp > pcoh(simplex_tree); + Persistent_cohomology< ST, Field_Zp > pcoh(simplex_tree); // initializes the coefficient field for homology pcoh.init_coefficients(coeff_field_characteristic); diff --git a/src/Persistent_cohomology/example/persistence_from_file.cpp b/src/Persistent_cohomology/example/persistence_from_file.cpp index 8eb8d0f3..67235467 100644 --- a/src/Persistent_cohomology/example/persistence_from_file.cpp +++ b/src/Persistent_cohomology/example/persistence_from_file.cpp @@ -54,7 +54,7 @@ int main(int argc, char * argv[]) { << std::endl; std::cout << " - p=" << p << " - min_persistence=" << min_persistence << std::endl; - // Construct the Rips complex in a Simplex Tree + // Read the list of simplices from a file. Simplex_tree<> simplex_tree; std::ifstream simplex_tree_stream(simplex_tree_file); diff --git a/src/Simplex_tree/example/simplex_tree_from_alpha_shapes_3.cpp b/src/Simplex_tree/example/simplex_tree_from_alpha_shapes_3.cpp index 45efe3ed..49d358ab 100644 --- a/src/Simplex_tree/example/simplex_tree_from_alpha_shapes_3.cpp +++ b/src/Simplex_tree/example/simplex_tree_from_alpha_shapes_3.cpp @@ -62,7 +62,8 @@ typedef Alpha_shape_3::Edge Edge; typedef std::list Vertex_list; // gudhi type definition -typedef Gudhi::Simplex_tree<>::Vertex_handle Simplex_tree_vertex; +typedef Gudhi::Simplex_tree<> Simplex_tree; +typedef Simplex_tree::Vertex_handle Simplex_tree_vertex; typedef std::map Alpha_shape_simplex_tree_map; typedef std::pair Alpha_shape_simplex_tree_pair; typedef std::vector< Simplex_tree_vertex > Simplex_tree_vector_vertex; @@ -161,7 +162,7 @@ int main(int argc, char * const argv[]) { // Loop on objects vector Vertex_list vertex_list; - Gudhi::Simplex_tree<> simplex_tree; + Simplex_tree simplex_tree; Alpha_shape_simplex_tree_map map_cgal_simplex_tree; std::vector::iterator the_alpha_value_iterator = the_alpha_values.begin(); for (auto object_iterator : the_objects) { -- cgit v1.2.3 From f82dc289e2ebe3eb257c42f27876fbc1c64341dd Mon Sep 17 00:00:00 2001 From: glisse Date: Fri, 11 Dec 2015 08:08:40 +0000 Subject: Clarify the semantics of FilteredComplex::simplex(key). git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@941 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: a2cb908a642ef53c5de25ba5113e03bb45652b9b --- src/Persistent_cohomology/concept/FilteredComplex.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/Persistent_cohomology') diff --git a/src/Persistent_cohomology/concept/FilteredComplex.h b/src/Persistent_cohomology/concept/FilteredComplex.h index 1834903b..e124d524 100644 --- a/src/Persistent_cohomology/concept/FilteredComplex.h +++ b/src/Persistent_cohomology/concept/FilteredComplex.h @@ -65,9 +65,9 @@ struct FilteredComplex Simplex_key key ( Simplex_handle sh ); /** \brief Returns the simplex associated to a key. * - * If key is different from null_key(), there must be a unique - * simplex having this key. */ - Simplex_handle simplex ( Simplex_key key ); + * If key is different from null_key(), returns the simplex that + * has index idx in the filtration. */ + Simplex_handle simplex ( Simplex_key idx ); /** \brief Assign a key to a simplex. */ void assign_key(Simplex_handle sh, Simplex_key key); -- cgit v1.2.3 From 4f73cb4a01692dbbe9547177b5b59425eae0d157 Mon Sep 17 00:00:00 2001 From: glisse Date: Tue, 15 Dec 2015 12:24:25 +0000 Subject: Don't use boost::tuple. git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@946 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 3988b09fafda67297cac8bd68629310cdfdc607e --- src/GudhUI/utils/K_nearest_builder.h | 10 ++++------ .../include/gudhi/Persistent_cohomology.h | 3 +-- .../gudhi/Persistent_cohomology/Persistent_cohomology_column.h | 1 - 3 files changed, 5 insertions(+), 9 deletions(-) (limited to 'src/Persistent_cohomology') diff --git a/src/GudhUI/utils/K_nearest_builder.h b/src/GudhUI/utils/K_nearest_builder.h index cab24b7c..7be0a4f4 100644 --- a/src/GudhUI/utils/K_nearest_builder.h +++ b/src/GudhUI/utils/K_nearest_builder.h @@ -29,12 +29,10 @@ #include #include #include -#include -#include #include -#include #include +#include #include "utils/UI_utils.h" #include "model/Complex_typedefs.h" @@ -43,9 +41,9 @@ template class K_nearest_builder { private: typedef Geometry_trait Kernel; typedef Point Point_d; - typedef boost::tuple Point_d_with_id; + typedef std::pair Point_d_with_id; typedef CGAL::Search_traits_d Traits_base; - typedef CGAL::Search_traits_adapter, + typedef CGAL::Search_traits_adapter, Traits_base> Traits; typedef CGAL::Orthogonal_k_neighbor_search Neighbor_search; typedef Neighbor_search::Tree Tree; @@ -81,7 +79,7 @@ template class K_nearest_builder { for (auto p : complex_.vertex_range()) { Neighbor_search search(tree, complex_.point(p), k + 1); for (auto it = ++search.begin(); it != search.end(); ++it) { - Vertex_handle q(boost::get<1>(it->first)); + Vertex_handle q(std::get<1>(it->first)); if (p != q && complex_.contains_vertex(p) && complex_.contains_vertex(q)) complex_.add_edge(p, q); } diff --git a/src/Persistent_cohomology/include/gudhi/Persistent_cohomology.h b/src/Persistent_cohomology/include/gudhi/Persistent_cohomology.h index 2a405830..643b810c 100644 --- a/src/Persistent_cohomology/include/gudhi/Persistent_cohomology.h +++ b/src/Persistent_cohomology/include/gudhi/Persistent_cohomology.h @@ -27,7 +27,6 @@ #include #include -#include #include #include #include @@ -223,7 +222,7 @@ class Persistent_cohomology { // Sparse column type for the annotation of the boundary of an element. typedef std::vector > A_ds_type; // Persistent interval type. The Arith_element field is used for the multi-field framework. - typedef boost::tuple Persistent_interval; + typedef std::tuple Persistent_interval; /** \brief Initializes the Persistent_cohomology class. * diff --git a/src/Persistent_cohomology/include/gudhi/Persistent_cohomology/Persistent_cohomology_column.h b/src/Persistent_cohomology/include/gudhi/Persistent_cohomology/Persistent_cohomology_column.h index 612658e6..5deb2d88 100644 --- a/src/Persistent_cohomology/include/gudhi/Persistent_cohomology/Persistent_cohomology_column.h +++ b/src/Persistent_cohomology/include/gudhi/Persistent_cohomology/Persistent_cohomology_column.h @@ -23,7 +23,6 @@ #ifndef PERSISTENT_COHOMOLOGY_PERSISTENT_COHOMOLOGY_COLUMN_H_ #define PERSISTENT_COHOMOLOGY_PERSISTENT_COHOMOLOGY_COLUMN_H_ -#include #include #include -- cgit v1.2.3 From 9aa92aa2b504d9530125a6a164f76c11f45d8bb5 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Fri, 8 Jan 2016 15:03:16 +0000 Subject: cpplint and cppcheck fixes git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@956 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: f54c0a2a375e8818c7162aec05249e446361834b --- src/Hasse_complex/include/gudhi/Hasse_complex.h | 10 ++-- .../example/parallel_rips_persistence.cpp | 2 +- src/Simplex_tree/include/gudhi/Simplex_tree.h | 4 +- .../gudhi/Simplex_tree/Simplex_tree_iterators.h | 60 ++++++++++++---------- .../gudhi/Simplex_tree/Simplex_tree_siblings.h | 2 +- src/common/include/gudhi/allocator.h | 10 ++-- 6 files changed, 47 insertions(+), 41 deletions(-) (limited to 'src/Persistent_cohomology') diff --git a/src/Hasse_complex/include/gudhi/Hasse_complex.h b/src/Hasse_complex/include/gudhi/Hasse_complex.h index 38887264..8b06b771 100644 --- a/src/Hasse_complex/include/gudhi/Hasse_complex.h +++ b/src/Hasse_complex/include/gudhi/Hasse_complex.h @@ -23,14 +23,14 @@ #ifndef HASSE_COMPLEX_H_ #define HASSE_COMPLEX_H_ +#include + #include #include #include // for pair #include -#include - #ifdef GUDHI_USE_TBB #include #endif @@ -109,12 +109,12 @@ class Hasse_complex { , dim_max_(cpx.dimension()) { int size = complex_.size(); #ifdef GUDHI_USE_TBB - tbb::parallel_for(0,size,[&](int idx){new (&complex_[idx]) Hasse_simp(cpx, cpx.simplex(idx));}); - for (int idx=0; idx #include #include -#include "gudhi/Hasse_complex.h" +#include #include diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index 356deb3a..708cdef9 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -528,7 +528,7 @@ class Simplex_tree { * The type InputVertexRange must be a range of Vertex_handle * on which we can call std::begin() function */ - template> + template> Simplex_handle find(const InputVertexRange & s) { auto first = std::begin(s); auto last = std::end(s); @@ -635,7 +635,7 @@ class Simplex_tree { * * The type InputVertexRange must be a range for which .begin() and * .end() return input iterators, with 'value_type' Vertex_handle. */ - template> + template> std::pair insert_simplex(const InputVertexRange & simplex, Filtration_value filtration = 0) { auto first = std::begin(simplex); 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 794060ee..936b7a1f 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 @@ -54,7 +54,7 @@ class Simplex_tree_simplex_vertex_iterator : public boost::iterator_facade< explicit Simplex_tree_simplex_vertex_iterator(SimplexTree * st) : // any end() iterator - sib_(NULL), + sib_(nullptr), v_(st->null_vertex()) { } @@ -99,19 +99,19 @@ class Simplex_tree_boundary_simplex_iterator : public boost::iterator_facade< // any end() iterator explicit Simplex_tree_boundary_simplex_iterator(SimplexTree * st) - : sib_(NULL), - sh_(st->null_simplex()) { + : sib_(nullptr), + sh_(st->null_simplex()), + st_(st) { } Simplex_tree_boundary_simplex_iterator(SimplexTree * st, Simplex_handle sh) - : suffix_(), - sib_(st->self_siblings(sh)), + : last_(sh->first), + sib_(nullptr), st_(st) { - last_ = sh->first; Siblings * sib = st->self_siblings(sh); next_ = sib->parent(); - sib_ = sib->oncles(); /* \todo check if NULL*/ - if (sib_ != NULL) { + sib_ = sib->oncles(); + if (sib_ != nullptr) { sh_ = sib_->find(next_); } else { sh_ = st->null_simplex(); @@ -131,7 +131,7 @@ class Simplex_tree_boundary_simplex_iterator : public boost::iterator_facade< } void increment() { - if (sib_ == NULL) { + if (sib_ == nullptr) { sh_ = st_->null_simplex(); return; } @@ -189,13 +189,15 @@ class Simplex_tree_complex_simplex_iterator : public boost::iterator_facade< // any end() iterator Simplex_tree_complex_simplex_iterator() - : st_(NULL) { + : sib_(nullptr), + st_(nullptr) { } explicit Simplex_tree_complex_simplex_iterator(SimplexTree * st) - : st_(st) { - if (st == NULL || st->root() == NULL || st->root()->members().empty()) { - st_ = NULL; + : sib_(nullptr), + st_(st) { + if (st == nullptr || st->root() == nullptr || st->root()->members().empty()) { + st_ = nullptr; } else { sh_ = st->root()->members().begin(); sib_ = st->root(); @@ -210,10 +212,10 @@ class Simplex_tree_complex_simplex_iterator : public boost::iterator_facade< // valid when iterating along the SAME boundary. bool equal(Simplex_tree_complex_simplex_iterator const& other) const { - if (other.st_ == NULL) { - return (st_ == NULL); + if (other.st_ == nullptr) { + return (st_ == nullptr); } - if (st_ == NULL) { + if (st_ == nullptr) { return false; } return (&(sh_->second) == &(other.sh_->second)); @@ -227,8 +229,8 @@ class Simplex_tree_complex_simplex_iterator : public boost::iterator_facade< void increment() { ++sh_; if (sh_ == sib_->members().end()) { - if (sib_->oncles() == NULL) { - st_ = NULL; + if (sib_->oncles() == nullptr) { + st_ = nullptr; return; } // reach the end sh_ = sib_->oncles()->members().find(sib_->parent()); @@ -261,15 +263,19 @@ class Simplex_tree_skeleton_simplex_iterator : public boost::iterator_facade< // any end() iterator Simplex_tree_skeleton_simplex_iterator() - : st_(NULL) { + : sib_(nullptr), + st_(nullptr), + dim_skel_(0), + curr_dim_(0) { } Simplex_tree_skeleton_simplex_iterator(SimplexTree * st, int dim_skel) - : st_(st), + : sib_(nullptr), + st_(st), dim_skel_(dim_skel), curr_dim_(0) { - if (st == NULL || st->root() == NULL || st->root()->members().empty()) { - st_ = NULL; + if (st == nullptr || st->root() == nullptr || st->root()->members().empty()) { + st_ = nullptr; } else { sh_ = st->root()->members().begin(); sib_ = st->root(); @@ -285,10 +291,10 @@ class Simplex_tree_skeleton_simplex_iterator : public boost::iterator_facade< // valid when iterating along the SAME boundary. bool equal(Simplex_tree_skeleton_simplex_iterator const& other) const { - if (other.st_ == NULL) { - return (st_ == NULL); + if (other.st_ == nullptr) { + return (st_ == nullptr); } - if (st_ == NULL) { + if (st_ == nullptr) { return false; } return (&(sh_->second) == &(other.sh_->second)); @@ -302,8 +308,8 @@ class Simplex_tree_skeleton_simplex_iterator : public boost::iterator_facade< void increment() { ++sh_; if (sh_ == sib_->members().end()) { - if (sib_->oncles() == NULL) { - st_ = NULL; + if (sib_->oncles() == nullptr) { + st_ = nullptr; return; } // reach the end sh_ = sib_->oncles()->members().find(sib_->parent()); diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_siblings.h b/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_siblings.h index 158ee1f7..072afc8d 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_siblings.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_siblings.h @@ -57,7 +57,7 @@ class Simplex_tree_siblings { /* Default constructor.*/ Simplex_tree_siblings() - : oncles_(NULL), + : oncles_(nullptr), parent_(-1), members_() { } diff --git a/src/common/include/gudhi/allocator.h b/src/common/include/gudhi/allocator.h index b825173b..4ede14e4 100644 --- a/src/common/include/gudhi/allocator.h +++ b/src/common/include/gudhi/allocator.h @@ -20,8 +20,8 @@ * along with this program. If not, see . */ -#ifndef GUDHI_ALLOCATOR_H_ -#define GUDHI_ALLOCATOR_H_ +#ifndef ALLOCATOR_H_ +#define ALLOCATOR_H_ #include #include @@ -43,13 +43,13 @@ struct no_init_allocator : Base { // Do nothing: that's the whole point! template - void construct(P*)noexcept{} + void construct(P*) noexcept {} - template void construct(P*p, U&&...u){ + template void construct(P*p, U&&...u) { Base_traits::construct(*(Base*)this, p, std::forward(u)...); } }; } // namespace Gudhi -#endif // GUDHI_ALLOCATOR_H_ +#endif // ALLOCATOR_H_ -- cgit v1.2.3