summaryrefslogtreecommitdiff
path: root/src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex_base.h
diff options
context:
space:
mode:
authorpdlotko <pdlotko@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2016-03-17 08:43:58 +0000
committerpdlotko <pdlotko@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2016-03-17 08:43:58 +0000
commitd133f17dede836cee1dfff47d2e00532573b9ead (patch)
tree649419c6dea7a603eec2676bfd44cbacd32cf188 /src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex_base.h
parent5389d8969d8386bb4c74dbef4b7c7992e9130f13 (diff)
cleanning up the stuff with iterators in Bitmap_cubical_complex_base.h class.
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/bitmap@1049 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 9630d6df6a2ecdb51ab25150454a563cd928b09a
Diffstat (limited to 'src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex_base.h')
-rw-r--r--src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex_base.h515
1 files changed, 313 insertions, 202 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 807be335..6d2b705c 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
@@ -22,7 +22,7 @@
#pragma once
-#include <iostream>
+#include <iostream>
#include <numeric>
#include <string>
#include <vector>
@@ -30,7 +30,7 @@
#include <fstream>
#include <algorithm>
#include <iterator>
-#include <limits>
+#include <limits>
#include <ctime>
#include "Bitmap_cubical_complex/counter.h"
@@ -69,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.
@@ -96,11 +96,11 @@ public:
* together with vector of filtration values of top dimensional cells.
**/
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(){}
+ **/
+ virtual ~Bitmap_cubical_complex_base(){}
/**
* The functions get_boundary_of_a_cell, get_coboundary_of_a_cell, get_dimension_of_a_cell
@@ -130,7 +130,9 @@ public:
**/
inline unsigned get_dimension_of_a_cell( size_t cell )const;
/**
- * In the case of get_cell_data, the output parameter is a reference to the value of a cube in a given position.
+ * In the case of get_cell_data, the output parameter is a reference to the value of a cube in a given position. This allows reading and changing the value of filtration.
+ * Note that if the value of a filtration is changed, the code do not check if we have a filtration or not. i.e. it do not check if the value of a filtration of a cell is
+ * not smaller than the value of a filtration of its boundary and not greater than the value of its coboundary.
**/
inline T& get_cell_data( size_t cell );
@@ -162,27 +164,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 );
+
+
/**
- * 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 )
+ * 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( size_t number_of_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( 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
+ * 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 );
-
+ 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
@@ -191,76 +193,179 @@ 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;
/**
* Constant iterator through all cells in the complex (in order they appear in the structure -- i.e.
* in lexicographical order).
**/
- typedef typename std::vector< T >::const_iterator all_cells_const_iterator;
-
+ //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();
- }
-
-
+ //all_cells_const_iterator all_cells_const_begin()const
+ //{
+ // return this->data.begin();
+ //}
+
+
/**
* 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_const_end()const
+ //{
+ // return this->data.end();
+ //}
+
+ /**
+ * Function returning an iterator to the first cell of the bitmap.
+ **/
+ //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_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_end() const
+ //{
+ // return this->data.end();
+ //}
+
+ /**
+ * Iterator through all cells in the complex (in order they appear in the structure -- i.e.
+ * in lexicographical order).
+ **/
+ class All_cells_iterator : std::iterator< std::input_iterator_tag, T >
{
- return this->data.end();
- }
+ public:
+ All_cells_iterator()
+ {
+ this->counter = 0;
+ }
+ All_cells_iterator operator++()
+ {
+ //first find first element of the counter that can be increased:
+ ++this->counter;
+ return *this;
+ }
+ All_cells_iterator operator++(int)
+ {
+ All_cells_iterator result = *this;
+ ++(*this);
+ return result;
+ }
+ All_cells_iterator operator =( const All_cells_iterator& rhs )
+ {
+ this->counter = rhs.counter;
+ return *this;
+ }
+ bool operator == ( const All_cells_iterator& rhs )const
+ {
+ if ( this->counter != rhs.counter )return false;
+ return true;
+ }
+ bool operator != ( const All_cells_iterator& rhs )const
+ {
+ return !(*this == rhs);
+ }
+ size_t operator*()
+ {
+ return this->counter;
+ }
+ friend class Bitmap_cubical_complex_base;
+ protected:
+ size_t counter;
+ };
+
/**
- * Function returning an iterator to the first cell of the bitmap.
+ * Function returning a All_cells_iterator to the first cell of the bitmap.
**/
- all_cells_iterator all_cells_begin()
+ All_cells_iterator all_cells_iterator_begin()
{
- return this->data.begin();
- }
-
+ All_cells_iterator a;
+ return a;
+ }
+
/**
- * Function returning a constant iterator to the first cell of the bitmap.
+ * Function returning a All_cells_iterator to the last cell of the bitmap.
**/
- all_cells_const_iterator all_cells_begin() const
+ All_cells_iterator all_cells_iterator_end()
{
- return this->data.begin();
- }
-
+ All_cells_iterator a;
+ a.counter = this->data.size();
+ return a;
+ }
+
/**
- * Function returning an iterator to the last cell of the bitmap.
+ * Boundary_range class provides ranges for boundary iterators.
+ **/
+ typedef typename std::vector< size_t >::iterator Boundary_iterator;
+ typedef typename std::vector< size_t > Boundary_range;
+
+ /**
+ * boundary_simplex_range creates an object of a Boundary_simplex_range class
+ * that provides ranges for the Boundary_simplex_iterator.
**/
- all_cells_iterator all_cells_end()
+ Boundary_range boundary_range(size_t sh)
{
- return this->data.end();
- }
-
+ return this->get_boundary_of_a_cell(sh);
+ }
+
/**
- * Function returning a constant iterator to the last cell of the bitmap.
+ * Coboundary_range class provides ranges for boundary iterators.
+ **/
+ typedef typename std::vector< size_t >::iterator Coboundary_iterator;
+ typedef typename std::vector< size_t > Coboundary_range;
+
+ /**
+ * boundary_simplex_range creates an object of a Boundary_simplex_range class
+ * that provides ranges for the Boundary_simplex_iterator.
**/
- all_cells_const_iterator all_cells_end() const
+ Coboundary_range coboundary_range(size_t sh)
{
- return this->data.end();
- }
+ return this->get_coboundary_of_a_cell(sh);
+ }
+
+
+
+
+
+
+
/**
* Iterator through top dimensional cells of the complex. The cells appear in order they are stored
* in the structure (i.e. in lexicographical order)
**/
- class Top_dimensional_cells_iterator : std::iterator< std::input_iterator_tag, double >
+ class Top_dimensional_cells_iterator : std::iterator< std::input_iterator_tag, T >
{
public:
Top_dimensional_cells_iterator( Bitmap_cubical_complex_base& b ):b(b)
{
- this->counter = std::vector<size_t>(b.dimension());
- //std::fill( this->counter.begin() , this->counter.end() , 0 );
- }
+ this->counter = std::vector<size_t>(b.dimension());
+ //std::fill( this->counter.begin() , this->counter.end() , 0 );
+ }
Top_dimensional_cells_iterator operator++()
{
//first find first element of the counter that can be increased:
@@ -308,15 +413,20 @@ public:
return !(*this == rhs);
}
- T& operator*()
- {
- //given the counter, compute the index in the array and return this element.
- unsigned index = 0;
- for ( size_t i = 0 ; i != this->counter.size() ; ++i )
- {
- index += (2*this->counter[i]+1)*this->b.multipliers[i];
- }
- return this->b.data[index];
+ //T& operator*()
+ //{
+ // //given the counter, compute the index in the array and return this element.
+ // unsigned index = 0;
+ // for ( size_t i = 0 ; i != this->counter.size() ; ++i )
+ // {
+ // index += (2*this->counter[i]+1)*this->b.multipliers[i];
+ // }
+ // return this->b.data[index];
+ //}
+
+ size_t operator*()
+ {
+ return this->compute_index_in_bitmap();
}
size_t compute_index_in_bitmap()const
@@ -327,7 +437,8 @@ public:
index += (2*this->counter[i]+1)*this->b.multipliers[i];
}
return index;
- }
+ }
+
void print_counter()const
{
@@ -340,19 +451,19 @@ 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.
+ * 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 a(*this);
return a;
- }
-
+ }
+
/**
- * Function returning a Top_dimensional_cells_iterator to the last top dimensional cell cell of the bitmap.
+ * Function returning a Top_dimensional_cells_iterator to the last top dimensional cell of the bitmap.
**/
Top_dimensional_cells_iterator top_dimensional_cells_end()
{
@@ -370,11 +481,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;
}
//****************************************************************************************************************//
@@ -412,7 +523,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 )
{
@@ -421,59 +532,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( 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( 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>
@@ -494,10 +605,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;
@@ -523,22 +634,22 @@ void Bitmap_cubical_complex_base<T>::setup_bitmap_based_on_top_dimensional_cells
size_t index = 0;
for ( it = this->top_dimensional_cells_begin() ; it != this->top_dimensional_cells_end() ; ++it )
{
- (*it) = top_dimensional_cells[index];
+ this->get_cell_data(*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 );
@@ -547,7 +658,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 )
{
@@ -564,7 +675,7 @@ void Bitmap_cubical_complex_base<T>::read_perseus_style_file( const char* perseu
while ( !inFiltration.eof() )
{
- double filtrationLevel;
+ T filtrationLevel;
inFiltration >> filtrationLevel;
if ( dbg )
{
@@ -574,35 +685,35 @@ void Bitmap_cubical_complex_base<T>::read_perseus_style_file( const char* perseu
<< this->get_dimension_of_a_cell(it.compute_index_in_bitmap())
<< " get the value : " << filtrationLevel << endl;
}
- *it = filtrationLevel;
+ this->get_cell_data(*it) = filtrationLevel;
++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>
@@ -615,29 +726,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
{
@@ -662,8 +773,8 @@ std::vector< size_t > Bitmap_cubical_complex_base<T>::get_coboundary_of_a_cell(
cell1 = cell1%this->multipliers[i-1];
}
return coboundary_elements;
-}
-
+}
+
@@ -712,14 +823,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.
@@ -745,20 +856,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 )
@@ -797,4 +908,4 @@ bool compareFirstElementsOfTuples( const std::pair< std::pair< T , size_t > , ch
}
-}
+}