summaryrefslogtreecommitdiff
path: root/src/Persistent_cohomology/include/gudhi/Persistent_cohomology.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/Persistent_cohomology/include/gudhi/Persistent_cohomology.h')
-rw-r--r--src/Persistent_cohomology/include/gudhi/Persistent_cohomology.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/Persistent_cohomology/include/gudhi/Persistent_cohomology.h b/src/Persistent_cohomology/include/gudhi/Persistent_cohomology.h
index 5b371f2b..108a53d7 100644
--- a/src/Persistent_cohomology/include/gudhi/Persistent_cohomology.h
+++ b/src/Persistent_cohomology/include/gudhi/Persistent_cohomology.h
@@ -41,6 +41,7 @@
#include <tuple>
#include <algorithm>
#include <string>
+#include <stdexcept> // for std::out_of_range
namespace Gudhi {
@@ -89,6 +90,7 @@ class Persistent_cohomology {
*
* @param[in] cpx Complex for which the persistent homology is computed.
* cpx is a model of FilteredComplex
+ * @exception std::out_of_range In case the number of simplices is more than Simplex_key type numeric limit.
*/
explicit Persistent_cohomology(Complex_ds& cpx)
: cpx_(&cpx),
@@ -106,6 +108,10 @@ class Persistent_cohomology {
interval_length_policy(&cpx, 0),
column_pool_(), // memory pools for the CAM
cell_pool_() {
+ if (cpx_->num_simplices() > std::numeric_limits<Simplex_key>::max()) {
+ // num_simplices must be strictly lower than the limit, because a value is reserved for null_key.
+ throw std::out_of_range ("The number of simplices is more than Simplex_key type numeric limit.");
+ }
Simplex_key idx_fil = 0;
for (auto sh : cpx_->filtration_simplex_range()) {
cpx_->assign_key(sh, idx_fil);