Skip to content

Commit

Permalink
Improved Indices
Browse files Browse the repository at this point in the history
Now it has a isStrictlyIncreasing() method.
  • Loading branch information
regislebrun committed Jul 30, 2024
1 parent e430edf commit 9a48e0f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/src/Base/Type/Indices.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions lib/src/Base/Type/openturns/Indices.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 9a48e0f

Please sign in to comment.