summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHind-M <hind.montassif@gmail.com>2021-07-27 11:01:31 +0200
committerHind-M <hind.montassif@gmail.com>2021-07-27 11:01:31 +0200
commita93e26976e5898b267d8b743e080e8869ff41b4f (patch)
tree63b20a84a2c049e663526ab109b9b469c6ad9429
parentaa1a040f6338ec938b9360de35196ad0518be502 (diff)
Remove unnecessary checks for primality
Document homology_coeff_field values in cubical
-rw-r--r--src/Persistent_cohomology/include/gudhi/Persistent_cohomology/Field_Zp.h8
-rw-r--r--src/Persistent_cohomology/test/persistent_cohomology_unit_test.cpp5
-rw-r--r--src/python/gudhi/cubical_complex.pyx4
-rw-r--r--src/python/gudhi/periodic_cubical_complex.pyx4
4 files changed, 11 insertions, 10 deletions
diff --git a/src/Persistent_cohomology/include/gudhi/Persistent_cohomology/Field_Zp.h b/src/Persistent_cohomology/include/gudhi/Persistent_cohomology/Field_Zp.h
index 7ecc9a80..8ec89e41 100644
--- a/src/Persistent_cohomology/include/gudhi/Persistent_cohomology/Field_Zp.h
+++ b/src/Persistent_cohomology/include/gudhi/Persistent_cohomology/Field_Zp.h
@@ -38,12 +38,12 @@ class Field_Zp {
Prime = charac;
- // Check that the provided prime is less than the maximum allowed as int and calculation below : 46337 ; i.e (max_prime-1)**2 <= INT_MAX
+ // Check that the provided prime is less than the maximum allowed as int, calculation below, and 'plus_times_equal' function : 46337 ; i.e (max_prime-1)*max_prime <= INT_MAX
if(Prime > 46337)
throw std::invalid_argument("Maximum homology_coeff_field allowed value is 46337");
// Check for primality
- if ((Prime == 0) || (Prime == 1) || ((Prime > 3) && ((Prime % 2 == 0) || (Prime % 3 == 0))))
+ if (Prime <= 1)
throw std::invalid_argument("homology_coeff_field must be a prime number");
inverse_.clear();
@@ -59,10 +59,6 @@ class Field_Zp {
mult = inv * i;
}
inverse_.push_back(inv);
- if ( (i*i <= Prime) && (((i-5)%6) == 0) ) {
- if ((Prime % i == 0) || (Prime % (i + 2) == 0))
- throw std::invalid_argument("homology_coeff_field must be a prime number");
- }
}
}
diff --git a/src/Persistent_cohomology/test/persistent_cohomology_unit_test.cpp b/src/Persistent_cohomology/test/persistent_cohomology_unit_test.cpp
index 35bb5988..041cb0fd 100644
--- a/src/Persistent_cohomology/test/persistent_cohomology_unit_test.cpp
+++ b/src/Persistent_cohomology/test/persistent_cohomology_unit_test.cpp
@@ -176,6 +176,11 @@ BOOST_AUTO_TEST_CASE( rips_persistent_cohomology_single_field_dim_5 )
test_rips_persistence_in_dimension(5);
}
+BOOST_AUTO_TEST_CASE( rips_persistent_cohomology_single_field_dim_6 )
+{
+ BOOST_CHECK_THROW(test_rips_persistence_in_dimension(6), std::invalid_argument);
+}
+
BOOST_AUTO_TEST_CASE( rips_persistent_cohomology_single_field_dim_11 )
{
test_rips_persistence_in_dimension(11);
diff --git a/src/python/gudhi/cubical_complex.pyx b/src/python/gudhi/cubical_complex.pyx
index adc40499..97c69a2d 100644
--- a/src/python/gudhi/cubical_complex.pyx
+++ b/src/python/gudhi/cubical_complex.pyx
@@ -147,7 +147,7 @@ cdef class CubicalComplex:
:func:`persistence` returns.
:param homology_coeff_field: The homology coefficient field. Must be a
- prime number
+ prime number. Default value is 11. Max is 46337.
:type homology_coeff_field: int.
:param min_persistence: The minimum persistence value to take into
account (strictly greater than min_persistence). Default value is
@@ -169,7 +169,7 @@ cdef class CubicalComplex:
"""This function computes and returns the persistence of the complex.
:param homology_coeff_field: The homology coefficient field. Must be a
- prime number
+ prime number. Default value is 11. Max is 46337.
:type homology_coeff_field: int.
:param min_persistence: The minimum persistence value to take into
account (strictly greater than min_persistence). Default value is
diff --git a/src/python/gudhi/periodic_cubical_complex.pyx b/src/python/gudhi/periodic_cubical_complex.pyx
index 0eaa5867..ef1d3080 100644
--- a/src/python/gudhi/periodic_cubical_complex.pyx
+++ b/src/python/gudhi/periodic_cubical_complex.pyx
@@ -148,7 +148,7 @@ cdef class PeriodicCubicalComplex:
:func:`persistence` returns.
:param homology_coeff_field: The homology coefficient field. Must be a
- prime number
+ prime number. Default value is 11. Max is 46337.
:type homology_coeff_field: int.
:param min_persistence: The minimum persistence value to take into
account (strictly greater than min_persistence). Default value is
@@ -170,7 +170,7 @@ cdef class PeriodicCubicalComplex:
"""This function computes and returns the persistence of the complex.
:param homology_coeff_field: The homology coefficient field. Must be a
- prime number
+ prime number. Default value is 11. Max is 46337.
:type homology_coeff_field: int.
:param min_persistence: The minimum persistence value to take into
account (strictly greater than min_persistence). Default value is