summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorglisse <glisse@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2017-07-10 15:05:46 +0000
committerglisse <glisse@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2017-07-10 15:05:46 +0000
commit2c353d0c3db1c5c8fc11cb28ea65c90c559766a1 (patch)
tree8b65f702dfd0e832d2ebed708803d5edc9cbded0 /src
parent2e7447cf1deb3a1ac08f2fe90cd780901da65016 (diff)
Cubical: use +inf instead of UINT_MAX as filtration value for non-simplices.
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@2595 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: c578be16d9559b6d271cdb63be3a58a015735ab7
Diffstat (limited to 'src')
-rw-r--r--src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex.h27
-rwxr-xr-xsrc/cython/test/test_cubical_complex.py4
2 files changed, 16 insertions, 15 deletions
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 5a87b9b8..f395de65 100644
--- a/src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex.h
+++ b/src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex.h
@@ -97,7 +97,7 @@ class Bitmap_cubical_complex : public T {
* with filtration on top dimensional cells.
**/
Bitmap_cubical_complex(const std::vector<unsigned>& dimensions,
- const std::vector<typename T::filtration_type>& top_dimensional_cells) :
+ const std::vector<Filtration_value>& top_dimensional_cells) :
T(dimensions, top_dimensional_cells),
key_associated_to_simplex(this->total_number_of_cells + 1) {
for (size_t i = 0; i != this->total_number_of_cells; ++i) {
@@ -111,13 +111,13 @@ class Bitmap_cubical_complex : public T {
/**
* 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::filtration_type
+ * in the following directions and vector of element of a type Filtration_value
* with filtration on top dimensional cells. The last parameter of the constructor is a vector of boolean of a length
* equal to the dimension of cubical complex.
* If the position i on this vector is true, then we impose periodic boundary conditions in this direction.
**/
Bitmap_cubical_complex(const std::vector<unsigned>& dimensions,
- const std::vector<typename T::filtration_type>& top_dimensional_cells,
+ const std::vector<Filtration_value>& top_dimensional_cells,
std::vector< bool > directions_in_which_periodic_b_cond_are_to_be_imposed) :
T(dimensions, top_dimensional_cells, directions_in_which_periodic_b_cond_are_to_be_imposed),
key_associated_to_simplex(this->total_number_of_cells + 1) {
@@ -170,20 +170,20 @@ class Bitmap_cubical_complex : public T {
if (globalDbg) {
std::cerr << "unsigned dimension(const Simplex_handle& sh)\n";
}
- if (sh != std::numeric_limits<Simplex_handle>::max()) return this->get_dimension_of_a_cell(sh);
+ if (sh != null_simplex()) return this->get_dimension_of_a_cell(sh);
return -1;
}
/**
* Return the filtration of a cell pointed by the Simplex_handle.
**/
- typename T::filtration_type filtration(Simplex_handle sh) {
+ Filtration_value filtration(Simplex_handle sh) {
if (globalDbg) {
- std::cerr << "T::filtration_type filtration(const Simplex_handle& sh)\n";
+ std::cerr << "Filtration_value filtration(const Simplex_handle& sh)\n";
}
// Returns the filtration value of a simplex.
- if (sh != std::numeric_limits<Simplex_handle>::max()) return this->data[sh];
- return std::numeric_limits<Simplex_handle>::max();
+ if (sh != null_simplex()) return this->data[sh];
+ return std::numeric_limits<Filtration_value>::infinity();
}
/**
@@ -203,7 +203,7 @@ class Bitmap_cubical_complex : public T {
if (globalDbg) {
std::cerr << "Simplex_key key(const Simplex_handle& sh)\n";
}
- if (sh != std::numeric_limits<Simplex_handle>::max()) {
+ if (sh != null_simplex()) {
return this->key_associated_to_simplex[sh];
}
return this->null_key();
@@ -216,7 +216,7 @@ class Bitmap_cubical_complex : public T {
if (globalDbg) {
std::cerr << "Simplex_handle simplex(Simplex_key key)\n";
}
- if (key != std::numeric_limits<Simplex_handle>::max()) {
+ if (key != null_key()) {
return this->simplex_associated_to_key[ key ];
}
return null_simplex();
@@ -229,7 +229,7 @@ class Bitmap_cubical_complex : public T {
if (globalDbg) {
std::cerr << "void assign_key(Simplex_handle& sh, Simplex_key key)\n";
}
- if (key == std::numeric_limits<Simplex_handle>::max()) return;
+ if (key == null_key()) return;
this->key_associated_to_simplex[sh] = key;
this->simplex_associated_to_key[key] = sh;
}
@@ -566,8 +566,9 @@ class is_before_in_filtration {
bool operator()(const typename Bitmap_cubical_complex<T>::Simplex_handle& sh1,
const typename Bitmap_cubical_complex<T>::Simplex_handle& sh2) const {
// Not using st_->filtration(sh1) because it uselessly tests for null_simplex.
- typename T::filtration_type fil1 = CC_->data[sh1];
- typename T::filtration_type fil2 = CC_->data[sh2];
+ typedef typename T::filtration_type Filtration_value;
+ Filtration_value fil1 = CC_->data[sh1];
+ Filtration_value fil2 = CC_->data[sh2];
if (fil1 != fil2) {
return fil1 < fil2;
}
diff --git a/src/cython/test/test_cubical_complex.py b/src/cython/test/test_cubical_complex.py
index 2e281ee4..9a365823 100755
--- a/src/cython/test/test_cubical_complex.py
+++ b/src/cython/test/test_cubical_complex.py
@@ -67,7 +67,7 @@ def test_dimension_constructor():
top_dimensional_cells = [1,2,3,4,5,6,7,8,9])
assert cub.__is_defined() == True
assert cub.__is_persistence_defined() == False
- assert cub.persistence() == [(1, (0.0, 100.0)), (0, (0.0, 1.8446744073709552e+19))]
+ assert cub.persistence() == [(1, (0.0, 100.0)), (0, (0.0, float('inf')))]
assert cub.__is_persistence_defined() == True
assert cub.betti_numbers() == [1, 0]
assert cub.persistent_betti_numbers(0, 1000) == [0, 0]
@@ -80,7 +80,7 @@ def test_dimension_constructor():
cub = CubicalComplex(perseus_file='CubicalOneSphere.txt')
assert cub.__is_defined() == True
assert cub.__is_persistence_defined() == False
- assert cub.persistence() == [(1, (0.0, 100.0)), (0, (0.0, 1.8446744073709552e+19))]
+ assert cub.persistence() == [(1, (0.0, 100.0)), (0, (0.0, float('inf')))]
assert cub.__is_persistence_defined() == True
assert cub.betti_numbers() == [1, 0, 0]
assert cub.persistent_betti_numbers(0, 1000) == [1, 0, 0]