diff --git a/lib/src/Base/Type/Indices.cxx b/lib/src/Base/Type/Indices.cxx index 3791b352f8..6853ae8d20 100644 --- a/lib/src/Base/Type/Indices.cxx +++ b/lib/src/Base/Type/Indices.cxx @@ -52,6 +52,16 @@ Bool Indices::isIncreasing() const return true; } +/* Check if the indices are strictly increasing */ +Bool Indices::isStrictlyIncreasing() const +{ + const UnsignedInteger size = getSize(); + if (!(size > 1)) return true; + for (UnsignedInteger i = 1; i < size; ++i) + if (operator[](i) <= operator[](i - 1)) return false; + return true; +} + /* Fill the indices with a linear progression, starting from start value by step stepsize */ void Indices::fill(const UnsignedInteger initialValue, const UnsignedInteger stepSize) diff --git a/lib/src/Base/Type/openturns/Indices.hxx b/lib/src/Base/Type/openturns/Indices.hxx index 86ccfd43b3..7d4e01a0be 100644 --- a/lib/src/Base/Type/openturns/Indices.hxx +++ b/lib/src/Base/Type/openturns/Indices.hxx @@ -81,6 +81,9 @@ public: /** Check if the indices are increasing */ Bool isIncreasing() const; + /** Check if the indices are strictly increasing */ + Bool isStrictlyIncreasing() const; + /** Fill the indices with a linear progression, starting from start value by step stepsize */ void fill(const UnsignedInteger initialValue = 0, const UnsignedInteger stepSize = 1);