Skip to content

Commit

Permalink
Fixes the check of the indices
Browse files Browse the repository at this point in the history
  • Loading branch information
mbaudin47 committed Jul 29, 2024
1 parent dbb17ca commit a3e4351
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
5 changes: 4 additions & 1 deletion lib/src/Base/Func/HyperbolicAnisotropicEnumerateFunction.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,10 @@ void HyperbolicAnisotropicEnumerateFunction::setUpperBound(const Indices & upper
EnumerateFunction HyperbolicAnisotropicEnumerateFunction::getMarginal(const Indices & indices) const
{
const UnsignedInteger inputDimension = getDimension();
indices.check(inputDimension);
if (!indices.check(inputDimension))
{
throw InvalidArgumentException(HERE) << "Indices " << indices << "must not exceed dimension " << inputDimension;
}
const UnsignedInteger activeDimension = indices.getSize();
Point weightMarginal(activeDimension);
for (UnsignedInteger i = 0; i < activeDimension; ++i)
Expand Down
5 changes: 4 additions & 1 deletion lib/src/Base/Func/LinearEnumerateFunction.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,10 @@ void LinearEnumerateFunction::setUpperBound(const Indices & /*upperBound*/)
EnumerateFunction LinearEnumerateFunction::getMarginal(const Indices & indices) const
{
const UnsignedInteger inputDimension = getDimension();
indices.check(inputDimension);
if (!indices.check(inputDimension))
{
throw InvalidArgumentException(HERE) << "Indices " << indices << "must not exceed dimension " << inputDimension;
}
const UnsignedInteger activeDimension = indices.getSize();
const LinearEnumerateFunction enumerateFunctionMarginal(activeDimension);
return enumerateFunctionMarginal;
Expand Down
5 changes: 4 additions & 1 deletion lib/src/Base/Func/NormInfEnumerateFunction.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,10 @@ UnsignedInteger NormInfEnumerateFunction::getMaximumDegreeStrataIndex(const Unsi
EnumerateFunction NormInfEnumerateFunction::getMarginal(const Indices & indices) const
{
const UnsignedInteger inputDimension = getDimension();
indices.check(inputDimension);
if (!indices.check(inputDimension))
{
throw InvalidArgumentException(HERE) << "Indices " << indices << "must not exceed dimension " << inputDimension;
}
const UnsignedInteger activeDimension = indices.getSize();
const NormInfEnumerateFunction enumerateFunctionMarginal(activeDimension);
return enumerateFunctionMarginal;
Expand Down

0 comments on commit a3e4351

Please sign in to comment.