summaryrefslogtreecommitdiff
path: root/src/Bitmap_cubical_complex
diff options
context:
space:
mode:
authorvrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2015-09-25 16:07:20 +0000
committervrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2015-09-25 16:07:20 +0000
commitdd2a15d1a8d2607848527513210330baebce9e8e (patch)
tree8fbd68fd390c6a62ac4e635a38aa2e4afff3cc78 /src/Bitmap_cubical_complex
parent62937147e40a7d2da7aa7a7a604808feeccaa75e (diff)
cpplint fixes
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/bitmap@795 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 94efebf169656da3179640ce9c02e8416cc75a18
Diffstat (limited to 'src/Bitmap_cubical_complex')
-rw-r--r--src/Bitmap_cubical_complex/example/Bitmap_cubical_complex.cpp30
-rw-r--r--src/Bitmap_cubical_complex/example/Random_bitmap_cubical_complex.cpp28
-rw-r--r--src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex.h294
-rw-r--r--src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex_base.h144
-rw-r--r--src/Bitmap_cubical_complex/include/gudhi/counter.h23
5 files changed, 277 insertions, 242 deletions
diff --git a/src/Bitmap_cubical_complex/example/Bitmap_cubical_complex.cpp b/src/Bitmap_cubical_complex/example/Bitmap_cubical_complex.cpp
index c0dbaf36..37c16618 100644
--- a/src/Bitmap_cubical_complex/example/Bitmap_cubical_complex.cpp
+++ b/src/Bitmap_cubical_complex/example/Bitmap_cubical_complex.cpp
@@ -20,33 +20,35 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-//for persistence algorithm
-#include "gudhi/reader_utils.h"
-#include "gudhi/Bitmap_cubical_complex.h"
-#include "gudhi/Persistent_cohomology.h"
+// for persistence algorithm
+#include <gudhi/reader_utils.h>
+#include <gudhi/Bitmap_cubical_complex.h>
+#include <gudhi/Persistent_cohomology.h>
#include <boost/program_options.hpp>
-using namespace Gudhi;
-using namespace Gudhi::persistent_cohomology;
-
-//standard stuff
+// standard stuff
#include <iostream>
#include <sstream>
+using namespace Gudhi;
+using namespace Gudhi::persistent_cohomology;
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 numbed in \
-the first line is a dimension D of a cubical complex. 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;
+ cout << "This program computes persistent homology, by using Bitmap_cubical_complex class, of cubical complexes "
+ "provided in text files in Perseus style (the only numbed in the first line is a dimension D of a cubical "
+ "complex. 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 cubical complex at the input. The program will now terminate.\n";
+ cout << "Wrong number of parameters. Please provide the name of a file with a Perseus style cubical complex at the "
+ "input. The program will now terminate.\n";
return 1;
}
@@ -55,7 +57,7 @@ lexicographical order. See CubicalOneSphere.txt or CubicalTwoSphere.txt for exam
// Compute the persistence diagram of the complex
persistent_cohomology::Persistent_cohomology< Bitmap_cubical_complex<double>, Field_Zp > pcoh(b);
- pcoh.init_coefficients(p); //initilizes the coefficient field for homology
+ pcoh.init_coefficients(p); // initializes the coefficient field for homology
pcoh.compute_persistent_cohomology(min_persistence);
diff --git a/src/Bitmap_cubical_complex/example/Random_bitmap_cubical_complex.cpp b/src/Bitmap_cubical_complex/example/Random_bitmap_cubical_complex.cpp
index de9d96e0..ac7557ce 100644
--- a/src/Bitmap_cubical_complex/example/Random_bitmap_cubical_complex.cpp
+++ b/src/Bitmap_cubical_complex/example/Random_bitmap_cubical_complex.cpp
@@ -21,31 +21,31 @@
*/
-//for persistence algorithm
-#include "gudhi/reader_utils.h"
-#include "gudhi/Bitmap_cubical_complex.h"
-#include "gudhi/Persistent_cohomology.h"
+// for persistence algorithm
+#include <gudhi/reader_utils.h>
+#include <gudhi/Bitmap_cubical_complex.h>
+#include <gudhi/Persistent_cohomology.h>
#include <boost/program_options.hpp>
-using namespace Gudhi;
-using namespace Gudhi::persistent_cohomology;
-
-//standard stuff
+// standard stuff
#include <iostream>
#include <sstream>
#include <vector>
#include <cstdlib>
#include <ctime>
+using namespace Gudhi;
+using namespace Gudhi::persistent_cohomology;
using namespace std;
int main(int argc, char** argv) {
srand(time(0));
- cout << "This program computes persistent homology, by using Bitmap_cubical_complex class, of cubical complexes. \
-The first parameter of the program is the dimension D of the cubical complex. The next D parameters are number of top dimensional cubes in each dimension of the cubical complex.\
-The program will create random cubical complex of that sizes and compute persistent homology of it." << endl;
+ cout << "This program computes persistent homology, by using Bitmap_cubical_complex class, of cubical complexes. "
+ "The first parameter of the program is the dimension D of the cubical complex. The next D parameters are number "
+ "of top dimensional cubes in each dimension of the cubical complex. The program will create random cubical "
+ "complex of that sizes and compute persistent homology of it." << endl;
int p = 2;
double min_persistence = 0;
@@ -64,17 +64,13 @@ The program will create random cubical complex of that sizes and compute persist
data.push_back(rand() / (double) RAND_MAX);
}
-
-
Bitmap_cubical_complex<double> b(sizes, data);
-
// Compute the persistence diagram of the complex
persistent_cohomology::Persistent_cohomology< Bitmap_cubical_complex<double>, Field_Zp > pcoh(b);
- pcoh.init_coefficients(p); //initilizes the coefficient field for homology
+ pcoh.init_coefficients(p); // initializes the coefficient field for homology
pcoh.compute_persistent_cohomology(min_persistence);
-
stringstream ss;
ss << "randomComplex_persistence";
std::ofstream out((char*) ss.str().c_str());
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 61ae8105..2f8cb0a3 100644
--- a/src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex.h
+++ b/src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex.h
@@ -23,38 +23,41 @@
#ifndef BITMAP_CUBICAL_COMPLEX_H_
#define BITMAP_CUBICAL_COMPLEX_H_
-#include <limits>
-
#include <gudhi/Bitmap_cubical_complex_base.h>
-//global variable, was used just for debugging.
+#include <limits>
+#include <utility> // for pair
+#include <algorithm> // for sort
+#include <vector> // for vector
+
+// global variable, was used just for debugging.
bool globalDbg = false;
template <typename T = double>
class Bitmap_cubical_complex : public Bitmap_cubical_complex_base<T> {
public:
- //*********************************************************************************************************************************//
- //Typedefs and typenames
- //*********************************************************************************************************************************//
+ //******************************************************************************************************************//
+ // Typedefs and typenames
+ //******************************************************************************************************************//
friend class Simplex_handle;
typedef size_t Simplex_key;
typedef T Filtration_value;
- //*********************************************************************************************************************************//
- //Simplex handle class
- //*********************************************************************************************************************************//
+ //******************************************************************************************************************//
+ // Simplex handle class
+ //******************************************************************************************************************//
/**
- * Handle of a cell, required for compatibility with the function to compute persistence in Gudhi. Elements of this class are: the pointer to the bitmap B in which the considered cell is
- * together with a position of this cell in B. Given this data, one can get all the information about the considered cell.
+ * Handle of a cell, required for compatibility with the function to compute persistence in Gudhi. Elements of this
+ * class are: the pointer to the bitmap B in which the considered cell is together with a position of this cell in B.
+ * Given this data, one can get all the information about the considered cell.
**/
class Simplex_handle {
public:
-
Simplex_handle() {
if (globalDbg) {
- cerr << "Simplex_handle()\n";
+ std::cerr << "Simplex_handle()\n";
}
this->b = 0;
this->position = 0;
@@ -62,7 +65,7 @@ class Bitmap_cubical_complex : public Bitmap_cubical_complex_base<T> {
Simplex_handle(Bitmap_cubical_complex<T>* b) {
if (globalDbg) {
- cerr << "Simplex_handle(Bitmap_cubical_complex<T>* b)\n";
+ std::cerr << "Simplex_handle(Bitmap_cubical_complex<T>* b)\n";
}
this->b = b;
this->position = 0;
@@ -70,14 +73,14 @@ class Bitmap_cubical_complex : public Bitmap_cubical_complex_base<T> {
Simplex_handle(const Simplex_handle& org) : b(org.b) {
if (globalDbg) {
- cerr << "Simplex_handle( const Simplex_handle& org )\n";
+ std::cerr << "Simplex_handle( const Simplex_handle& org )\n";
}
this->position = org.position;
}
Simplex_handle& operator=(const Simplex_handle& rhs) {
if (globalDbg) {
- cerr << "Simplex_handle operator = \n";
+ std::cerr << "Simplex_handle operator = \n";
}
this->position = rhs.position;
this->b = rhs.b;
@@ -86,8 +89,8 @@ class Bitmap_cubical_complex : public Bitmap_cubical_complex_base<T> {
Simplex_handle(Bitmap_cubical_complex<T>* b, Simplex_key position) {
if (globalDbg) {
- cerr << "Simplex_handle(Bitmap_cubical_complex<T>* b , Simplex_key position)\n";
- cerr << "Position : " << position << endl;
+ std::cerr << "Simplex_handle(Bitmap_cubical_complex<T>* b , Simplex_key position)\n";
+ std::cerr << "Position : " << position << std::endl;
}
this->b = b;
this->position = position;
@@ -95,27 +98,28 @@ class Bitmap_cubical_complex : public Bitmap_cubical_complex_base<T> {
friend class Bitmap_cubical_complex<T>;
private:
Bitmap_cubical_complex<T>* b;
- Simplex_key position; //Assumption -- this field always keep the REAL position of simplex in the bitmap, no matter what keys have been.
- //to deal with the keys, the class Bitmap_cubical_complex have extra vectors: keyAssociatedToSimplex and simplexAssociatedToKey
- //that allow to move between actual cell and the key assigned to it.
+ Simplex_key position;
+ // Assumption -- this field always keep the REAL position of simplex in the bitmap, no matter what keys have been.
+ // to deal with the keys, the class Bitmap_cubical_complex have extra vectors: keyAssociatedToSimplex and
+ // simplexAssociatedToKey that allow to move between actual cell and the key assigned to it.
};
- //*********************************************************************************************************************************//
- //Constructors
- //*********************************************************************************************************************************//
- //Over here we need to definie various input types. I am proposing the following ones:
- //Perseus style
- //H5 files? TODO
- //binary files with little endiangs / big endians? TODO
- //constructor from a vector of elements of a type T. TODO
+ //******************************************************************************************************************//
+ // Constructors
+ //******************************************************************************************************************//
+ // Over here we need to definie various input types. I am proposing the following ones:
+ // Perseus style
+ // TODO(Pawel Dlotko): H5 files?
+ // TODO(Pawel Dlotko): binary files with little endiangs / big endians?
+ // TODO(Pawel Dlotko): constructor from a vector of elements of a type T.
/**
* Constructor form a Perseus-style file.
**/
Bitmap_cubical_complex(char* perseusStyleFile) : Bitmap_cubical_complex_base<T>(perseusStyleFile) {
if (globalDbg) {
- cerr << "Bitmap_cubical_complex( char* perseusStyleFile )\n";
+ std::cerr << "Bitmap_cubical_complex( char* perseusStyleFile )\n";
}
std::vector< size_t > keyAssociatedToSimplex(this->totalNumberOfCells + 1);
std::vector< size_t > simplexAssociatedToKey(this->totalNumberOfCells + 1);
@@ -125,16 +129,17 @@ class Bitmap_cubical_complex : public Bitmap_cubical_complex_base<T> {
}
this->keyAssociatedToSimplex = keyAssociatedToSimplex;
this->simplexAssociatedToKey = simplexAssociatedToKey;
- //we initialize this only once, in each constructor, when the bitmap is constructed. If the user decide to change some elements of the bitmap, then this procedure need
- //to be called again.
+ // we initialize this only once, in each constructor, when the bitmap is constructed. If the user decide to change
+ // some elements of the bitmap, then this procedure need to be called again.
this->initializeElementsOrderedAccordingToFiltration();
}
/**
- * Constructor that requires vector of elements of type unsigned, which gives number of top dimensional cells in the following directions and vector of element of a type T
- * with filtration on top dimensional cells.
+ * Constructor that requires vector of elements of type unsigned, which gives number of top dimensional cells in the
+ * following directions and vector of element of a type T with filtration on top dimensional cells.
**/
- Bitmap_cubical_complex(std::vector<unsigned> dimensions, std::vector<T> topDimensionalCells) : Bitmap_cubical_complex_base<T>(dimensions, topDimensionalCells) {
+ Bitmap_cubical_complex(std::vector<unsigned> dimensions, std::vector<T> topDimensionalCells)
+ : Bitmap_cubical_complex_base<T>(dimensions, topDimensionalCells) {
std::vector< size_t > keyAssociatedToSimplex(this->totalNumberOfCells + 1);
std::vector< size_t > simplexAssociatedToKey(this->totalNumberOfCells + 1);
@@ -143,14 +148,14 @@ class Bitmap_cubical_complex : public Bitmap_cubical_complex_base<T> {
}
this->keyAssociatedToSimplex = keyAssociatedToSimplex;
this->simplexAssociatedToKey = simplexAssociatedToKey;
- //we initialize this only once, in each constructor, when the bitmap is constructed. If the user decide to change some elements of the bitmap, then this procedure need
- //to be called again.
+ // we initialize this only once, in each constructor, when the bitmap is constructed. If the user decide to change
+ // some elements of the bitmap, then this procedure need to be called again.
this->initializeElementsOrderedAccordingToFiltration();
}
- //*********************************************************************************************************************************//
- //Other 'easy' functions
- //*********************************************************************************************************************************//
+ //******************************************************************************************************************//
+ // Other 'easy' functions
+ //******************************************************************************************************************//
/**
* Returns number of all cubes in the complex.
@@ -178,7 +183,7 @@ class Bitmap_cubical_complex : public Bitmap_cubical_complex_base<T> {
**/
size_t dimension(const Simplex_handle& sh) {
if (globalDbg) {
- cerr << "int dimension(const Simplex_handle& sh)\n";
+ std::cerr << "int dimension(const Simplex_handle& sh)\n";
}
if (sh.position != this->data.size()) return sh.b->get_dimension_of_a_cell(sh.position);
return std::numeric_limits<size_t>::max();
@@ -189,9 +194,9 @@ class Bitmap_cubical_complex : public Bitmap_cubical_complex_base<T> {
**/
T filtration(const Simplex_handle& sh) {
if (globalDbg) {
- cerr << "T filtration(const Simplex_handle& sh)\n";
+ std::cerr << "T filtration(const Simplex_handle& sh)\n";
}
- //Returns the filtration value of a simplex.
+ // Returns the filtration value of a simplex.
if (sh.position != this->data.size()) return sh.b->data[ sh.position ];
return INT_MAX;
}
@@ -201,7 +206,7 @@ class Bitmap_cubical_complex : public Bitmap_cubical_complex_base<T> {
**/
Simplex_key null_key() {
if (globalDbg) {
- cerr << "Simplex_key null_key()\n";
+ std::cerr << "Simplex_key null_key()\n";
}
return this->data.size();
}
@@ -211,7 +216,7 @@ class Bitmap_cubical_complex : public Bitmap_cubical_complex_base<T> {
**/
Simplex_key key(const Simplex_handle& sh) {
if (globalDbg) {
- cerr << "Simplex_key key(const Simplex_handle& sh)\n";
+ std::cerr << "Simplex_key key(const Simplex_handle& sh)\n";
}
return sh.b->keyAssociatedToSimplex[ sh.position ];
}
@@ -221,7 +226,7 @@ class Bitmap_cubical_complex : public Bitmap_cubical_complex_base<T> {
**/
Simplex_handle simplex(Simplex_key key) {
if (globalDbg) {
- cerr << "Simplex_handle simplex(Simplex_key key)\n";
+ std::cerr << "Simplex_handle simplex(Simplex_key key)\n";
}
return Simplex_handle(this, this->simplexAssociatedToKey[ key ]);
}
@@ -231,7 +236,7 @@ class Bitmap_cubical_complex : public Bitmap_cubical_complex_base<T> {
**/
void assign_key(Simplex_handle& sh, Simplex_key key) {
if (globalDbg) {
- cerr << "void assign_key(Simplex_handle& sh, Simplex_key key)\n";
+ std::cerr << "void assign_key(Simplex_handle& sh, Simplex_key key)\n";
}
this->keyAssociatedToSimplex[sh.position] = key;
this->simplexAssociatedToKey[key] = sh.position;
@@ -244,9 +249,9 @@ class Bitmap_cubical_complex : public Bitmap_cubical_complex_base<T> {
- //*********************************************************************************************************************************//
- //Iterators
- //*********************************************************************************************************************************//
+ //******************************************************************************************************************//
+ // Iterators
+ //******************************************************************************************************************//
/**
* Boundary_simplex_iterator class allows iteration on boundary of each cube.
@@ -254,13 +259,12 @@ class Bitmap_cubical_complex : public Bitmap_cubical_complex_base<T> {
class Boundary_simplex_range;
class Boundary_simplex_iterator : std::iterator< std::input_iterator_tag, Simplex_handle > {
- //Iterator on the simplices belonging to the boundary of a simplex.
- //value_type must be 'Simplex_handle'.
+ // Iterator on the simplices belonging to the boundary of a simplex.
+ // value_type must be 'Simplex_handle'.
public:
-
Boundary_simplex_iterator(Simplex_handle& sh) : sh(sh) {
if (globalDbg) {
- cerr << "Boundary_simplex_iterator( Simplex_handle& sh )\n";
+ std::cerr << "Boundary_simplex_iterator( Simplex_handle& sh )\n";
}
this->position = 0;
this->boundaryElements = this->sh.b->get_boundary_of_a_cell(this->sh.position);
@@ -268,7 +272,7 @@ class Bitmap_cubical_complex : public Bitmap_cubical_complex_base<T> {
Boundary_simplex_iterator operator++() {
if (globalDbg) {
- cerr << "Boundary_simplex_iterator operator++()\n";
+ std::cerr << "Boundary_simplex_iterator operator++()\n";
}
++this->position;
return *this;
@@ -282,16 +286,17 @@ class Bitmap_cubical_complex : public Bitmap_cubical_complex_base<T> {
Boundary_simplex_iterator operator=(const Boundary_simplex_iterator& rhs) {
if (globalDbg) {
- cerr << "Boundary_simplex_iterator operator =\n";
+ std::cerr << "Boundary_simplex_iterator operator =\n";
}
this->sh = rhs.sh;
this->boundaryElements.clear();
- this->boundaryElementsinsert(this->boundaryElements.end(), rhs.boundaryElements.begin(), rhs.boundaryElements.end());
+ this->boundaryElementsinsert(this->boundaryElements.end(),
+ rhs.boundaryElements.begin(), rhs.boundaryElements.end());
}
bool operator==(const Boundary_simplex_iterator& rhs) {
if (globalDbg) {
- cerr << "bool operator ==\n";
+ std::cerr << "bool operator ==\n";
}
if (this->position == rhs.position) {
if (this->boundaryElements.size() != rhs.boundaryElements.size())return false;
@@ -305,14 +310,14 @@ class Bitmap_cubical_complex : public Bitmap_cubical_complex_base<T> {
bool operator!=(const Boundary_simplex_iterator& rhs) {
if (globalDbg) {
- cerr << "bool operator != \n";
+ std::cerr << "bool operator != \n";
}
return !(*this == rhs);
}
Simplex_handle operator*() {
if (globalDbg) {
- cerr << "Simplex_handle operator*\n";
+ std::cerr << "Simplex_handle operator*\n";
}
return Simplex_handle(this->sh.b, this->boundaryElements[this->position]);
}
@@ -328,15 +333,14 @@ class Bitmap_cubical_complex : public Bitmap_cubical_complex_base<T> {
* Boundary_simplex_range class provides ranges for boundary iterators.
**/
class Boundary_simplex_range {
- //Range giving access to the simplices in the boundary of a simplex.
- //.begin() and .end() return type Boundary_simplex_iterator.
+ // Range giving access to the simplices in the boundary of a simplex.
+ // .begin() and .end() return type Boundary_simplex_iterator.
public:
-
- Boundary_simplex_range(const Simplex_handle& sh) : sh(sh) { };
+ Boundary_simplex_range(const Simplex_handle& sh) : sh(sh) { }
Boundary_simplex_iterator begin() {
if (globalDbg) {
- cerr << "Boundary_simplex_iterator begin\n";
+ std::cerr << "Boundary_simplex_iterator begin\n";
}
Boundary_simplex_iterator it(this->sh);
return it;
@@ -344,12 +348,13 @@ class Bitmap_cubical_complex : public Bitmap_cubical_complex_base<T> {
Boundary_simplex_iterator end() {
if (globalDbg) {
- cerr << "Boundary_simplex_iterator end()\n";
+ std::cerr << "Boundary_simplex_iterator end()\n";
}
Boundary_simplex_iterator it(this->sh);
it.position = it.boundaryElements.size();
return it;
}
+
private:
Simplex_handle sh;
};
@@ -363,17 +368,16 @@ class Bitmap_cubical_complex : public Bitmap_cubical_complex_base<T> {
class Filtration_simplex_range;
class Filtration_simplex_iterator : std::iterator< std::input_iterator_tag, Simplex_handle > {
- //Iterator over all simplices of the complex in the order of the indexing scheme.
- //'value_type' must be 'Simplex_handle'.
+ // Iterator over all simplices of the complex in the order of the indexing scheme.
+ // 'value_type' must be 'Simplex_handle'.
public:
+ Filtration_simplex_iterator(Bitmap_cubical_complex* b) : b(b), position(0) { }
- Filtration_simplex_iterator(Bitmap_cubical_complex* b) : b(b), position(0) { };
-
- Filtration_simplex_iterator() : b(NULL) { };
+ Filtration_simplex_iterator() : b(NULL) { }
Filtration_simplex_iterator operator++() {
if (globalDbg) {
- cerr << "Filtration_simplex_iterator operator++\n";
+ std::cerr << "Filtration_simplex_iterator operator++\n";
}
++this->position;
return (*this);
@@ -387,7 +391,7 @@ class Bitmap_cubical_complex : public Bitmap_cubical_complex_base<T> {
Filtration_simplex_iterator operator=(const Filtration_simplex_iterator& rhs) {
if (globalDbg) {
- cerr << "Filtration_simplex_iterator operator =\n";
+ std::cerr << "Filtration_simplex_iterator operator =\n";
}
this->b = rhs.b;
this->position = rhs.position;
@@ -395,7 +399,7 @@ class Bitmap_cubical_complex : public Bitmap_cubical_complex_base<T> {
bool operator==(const Filtration_simplex_iterator& rhs) {
if (globalDbg) {
- cerr << "bool operator == ( const Filtration_simplex_iterator& rhs )\n";
+ std::cerr << "bool operator == ( const Filtration_simplex_iterator& rhs )\n";
}
if (this->position == rhs.position) {
return true;
@@ -405,14 +409,14 @@ class Bitmap_cubical_complex : public Bitmap_cubical_complex_base<T> {
bool operator!=(const Filtration_simplex_iterator& rhs) {
if (globalDbg) {
- cerr << "bool operator != ( const Filtration_simplex_iterator& rhs )\n";
+ std::cerr << "bool operator != ( const Filtration_simplex_iterator& rhs )\n";
}
return !(*this == rhs);
}
Simplex_handle operator*() {
if (globalDbg) {
- cerr << "Simplex_handle operator*()\n";
+ std::cerr << "Simplex_handle operator*()\n";
}
return Simplex_handle(this->b, this->b->elementsOrderedAccordingToFiltration[ this->position ]);
}
@@ -427,22 +431,21 @@ class Bitmap_cubical_complex : public Bitmap_cubical_complex_base<T> {
* Filtration_simplex_range provides the ranges for Filtration_simplex_iterator.
**/
class Filtration_simplex_range {
- //Range over the simplices of the complex in the order of the filtration.
- //.begin() and .end() return type Filtration_simplex_iterator.
+ // Range over the simplices of the complex in the order of the filtration.
+ // .begin() and .end() return type Filtration_simplex_iterator.
public:
-
- Filtration_simplex_range(Bitmap_cubical_complex<T>* b) : b(b) { };
+ Filtration_simplex_range(Bitmap_cubical_complex<T>* b) : b(b) { }
Filtration_simplex_iterator begin() {
if (globalDbg) {
- cerr << "Filtration_simplex_iterator begin() \n";
+ std::cerr << "Filtration_simplex_iterator begin() \n";
}
return Filtration_simplex_iterator(this->b);
}
Filtration_simplex_iterator end() {
if (globalDbg) {
- cerr << "Filtration_simplex_iterator end()\n";
+ std::cerr << "Filtration_simplex_iterator end()\n";
}
Filtration_simplex_iterator it(this->b);
it.position = this->b->elementsOrderedAccordingToFiltration.size();
@@ -454,40 +457,44 @@ class Bitmap_cubical_complex : public Bitmap_cubical_complex_base<T> {
- //*********************************************************************************************************************************//
- //Methods to access iterators from the container:
+ //******************************************************************************************************************//
+ // Methods to access iterators from the container:
/**
* boundary_simplex_range creates an object of a Boundary_simplex_range class that provides ranges for the Boundary_simplex_iterator.
**/
Boundary_simplex_range boundary_simplex_range(Simplex_handle& sh) {
if (globalDbg) {
- cerr << "Boundary_simplex_range boundary_simplex_range(Simplex_handle& sh)\n";
+ std::cerr << "Boundary_simplex_range boundary_simplex_range(Simplex_handle& sh)\n";
}
- //Returns a range giving access to all simplices of the boundary of a simplex, i.e. the set of codimension 1 subsimplices of the Simplex.
+ // Returns a range giving access to all simplices of the boundary of a simplex, i.e. the set of
+ // codimension 1 subsimplices of the Simplex.
return Boundary_simplex_range(sh);
}
/**
- * filtration_simplex_range creates an object of a Filtration_simplex_range class that provides ranges for the Filtration_simplex_iterator.
+ * filtration_simplex_range creates an object of a Filtration_simplex_range class that provides ranges for the
+ * Filtration_simplex_iterator.
**/
Filtration_simplex_range filtration_simplex_range() {
if (globalDbg) {
- cerr << "Filtration_simplex_range filtration_simplex_range()\n";
+ std::cerr << "Filtration_simplex_range filtration_simplex_range()\n";
}
- //Returns a range over the simplices of the complex in the order of the filtration
+ // Returns a range over the simplices of the complex in the order of the filtration
return Filtration_simplex_range(this);
}
- //*********************************************************************************************************************************//
+ //******************************************************************************************************************//
- //*********************************************************************************************************************************//
- //Elements which are in Gudhi now, but I (and in all the cases I asked also Marc) do not understand why they are there.
- //TODO -- the file IndexingTag.h in the Gudhi library contains an empty structure, so I understand that this is something that was planned (for simplicial maps?)
- //but was never finished. The only idea I have here is to use the same empty structure from IndexingTag.h file, but only if the compiler needs it. If the compiler
- //do not need it, then I would rather not add here elements which I do not understand.
- //typedef Indexing_tag
+ //******************************************************************************************************************//
+ // Elements which are in Gudhi now, but I (and in all the cases I asked also Marc) do not understand why they are
+ // there.
+ // TODO(Pawel Dlotko): The file IndexingTag.h in the Gudhi library contains an empty structure, so I understand that
+ // this is something that was planned (for simplicial maps?) but was never finished. The only idea I have here is
+ // to use the same empty structure from IndexingTag.h file, but only if the compiler needs it. If the compiler
+ // do not need it, then I would rather not add here elements which I do not understand.
+ // typedef Indexing_tag
/**
* Function needed for compatibility with Gudhi. Not useful for other purposes.
@@ -495,11 +502,13 @@ class Bitmap_cubical_complex : public Bitmap_cubical_complex_base<T> {
std::pair<Simplex_handle, Simplex_handle> endpoints(Simplex_handle sh) {
std::vector< size_t > bdry = this->get_boundary_of_a_cell(sh.position);
if (globalDbg) {
- cerr << "std::pair<Simplex_handle, Simplex_handle> endpoints( Simplex_handle sh )\n";
- cerr << "bdry.size() : " << bdry.size() << endl;
+ std::cerr << "std::pair<Simplex_handle, Simplex_handle> endpoints( Simplex_handle sh )\n";
+ std::cerr << "bdry.size() : " << bdry.size() << std::endl;
}
- //this method returns two first elements from the boundary of sh.
- if (bdry.size() < 2)throw ("Error in endpoints in Bitmap_cubical_complex class. The cell for which this method was called have less than two elements in the boundary.");
+ // this method returns two first elements from the boundary of sh.
+ if (bdry.size() < 2)
+ throw("Error in endpoints in Bitmap_cubical_complex class. "
+ "The cell for which this method was called have less than two elements in the boundary.");
return std::make_pair(Simplex_handle(this, bdry[0]), Simplex_handle(this, bdry[1]));
}
@@ -510,30 +519,31 @@ class Bitmap_cubical_complex : public Bitmap_cubical_complex_base<T> {
class Skeleton_simplex_range;
class Skeleton_simplex_iterator : std::iterator< std::input_iterator_tag, Simplex_handle > {
- //Iterator over all simplices of the complex in the order of the indexing scheme.
- //'value_type' must be 'Simplex_handle'.
+ // Iterator over all simplices of the complex in the order of the indexing scheme.
+ // 'value_type' must be 'Simplex_handle'.
public:
-
Skeleton_simplex_iterator(Bitmap_cubical_complex* b, size_t d) : b(b), dimension(d) {
if (globalDbg) {
- cerr << "Skeleton_simplex_iterator ( Bitmap_cubical_complex* b , size_t d )\n";
+ std::cerr << "Skeleton_simplex_iterator ( Bitmap_cubical_complex* b , size_t d )\n";
}
- //find the position of the first simplex of a dimension d
+ // find the position of the first simplex of a dimension d
this->position = 0;
- while ((this->position != b->data.size()) && (this->b->get_dimension_of_a_cell(this->position) != this->dimension)) {
+ while ((this->position != b->data.size()) &&
+ (this->b->get_dimension_of_a_cell(this->position) != this->dimension)) {
++this->position;
}
- };
+ }
- Skeleton_simplex_iterator() : b(NULL), dimension(0) { };
+ Skeleton_simplex_iterator() : b(NULL), dimension(0) { }
Skeleton_simplex_iterator operator++() {
if (globalDbg) {
- cerr << "Skeleton_simplex_iterator operator++()\n";
+ std::cerr << "Skeleton_simplex_iterator operator++()\n";
}
- //increment the position as long as you did not get to the next element of the dimension dimension.
+ // increment the position as long as you did not get to the next element of the dimension dimension.
++this->position;
- while ((this->position != this->b->data.size()) && (this->b->get_dimension_of_a_cell(this->position) != this->dimension)) {
+ while ((this->position != this->b->data.size()) &&
+ (this->b->get_dimension_of_a_cell(this->position) != this->dimension)) {
++this->position;
}
return (*this);
@@ -547,7 +557,7 @@ class Bitmap_cubical_complex : public Bitmap_cubical_complex_base<T> {
Skeleton_simplex_iterator operator=(const Skeleton_simplex_iterator& rhs) {
if (globalDbg) {
- cerr << "Skeleton_simplex_iterator operator =\n";
+ std::cerr << "Skeleton_simplex_iterator operator =\n";
}
this->b = rhs.b;
this->position = rhs.position;
@@ -555,7 +565,7 @@ class Bitmap_cubical_complex : public Bitmap_cubical_complex_base<T> {
bool operator==(const Skeleton_simplex_iterator& rhs) {
if (globalDbg) {
- cerr << "bool operator ==\n";
+ std::cerr << "bool operator ==\n";
}
if (this->position == rhs.position) {
return true;
@@ -565,14 +575,14 @@ class Bitmap_cubical_complex : public Bitmap_cubical_complex_base<T> {
bool operator!=(const Skeleton_simplex_iterator& rhs) {
if (globalDbg) {
- cerr << "bool operator != ( const Skeleton_simplex_iterator& rhs )\n";
+ std::cerr << "bool operator != ( const Skeleton_simplex_iterator& rhs )\n";
}
return !(*this == rhs);
}
Simplex_handle operator*() {
if (globalDbg) {
- cerr << "Simplex_handle operator*() \n";
+ std::cerr << "Simplex_handle operator*() \n";
}
return Simplex_handle(this->b, this->position);
}
@@ -588,27 +598,27 @@ class Bitmap_cubical_complex : public Bitmap_cubical_complex_base<T> {
* Class needed for compatibility with Gudhi. Not useful for other purposes.
**/
class Skeleton_simplex_range {
- //Range over the simplices of the complex in the order of the filtration.
- //.begin() and .end() return type Filtration_simplex_iterator.
+ // Range over the simplices of the complex in the order of the filtration.
+ // .begin() and .end() return type Filtration_simplex_iterator.
public:
-
- Skeleton_simplex_range(Bitmap_cubical_complex<T>* b, int dimension) : b(b), dimension(dimension) { };
+ Skeleton_simplex_range(Bitmap_cubical_complex<T>* b, int dimension) : b(b), dimension(dimension) { }
Skeleton_simplex_iterator begin() {
if (globalDbg) {
- cerr << "Skeleton_simplex_iterator begin()\n";
+ std::cerr << "Skeleton_simplex_iterator begin()\n";
}
return Skeleton_simplex_iterator(this->b, this->dimension);
}
Skeleton_simplex_iterator end() {
if (globalDbg) {
- cerr << "Skeleton_simplex_iterator end()\n";
+ std::cerr << "Skeleton_simplex_iterator end()\n";
}
Skeleton_simplex_iterator it(this->b, this->dimension);
it.position = this->b->data.size();
return it;
}
+
private:
Bitmap_cubical_complex<T>* b;
int dimension;
@@ -619,22 +629,22 @@ class Bitmap_cubical_complex : public Bitmap_cubical_complex_base<T> {
**/
Skeleton_simplex_range skeleton_simplex_range(int dimension) {
if (globalDbg) {
- cerr << "Skeleton_simplex_range skeleton_simplex_range( int dimension )\n";
+ std::cerr << "Skeleton_simplex_range skeleton_simplex_range( int dimension )\n";
}
return Skeleton_simplex_range(this, dimension);
}
- //*********************************************************************************************************************************//
- //functions used for debugging:
+ //******************************************************************************************************************//
+ // functions used for debugging:
/**
* Function used for debugging purposes.
**/
void printKeyAssociatedToSimplex() {
for (size_t i = 0; i != this->data.size(); ++i) {
- cerr << i << " -> " << this->simplexAssociatedToKey[i] << endl;
+ std::cerr << i << " -> " << this->simplexAssociatedToKey[i] << std::endl;
}
}
@@ -648,13 +658,17 @@ class Bitmap_cubical_complex : public Bitmap_cubical_complex_base<T> {
private:
std::vector< size_t > keyAssociatedToSimplex;
std::vector< size_t > simplexAssociatedToKey;
- std::vector< size_t > elementsOrderedAccordingToFiltration; //needed by Filtration_simplex_iterator. If this iterator is not used, this field is not initialized.
-}; //Bitmap_cubical_complex
+ // needed by Filtration_simplex_iterator. If this iterator is not used, this field is not initialized.
+ std::vector< size_t > elementsOrderedAccordingToFiltration;
+};
template <typename T>
-bool compareElementsForElementsOrderedAccordingToFiltration(const std::pair< size_t, std::pair< T, char > >& f, const std::pair< size_t, std::pair< T, char > >& s) {
+bool compareElementsForElementsOrderedAccordingToFiltration(const std::pair< size_t,
+ std::pair< T, char > >& f,
+ const std::pair< size_t,
+ std::pair< T, char > >& s) {
if (globalDbg) {
- cerr << "ompareElementsForElementsOrderedAccordingToFiltration\n";
+ std::cerr << "ompareElementsForElementsOrderedAccordingToFiltration\n";
}
if (f.second.first < s.second.first) {
return true;
@@ -662,14 +676,15 @@ bool compareElementsForElementsOrderedAccordingToFiltration(const std::pair< siz
if (f.second.first > s.second.first) {
return false;
} else {
- //in this case f.second.first == s.second.first, and we use dimension to compare:
+ // in this case f.second.first == s.second.first, and we use dimension to compare:
if (f.second.second < s.second.second) {
return true;
} else {
if (f.second.second > s.second.second) {
return false;
} else {
- //in this case, both the filtration value and the dimensions for those cells are the same. Since it may be nice to have a stable sorting procedure, in this case, we compare positions in the bitmap:
+ // in this case, both the filtration value and the dimensions for those cells are the same.
+ // Since it may be nice to have a stable sorting procedure, in this case, we compare positions in the bitmap:
return ( f.first < s.first);
}
}
@@ -680,21 +695,24 @@ bool compareElementsForElementsOrderedAccordingToFiltration(const std::pair< siz
template <typename T>
void Bitmap_cubical_complex<T>::initializeElementsOrderedAccordingToFiltration() {
if (globalDbg) {
- cerr << "void Bitmap_cubical_complex<T>::initializeElementsOrderedAccordingToFiltration() \n";
+ std::cerr << "void Bitmap_cubical_complex<T>::initializeElementsOrderedAccordingToFiltration() \n";
}
- //( position , (filtration , dimension) )
+ // ( position , (filtration , dimension) )
std::vector< std::pair< size_t, std::pair< T, char > > > dataOfElementsFromBitmap(this->data.size());
for (size_t i = 0; i != this->data.size(); ++i) {
- //TODO -- this can be optimized by having a counter here. We do not need to re-compute the dimension for every cell from scratch
+ // TODO(Pawel Dlotko): This can be optimized by having a counter here. We do not need to re-compute the dimension
+ // for every cell from scratch
dataOfElementsFromBitmap[i] = std::make_pair(i, std::make_pair(this->data[i], this->get_dimension_of_a_cell(i)));
}
- std::sort(dataOfElementsFromBitmap.begin(), dataOfElementsFromBitmap.end(), compareElementsForElementsOrderedAccordingToFiltration<T>);
+ std::sort(dataOfElementsFromBitmap.begin(), dataOfElementsFromBitmap.end(),
+ compareElementsForElementsOrderedAccordingToFiltration<T>);
- std::vector< size_t > elementsOfBitmapOrderedAccordingToFiltrationThenAccordingToDimensionThenAccordingToPositionInBitmap(this->data.size());
+ // Elements of bitmap ordered according to filtration then according to dimension then according to position in bitmap
+ std::vector< size_t > elements_of_bitmap_ordered(this->data.size());
for (size_t i = 0; i != dataOfElementsFromBitmap.size(); ++i) {
- elementsOfBitmapOrderedAccordingToFiltrationThenAccordingToDimensionThenAccordingToPositionInBitmap[i] = dataOfElementsFromBitmap[i].first;
+ elements_of_bitmap_ordered[i] = dataOfElementsFromBitmap[i].first;
}
- this->elementsOrderedAccordingToFiltration = elementsOfBitmapOrderedAccordingToFiltrationThenAccordingToDimensionThenAccordingToPositionInBitmap;
+ this->elementsOrderedAccordingToFiltration = elements_of_bitmap_ordered;
}
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 26c97872..d9c91832 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,20 +23,17 @@
#ifndef BITMAP_CUBICAL_COMPLEX_BASE_H_
#define BITMAP_CUBICAL_COMPLEX_BASE_H_
+#include <gudhi/counter.h>
+
#include <iostream>
#include <string>
#include <vector>
-#include <string>
#include <cstdlib>
#include <climits>
#include <fstream>
#include <algorithm>
#include <iterator>
-#include <gudhi/counter.h>
-
-using namespace std;
-
/**
* This is a class implementing a basic bitmap data structure to store cubical complexes. It implements only the most basic subroutines.
* The idea of the bitmap is the following. Our aim is to have a memory efficient data structure to store d-dimensional cubical complex C being a cubical decomposition
@@ -89,7 +86,7 @@ class Bitmap_cubical_complex_base {
* cells. The most typical one is by so called lower star filtration. This function is always called by any constructor which takes the top dimensional cells. If you use such a constructor,
* then there is no need to call this function. Call it only if you are putting the filtration of the cells by your own (for instance by using topDimensionalCellsIterator).
**/
- void impose_lower_star_filtration(); //assume that top dimensional cells are already set.
+ void impose_lower_star_filtration(); // assume that top dimensional cells are already set.
/**
* Returns dimension of a complex.
@@ -109,9 +106,9 @@ class Bitmap_cubical_complex_base {
* Writing to stream operator.
**/
template <typename K>
- friend ostream& operator<<(ostream & os_, const Bitmap_cubical_complex_base<K>& b_);
+ friend std::ostream& operator<<(std::ostream & os_, const Bitmap_cubical_complex_base<K>& b_);
- //ITERATORS
+ // ITERATORS
/**
* Iterator through all cells in the complex (in order they appear in the structure -- i.e. in lexicographical order).
@@ -142,7 +139,6 @@ class Bitmap_cubical_complex_base {
**/
class Top_dimensional_cells_iterator : std::iterator< std::input_iterator_tag, double > {
public:
-
Top_dimensional_cells_iterator(Bitmap_cubical_complex_base& b_) : b(b_) {
for (size_t i = 0; i != b_.dimension(); ++i) {
this->counter.push_back(0);
@@ -150,7 +146,7 @@ class Bitmap_cubical_complex_base {
}
Top_dimensional_cells_iterator operator++() {
- //first find first element of the counter that can be increased:
+ // first find first element of the counter that can be increased:
size_t dim = 0;
while ((dim != this->b.dimension()) && (this->counter[dim] == this->b.sizes[dim] - 1))++dim;
@@ -191,7 +187,7 @@ class Bitmap_cubical_complex_base {
}
T& operator*() {
- //given the counter, compute the index in the array and return this element.
+ // 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];
@@ -209,7 +205,7 @@ class Bitmap_cubical_complex_base {
void printCounter() {
for (size_t i = 0; i != this->counter.size(); ++i) {
- cout << this->counter[i] << " ";
+ std::cout << this->counter[i] << " ";
}
}
friend class Bitmap_cubical_complex_base;
@@ -255,10 +251,10 @@ class Bitmap_cubical_complex_base {
for (size_t i = 0; i != sizes_.size(); ++i) {
this->sizes.push_back(sizes_[i]);
this->multipliers.push_back(multiplier);
- //multiplier *= 2*(sizes[i]+1)+1;
+ // multiplier *= 2*(sizes[i]+1)+1;
multiplier *= 2 * sizes_[i] + 1;
}
- //std::reverse( this->sizes.begin() , this->sizes.end() );
+ // std::reverse( this->sizes.begin() , this->sizes.end() );
std::vector<T> data(multiplier);
std::fill(data.begin(), data.end(), INT_MAX);
this->totalNumberOfCells = multiplier;
@@ -287,9 +283,11 @@ class Bitmap_cubical_complex_base {
};
template <typename K>
-ostream& operator<<(ostream & out_, const Bitmap_cubical_complex_base<K>& b_) {
- //for ( typename bitmap<K>::all_cells_const_iterator it = b.all_cells_const_begin() ; it != b.all_cells_const_end() ; ++it )
- for (typename Bitmap_cubical_complex_base<K>::all_cells_const_iterator it = b_.all_cells_const_begin(); it != b_.all_cells_const_end(); ++it) {
+std::ostream& operator<<(std::ostream & out_, const Bitmap_cubical_complex_base<K>& b_) {
+ // for ( typename bitmap<K>::all_cells_const_iterator it = b.all_cells_const_begin() ;
+ // it != b.all_cells_const_end() ; ++it )
+ for (typename Bitmap_cubical_complex_base<K>::all_cells_const_iterator it = b_.all_cells_const_begin();
+ it != b_.all_cells_const_end(); ++it) {
out_ << *it << " ";
}
return out_;
@@ -301,7 +299,8 @@ Bitmap_cubical_complex_base<T>::Bitmap_cubical_complex_base(std::vector<unsigned
}
template <typename T>
-Bitmap_cubical_complex_base<T>::Bitmap_cubical_complex_base(std::vector<unsigned> sizesInFollowingDirections_, std::vector<T> topDimensionalCells_) {
+Bitmap_cubical_complex_base<T>::Bitmap_cubical_complex_base(std::vector<unsigned> sizesInFollowingDirections_,
+ std::vector<T> topDimensionalCells_) {
this->set_up_containers(sizesInFollowingDirections_);
size_t numberOfTopDimensionalElements = 1;
@@ -309,8 +308,12 @@ Bitmap_cubical_complex_base<T>::Bitmap_cubical_complex_base(std::vector<unsigned
numberOfTopDimensionalElements *= sizesInFollowingDirections_[i];
}
if (numberOfTopDimensionalElements != topDimensionalCells_.size()) {
- cerr << "Error in constructor Bitmap_cubical_complex_base( std::vector<size_t> sizesInFollowingDirections_ , std::vector<float> topDimensionalCells_ ). Number of top dimensional elements that follow from sizesInFollowingDirections vector is different than the size of topDimensionalCells vector." << endl;
- throw ("Error in constructor Bitmap_cubical_complex_base( std::vector<size_t> sizesInFollowingDirections_ , std::vector<float> topDimensionalCells_ ). Number of top dimensional elements that follow from sizesInFollowingDirections vector is different than the size of topDimensionalCells vector.");
+ std::cerr << "Error in constructor Bitmap_cubical_complex_base( std::vector<size_t> sizesInFollowingDirections_ , "
+ "std::vector<float> topDimensionalCells_ ). Number of top dimensional elements that follow from "
+ "sizesInFollowingDirections vector is different than the size of topDimensionalCells vector." << std::endl;
+ throw("Error in constructor Bitmap_cubical_complex_base( std::vector<size_t> sizesInFollowingDirections_ , "
+ "std::vector<float> topDimensionalCells_ ). Number of top dimensional elements that follow from "
+ "sizesInFollowingDirections vector is different than the size of topDimensionalCells vector.");
}
Bitmap_cubical_complex_base<T>::Top_dimensional_cells_iterator it(*this);
@@ -325,13 +328,13 @@ Bitmap_cubical_complex_base<T>::Bitmap_cubical_complex_base(std::vector<unsigned
template <typename T>
Bitmap_cubical_complex_base<T>::Bitmap_cubical_complex_base(char* perseusStyleFile_) {
bool dbg = false;
- ifstream inFiltration, inIds;
+ std::ifstream inFiltration, inIds;
inFiltration.open(perseusStyleFile_);
unsigned dimensionOfData;
inFiltration >> dimensionOfData;
if (dbg) {
- cerr << "dimensionOfData : " << dimensionOfData << endl;
+ std::cerr << "dimensionOfData : " << dimensionOfData << std::endl;
}
std::vector<unsigned> sizes;
@@ -341,7 +344,7 @@ Bitmap_cubical_complex_base<T>::Bitmap_cubical_complex_base(char* perseusStyleFi
sizeInThisDimension = abs(sizeInThisDimension);
sizes.push_back(sizeInThisDimension);
if (dbg) {
- cerr << "sizeInThisDimension : " << sizeInThisDimension << endl;
+ std::cerr << "sizeInThisDimension : " << sizeInThisDimension << std::endl;
}
}
this->set_up_containers(sizes);
@@ -349,12 +352,14 @@ Bitmap_cubical_complex_base<T>::Bitmap_cubical_complex_base(char* perseusStyleFi
Bitmap_cubical_complex_base<T>::Top_dimensional_cells_iterator it(*this);
it = this->top_dimensional_cells_begin();
- //TODO -- over here we also need to read id's of cell and put them to bitmapElement structure!
+ // TODO(Pawel Dlotko): Over here we also need to read id's of cell and put them to bitmapElement structure!
while (!inFiltration.eof()) {
double filtrationLevel;
inFiltration >> filtrationLevel;
if (dbg) {
- cerr << "Cell of an index : " << it.computeIndexInBitmap() << " and dimension: " << this->get_dimension_of_a_cell(it.computeIndexInBitmap()) << " get the value : " << filtrationLevel << endl;
+ std::cerr << "Cell of an index : " << it.computeIndexInBitmap() << " and dimension: " <<
+ this->get_dimension_of_a_cell(it.computeIndexInBitmap()) << " get the value : " <<
+ filtrationLevel << std::endl;
}
*it = filtrationLevel;
++it;
@@ -366,7 +371,8 @@ Bitmap_cubical_complex_base<T>::Bitmap_cubical_complex_base(char* perseusStyleFi
template <typename T>
std::vector< size_t > Bitmap_cubical_complex_base<T>::get_boundary_of_a_cell(size_t cell_) {
bool bdg = false;
- //first of all, we need to take the list of coordinates in which the cell has nonzero length. We do it by using modified version to compute dimension of a cell:
+ // First of all, we need to take the list of coordinates in which the cell has nonzero length.
+ // We do it by using modified version to compute dimension of a cell:
std::vector< unsigned > dimensionsInWhichCellHasNonzeroLength;
unsigned dimension = 0;
size_t cell1 = cell_;
@@ -380,9 +386,9 @@ std::vector< size_t > Bitmap_cubical_complex_base<T>::get_boundary_of_a_cell(siz
}
if (bdg) {
- cerr << "dimensionsInWhichCellHasNonzeroLength : \n";
+ std::cerr << "dimensionsInWhichCellHasNonzeroLength : \n";
for (size_t i = 0; i != dimensionsInWhichCellHasNonzeroLength.size(); ++i) {
- cerr << dimensionsInWhichCellHasNonzeroLength[i] << endl;
+ std::cerr << dimensionsInWhichCellHasNonzeroLength[i] << std::endl;
}
getchar();
}
@@ -393,9 +399,12 @@ std::vector< size_t > Bitmap_cubical_complex_base<T>::get_boundary_of_a_cell(siz
boundaryElements.push_back(cell_ - multipliers[ dimensionsInWhichCellHasNonzeroLength[i] ]);
boundaryElements.push_back(cell_ + multipliers[ dimensionsInWhichCellHasNonzeroLength[i] ]);
- if (bdg) cerr << "multipliers[dimensionsInWhichCellHasNonzeroLength[i]] : " << multipliers[dimensionsInWhichCellHasNonzeroLength[i]] << endl;
- if (bdg) cerr << "cell_ - multipliers[dimensionsInWhichCellHasNonzeroLength[i]] : " << cell_ - multipliers[dimensionsInWhichCellHasNonzeroLength[i]] << endl;
- if (bdg) cerr << "cell_ + multipliers[dimensionsInWhichCellHasNonzeroLength[i]] : " << cell_ + multipliers[dimensionsInWhichCellHasNonzeroLength[i]] << endl;
+ if (bdg) std::cerr << "multipliers[dimensionsInWhichCellHasNonzeroLength[i]] : " <<
+ multipliers[dimensionsInWhichCellHasNonzeroLength[i]] << std::endl;
+ if (bdg) std::cerr << "cell_ - multipliers[dimensionsInWhichCellHasNonzeroLength[i]] : " <<
+ cell_ - multipliers[dimensionsInWhichCellHasNonzeroLength[i]] << std::endl;
+ if (bdg) std::cerr << "cell_ + multipliers[dimensionsInWhichCellHasNonzeroLength[i]] : " <<
+ cell_ + multipliers[dimensionsInWhichCellHasNonzeroLength[i]] << std::endl;
}
return boundaryElements;
}
@@ -403,7 +412,8 @@ std::vector< size_t > Bitmap_cubical_complex_base<T>::get_boundary_of_a_cell(siz
template <typename T>
std::vector< size_t > Bitmap_cubical_complex_base<T>::get_coboundary_of_a_cell(size_t cell_) {
bool bdg = false;
- //first of all, we need to take the list of coordinates in which the cell has nonzero length. We do it by using modified version to compute dimension of a cell:
+ // First of all, we need to take the list of coordinates in which the cell has nonzero length.
+ // We do it by using modified version to compute dimension of a cell:
std::vector< unsigned > dimensionsInWhichCellHasZeroLength;
unsigned dimension = 0;
size_t cell1 = cell_;
@@ -417,16 +427,16 @@ std::vector< size_t > Bitmap_cubical_complex_base<T>::get_coboundary_of_a_cell(s
}
std::vector<unsigned> counter = this->compute_counter_for_given_cell(cell_);
- //reverse(counter.begin() , counter.end());
+ // reverse(counter.begin() , counter.end());
if (bdg) {
- cerr << "dimensionsInWhichCellHasZeroLength : \n";
+ std::cerr << "dimensionsInWhichCellHasZeroLength : \n";
for (size_t i = 0; i != dimensionsInWhichCellHasZeroLength.size(); ++i) {
- cerr << dimensionsInWhichCellHasZeroLength[i] << endl;
+ std::cerr << dimensionsInWhichCellHasZeroLength[i] << std::endl;
}
- cerr << "\n counter : " << endl;
+ std::cerr << "\n counter : " << std::endl;
for (size_t i = 0; i != counter.size(); ++i) {
- cerr << counter[i] << endl;
+ std::cerr << counter[i] << std::endl;
}
getchar();
}
@@ -435,27 +445,29 @@ std::vector< size_t > Bitmap_cubical_complex_base<T>::get_coboundary_of_a_cell(s
if (dimensionsInWhichCellHasZeroLength.size() == 0)return coboundaryElements;
for (size_t i = 0; i != dimensionsInWhichCellHasZeroLength.size(); ++i) {
if (bdg) {
- cerr << "Dimension : " << i << endl;
+ std::cerr << "Dimension : " << i << std::endl;
if (counter[dimensionsInWhichCellHasZeroLength[i]] == 0) {
- cerr << "In dimension : " << i << " we cannot substract, since we will jump out of a Bitmap_cubical_complex_base \n";
+ std::cerr << "In dimension : " << i <<
+ " we cannot substract, since we will jump out of a Bitmap_cubical_complex_base \n";
}
if (counter[dimensionsInWhichCellHasZeroLength[i]] == 2 * this->sizes[dimensionsInWhichCellHasZeroLength[i]]) {
- cerr << "In dimension : " << i << " we cannot substract, since we will jump out of a Bitmap_cubical_complex_base \n";
+ std::cerr << "In dimension : " << i <<
+ " we cannot substract, since we will jump out of a Bitmap_cubical_complex_base \n";
}
}
- if ((cell_ > multipliers[dimensionsInWhichCellHasZeroLength[i]]) && (counter[dimensionsInWhichCellHasZeroLength[i]] != 0))
- //if ( counter[dimensionsInWhichCellHasZeroLength[i]] != 0 )
- {
- if (bdg)cerr << "Subtracting : " << cell_ - multipliers[dimensionsInWhichCellHasZeroLength[i]] << endl;
+ if ((cell_ > multipliers[dimensionsInWhichCellHasZeroLength[i]]) &&
+ (counter[dimensionsInWhichCellHasZeroLength[i]] != 0)) {
+ // if ( counter[dimensionsInWhichCellHasZeroLength[i]] != 0 )
+ if (bdg)std::cerr << "Subtracting : " << cell_ - multipliers[dimensionsInWhichCellHasZeroLength[i]] << std::endl;
coboundaryElements.push_back(cell_ - multipliers[dimensionsInWhichCellHasZeroLength[i]]);
}
- if ((cell_ + multipliers[dimensionsInWhichCellHasZeroLength[i]] < this->data.size()) && (counter[dimensionsInWhichCellHasZeroLength[i]] != 2 * this->sizes[dimensionsInWhichCellHasZeroLength[i]]))
- //if ( counter[dimensionsInWhichCellHasZeroLength[i]] != 2*this->sizes[dimensionsInWhichCellHasZeroLength[i]] )
- {
+ if ((cell_ + multipliers[dimensionsInWhichCellHasZeroLength[i]] < this->data.size()) &&
+ (counter[dimensionsInWhichCellHasZeroLength[i]] != 2 * this->sizes[dimensionsInWhichCellHasZeroLength[i]])) {
+ // if ( counter[dimensionsInWhichCellHasZeroLength[i]] != 2*this->sizes[dimensionsInWhichCellHasZeroLength[i]] )
coboundaryElements.push_back(cell_ + multipliers[dimensionsInWhichCellHasZeroLength[i]]);
- if (bdg)cerr << "Adding : " << cell_ + multipliers[dimensionsInWhichCellHasZeroLength[i]] << endl;
+ if (bdg)std::cerr << "Adding : " << cell_ + multipliers[dimensionsInWhichCellHasZeroLength[i]] << std::endl;
}
}
return coboundaryElements;
@@ -464,19 +476,19 @@ std::vector< size_t > Bitmap_cubical_complex_base<T>::get_coboundary_of_a_cell(s
template <typename T>
unsigned Bitmap_cubical_complex_base<T>::get_dimension_of_a_cell(size_t cell_) {
bool dbg = false;
- if (dbg)cerr << "\n\n\n Computing position o a cell of an index : " << cell_ << endl;
+ if (dbg)std::cerr << "\n\n\n Computing position o a cell of an index : " << cell_ << std::endl;
unsigned dimension = 0;
for (size_t i = this->multipliers.size(); i != 0; --i) {
unsigned position = cell_ / multipliers[i - 1];
- if (dbg)cerr << "i-1 :" << i - 1 << endl;
- if (dbg)cerr << "cell_ : " << cell_ << endl;
- if (dbg)cerr << "position : " << position << endl;
- if (dbg)cerr << "multipliers[" << i - 1 << "] = " << multipliers[i - 1] << endl;
+ if (dbg)std::cerr << "i-1 :" << i - 1 << std::endl;
+ if (dbg)std::cerr << "cell_ : " << cell_ << std::endl;
+ if (dbg)std::cerr << "position : " << position << std::endl;
+ if (dbg)std::cerr << "multipliers[" << i - 1 << "] = " << multipliers[i - 1] << std::endl;
if (dbg)getchar();
if (position % 2 == 1) {
- if (dbg)cerr << "Nonzero length in this direction \n";
+ if (dbg)std::cerr << "Nonzero length in this direction \n";
dimension++;
}
cell_ = cell_ % multipliers[i - 1];
@@ -493,11 +505,12 @@ template <typename T>
void Bitmap_cubical_complex_base<T>::impose_lower_star_filtration() {
bool dbg = false;
- //this vector will be used to check which elements have already been taken care of in imposing 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> isThisCellConsidered(this->data.size(), false);
std::vector<size_t> indicesToConsider;
- //we assume here that we already have a filtration on the top dimensional cells and we have to extend it to lower ones.
+ // 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<T>::Top_dimensional_cells_iterator it(*this);
for (it = this->top_dimensional_cells_begin(); it != this->top_dimensional_cells_end(); ++it) {
indicesToConsider.push_back(it.computeIndexInBitmap());
@@ -505,9 +518,9 @@ void Bitmap_cubical_complex_base<T>::impose_lower_star_filtration() {
while (indicesToConsider.size()) {
if (dbg) {
- cerr << "indicesToConsider in this iteration \n";
+ std::cerr << "indicesToConsider in this iteration \n";
for (size_t i = 0; i != indicesToConsider.size(); ++i) {
- cout << indicesToConsider[i] << " ";
+ std::cout << indicesToConsider[i] << " ";
}
getchar();
}
@@ -529,9 +542,12 @@ void Bitmap_cubical_complex_base<T>::impose_lower_star_filtration() {
}
template <typename T>
-std::vector< size_t > Bitmap_cubical_complex_base<T>::generate_vector_of_shifts_for_bitmaps_with_periodic_boundary_conditions(std::vector< bool > directionsForPeriodicBCond_) {
+std::vector< size_t >
+Bitmap_cubical_complex_base<T>::generate_vector_of_shifts_for_bitmaps_with_periodic_boundary_conditions(std::vector< bool > directionsForPeriodicBCond_) {
bool dbg = false;
- if (this->sizes.size() != directionsForPeriodicBCond_.size())throw "directionsForPeriodicBCond_ vector size is different from the size of the bitmap. The program will now terminate \n";
+ if (this->sizes.size() != directionsForPeriodicBCond_.size())
+ throw ("directionsForPeriodicBCond_ vector size is different from the size of the bitmap. "
+ "The program will now terminate \n");
std::vector<int> sizes(this->sizes.size());
for (size_t i = 0; i != this->sizes.size(); ++i)sizes[i] = 2 * this->sizes[i];
@@ -544,7 +560,7 @@ std::vector< size_t > Bitmap_cubical_complex_base<T>::generate_vector_of_shifts_
size_t position;
if (!c.isFinal()) {
position = i;
- //result.push_back( i );
+ // result.push_back( i );
} else {
std::vector< bool > finals = c.directionsOfFinals();
bool jumpInPosition = false;
@@ -555,7 +571,7 @@ std::vector< size_t > Bitmap_cubical_complex_base<T>::generate_vector_of_shifts_
}
}
if (jumpInPosition == true) {
- //in this case this guy is final, so we need to find 'the opposite one'
+ // in this case this guy is final, so we need to find 'the opposite one'
position = compute_position_in_bitmap(c.findOpposite(directionsForPeriodicBCond_));
} else {
position = i;
@@ -563,8 +579,8 @@ std::vector< size_t > Bitmap_cubical_complex_base<T>::generate_vector_of_shifts_
}
result.push_back(position);
if (dbg) {
- cerr << " position : " << position << endl;
- cerr << c << endl;
+ std::cerr << " position : " << position << std::endl;
+ std::cerr << c << std::endl;
getchar();
}
diff --git a/src/Bitmap_cubical_complex/include/gudhi/counter.h b/src/Bitmap_cubical_complex/include/gudhi/counter.h
index 9df819b2..9445a422 100644
--- a/src/Bitmap_cubical_complex/include/gudhi/counter.h
+++ b/src/Bitmap_cubical_complex/include/gudhi/counter.h
@@ -26,17 +26,15 @@
#include <iostream>
#include <vector>
-using namespace std;
-
/**
* This is an implementation of a simple counter. It is needed for the implementation of a bitmapCubicalComplex.
**/
class counter {
public:
-
/**
- * Constructor of a counter class. It takes only the parameter which is the end value of the counter. The default beginning value is a vector of the same length as the endd, filled-in with zeros.
+ * Constructor of a counter class. It takes only the parameter which is the end value of the counter.
+ * The default beginning value is a vector of the same length as the end, filled-in with zeros.
**/
counter(std::vector< int > endd) {
for (size_t i = 0; i != endd.size(); ++i) {
@@ -47,10 +45,12 @@ class counter {
}
/**
- * Constructor of a counter class. It takes as the input beginn and end vector. It assumes that begin vector is lexicographically below the end vector.
+ * Constructor of a counter class. It takes as the input beginn and endd vector. It assumes that begin vector is
+ * lexicographically below the end vector.
**/
counter(std::vector< int > beginn, std::vector< int > endd) {
- if (beginn.size() != endd.size())throw "In constructor of a counter, begin and end vectors do not have the same size. Program terminate";
+ if (beginn.size() != endd.size())
+ throw("In constructor of a counter, begin and end vectors do not have the same size. Program terminate");
for (size_t i = 0; i != endd.size(); ++i) {
this->current.push_back(0);
this->begin.push_back(0);
@@ -59,7 +59,8 @@ class counter {
}
/**
- * Function to increment the counter. If the value returned by the function is true, then the incrementation process was successful.
+ * Function to increment the counter. If the value returned by the function is true, then the incrementation process
+ * was successful.
* If the value of the function is false, that means, that the counter have reached its end-value.
**/
bool increment() {
@@ -87,8 +88,9 @@ class counter {
}
/**
- * Function required in the implementation of bitmapCubicalComplexWPeriodicBoundaryCondition. Its aim is to find an counter corresponding to the element the following
- * boundary element is identified with when periodic boundary conditions are imposed.
+ * Function required in the implementation of bitmapCubicalComplexWPeriodicBoundaryCondition.
+ * Its aim is to find an counter corresponding to the element the following boundary element is identified with
+ * when periodic boundary conditions are imposed.
**/
std::vector< int > findOpposite(std::vector< bool > directionsForPeriodicBCond) {
std::vector< int > result;
@@ -121,12 +123,13 @@ class counter {
* Function to write counter to the stream.
**/
friend std::ostream& operator<<(std::ostream& out, const counter& c) {
- //cerr << "c.current.size() : " << c.current.size() << endl;
+ // std::cerr << "c.current.size() : " << c.current.size() << std::endl;
for (size_t i = 0; i != c.current.size(); ++i) {
out << c.current[i] << " ";
}
return out;
}
+
private:
std::vector< int > begin;
std::vector< int > end;