Skip to content

Commit

Permalink
BUG: Let elx::ConjugateGradientFRPR override ITK's FRPROptimizer
Browse files Browse the repository at this point in the history
`elx::ConjugateGradientFRPR` member functions GetValueAndDerivative and LineOptimize did originally override the corresponding virtual member functions of ITK's FRPROptimizer. This property was broken by a change in the signature of those ITK member functions: ITK commit InsightSoftwareConsortium/ITK@a088a95, "PERF: Changed to pass by reference for faster performance", 2008-04-23

This commit restores those "overrides", by adjusting the signature of the `elx::ConjugateGradientFRPR` member functions, in accordance with those ITK member functions.

Bug found by macos-12/clang compiler warnings, like:

> warning: 'elastix::ConjugateGradientFRPR::GetValueAndDerivative' hides overloaded virtual function [-Woverloaded-virtual]

Note: These two `elx::ConjugateGradientFRPR` member functions don't seem to be tested at the CI, currently.
  • Loading branch information
N-Dekker committed May 14, 2024
1 parent a5b7960 commit 34bdc3b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ class ITK_TEMPLATE_EXPORT ConjugateGradientFRPR
* This implementation calls the Superclass' implementation and caches
* the computed derivative's magnitude. Besides, it invokes the
* SelectNewSamples method. */
virtual void
GetValueAndDerivative(ParametersType p, double * val, ParametersType * xi);
void
GetValueAndDerivative(ParametersType & p, double * val, ParametersType * xi) override;

/** The LineBracket routine from NRC. Uses current origin and line direction
* (from SetLine) to find a triple of points (ax, bx, cx) that bracket the
Expand Down Expand Up @@ -206,8 +206,8 @@ class ITK_TEMPLATE_EXPORT ConjugateGradientFRPR
* store the line search direction's (xi) magnitude and call the superclass'
* implementation.
*/
virtual void
LineOptimize(ParametersType * p, ParametersType xi, double * val);
void
LineOptimize(ParametersType * p, ParametersType & xi, double * val) override;

private:
elxOverrideGetSelfMacro;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ ConjugateGradientFRPR<TElastix>::SetInitialPosition(const ParametersType & param

template <class TElastix>
void
ConjugateGradientFRPR<TElastix>::GetValueAndDerivative(ParametersType p, double * val, ParametersType * xi)
ConjugateGradientFRPR<TElastix>::GetValueAndDerivative(ParametersType & p, double * val, ParametersType * xi)
{
/** This implementation forces the metric to select new samples
* (if the user asked for this), calls the Superclass'
Expand Down Expand Up @@ -361,7 +361,7 @@ ConjugateGradientFRPR<TElastix>::BracketedLineOptimize(double ax,
*/
template <class TElastix>
void
ConjugateGradientFRPR<TElastix>::LineOptimize(ParametersType * p, ParametersType xi, double * val)
ConjugateGradientFRPR<TElastix>::LineOptimize(ParametersType * p, ParametersType & xi, double * val)
{
this->m_CurrentSearchDirectionMagnitude = xi.magnitude();
this->Superclass1::LineOptimize(p, xi, val);
Expand Down

0 comments on commit 34bdc3b

Please sign in to comment.