Skip to content

Commit

Permalink
Implements getMarginal() using derived classes
Browse files Browse the repository at this point in the history
  • Loading branch information
mbaudin47 committed May 18, 2024
1 parent aedf2c5 commit 004f56c
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 16 deletions.
5 changes: 5 additions & 0 deletions lib/src/Base/Func/EnumerateFunction.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,9 @@ Indices EnumerateFunction::getUpperBound() const
return getImplementation()->getUpperBound();
}

EnumerateFunction EnumerateFunction::getMarginal(const Indices & indices) const
{
return getImplementation()->getMarginal(indices);
}

END_NAMESPACE_OPENTURNS
5 changes: 5 additions & 0 deletions lib/src/Base/Func/EnumerateFunctionImplementation.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -148,5 +148,10 @@ void EnumerateFunctionImplementation::load(Advocate & adv)
upperBound_ = Indices(getDimension(), std::numeric_limits<UnsignedInteger>::max());
}

/* Returns the marginal enumerate function */
EnumerateFunctionImplementation EnumerateFunctionImplementation::getMarginal(const Indices &) const
{
throw NotYetImplementedException(HERE) << "In EnumerateFunctionImplementation::getMarginal";
}

END_NAMESPACE_OPENTURNS
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ void HyperbolicAnisotropicEnumerateFunction::setUpperBound(const Indices & upper
}

/* The marginal enumerate function */
HyperbolicAnisotropicEnumerateFunction HyperbolicAnisotropicEnumerateFunction::getMarginal(const Indices & indices) const
EnumerateFunctionImplementation HyperbolicAnisotropicEnumerateFunction::getMarginal(const Indices & indices) const
{
const UnsignedInteger inputDimension = getDimension();
indices.check(inputDimension);
Expand Down
2 changes: 1 addition & 1 deletion lib/src/Base/Func/LinearEnumerateFunction.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ void LinearEnumerateFunction::setUpperBound(const Indices & /*upperBound*/)
}

/* The marginal enumerate function */
LinearEnumerateFunction LinearEnumerateFunction::getMarginal(const Indices & indices) const
EnumerateFunctionImplementation LinearEnumerateFunction::getMarginal(const Indices & indices) const
{
const UnsignedInteger inputDimension = getDimension();
indices.check(inputDimension);
Expand Down
2 changes: 1 addition & 1 deletion lib/src/Base/Func/NormInfEnumerateFunction.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ UnsignedInteger NormInfEnumerateFunction::getMaximumDegreeStrataIndex(const Unsi
}

/* The marginal enumerate function */
NormInfEnumerateFunction NormInfEnumerateFunction::getMarginal(const Indices & indices) const
EnumerateFunctionImplementation NormInfEnumerateFunction::getMarginal(const Indices & indices) const
{
const UnsignedInteger inputDimension = getDimension();
indices.check(inputDimension);
Expand Down
3 changes: 3 additions & 0 deletions lib/src/Base/Func/openturns/EnumerateFunction.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ public:
/** Basis size from degree */
UnsignedInteger getBasisSizeFromTotalDegree(const UnsignedInteger maximumDegree) const;

/** The marginal enumerate function */
EnumerateFunction getMarginal(const Indices & indices) const;

/** Dimension accessor */
void setDimension(const UnsignedInteger dimension);
UnsignedInteger getDimension() const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ public:
/** Basis size from total degree */
virtual UnsignedInteger getBasisSizeFromTotalDegree(const UnsignedInteger maximumDegree) const;

/** The marginal enumerate function */
virtual EnumerateFunctionImplementation getMarginal(const Indices & indices) const;

/** Dimension accessor */
void setDimension(const UnsignedInteger dimension);
UnsignedInteger getDimension() const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public:
void setUpperBound(const Indices & upperBound) override;

/** The marginal enumerate function */
HyperbolicAnisotropicEnumerateFunction getMarginal(const Indices & indices) const;
EnumerateFunctionImplementation getMarginal(const Indices & indices) const override;

/** Method save() stores the object through the StorageManager */
void save(Advocate & adv) const override;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/Base/Func/openturns/LinearEnumerateFunction.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public:
void setUpperBound(const Indices & upperBound) override;

/** The marginal enumerate function */
LinearEnumerateFunction getMarginal(const Indices & indices) const;
EnumerateFunctionImplementation getMarginal(const Indices & indices) const override;

/** Method save() stores the object through the StorageManager */
void save(Advocate & adv) const override;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/Base/Func/openturns/NormInfEnumerateFunction.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public:
UnsignedInteger getMaximumDegreeStrataIndex(const UnsignedInteger maximumDegree) const override;

/** The marginal enumerate function */
NormInfEnumerateFunction getMarginal(const Indices & indices) const;
EnumerateFunctionImplementation getMarginal(const Indices & indices) const override;

/** Method save() stores the object through the StorageManager */
void save(Advocate & adv) const override;
Expand Down
10 changes: 0 additions & 10 deletions lib/test/t_LinearEnumerateFunction_std.expout
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,3 @@ index=7, multi-index=[0,2,0], linear index=7
index=8, multi-index=[0,1,1], linear index=8
index=9, multi-index=[0,0,2], linear index=9
Test getMarginal()
index=0, multi-index=[0,0,0,0,0]
index=1, multi-index=[1,0,0,0,0]
index=2, multi-index=[0,1,0,0,0]
index=3, multi-index=[0,0,1,0,0]
index=4, multi-index=[0,0,0,1,0]
index=5, multi-index=[0,0,0,0,1]
index=6, multi-index=[2,0,0,0,0]
index=7, multi-index=[1,1,0,0,0]
index=8, multi-index=[1,0,1,0,0]
index=9, multi-index=[1,0,0,1,0]

0 comments on commit 004f56c

Please sign in to comment.