From d8458ddebd00b307f4e7ff5bc4d57f7d70b0f733 Mon Sep 17 00:00:00 2001 From: Jonas Rembser Date: Fri, 20 Sep 2024 20:06:50 +0200 Subject: [PATCH] [Minuit2] Revert recent changes to virtual function signature This reverts part of 63636f6aeb3 from a few days ago, which also changed the interface of virtual functions, which was not the intention and breaks user code. --- math/minuit2/inc/Minuit2/FCNAdapter.h | 9 +-------- math/minuit2/inc/Minuit2/FCNBase.h | 10 +++++----- math/minuit2/inc/Minuit2/FCNGradAdapter.h | 14 +++++++------- math/minuit2/inc/Minuit2/FumiliChi2FCN.h | 4 ++-- math/minuit2/inc/Minuit2/FumiliFCNAdapter.h | 14 ++++---------- math/minuit2/inc/Minuit2/FumiliFCNBase.h | 6 +++--- .../inc/Minuit2/FumiliMaximumLikelihoodFCN.h | 6 ++---- math/minuit2/inc/Minuit2/FumiliStandardChi2FCN.h | 6 ++---- .../Minuit2/FumiliStandardMaximumLikelihoodFCN.h | 6 ++---- math/minuit2/inc/Minuit2/GenericFunction.h | 2 +- math/minuit2/inc/Minuit2/ParametricFunction.h | 10 ++++------ math/minuit2/src/FumiliStandardChi2FCN.cxx | 4 ++-- .../src/FumiliStandardMaximumLikelihoodFCN.cxx | 4 ++-- math/minuit2/src/ParametricFunction.cxx | 4 +--- math/minuit2/test/MnSim/GaussFcn.cxx | 2 +- math/minuit2/test/MnSim/GaussFcn.h | 9 +++------ math/minuit2/test/MnSim/GaussFcn2.cxx | 2 +- math/minuit2/test/MnSim/GaussFcn2.h | 3 +-- math/minuit2/test/MnSim/GaussianModelFunction.h | 8 +++----- math/minuit2/test/MnSim/ParallelTest.cxx | 2 +- math/minuit2/test/MnSim/PaulTest4.cxx | 8 ++------ math/minuit2/test/MnSim/ReneTest.cxx | 4 +--- math/minuit2/test/MnTutorial/Quad12F.h | 2 +- math/minuit2/test/MnTutorial/Quad1F.h | 14 +++++--------- math/minuit2/test/MnTutorial/Quad4F.h | 14 +++----------- math/minuit2/test/MnTutorial/Quad8F.h | 2 +- 26 files changed, 61 insertions(+), 108 deletions(-) diff --git a/math/minuit2/inc/Minuit2/FCNAdapter.h b/math/minuit2/inc/Minuit2/FCNAdapter.h index 3e5e5a16a3ce7..5aa4ae7d1742a 100644 --- a/math/minuit2/inc/Minuit2/FCNAdapter.h +++ b/math/minuit2/inc/Minuit2/FCNAdapter.h @@ -37,19 +37,12 @@ class FCNAdapter : public FCNBase { public: FCNAdapter(const Function &f, double up = 1.) : fFunc(f), fUp(up) {} - ~FCNAdapter() override {} - - double operator()(std::span v) const override { return fFunc.operator()(&v[0]); } + double operator()(std::vector const& v) const override { return fFunc.operator()(&v[0]); } double operator()(const double *v) const { return fFunc.operator()(v); } double Up() const override { return fUp; } void SetErrorDef(double up) override { fUp = up; } - // virtual std::vector Gradient(const std::vector&) const; - - // forward interface - // virtual double operator()(int npar, double* params,int iflag = 4) const; - private: const Function &fFunc; double fUp; diff --git a/math/minuit2/inc/Minuit2/FCNBase.h b/math/minuit2/inc/Minuit2/FCNBase.h index 412544f4d01d9..7ab93ce5c6099 100644 --- a/math/minuit2/inc/Minuit2/FCNBase.h +++ b/math/minuit2/inc/Minuit2/FCNBase.h @@ -74,7 +74,7 @@ class FCNBase : public GenericFunction { */ - double operator()(std::span v) const override = 0; + double operator()(std::vector const &v) const override = 0; /** @@ -112,8 +112,8 @@ class FCNBase : public GenericFunction { virtual bool HasGradient() const { return false; } - virtual std::vector Gradient(std::span ) const { return {}; } - virtual std::vector GradientWithPrevResult(std::span parameters, double * /*previous_grad*/, + virtual std::vector Gradient(std::vector const&) const { return {}; } + virtual std::vector GradientWithPrevResult(std::vector const& parameters, double * /*previous_grad*/, double * /*previous_g2*/, double * /*previous_gstep*/) const { return Gradient(parameters); @@ -124,10 +124,10 @@ class FCNBase : public GenericFunction { }; /// return second derivatives (diagonal of the Hessian matrix) - virtual std::vector G2(std::span ) const { return {};} + virtual std::vector G2(std::vector const&) const { return {};} /// return Hessian - virtual std::vector Hessian(std::span ) const { return {};} + virtual std::vector Hessian(std::vector const&) const { return {};} virtual bool HasHessian() const { return false; } diff --git a/math/minuit2/inc/Minuit2/FCNGradAdapter.h b/math/minuit2/inc/Minuit2/FCNGradAdapter.h index e7fedf76d46c3..4ddaae08b409a 100644 --- a/math/minuit2/inc/Minuit2/FCNGradAdapter.h +++ b/math/minuit2/inc/Minuit2/FCNGradAdapter.h @@ -41,17 +41,17 @@ class FCNGradAdapter : public FCNBase { bool HasGradient() const override { return true; } - double operator()(std::span v) const override { return fFunc.operator()(&v[0]); } + double operator()(std::vector const& v) const override { return fFunc.operator()(&v[0]); } double operator()(const double *v) const { return fFunc.operator()(v); } double Up() const override { return fUp; } - std::vector Gradient(std::span v) const override + std::vector Gradient(std::vector const& v) const override { fFunc.Gradient(&v[0], &fGrad[0]); return fGrad; } - std::vector GradientWithPrevResult(std::span v, double *previous_grad, double *previous_g2, + std::vector GradientWithPrevResult(std::vector const& v, double *previous_grad, double *previous_g2, double *previous_gstep) const override { fFunc.GradientWithPrevResult(&v[0], &fGrad[0], previous_grad, previous_g2, previous_gstep); @@ -67,7 +67,7 @@ class FCNGradAdapter : public FCNBase { } /// return second derivatives (diagonal of the Hessian matrix) - std::vector G2(std::span x) const override { + std::vector G2(std::vector const& x) const override { if (fG2Func) return fG2Func(x); if (fHessianFunc) { @@ -88,7 +88,7 @@ class FCNGradAdapter : public FCNBase { } /// compute Hessian. Return Hessian as a std::vector of size(n*n) - std::vector Hessian(std::span x ) const override { + std::vector Hessian(std::vector const& x ) const override { unsigned int n = fFunc.NDim(); if (fHessianFunc) { if (fHessian.empty() ) fHessian.resize(n * n); @@ -126,8 +126,8 @@ class FCNGradAdapter : public FCNBase { mutable std::vector fHessian; mutable std::vector fG2Vec; - std::function(std::span )> fG2Func; - mutable std::function , double *)> fHessianFunc; + std::function(std::vector const& )> fG2Func; + mutable std::function const& , double *)> fHessianFunc; }; } // end namespace Minuit2 diff --git a/math/minuit2/inc/Minuit2/FumiliChi2FCN.h b/math/minuit2/inc/Minuit2/FumiliChi2FCN.h index 5126312da537a..21827f5ec1aa2 100644 --- a/math/minuit2/inc/Minuit2/FumiliChi2FCN.h +++ b/math/minuit2/inc/Minuit2/FumiliChi2FCN.h @@ -87,7 +87,7 @@ class FumiliChi2FCN : public FumiliFCNBase { */ - virtual std::vector Elements(std::span par) const = 0; + virtual std::vector Elements(std::vector const &par) const = 0; /** @@ -129,7 +129,7 @@ class FumiliChi2FCN : public FumiliFCNBase { */ - double operator()(std::span par) const override + double operator()(std::vector const &par) const override { double chiSquare = 0.0; diff --git a/math/minuit2/inc/Minuit2/FumiliFCNAdapter.h b/math/minuit2/inc/Minuit2/FumiliFCNAdapter.h index 56770149b9e44..e5c6995fc06f8 100644 --- a/math/minuit2/inc/Minuit2/FumiliFCNAdapter.h +++ b/math/minuit2/inc/Minuit2/FumiliFCNAdapter.h @@ -48,15 +48,13 @@ class FumiliFCNAdapter : public FumiliFCNBase { FumiliFCNAdapter(const Function &f, unsigned int ndim, double up = 1.) : FumiliFCNBase(ndim), fFunc(f), fUp(up) {} - ~FumiliFCNAdapter() override {} - - double operator()(std::span v) const override { return fFunc.operator()(&v[0]); } + double operator()(std::vector const &v) const override { return fFunc.operator()(&v[0]); } double operator()(const double *v) const { return fFunc.operator()(v); } double Up() const override { return fUp; } void SetErrorDef(double up) override { fUp = up; } - // virtual std::vector Gradient(std::span ) const; + // virtual std::vector Gradient(std::vector const &) const; // forward interface // virtual double operator()(int npar, double* params,int iflag = 4) const; @@ -64,22 +62,18 @@ class FumiliFCNAdapter : public FumiliFCNBase { /** evaluate gradient hessian and function value needed by fumili */ - void EvaluateAll(std::span v) override; + void EvaluateAll(std::vector const &v) override; private: - // data member - const Function &fFunc; double fUp; }; template -void FumiliFCNAdapter::EvaluateAll(std::span v) +void FumiliFCNAdapter::EvaluateAll(std::vector const &v) { MnPrint print("FumiliFCNAdapter"); - // typedef FumiliFCNAdapter::Function Function; - // evaluate all elements unsigned int npar = Dimension(); if (npar != v.size()) diff --git a/math/minuit2/inc/Minuit2/FumiliFCNBase.h b/math/minuit2/inc/Minuit2/FumiliFCNBase.h index 2f15251c6f883..1e754b9c03b91 100644 --- a/math/minuit2/inc/Minuit2/FumiliFCNBase.h +++ b/math/minuit2/inc/Minuit2/FumiliFCNBase.h @@ -84,7 +84,7 @@ class FumiliFCNBase : public FCNBase { **/ - virtual void EvaluateAll(std::span par) = 0; + virtual void EvaluateAll(std::vector const& par) = 0; /** Return cached Value of objective function estimated previously using the FumiliFCNBase::EvaluateAll method @@ -98,7 +98,7 @@ class FumiliFCNBase : public FCNBase { **/ virtual const std::vector &Gradient() const { return fGradient; } - std::vector Gradient(std::span) const override { return fGradient;} + std::vector Gradient(std::vector const&) const override { return fGradient;} /** Return Value of the i-th j-th element of the Hessian matrix estimated previously using the @@ -107,7 +107,7 @@ class FumiliFCNBase : public FCNBase { @param col col Index of the matrix **/ - std::vector Hessian(std::span) const override { return fHessian;} + std::vector Hessian(std::vector const&) const override { return fHessian;} virtual double Hessian(unsigned int row, unsigned int col) const { assert(row < fGradient.size() && col < fGradient.size()); diff --git a/math/minuit2/inc/Minuit2/FumiliMaximumLikelihoodFCN.h b/math/minuit2/inc/Minuit2/FumiliMaximumLikelihoodFCN.h index 59669e7d5d29b..975f0598ac80d 100644 --- a/math/minuit2/inc/Minuit2/FumiliMaximumLikelihoodFCN.h +++ b/math/minuit2/inc/Minuit2/FumiliMaximumLikelihoodFCN.h @@ -48,8 +48,6 @@ class FumiliMaximumLikelihoodFCN : public FumiliFCNBase { public: FumiliMaximumLikelihoodFCN() {} - ~FumiliMaximumLikelihoodFCN() override {} - /** Sets the model function for the data (for example gaussian+linear for a peak) @@ -84,7 +82,7 @@ class FumiliMaximumLikelihoodFCN : public FumiliFCNBase { */ - virtual std::vector Elements(std::span par) const = 0; + virtual std::vector Elements(std::vector const &par) const = 0; /** @@ -126,7 +124,7 @@ class FumiliMaximumLikelihoodFCN : public FumiliFCNBase { */ - double operator()(std::span par) const override + double operator()(std::vector const &par) const override { double sumoflogs = 0.0; diff --git a/math/minuit2/inc/Minuit2/FumiliStandardChi2FCN.h b/math/minuit2/inc/Minuit2/FumiliStandardChi2FCN.h index 39873f28beb49..a35bc518b9726 100644 --- a/math/minuit2/inc/Minuit2/FumiliStandardChi2FCN.h +++ b/math/minuit2/inc/Minuit2/FumiliStandardChi2FCN.h @@ -122,8 +122,6 @@ class FumiliStandardChi2FCN : public FumiliChi2FCN { } } - ~FumiliStandardChi2FCN() override {} - /** Evaluates the model function for the different measurement points and @@ -141,7 +139,7 @@ class FumiliStandardChi2FCN : public FumiliChi2FCN { */ - std::vector Elements(std::span par) const override; + std::vector Elements(std::vector const &par) const override; /** @@ -176,7 +174,7 @@ class FumiliStandardChi2FCN : public FumiliChi2FCN { **/ - void EvaluateAll(std::span par) override; + void EvaluateAll(std::vector const &par) override; private: std::vector fMeasurements; diff --git a/math/minuit2/inc/Minuit2/FumiliStandardMaximumLikelihoodFCN.h b/math/minuit2/inc/Minuit2/FumiliStandardMaximumLikelihoodFCN.h index 48f30aef9d569..2bb52d48dce30 100644 --- a/math/minuit2/inc/Minuit2/FumiliStandardMaximumLikelihoodFCN.h +++ b/math/minuit2/inc/Minuit2/FumiliStandardMaximumLikelihoodFCN.h @@ -74,8 +74,6 @@ class FumiliStandardMaximumLikelihoodFCN : public FumiliMaximumLikelihoodFCN { fPositions.assign(pos.begin(), pos.end()); } - ~FumiliStandardMaximumLikelihoodFCN() override {} - /** Evaluates the model function for the different measurement points and @@ -88,7 +86,7 @@ class FumiliStandardMaximumLikelihoodFCN : public FumiliMaximumLikelihoodFCN { */ - std::vector Elements(std::span par) const override; + std::vector Elements(std::vector const &par) const override; /** @@ -123,7 +121,7 @@ class FumiliStandardMaximumLikelihoodFCN : public FumiliMaximumLikelihoodFCN { **/ - void EvaluateAll(std::span par) override; + void EvaluateAll(std::vector const &par) override; private: std::vector> fPositions; diff --git a/math/minuit2/inc/Minuit2/GenericFunction.h b/math/minuit2/inc/Minuit2/GenericFunction.h index cc7959ae3d717..f7c65118c6262 100644 --- a/math/minuit2/inc/Minuit2/GenericFunction.h +++ b/math/minuit2/inc/Minuit2/GenericFunction.h @@ -49,7 +49,7 @@ class GenericFunction { */ - virtual double operator()(std::span x) const = 0; + virtual double operator()(std::vector const& x) const = 0; }; } // namespace Minuit2 diff --git a/math/minuit2/inc/Minuit2/ParametricFunction.h b/math/minuit2/inc/Minuit2/ParametricFunction.h index 2733b6adca09a..c7b0270772b66 100644 --- a/math/minuit2/inc/Minuit2/ParametricFunction.h +++ b/math/minuit2/inc/Minuit2/ParametricFunction.h @@ -65,8 +65,6 @@ class ParametricFunction : public FCNBase { ParametricFunction(int nparams) : par(nparams) {} - ~ParametricFunction() override {} - /** Sets the parameters of the ParametricFunction. @@ -75,7 +73,7 @@ class ParametricFunction : public FCNBase { */ - virtual void SetParameters(std::span params) const + virtual void SetParameters(std::vector const& params) const { assert(params.size() == par.size()); @@ -115,7 +113,7 @@ class ParametricFunction : public FCNBase { */ - double operator()(std::span x) const override = 0; + double operator()(std::vector const& x) const override = 0; /** @@ -134,7 +132,7 @@ class ParametricFunction : public FCNBase { */ - virtual double operator()(std::span x, std::span params) const + virtual double operator()(std::vector const& x, std::vector const& params) const { SetParameters(params); return operator()(x); @@ -153,7 +151,7 @@ class ParametricFunction : public FCNBase { */ - virtual std::vector GetGradient(std::span x) const; + virtual std::vector GetGradient(std::vector const& x) const; protected: /** diff --git a/math/minuit2/src/FumiliStandardChi2FCN.cxx b/math/minuit2/src/FumiliStandardChi2FCN.cxx index ea0cce62b5d80..8cd7a339e863a 100644 --- a/math/minuit2/src/FumiliStandardChi2FCN.cxx +++ b/math/minuit2/src/FumiliStandardChi2FCN.cxx @@ -16,7 +16,7 @@ namespace ROOT { namespace Minuit2 { -std::vector FumiliStandardChi2FCN::Elements(std::span par) const +std::vector FumiliStandardChi2FCN::Elements(std::vector const &par) const { // Calculate the f(i) contribution to the Chi2. Chi2 = Sum[f(i)**2] @@ -54,7 +54,7 @@ int FumiliStandardChi2FCN::GetNumberOfMeasurements() const return fPositions.size(); } -void FumiliStandardChi2FCN::EvaluateAll(std::span par) +void FumiliStandardChi2FCN::EvaluateAll(std::vector const &par) { // Evaluate chi2 value, gradient and hessian all in a single // loop on the measurements diff --git a/math/minuit2/src/FumiliStandardMaximumLikelihoodFCN.cxx b/math/minuit2/src/FumiliStandardMaximumLikelihoodFCN.cxx index 3127c89aff33a..ba2ef78ef4245 100644 --- a/math/minuit2/src/FumiliStandardMaximumLikelihoodFCN.cxx +++ b/math/minuit2/src/FumiliStandardMaximumLikelihoodFCN.cxx @@ -17,7 +17,7 @@ namespace ROOT { namespace Minuit2 { -std::vector FumiliStandardMaximumLikelihoodFCN::Elements(std::span par) const +std::vector FumiliStandardMaximumLikelihoodFCN::Elements(std::vector const &par) const { // calculate likelihood element f(i) = pdf(x(i)) @@ -54,7 +54,7 @@ int FumiliStandardMaximumLikelihoodFCN::GetNumberOfMeasurements() const return fPositions.size(); } -void FumiliStandardMaximumLikelihoodFCN::EvaluateAll(std::span par) +void FumiliStandardMaximumLikelihoodFCN::EvaluateAll(std::vector const &par) { // Evaluate in one loop likelihood value, gradient and hessian diff --git a/math/minuit2/src/ParametricFunction.cxx b/math/minuit2/src/ParametricFunction.cxx index 9bd77a74b978e..c0549dcdb3085 100644 --- a/math/minuit2/src/ParametricFunction.cxx +++ b/math/minuit2/src/ParametricFunction.cxx @@ -19,9 +19,7 @@ namespace ROOT { namespace Minuit2 { -//#include "Minuit2/MnPrint.h" - -std::vector ParametricFunction::GetGradient(std::span x) const +std::vector ParametricFunction::GetGradient(std::vector const &x) const { // calculate the numerical gradient (using Numerical2PGradientCalculator) diff --git a/math/minuit2/test/MnSim/GaussFcn.cxx b/math/minuit2/test/MnSim/GaussFcn.cxx index d31f1c85ca99d..64227039c27fc 100644 --- a/math/minuit2/test/MnSim/GaussFcn.cxx +++ b/math/minuit2/test/MnSim/GaussFcn.cxx @@ -16,7 +16,7 @@ namespace ROOT { namespace Minuit2 { -double GaussFcn::operator()(std::span par) const +double GaussFcn::operator()(std::vector const &par) const { assert(par.size() == 3); diff --git a/math/minuit2/test/MnSim/GaussFcn.h b/math/minuit2/test/MnSim/GaussFcn.h index 8eb2f7463f3ec..eb43616529ac9 100644 --- a/math/minuit2/test/MnSim/GaussFcn.h +++ b/math/minuit2/test/MnSim/GaussFcn.h @@ -24,15 +24,12 @@ class GaussFcn : public FCNBase { GaussFcn(std::span meas, std::span pos, std::span mvar) : fMeasurements(meas.begin(), meas.end()), fPositions(pos.begin(), pos.end()), - fMVariances(mvar.begin(), mvar.end()), - fErrorDef(1.) + fMVariances(mvar.begin(), mvar.end()) { } - ~GaussFcn() override {} - double Up() const override { return fErrorDef; } - double operator()(std::span) const override; + double operator()(std::vector const &) const override; std::vector Measurements() const { return fMeasurements; } std::vector Positions() const { return fPositions; } @@ -44,7 +41,7 @@ class GaussFcn : public FCNBase { std::vector fMeasurements; std::vector fPositions; std::vector fMVariances; - double fErrorDef; + double fErrorDef = 1.; }; } // namespace Minuit2 diff --git a/math/minuit2/test/MnSim/GaussFcn2.cxx b/math/minuit2/test/MnSim/GaussFcn2.cxx index 9ed7837eda2d7..56bf16a903af5 100644 --- a/math/minuit2/test/MnSim/GaussFcn2.cxx +++ b/math/minuit2/test/MnSim/GaussFcn2.cxx @@ -16,7 +16,7 @@ namespace ROOT { namespace Minuit2 { -double GaussFcn2::operator()(std::span par) const +double GaussFcn2::operator()(std::vector const &par) const { assert(par.size() == 6); diff --git a/math/minuit2/test/MnSim/GaussFcn2.h b/math/minuit2/test/MnSim/GaussFcn2.h index f654d68247047..0b9739be23fbc 100644 --- a/math/minuit2/test/MnSim/GaussFcn2.h +++ b/math/minuit2/test/MnSim/GaussFcn2.h @@ -29,12 +29,11 @@ class GaussFcn2 : public FCNBase { { Init(); } - ~GaussFcn2() override {} virtual void Init(); double Up() const override { return 1.; } - double operator()(std::span) const override; + double operator()(std::vector const &) const override; double ErrorDef() const override { return Up(); } std::vector Measurements() const { return fMeasurements; } diff --git a/math/minuit2/test/MnSim/GaussianModelFunction.h b/math/minuit2/test/MnSim/GaussianModelFunction.h index d619c25212823..88f924a28cfec 100644 --- a/math/minuit2/test/MnSim/GaussianModelFunction.h +++ b/math/minuit2/test/MnSim/GaussianModelFunction.h @@ -82,8 +82,6 @@ class GaussianModelFunction : public ParametricFunction { GaussianModelFunction(std::span params) : ParametricFunction(params) { assert(params.size() == 1); } - ~GaussianModelFunction() override {} - /** Calculates the Gaussian as a function of the given input. @@ -97,7 +95,7 @@ class GaussianModelFunction : public ParametricFunction { */ - double operator()(std::span x) const override + double operator()(std::vector const &x) const override { assert(x.size() == 3); @@ -128,7 +126,7 @@ class GaussianModelFunction : public ParametricFunction { */ - double operator()(std::span x, std::span param) const override + double operator()(std::vector const &x, std::vector const ¶m) const override { constexpr double two_pi = 2 * 3.14159265358979323846; // M_PI is not standard @@ -148,7 +146,7 @@ class GaussianModelFunction : public ParametricFunction { double Up() const override { return 1.0; } - std::vector GetGradient(std::span x) const override + std::vector GetGradient(std::vector const &x) const override { std::span param = GetParameters(); diff --git a/math/minuit2/test/MnSim/ParallelTest.cxx b/math/minuit2/test/MnSim/ParallelTest.cxx index 7646bb87f5f7c..2165284ae343a 100644 --- a/math/minuit2/test/MnSim/ParallelTest.cxx +++ b/math/minuit2/test/MnSim/ParallelTest.cxx @@ -59,7 +59,7 @@ struct LogLikeFCN : public FCNBase { LogLikeFCN(const Data &data) : fData(data) {} - double operator()(std::span p) const override + double operator()(std::vector const &p) const override { double logl = 0; int ndata = fData.size(); diff --git a/math/minuit2/test/MnSim/PaulTest4.cxx b/math/minuit2/test/MnSim/PaulTest4.cxx index d177296a5f9be..0f78cd0805148 100644 --- a/math/minuit2/test/MnSim/PaulTest4.cxx +++ b/math/minuit2/test/MnSim/PaulTest4.cxx @@ -53,9 +53,7 @@ class PowerLawChi2FCN : public FCNBase { { } - ~PowerLawChi2FCN() override {} - - double operator()(std::span par) const override + double operator()(std::vector const &par) const override { assert(par.size() == 2); PowerLawFunc pl(par[0], par[1]); @@ -84,9 +82,7 @@ class PowerLawLogLikeFCN : public FCNBase { { } - ~PowerLawLogLikeFCN() override {} - - double operator()(std::span par) const override + double operator()(std::vector const &par) const override { assert(par.size() == 2); PowerLawFunc pl(par[0], par[1]); diff --git a/math/minuit2/test/MnSim/ReneTest.cxx b/math/minuit2/test/MnSim/ReneTest.cxx index e06a719075dba..3bc381346f235 100644 --- a/math/minuit2/test/MnSim/ReneTest.cxx +++ b/math/minuit2/test/MnSim/ReneTest.cxx @@ -28,9 +28,7 @@ class ReneFcn : public FCNBase { public: ReneFcn(std::span meas) : fMeasurements(meas.begin(), meas.end()) {} - ~ReneFcn() override {} - - double operator()(std::span par) const override + double operator()(std::vector const &par) const override { double a = par[2]; double b = par[1]; diff --git a/math/minuit2/test/MnTutorial/Quad12F.h b/math/minuit2/test/MnTutorial/Quad12F.h index e43c4143a54fd..217209695e804 100644 --- a/math/minuit2/test/MnTutorial/Quad12F.h +++ b/math/minuit2/test/MnTutorial/Quad12F.h @@ -18,7 +18,7 @@ namespace Minuit2 { class Quad12F : public FCNBase { public: - double operator()(std::span par) const override + double operator()(std::vector const &par) const override { double x = par[0]; diff --git a/math/minuit2/test/MnTutorial/Quad1F.h b/math/minuit2/test/MnTutorial/Quad1F.h index 4ecfb045908a7..1790130c4376b 100644 --- a/math/minuit2/test/MnTutorial/Quad1F.h +++ b/math/minuit2/test/MnTutorial/Quad1F.h @@ -18,24 +18,20 @@ namespace Minuit2 { class Quad1F : public FCNGradientBase { public: - Quad1F() : fErrorDef(1.) {} - - ~Quad1F() override {} - - double operator()(std::span par) const override + double operator()(std::vector const &par) const override { double x = par[0]; - return (x * x); + return x * x; } - std::vector Gradient(std::span par) const override + std::vector Gradient(std::vector const &par) const override { double x = par[0]; - return (std::vector(1, 2. * x)); + return std::vector(1, 2. * x); } void SetErrorDef(double up) override { fErrorDef = up; } @@ -45,7 +41,7 @@ class Quad1F : public FCNGradientBase { const FCNBase *Base() const { return this; } private: - double fErrorDef; + double fErrorDef = 1.; }; } // namespace Minuit2 diff --git a/math/minuit2/test/MnTutorial/Quad4F.h b/math/minuit2/test/MnTutorial/Quad4F.h index 38d1f68dfe850..d050e2b48d1f9 100644 --- a/math/minuit2/test/MnTutorial/Quad4F.h +++ b/math/minuit2/test/MnTutorial/Quad4F.h @@ -18,11 +18,7 @@ namespace Minuit2 { class Quad4F : public FCNBase { public: - Quad4F() {} - - ~Quad4F() override {} - - double operator()(std::span par) const override + double operator()(std::vector const &par) const override { double x = par[0]; @@ -42,11 +38,7 @@ class Quad4F : public FCNBase { class Quad4FGrad : public FCNGradientBase { public: - Quad4FGrad() {} - - ~Quad4FGrad() override {} - - double operator()(std::span par) const override + double operator()(std::vector const &par) const override { double x = par[0]; @@ -57,7 +49,7 @@ class Quad4FGrad : public FCNGradientBase { return ((1. / 70.) * (21 * x * x + 20 * y * y + 19 * z * z - 14 * x * z - 20 * y * z) + w * w); } - std::vector Gradient(std::span par) const override + std::vector Gradient(std::vector const &par) const override { double x = par[0]; diff --git a/math/minuit2/test/MnTutorial/Quad8F.h b/math/minuit2/test/MnTutorial/Quad8F.h index 7ef9e8680b00b..974d443c8e2a9 100644 --- a/math/minuit2/test/MnTutorial/Quad8F.h +++ b/math/minuit2/test/MnTutorial/Quad8F.h @@ -18,7 +18,7 @@ namespace Minuit2 { class Quad8F : public FCNBase { public: - double operator()(std::span par) const override + double operator()(std::vector const &par) const override { double x = par[0];