From 04c63ee74520c966451b0cb1713df8b3e9ca5bfb Mon Sep 17 00:00:00 2001 From: pdlotko Date: Mon, 21 Mar 2016 08:21:22 +0000 Subject: Answers to comments. git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/bitmap@1063 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 99cebe0573d75c98c8559ae4572b8f510e5cd9c0 --- .../include/gudhi/Bitmap_cubical_complex_base.h | 46 +++++++++++++--------- ...cal_complex_periodic_boundary_conditions_base.h | 6 +-- src/Bitmap_cubical_complex/test/Bitmap_test.cpp | 10 ++--- 3 files changed, 36 insertions(+), 26 deletions(-) diff --git a/src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex_base.h b/src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex_base.h index e081764c..f0517a86 100644 --- a/src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex_base.h +++ b/src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex_base.h @@ -170,7 +170,7 @@ public: /** * Function that put the input data to bins. By putting data to bins we mean rounding them to a sequence of values equally distributed in the range of data. * Sometimes if most of the cells have different birth-death times, the performance of the algorithms to compute persistence gets - * worst. When dealing with this type of data, one may want to put different values on cells to some number of bins. The function put_data_toBins( size_t number_of_bins ) + * worst. When dealing with this type of data, one may want to put different values on cells to some number of bins. The function put_data_to_bins( size_t number_of_bins ) * ais designed for that purpose. The parameter of the function is the number of bins (distinct values) we want to have in the cubical complex. **/ void put_data_to_bins( size_t number_of_bins ); @@ -178,7 +178,7 @@ public: /** * Function that put the input data to bins. By putting data to bins we mean rounding them to a sequence of values equally distributed in the range of data. * Sometimes if most of the cells have different birth-death times, the performance of the algorithms to compute persistence gets - * worst. When dealing with this type of data, one may want to put different values on cells to some number of bins. The function put_data_toBins( T diameter_of_bin ) is + * worst. When dealing with this type of data, one may want to put different values on cells to some number of bins. The function put_data_to_bins( T diameter_of_bin ) is * designed for that purpose. The parameter of it is the diameter of each bin. Note that the bottleneck distance between the persistence diagram of the cubical complex * before and after using such a function will be bounded by the parameter diameter_of_bin. **/ @@ -263,12 +263,12 @@ public: /** - * All_cells_iterator_range class provides ranges for All_cells_iterator + * All_cells_range class provides ranges for All_cells_iterator **/ - class All_cells_iterator_range + class All_cells_range { public: - All_cells_iterator_range(Bitmap_cubical_complex_base* b):b(b){}; + All_cells_range(Bitmap_cubical_complex_base* b):b(b){}; All_cells_iterator begin() { return b->all_cells_iterator_begin(); @@ -279,7 +279,12 @@ public: } private: Bitmap_cubical_complex_base* b; - }; + }; + + All_cells_range all_cells_range() + { + return All_cells_range(this); + } /** @@ -300,7 +305,7 @@ public: /** * Coboundary_range class provides ranges for boundary iterators. **/ - typedef typename std::vector< size_t >::iterator Coboundary_iterator; + typedef typename std::vector< size_t >::const_iterator Coboundary_iterator; typedef typename std::vector< size_t > Coboundary_range; /** @@ -426,7 +431,7 @@ public: /** * Function returning a Top_dimensional_cells_iterator to the first top dimensional cell of the bitmap. **/ - Top_dimensional_cells_iterator top_dimensional_cells_begin() + Top_dimensional_cells_iterator top_dimensional_cells_iterator_begin() { Top_dimensional_cells_iterator a(*this); return a; @@ -435,7 +440,7 @@ public: /** * Function returning a Top_dimensional_cells_iterator to the last top dimensional cell of the bitmap. **/ - Top_dimensional_cells_iterator top_dimensional_cells_end() + Top_dimensional_cells_iterator top_dimensional_cells_iterator_end() { Top_dimensional_cells_iterator a(*this); for ( size_t i = 0 ; i != this->dimension() ; ++i ) @@ -447,23 +452,28 @@ public: } /** - * All_cells_iterator_range class provides ranges for Top_dimensional_cells_iterator_range + * Top_dimensional_cells_iterator_range class provides ranges for Top_dimensional_cells_iterator_range **/ - class Top_dimensional_cells_iterator_range + class Top_dimensional_cells_range { public: - Top_dimensional_cells_iterator_range(Bitmap_cubical_complex_base* b):b(b){}; + Top_dimensional_cells_range(Bitmap_cubical_complex_base* b):b(b){}; Top_dimensional_cells_iterator begin() { - return b->top_dimensional_cells_begin(); + return b->top_dimensional_cells_iterator_begin(); } Top_dimensional_cells_iterator end() { - return b->top_dimensional_cells_end(); + return b->top_dimensional_cells_iterator_end(); } private: Bitmap_cubical_complex_base* b; - }; + }; + + Top_dimensional_cells_range top_dimensional_cells_range() + { + return Top_dimensional_cells_range(this); + } //****************************************************************************************************************// @@ -621,7 +631,7 @@ void Bitmap_cubical_complex_base::setup_bitmap_based_on_top_dimensional_cells Bitmap_cubical_complex_base::Top_dimensional_cells_iterator it(*this); size_t index = 0; - for ( it = this->top_dimensional_cells_begin() ; it != this->top_dimensional_cells_end() ; ++it ) + for ( it = this->top_dimensional_cells_iterator_begin() ; it != this->top_dimensional_cells_iterator_end() ; ++it ) { this->get_cell_data(*it) = top_dimensional_cells[index]; ++index; @@ -660,7 +670,7 @@ void Bitmap_cubical_complex_base::read_perseus_style_file( const char* perseu this->set_up_containers( sizes ); Bitmap_cubical_complex_base::Top_dimensional_cells_iterator it(*this); - it = this->top_dimensional_cells_begin(); + it = this->top_dimensional_cells_iterator_begin(); while ( !inFiltration.eof() ) { @@ -824,7 +834,7 @@ void Bitmap_cubical_complex_base::impose_lower_star_filtration() //we assume here that we already have a filtration on the top dimensional cells and //we have to extend it to lower ones. typename Bitmap_cubical_complex_base::Top_dimensional_cells_iterator it(*this); - for ( it = this->top_dimensional_cells_begin() ; it != this->top_dimensional_cells_end() ; ++it ) + for ( it = this->top_dimensional_cells_iterator_begin() ; it != this->top_dimensional_cells_iterator_end() ; ++it ) { indices_to_consider.push_back( it.compute_index_in_bitmap() ); } diff --git a/src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex_periodic_boundary_conditions_base.h b/src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex_periodic_boundary_conditions_base.h index 9a5ef0eb..956e74a7 100644 --- a/src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex_periodic_boundary_conditions_base.h +++ b/src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex_periodic_boundary_conditions_base.h @@ -119,7 +119,7 @@ void Bitmap_cubical_complex_periodic_boundary_conditions_base::construct_comp this->set_up_containers( dimensions ); size_t i = 0; - for ( typename Bitmap_cubical_complex_periodic_boundary_conditions_base::Top_dimensional_cells_iterator it = this->top_dimensional_cells_begin() ; it != this->top_dimensional_cells_end() ; ++it ) + for ( typename Bitmap_cubical_complex_periodic_boundary_conditions_base::Top_dimensional_cells_iterator it = this->top_dimensional_cells_iterator_begin() ; it != this->top_dimensional_cells_iterator_end() ; ++it ) { this->get_cell_data(*it) = topDimensionalCells[i]; ++i; @@ -162,7 +162,7 @@ Bitmap_cubical_complex_periodic_boundary_conditions_base::Bitmap_cubical_comp this->set_up_containers( sizes ); typename Bitmap_cubical_complex_periodic_boundary_conditions_base::Top_dimensional_cells_iterator it(*this); - it = this->top_dimensional_cells_begin(); + it = this->top_dimensional_cells_iterator_begin(); while ( !inFiltration.eof() ) { @@ -230,7 +230,7 @@ Bitmap_cubical_complex_periodic_boundary_conditions_base::Bitmap_cubical_comp this->set_up_containers( sizes ); size_t i = 0; - for ( typename Bitmap_cubical_complex_periodic_boundary_conditions_base::Top_dimensional_cells_iterator it = this->top_dimensional_cells_begin() ; it != this->top_dimensional_cells_end() ; ++it ) + for ( typename Bitmap_cubical_complex_periodic_boundary_conditions_base::Top_dimensional_cells_iterator it = this->top_dimensional_cells_iterator_begin() ; it != this->top_dimensional_cells_iterator_end() ; ++it ) { *it = data[i]; ++i; diff --git a/src/Bitmap_cubical_complex/test/Bitmap_test.cpp b/src/Bitmap_cubical_complex/test/Bitmap_test.cpp index b7a1c8b6..35c54ade 100644 --- a/src/Bitmap_cubical_complex/test/Bitmap_test.cpp +++ b/src/Bitmap_cubical_complex/test/Bitmap_test.cpp @@ -94,13 +94,13 @@ BOOST_AUTO_TEST_CASE(topDimensionalCellsIterator_test) { int i = 0; for (Bitmap_cubical_complex< Bitmap_cubical_complex_base >::Top_dimensional_cells_iterator - it = increasing.top_dimensional_cells_begin(); it != increasing.top_dimensional_cells_end(); ++it) { + it = increasing.top_dimensional_cells_iterator_begin(); it != increasing.top_dimensional_cells_iterator_end(); ++it) { BOOST_CHECK(increasing.get_cell_data(*it) == expectedFiltrationValues2[i]); ++i; } i = 0; for (Bitmap_cubical_complex< Bitmap_cubical_complex_base >::Top_dimensional_cells_iterator - it = hole.top_dimensional_cells_begin(); it != hole.top_dimensional_cells_end(); ++it) { + it = hole.top_dimensional_cells_iterator_begin(); it != hole.top_dimensional_cells_iterator_end(); ++it) { BOOST_CHECK(hole.get_cell_data(*it) == expectedFiltrationValues1[i]); ++i; } @@ -1229,7 +1229,7 @@ BOOST_AUTO_TEST_CASE(all_cells_iterator_and_boundary_iterators_in_Bitmap_cubical int bd_it = 0; int cbd_it = 0; - Bitmap_cubical_complex_base::All_cells_iterator_range range(&ba); + Bitmap_cubical_complex_base::All_cells_range range(&ba); for ( Bitmap_cubical_complex_base::All_cells_iterator it = range.begin() ; it != range.end() ; ++it ) { BOOST_CHECK( expected_filtration[i] == ba.get_cell_data( *it ) ); @@ -1415,7 +1415,7 @@ BOOST_AUTO_TEST_CASE(all_cells_iterator_and_boundary_iterators_in_Bitmap_cubical int bd_it = 0; int cbd_it = 0; - Bitmap_cubical_complex_base::All_cells_iterator_range range(&ba); + Bitmap_cubical_complex_base::All_cells_range range = ba.all_cells_range(); for ( Bitmap_cubical_complex_base::All_cells_iterator it = range.begin() ; it != range.end() ; ++it ) { BOOST_CHECK( expected_filtration[i] == ba.get_cell_data( *it ) ); @@ -1481,7 +1481,7 @@ BOOST_AUTO_TEST_CASE(Top_dimensional_cells_iterator_range_check) Bitmap_cubical_complex_base ba( sizes , data ); int i = 0; - Bitmap_cubical_complex_base::Top_dimensional_cells_iterator_range range(&ba); + Bitmap_cubical_complex_base::Top_dimensional_cells_range range = ba.top_dimensional_cells_range(); for ( Bitmap_cubical_complex_base::Top_dimensional_cells_iterator it = range.begin() ; it != range.end() ; ++it ) { BOOST_CHECK( data[i] == ba.get_cell_data( *it ) ); -- cgit v1.2.3