Commit 4785410b authored by Joseph Boudreau's avatar Joseph Boudreau
Browse files

Adding override keyword to functions overriding virtual functions in the base class

parent 36504d21
......@@ -28,14 +28,14 @@ namespace Genfun {
ACos(const ACos &right);
// Retreive function value
virtual double operator ()(double argument) const;
virtual double operator ()(const Argument & a) const {return operator() (a[0]);}
virtual double operator ()(double argument) const override;
virtual double operator ()(const Argument & a) const override {return operator() (a[0]);}
// Derivative.
Derivative partial (unsigned int) const;
Derivative partial (unsigned int) const override;
// Does this function have an analytic derivative?
virtual bool hasAnalyticDerivative() const {return true;}
virtual bool hasAnalyticDerivative() const override {return true;}
private:
......
......@@ -26,14 +26,14 @@ namespace Genfun {
ASin(const ASin &right);
// Retreive function value
virtual double operator ()(double argument) const;
virtual double operator ()(const Argument & a) const {return operator() (a[0]);}
virtual double operator ()(double argument) const override;
virtual double operator ()(const Argument & a) const override {return operator() (a[0]);}
// Derivative.
Derivative partial (unsigned int) const;
Derivative partial (unsigned int) const override;
// Does this function have an analytic derivative?
virtual bool hasAnalyticDerivative() const {return true;}
virtual bool hasAnalyticDerivative() const override {return true;}
private:
......
......@@ -26,14 +26,14 @@ namespace Genfun {
ATan(const ATan &right);
// Retreive function value
virtual double operator ()(double argument) const;
virtual double operator ()(const Argument & a) const {return operator() (a[0]);}
virtual double operator ()(double argument) const override;
virtual double operator ()(const Argument & a) const override {return operator() (a[0]);}
// Derivative.
Derivative partial (unsigned int) const;
Derivative partial (unsigned int) const override;
// Does this function have an analytic derivative?
virtual bool hasAnalyticDerivative() const {return true;}
virtual bool hasAnalyticDerivative() const override {return true;}
private:
......
......@@ -28,8 +28,8 @@ namespace Genfun {
virtual ~Abs();
// Retrieve function value
virtual double operator ()(double argument) const;
virtual double operator ()(const Argument & a) const {return operator() (a[0]);}
virtual double operator ()(double argument) const override;
virtual double operator ()(const Argument & a) const override {return operator() (a[0]);}
private:
......
......@@ -59,7 +59,7 @@ namespace Genfun {
virtual ~AbsFunction();
// Function value: N-dimensional functions must override these:
virtual unsigned int dimensionality() const ; // returns 1;
virtual unsigned int dimensionality() const; // returns 1;
// Function value
virtual double operator() (double argument) const=0;
......@@ -129,39 +129,24 @@ typedef const AbsFunction & GENFUNCTION;
//----------------------------------------------------------------------------
//
// This macro does all the ugly boilerplate. For reference I will lis what
// it is doing:
//
// 1). It uses the base class function composition operator. It would be
// nice to just use the
//
// using AbsFunction::operator();
//
// directive but unfortunately this is compiler-dependent!
// These macros do all the ugly boilerplate.
//
//----------------------------------------------------------------------------
// A more modern way to accomplish this, which is slicker:
#define FUNCTION_OBJECT_DEF(classname) \
public: \
virtual FunctionComposition operator()(const AbsFunction &function) const; \
virtual ParameterComposition operator()(const AbsParameter &p) const; \
virtual classname *clone() const; \
using Genfun::AbsFunction::operator(); \
virtual classname *clone() const override; \
private:
//----------------------------------------------------------------------------
//
// This macro implements the ugly boilerplate
//
#define FUNCTION_OBJECT_IMP(classname) \
inline FunctionComposition classname::operator()(const AbsFunction & function) const\
{ \
return AbsFunction::operator() (function); \
} \
inline ParameterComposition classname::operator()(const AbsParameter & p) const\
{ \
return AbsFunction::operator() (p); \
} \
inline classname *classname::clone() const \
{ \
return new classname(*this); \
......
......@@ -28,8 +28,8 @@ namespace Genfun {
virtual ~Airy();
// Retreive function value
virtual double operator ()(double argument) const;
virtual double operator ()(const Argument & a) const {return operator() (a[0]);}
virtual double operator ()(double argument) const override;
virtual double operator ()(const Argument & a) const override {return operator() (a[0]);}
private:
......
......@@ -47,8 +47,8 @@ namespace Genfun {
virtual ~AnalyticConvolution();
// Retreive function value
virtual double operator ()(double argument) const;
virtual double operator ()(const Argument & a) const {return operator() (a[0]);}
virtual double operator ()(double argument) const override;
virtual double operator ()(const Argument & a) const override {return operator() (a[0]);}
// Frequency of oscillation
Parameter & frequency();
......
......@@ -27,8 +27,8 @@ class ArrayFunction : public AbsFunction {
ArrayFunction(const ArrayFunction &right);
// Retreive function value
virtual double operator ()(double argument) const;
virtual double operator ()(const Argument & a) const {return operator() (a[0]);}
virtual double operator ()(double argument) const override;
virtual double operator ()(const Argument & a) const override {return operator() (a[0]);}
private:
......
......@@ -37,8 +37,8 @@ namespace Genfun {
// Retreive function value
virtual double operator ()(double argument) const;
virtual double operator ()(const Argument & a) const {return operator() (a[0]);}
virtual double operator ()(double argument) const override;
virtual double operator ()(const Argument & a) const override {return operator() (a[0]);}
// Get the integer variable n
unsigned int n() const;
......
......@@ -33,8 +33,8 @@ namespace Genfun {
virtual ~AssociatedLegendre();
// Retreive function value
virtual double operator ()(double argument) const;
virtual double operator ()(const Argument & a) const {return operator() (a[0]);}
virtual double operator ()(double argument) const override;
virtual double operator ()(const Argument & a) const override {return operator() (a[0]);}
// Get the integer variable l
unsigned int l() const;
......
......@@ -47,8 +47,8 @@ namespace FractionalOrder {
virtual ~Bessel();
// Retreive function value
virtual double operator ()(double argument) const;
virtual double operator ()(const Argument & a) const {return operator() (a[0]);}
virtual double operator ()(double argument) const override;
virtual double operator ()(const Argument & a) const override {return operator() (a[0]);}
// Get the order of the Bessel Function. Default value, 0.0. If modified the
// Bessel function
......@@ -92,8 +92,8 @@ namespace IntegralOrder {
virtual ~Bessel();
// Retreive function value
virtual double operator ()(double argument) const;
virtual double operator ()(const Argument & a) const {return operator() (a[0]);}
virtual double operator ()(double argument) const override;
virtual double operator ()(const Argument & a) const override {return operator() (a[0]);}
private:
......
......@@ -34,8 +34,8 @@ namespace Genfun {
virtual ~BetaDistribution();
// Retreive function value
virtual double operator ()(double argument) const;
virtual double operator ()(const Argument & a) const {return operator() (a[0]);}
virtual double operator ()(double argument) const override;
virtual double operator ()(const Argument & a) const override {return operator() (a[0]);}
// Get the paramter alpha
Parameter & alpha();
......
......@@ -33,11 +33,11 @@ namespace Genfun {
virtual ~BivariateGaussian();
// Retreive function value
virtual double operator ()(double argument) const; // Gives an error.
virtual double operator ()(const Argument & a) const; // Must use this one
virtual double operator ()(double argument) const override; // Gives an error.
virtual double operator ()(const Argument & a) const override; // Must use this one
// Dimensionality
virtual unsigned int dimensionality() const;
virtual unsigned int dimensionality() const override;
// Get the mean of the BivariateGaussian
Parameter & mean0();
......
......@@ -89,8 +89,8 @@ namespace Genfun {
EnergyFunction(const EnergyFunction &right);
// Retreive function value
virtual double operator ()(double argument) const;
virtual double operator ()(const Argument & a) const {return operator() (a[0]);}
virtual double operator ()(double argument) const override;
virtual double operator ()(const Argument & a) const override {return operator() (a[0]);}
private:
......
......@@ -33,17 +33,17 @@ namespace Genfun {
virtual ~ConstMinusFunction();
// Retreive function value
virtual double operator ()(double argument) const;
virtual double operator ()(const Argument & a) const;
virtual double operator ()(double argument) const override;
virtual double operator ()(const Argument & a) const override;
// Dimensionality
virtual unsigned int dimensionality() const;
virtual unsigned int dimensionality() const override;
// Derivative.
Derivative partial (unsigned int) const;
Derivative partial (unsigned int) const override;
// Does this function have an analytic derivative?
virtual bool hasAnalyticDerivative() const {return true;}
virtual bool hasAnalyticDerivative() const override {return true;}
private:
......
......@@ -33,17 +33,17 @@ namespace Genfun {
virtual ~ConstOverFunction();
// Retreive function value
virtual double operator ()(double argument) const;
virtual double operator ()(const Argument & a) const;
virtual double operator ()(double argument) const override;
virtual double operator ()(const Argument & a) const override;
// Dimensionality
virtual unsigned int dimensionality() const;
virtual unsigned int dimensionality() const override;
// Derivative.
Derivative partial (unsigned int) const;
Derivative partial (unsigned int) const override;
// Does this function have an analytic derivative?
virtual bool hasAnalyticDerivative() const {return true;}
virtual bool hasAnalyticDerivative() const override {return true;}
private:
......
......@@ -33,17 +33,17 @@ namespace Genfun {
virtual ~ConstPlusFunction();
// Retreive function value
virtual double operator ()(double argument) const;
virtual double operator ()(const Argument & a) const;
virtual double operator ()(double argument) const override;
virtual double operator ()(const Argument & argument) const override;
// Dimensionality
virtual unsigned int dimensionality() const;
virtual unsigned int dimensionality() const override;
// Derivative.
Derivative partial (unsigned int) const;
Derivative partial (unsigned int) const override;
// Does this function have an analytic derivative?
virtual bool hasAnalyticDerivative() const {return true;}
virtual bool hasAnalyticDerivative() const override {return true;}
private:
......
......@@ -32,17 +32,17 @@ namespace Genfun {
virtual ~ConstTimesFunction();
// Retreive function value
virtual double operator ()(double argument) const;
virtual double operator ()(const Argument & a) const;
virtual double operator ()(double argument) const override;
virtual double operator ()(const Argument & a) const override;
// Dimensionality
virtual unsigned int dimensionality() const;
virtual unsigned int dimensionality() const override;
// Derivative.
Derivative partial (unsigned int) const;
Derivative partial (unsigned int) const override;
// Does this function have an analytic derivative?
virtual bool hasAnalyticDerivative() const {return true;}
virtual bool hasAnalyticDerivative() const override {return true;}
private:
......
......@@ -32,14 +32,14 @@ namespace Genfun {
Cos(const Cos &right);
// Retreive function value
virtual double operator ()(double argument) const;
virtual double operator ()(const Argument & a) const {return operator() (a[0]);}
virtual double operator ()(double argument) const override;
virtual double operator ()(const Argument & a) const override {return operator() (a[0]);}
// Derivative.
Derivative partial (unsigned int) const;
Derivative partial (unsigned int) const override;
// Does this function have an analytic derivative?
virtual bool hasAnalyticDerivative() const {return true;}
virtual bool hasAnalyticDerivative() const override {return true;}
private:
......
......@@ -34,8 +34,8 @@ namespace Genfun {
virtual ~CubicSplinePolynomial();
// Retreive function value
virtual double operator ()(double argument) const;
virtual double operator ()(const Argument & a) const {return operator() (a[0]);}
virtual double operator ()(double argument) const override;
virtual double operator ()(const Argument & a) const override {return operator() (a[0]);}
// Puncture this thing:
void addPoint(double x, double y);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment