summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorpdlotko <pdlotko@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2016-03-14 12:59:53 +0000
committerpdlotko <pdlotko@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2016-03-14 12:59:53 +0000
commit5389d8969d8386bb4c74dbef4b7c7992e9130f13 (patch)
tree25864562808aa410483b482b1944efcbcb6e43b7 /src
parentff41ff166c9ea66fcc1187056053e43bf7d7be8f (diff)
Answers to Marc's comments.
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/bitmap@1042 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 481841d609bae68df85a93527e6d3cc20f1b06e2
Diffstat (limited to 'src')
-rw-r--r--src/Bitmap_cubical_complex/example/Bitmap_cubical_complex.cpp146
-rw-r--r--src/Bitmap_cubical_complex/example/CMakeLists.txt4
-rw-r--r--src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex.h8
-rw-r--r--src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex_base.h355
-rw-r--r--src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex_periodic_boundary_conditions_base.h10
5 files changed, 288 insertions, 235 deletions
diff --git a/src/Bitmap_cubical_complex/example/Bitmap_cubical_complex.cpp b/src/Bitmap_cubical_complex/example/Bitmap_cubical_complex.cpp
index 39a55f24..4c30ee85 100644
--- a/src/Bitmap_cubical_complex/example/Bitmap_cubical_complex.cpp
+++ b/src/Bitmap_cubical_complex/example/Bitmap_cubical_complex.cpp
@@ -1,73 +1,73 @@
- /* 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): Pawel Dlotko
- *
- * Copyright (C) 2015 INRIA Saclay (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 <http://www.gnu.org/licenses/>.
- */
-
-
-#include <gudhi/reader_utils.h>
-#include <gudhi/Bitmap_cubical_complex.h>
-#include <gudhi/Persistent_cohomology.h>
-
-
-using namespace Gudhi;
-using namespace Gudhi::Cubical_complex;
-using namespace Gudhi::persistent_cohomology;
-
-//standard stuff
-#include <iostream>
-#include <sstream>
-#include <vector>
-
-using namespace std;
-
-
-int main( int argc , char** argv )
-{
- cout << "This program computes persistent homology, by using bitmap_cubical_complex class, of cubical complexes provided in text files in Perseus style (the only numbered in \
-the first line is a dimension D of a bitmap. In the lines I between 2 and D+1 there are numbers of top dimensional cells in the direction I. Let N denote product \
-of the numbers in the lines between 2 and D. In the lines D+2 to D+2+N there are filtrations of top dimensional cells. We assume that the cells are in the \
-lexicographical order. See CubicalOneSphere.txt or CubicalTwoSphere.txt for example." << endl;
-
- int p = 2;
- double min_persistence = 0;
-
- if ( argc != 2 )
- {
- cout << "Wrong number of parameters. Please provide the name of a file with a Perseus style bitmap at the input. The program will now terminate.\n";
- return 1;
- }
-
- Bitmap_cubical_complex< Bitmap_cubical_complex_base<double> > b( argv[1] );
-
-
- // Compute the persistence diagram of the complex
- persistent_cohomology::Persistent_cohomology< Bitmap_cubical_complex< Bitmap_cubical_complex_base<double> >, Field_Zp > pcoh(b);
- pcoh.init_coefficients( p ); //initilizes the coefficient field for homology
- pcoh.compute_persistent_cohomology( min_persistence );
-
-
- stringstream ss;
- ss << argv[1] << "_persistence";
- std::ofstream out((char*)ss.str().c_str());
- pcoh.output_diagram(out);
- out.close();
-
- return 0;
-}
+ /* 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): Pawel Dlotko
+ *
+ * Copyright (C) 2015 INRIA Saclay (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 <http://www.gnu.org/licenses/>.
+ */
+
+
+#include <gudhi/reader_utils.h>
+#include <gudhi/Bitmap_cubical_complex_base.h>
+#include <gudhi/Bitmap_cubical_complex.h>
+#include <gudhi/Persistent_cohomology.h>
+
+
+using namespace Gudhi;
+using namespace Gudhi::Cubical_complex;
+using namespace Gudhi::persistent_cohomology;
+
+//standard stuff
+#include <iostream>
+#include <sstream>
+#include <vector>
+
+using namespace std;
+
+
+int main( int argc , char** argv )
+{
+ cout << "This program computes persistent homology, by using bitmap_cubical_complex class, of cubical complexes provided in text files in Perseus style (the only numbered in \
+the first line is a dimension D of a bitmap. In the lines I between 2 and D+1 there are numbers of top dimensional cells in the direction I. Let N denote product \
+of the numbers in the lines between 2 and D. In the lines D+2 to D+2+N there are filtrations of top dimensional cells. We assume that the cells are in the \
+lexicographical order. See CubicalOneSphere.txt or CubicalTwoSphere.txt for example." << endl;
+
+ int p = 2;
+ double min_persistence = 0;
+
+ if ( argc != 2 )
+ {
+ cout << "Wrong number of parameters. Please provide the name of a file with a Perseus style bitmap at the input. The program will now terminate.\n";
+ return 1;
+ }
+
+ Bitmap_cubical_complex< Bitmap_cubical_complex_base<double> > b( argv[1] );
+
+ // Compute the persistence diagram of the complex
+ persistent_cohomology::Persistent_cohomology< Bitmap_cubical_complex< Bitmap_cubical_complex_base<double> >, Field_Zp > pcoh(b);
+ pcoh.init_coefficients( p ); //initilizes the coefficient field for homology
+
+ pcoh.compute_persistent_cohomology( min_persistence );
+
+ stringstream ss;
+ ss << argv[1] << "_persistence";
+ std::ofstream out((char*)ss.str().c_str());
+ pcoh.output_diagram(out);
+ out.close();
+
+ return 0;
+}
diff --git a/src/Bitmap_cubical_complex/example/CMakeLists.txt b/src/Bitmap_cubical_complex/example/CMakeLists.txt
index fbd1b28b..14c94e8e 100644
--- a/src/Bitmap_cubical_complex/example/CMakeLists.txt
+++ b/src/Bitmap_cubical_complex/example/CMakeLists.txt
@@ -13,5 +13,5 @@ add_test(Random_bitmap_cubical_complex ${CMAKE_CURRENT_BINARY_DIR}/Random_bitmap
add_executable ( Bitmap_cubical_complex_periodic_boundary_conditions Bitmap_cubical_complex_periodic_boundary_conditions.cpp )
target_link_libraries(Bitmap_cubical_complex_periodic_boundary_conditions ${Boost_SYSTEM_LIBRARY})
-add_executable ( Compute_persistence_with_phat Compute_persistence_with_phat.cpp )
-target_link_libraries(Compute_persistence_with_phat ${Boost_SYSTEM_LIBRARY}) \ No newline at end of file
+#add_executable ( Compute_persistence_with_phat Compute_persistence_with_phat.cpp )
+#target_link_libraries(Compute_persistence_with_phat ${Boost_SYSTEM_LIBRARY}) \ No newline at end of file
diff --git a/src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex.h b/src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex.h
index 70f19e03..4dd295e7 100644
--- a/src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex.h
+++ b/src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex.h
@@ -23,6 +23,7 @@
#pragma once
#include <limits>
+#include <numeric>
#include "Bitmap_cubical_complex_base.h"
#include "Bitmap_cubical_complex_periodic_boundary_conditions_base.h"
@@ -127,7 +128,12 @@ public:
//If the user decide to change some elements of the bitmap, then this procedure need
//to be called again.
this->initialize_simplex_associated_to_key();
- }
+ }
+
+ /**
+ * Destructor of the Bitmap_cubical_complex class.
+ **/
+ virtual ~Bitmap_cubical_complex(){}
//*********************************************//
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 22b703a9..807be335 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
@@ -23,13 +23,14 @@
#pragma once
#include <iostream>
+#include <numeric>
#include <string>
#include <vector>
#include <string>
#include <fstream>
#include <algorithm>
#include <iterator>
-#include <limits>
+#include <limits>
#include <ctime>
#include "Bitmap_cubical_complex/counter.h"
@@ -43,7 +44,11 @@ namespace Cubical_complex
{
-
+/**
+ *@class Bitmap_cubical_complex_base
+ *@brief Cubical complex represented as a bitmap, class with basic implementation.
+ *@ingroup cubical_complex
+ */
/**
* This is a class implementing a basic bitmap data structure to store cubical complexes.
* It implements only the most basic subroutines.
@@ -64,13 +69,13 @@ namespace Cubical_complex
template <typename T>
class Bitmap_cubical_complex_base
{
-public:
- typedef T filtration_type;
- /**
- *Default constructor
- **/
- Bitmap_cubical_complex_base()
- {
+public:
+ typedef T filtration_type;
+ /**
+ *Default constructor
+ **/
+ Bitmap_cubical_complex_base()
+ {
}
/**
* There are a few constructors of a Bitmap_cubical_complex_base class.
@@ -93,6 +98,11 @@ public:
Bitmap_cubical_complex_base( const std::vector<unsigned>& dimensions , const std::vector<T>& top_dimensional_cells );
/**
+ * Destructor of the Bitmap_cubical_complex_base class.
+ **/
+ virtual ~Bitmap_cubical_complex_base(){}
+
+ /**
* The functions get_boundary_of_a_cell, get_coboundary_of_a_cell, get_dimension_of_a_cell
* and get_cell_data are the basic
* functions that compute boundary / coboundary / dimension and the filtration
@@ -152,18 +162,27 @@ public:
* Writing to stream operator.
**/
template <typename K>
- friend ostream& operator << ( ostream & os , const Bitmap_cubical_complex_base<K>& b );
-
-
+ friend ostream& operator << ( ostream & os , const Bitmap_cubical_complex_base<K>& b );
+
+
/**
- * Functions that put the input data to bins.
+ * Function that put the input data to bins. 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 )
+ * 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_toBins( size_t number_of_bins );
- void put_data_toBins( T diameter_of_bin );
-
+
+ /**
+ * Function that put the input data to bins. 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
+ * 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.
+ **/
+ void put_data_toBins( T diameter_of_bin );
+
/**
* Functions to find min and max values of filtration.
- **/
+ **/
std::pair< T ,T > min_max_filtration();
//ITERATORS
@@ -172,42 +191,60 @@ public:
* Iterator through all cells in the complex (in order they appear in the structure -- i.e.
* in lexicographical order).
**/
- typedef typename std::vector< T >::iterator all_cells_iterator;
-
+ typedef typename std::vector< T >::iterator all_cells_iterator;
+
+
/**
- * Function returning an iterator to the first cell of the bitmap.
+ * Constant iterator through all cells in the complex (in order they appear in the structure -- i.e.
+ * in lexicographical order).
**/
- all_cells_iterator all_cells_begin()
+ typedef typename std::vector< T >::const_iterator all_cells_const_iterator;
+
+ /**
+ * Function returning a constant iterator to the first cell of the bitmap.
+ **/
+ all_cells_const_iterator all_cells_const_begin()const
{
return this->data.begin();
- }
-
- /**
- * Function returning an iterator to the last cell of the bitmap.
+ }
+
+
+ /**
+ * Function returning a constant iterator to the last cell of the bitmap.
**/
- all_cells_iterator all_cells_end()const
+ all_cells_const_iterator all_cells_const_end()const
{
return this->data.end();
}
/**
- * Constant iterator through all cells in the complex (in order they appear in the structure -- i.e.
- * in lexicographical order).
+ * Function returning an iterator to the first cell of the bitmap.
**/
- typedef typename std::vector< T >::const_iterator all_cells_const_iterator;
-
+ all_cells_iterator all_cells_begin()
+ {
+ return this->data.begin();
+ }
+
/**
* Function returning a constant iterator to the first cell of the bitmap.
**/
- all_cells_const_iterator all_cells_const_begin()const
+ all_cells_const_iterator all_cells_begin() const
{
return this->data.begin();
- }
-
+ }
+
+ /**
+ * Function returning an iterator to the last cell of the bitmap.
+ **/
+ all_cells_iterator all_cells_end()
+ {
+ return this->data.end();
+ }
+
/**
* Function returning a constant iterator to the last cell of the bitmap.
**/
- all_cells_const_iterator all_cells_const_end()const
+ all_cells_const_iterator all_cells_end() const
{
return this->data.end();
}
@@ -303,8 +340,8 @@ public:
protected:
std::vector< size_t > counter;
Bitmap_cubical_complex_base& b;
- };
-
+ };
+
/**
* Function returning a Top_dimensional_cells_iterator to the first top dimensional cell cell of the bitmap.
**/
@@ -312,8 +349,8 @@ public:
{
Top_dimensional_cells_iterator a(*this);
return a;
- }
-
+ }
+
/**
* Function returning a Top_dimensional_cells_iterator to the last top dimensional cell cell of the bitmap.
**/
@@ -333,11 +370,11 @@ public:
//****************************************************************************************************************//
//****************************************************************************************************************//
//****************************************************************************************************************//
-
-
-inline size_t number_cells()const
-{
- return this->total_number_of_cells;
+
+
+inline size_t number_cells()const
+{
+ return this->total_number_of_cells;
}
//****************************************************************************************************************//
@@ -375,7 +412,7 @@ protected:
std::vector<unsigned> compute_counter_for_given_cell( size_t cell )const
{
- std::vector<unsigned> counter;
+ std::vector<unsigned> counter;
counter.reserve( this->sizes.size() );
for ( size_t dim = this->sizes.size() ; dim != 0 ; --dim )
{
@@ -384,59 +421,59 @@ protected:
}
std::reverse( counter.begin() , counter.end() );
return counter;
- }
- void read_perseus_style_file( const char* perseus_style_file );
- void setup_bitmap_based_on_top_dimensional_cells_list(const std::vector<unsigned>& sizes_in_following_directions , const std::vector<T>& top_dimensional_cells);
- Bitmap_cubical_complex_base( const char* perseus_style_file , std::vector<bool> directions );
- Bitmap_cubical_complex_base( const std::vector<unsigned>& sizes , std::vector<bool> directions );
+ }
+ void read_perseus_style_file( const char* perseus_style_file );
+ void setup_bitmap_based_on_top_dimensional_cells_list(const std::vector<unsigned>& sizes_in_following_directions , const std::vector<T>& top_dimensional_cells);
+ Bitmap_cubical_complex_base( const char* perseus_style_file , std::vector<bool> directions );
+ Bitmap_cubical_complex_base( const std::vector<unsigned>& sizes , std::vector<bool> directions );
Bitmap_cubical_complex_base( const std::vector<unsigned>& dimensions , const std::vector<T>& top_dimensional_cells , std::vector<bool> directions );
};
-template <typename T>
-void Bitmap_cubical_complex_base<T>::put_data_toBins( size_t number_of_bins )
-{
- bool bdg = false;
-
- std::pair< T ,T > min_max = this->min_max_filtration();
- T dx = (min_max.second-min_max.first)/(T)number_of_bins;
-
- //now put the data into the appropriate bins:
- for ( size_t i = 0 ; i != this->data.size() ; ++i )
- {
- if ( bdg ){cerr << "Before binning : " << this->data[i] << endl;}
- this->data[i] = min_max.first + dx*(this->data[i]-min_max.first)/number_of_bins;
- if ( bdg ){cerr << "After binning : " << this->data[i] << endl;getchar();}
- }
-}
-
template <typename T>
-void Bitmap_cubical_complex_base<T>::put_data_toBins( T diameter_of_bin )
-{
- bool bdg = false;
- std::pair< T ,T > min_max = this->min_max_filtration();
-
- size_t number_of_bins = (min_max.second - min_max.first)/diameter_of_bin;
- //now put the data into the appropriate bins:
- for ( size_t i = 0 ; i != this->data.size() ; ++i )
- {
- if ( bdg ){cerr << "Before binning : " << this->data[i] << endl;}
- this->data[i] = min_max.first + diameter_of_bin*(this->data[i]-min_max.first)/number_of_bins;
- if ( bdg ){cerr << "After binning : " << this->data[i] << endl;getchar();}
- }
-}
-
-template <typename T>
-std::pair< T ,T > Bitmap_cubical_complex_base<T>::min_max_filtration()
-{
- std::pair< T ,T > min_max( std::numeric_limits<T>::max() , std::numeric_limits<T>::min() );
- for ( size_t i = 0 ; i != this->data.size() ; ++i )
- {
- if ( this->data[i] < min_max.first )min_max.first = this->data[i];
- if ( this->data[i] > min_max.second )min_max.second = this->data[i];
- }
- return min_max;
-}
+void Bitmap_cubical_complex_base<T>::put_data_toBins( size_t number_of_bins )
+{
+ bool bdg = false;
+
+ std::pair< T ,T > min_max = this->min_max_filtration();
+ T dx = (min_max.second-min_max.first)/(T)number_of_bins;
+
+ //now put the data into the appropriate bins:
+ for ( size_t i = 0 ; i != this->data.size() ; ++i )
+ {
+ if ( bdg ){cerr << "Before binning : " << this->data[i] << endl;}
+ this->data[i] = min_max.first + dx*(this->data[i]-min_max.first)/number_of_bins;
+ if ( bdg ){cerr << "After binning : " << this->data[i] << endl;getchar();}
+ }
+}
+
+template <typename T>
+void Bitmap_cubical_complex_base<T>::put_data_toBins( T diameter_of_bin )
+{
+ bool bdg = false;
+ std::pair< T ,T > min_max = this->min_max_filtration();
+
+ size_t number_of_bins = (min_max.second - min_max.first)/diameter_of_bin;
+ //now put the data into the appropriate bins:
+ for ( size_t i = 0 ; i != this->data.size() ; ++i )
+ {
+ if ( bdg ){cerr << "Before binning : " << this->data[i] << endl;}
+ this->data[i] = min_max.first + diameter_of_bin*(this->data[i]-min_max.first)/number_of_bins;
+ if ( bdg ){cerr << "After binning : " << this->data[i] << endl;getchar();}
+ }
+}
+
+template <typename T>
+std::pair< T ,T > Bitmap_cubical_complex_base<T>::min_max_filtration()
+{
+ std::pair< T ,T > min_max( std::numeric_limits<T>::max() , std::numeric_limits<T>::min() );
+ for ( size_t i = 0 ; i != this->data.size() ; ++i )
+ {
+ if ( this->data[i] < min_max.first )min_max.first = this->data[i];
+ if ( this->data[i] > min_max.second )min_max.second = this->data[i];
+ }
+ return min_max;
+}
template <typename K>
@@ -457,10 +494,10 @@ Bitmap_cubical_complex_base<T>::Bitmap_cubical_complex_base
{
this->set_up_containers( sizes );
}
-
-template <typename T>
-void Bitmap_cubical_complex_base<T>::setup_bitmap_based_on_top_dimensional_cells_list(const std::vector<unsigned>& sizes_in_following_directions , const std::vector<T>& top_dimensional_cells)
-{
+
+template <typename T>
+void Bitmap_cubical_complex_base<T>::setup_bitmap_based_on_top_dimensional_cells_list(const std::vector<unsigned>& sizes_in_following_directions , const std::vector<T>& top_dimensional_cells)
+{
this->set_up_containers( sizes_in_following_directions );
size_t number_of_top_dimensional_elements = 1;
@@ -489,19 +526,19 @@ void Bitmap_cubical_complex_base<T>::setup_bitmap_based_on_top_dimensional_cells
(*it) = top_dimensional_cells[index];
++index;
}
- this->impose_lower_star_filtration();
-}
+ this->impose_lower_star_filtration();
+}
template <typename T>
Bitmap_cubical_complex_base<T>::Bitmap_cubical_complex_base
( const std::vector<unsigned>& sizes_in_following_directions , const std::vector<T>& top_dimensional_cells )
{
this->setup_bitmap_based_on_top_dimensional_cells_list( sizes_in_following_directions , top_dimensional_cells );
-}
-
-template <typename T>
-void Bitmap_cubical_complex_base<T>::read_perseus_style_file( const char* perseus_style_file )
-{
+}
+
+template <typename T>
+void Bitmap_cubical_complex_base<T>::read_perseus_style_file( const char* perseus_style_file )
+{
bool dbg = false;
ifstream inFiltration, inIds;
inFiltration.open( perseus_style_file );
@@ -510,7 +547,7 @@ void Bitmap_cubical_complex_base<T>::read_perseus_style_file( const char* perseu
if (dbg){cerr << "dimensionOfData : " << dimensionOfData << endl;getchar();}
- std::vector<unsigned> sizes;
+ std::vector<unsigned> sizes;
sizes.reserve( dimensionOfData );
for ( size_t i = 0 ; i != dimensionOfData ; ++i )
{
@@ -541,31 +578,31 @@ void Bitmap_cubical_complex_base<T>::read_perseus_style_file( const char* perseu
++it;
}
inFiltration.close();
- this->impose_lower_star_filtration();
-}
-
-template <typename T>
-Bitmap_cubical_complex_base<T>::Bitmap_cubical_complex_base( const char* perseus_style_file , std::vector<bool> directions )
-{
- //this constructor is here just for compatibility with a class that creates cubical complexes with periodic bundary conditions.
- //It ignores the last parameter of the function.
- this->read_perseus_style_file( perseus_style_file );
-}
-
-template <typename T>
-Bitmap_cubical_complex_base<T>::Bitmap_cubical_complex_base( const std::vector<unsigned>& sizes , std::vector<bool> directions )
-{
- //this constructor is here just for compatibility with a class that creates cubical complexes with periodic bundary conditions.
- //It ignores the last parameter of the function.
- this->set_up_containers( sizes );
-}
-
-template <typename T>
+ this->impose_lower_star_filtration();
+}
+
+template <typename T>
+Bitmap_cubical_complex_base<T>::Bitmap_cubical_complex_base( const char* perseus_style_file , std::vector<bool> directions )
+{
+ //this constructor is here just for compatibility with a class that creates cubical complexes with periodic bundary conditions.
+ //It ignores the last parameter of the function.
+ this->read_perseus_style_file( perseus_style_file );
+}
+
+template <typename T>
+Bitmap_cubical_complex_base<T>::Bitmap_cubical_complex_base( const std::vector<unsigned>& sizes , std::vector<bool> directions )
+{
+ //this constructor is here just for compatibility with a class that creates cubical complexes with periodic bundary conditions.
+ //It ignores the last parameter of the function.
+ this->set_up_containers( sizes );
+}
+
+template <typename T>
Bitmap_cubical_complex_base<T>::Bitmap_cubical_complex_base( const std::vector<unsigned>& dimensions , const std::vector<T>& top_dimensional_cells , std::vector<bool> directions )
-{
- //this constructor is here just for compatibility with a class that creates cubical complexes with periodic bundary conditions.
- //It ignores the last parameter of the function.
- this->setup_bitmap_based_on_top_dimensional_cells_list( dimensions , top_dimensional_cells );
+{
+ //this constructor is here just for compatibility with a class that creates cubical complexes with periodic bundary conditions.
+ //It ignores the last parameter of the function.
+ this->setup_bitmap_based_on_top_dimensional_cells_list( dimensions , top_dimensional_cells );
}
template <typename T>
@@ -578,29 +615,29 @@ Bitmap_cubical_complex_base<T>::Bitmap_cubical_complex_base( const char* perseus
template <typename T>
std::vector< size_t > Bitmap_cubical_complex_base<T>::get_boundary_of_a_cell( size_t cell )const
{
- std::vector< size_t > boundary_elements;
-
- //Speed traded of for memory. Check if it is better in practice.
- boundary_elements.reserve( this->dimension()*2 );
+ std::vector< size_t > boundary_elements;
+
+ //Speed traded of for memory. Check if it is better in practice.
+ boundary_elements.reserve( this->dimension()*2 );
size_t cell1 = cell;
for ( size_t i = this->multipliers.size() ; i != 0 ; --i )
{
unsigned position = cell1/this->multipliers[i-1];
if ( position%2 == 1 )
- {
- boundary_elements.push_back( cell - this->multipliers[ i-1 ] );
+ {
+ boundary_elements.push_back( cell - this->multipliers[ i-1 ] );
boundary_elements.push_back( cell + this->multipliers[ i-1 ] );
}
cell1 = cell1%this->multipliers[i-1];
}
return boundary_elements;
-}
+}
+
+
+
-
-
-
template <typename T>
std::vector< size_t > Bitmap_cubical_complex_base<T>::get_coboundary_of_a_cell( size_t cell )const
{
@@ -625,8 +662,8 @@ std::vector< size_t > Bitmap_cubical_complex_base<T>::get_coboundary_of_a_cell(
cell1 = cell1%this->multipliers[i-1];
}
return coboundary_elements;
-}
-
+}
+
@@ -675,14 +712,14 @@ void Bitmap_cubical_complex_base<T>::impose_lower_star_filtration()
//this vector will be used to check which elements have already been taken care of
//in imposing lower star filtration:
std::vector<bool> is_this_cell_considered( this->data.size() , false );
-
- size_t size_to_reserve = 1;
- for ( size_t i = 0 ; i != this->multipliers.size() ; ++i )
- {
- size_to_reserve *= (size_t)((this->multipliers[i]-1)/2);
- }
-
- std::vector<size_t> indices_to_consider;
+
+ size_t size_to_reserve = 1;
+ for ( size_t i = 0 ; i != this->multipliers.size() ; ++i )
+ {
+ size_to_reserve *= (size_t)((this->multipliers[i]-1)/2);
+ }
+
+ std::vector<size_t> indices_to_consider;
indices_to_consider.reserve( size_to_reserve );
//we assume here that we already have a filtration on the top dimensional cells and
//we have to extend it to lower ones.
@@ -708,20 +745,20 @@ void Bitmap_cubical_complex_base<T>::impose_lower_star_filtration()
{
std::vector<size_t> bd = this->get_boundary_of_a_cell( indices_to_consider[i] );
for ( size_t boundaryIt = 0 ; boundaryIt != bd.size() ; ++boundaryIt )
- {
- if ( dbg )
- {
- cerr << "filtration of a cell : " << bd[boundaryIt] << " is : " << this->data[ bd[boundaryIt] ] << " while of a cell: " << indices_to_consider[i] << " is: " << this->data[ indices_to_consider[i] ] << endl;
- getchar();
-
+ {
+ if ( dbg )
+ {
+ cerr << "filtration of a cell : " << bd[boundaryIt] << " is : " << this->data[ bd[boundaryIt] ] << " while of a cell: " << indices_to_consider[i] << " is: " << this->data[ indices_to_consider[i] ] << endl;
+ getchar();
+
}
if ( this->data[ bd[boundaryIt] ] > this->data[ indices_to_consider[i] ] )
{
- this->data[ bd[boundaryIt] ] = this->data[ indices_to_consider[i] ];
- if ( dbg )
- {
- cerr << "Setting the value of a cell : " << bd[boundaryIt] << " to : " << this->data[ indices_to_consider[i] ] << endl;
- getchar();
+ this->data[ bd[boundaryIt] ] = this->data[ indices_to_consider[i] ];
+ if ( dbg )
+ {
+ cerr << "Setting the value of a cell : " << bd[boundaryIt] << " to : " << this->data[ indices_to_consider[i] ] << endl;
+ getchar();
}
}
if ( is_this_cell_considered[ bd[boundaryIt] ] == false )
@@ -760,4 +797,4 @@ bool compareFirstElementsOfTuples( const std::pair< std::pair< T , size_t > , ch
}
-}
+}
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 f0fd785f..8c1254db 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
@@ -38,6 +38,11 @@ namespace Cubical_complex
/**
+ *@class Bitmap_cubical_complex_periodic_boundary_conditions_base
+ *@brief Cubical complex with periodic boundary conditions represented as a bitmap.
+ *@ingroup cubical_complex
+ */
+/**
* This is a class implementing a bitmap data structure with periodic boundary conditions. Most of the functions are identical to the functions from Bitmap_cubical_complex_base.
* The ones that needed to be updated are the constructors and get_boundary_of_a_cell and get_coboundary_of_a_cell.
*/
@@ -64,6 +69,11 @@ public:
*/
Bitmap_cubical_complex_periodic_boundary_conditions_base( const std::vector<unsigned>& dimensions , const std::vector<T>& topDimensionalCells , const std::vector< bool >& directions_in_which_periodic_b_cond_are_to_be_imposed );
+ /**
+ * Destructor of the Bitmap_cubical_complex_periodic_boundary_conditions_base class.
+ **/
+ virtual ~Bitmap_cubical_complex_periodic_boundary_conditions_base(){}
+
//overwritten methods co compute boundary and coboundary
/**
* A version of a function that return boundary of a given cell for an object of Bitmap_cubical_complex_periodic_boundary_conditions_base class.