File indexing completed on 2025-01-18 10:10:08
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef ROOT_Fit_FcnAdapter_H_
0011 #define ROOT_Fit_FcnAdapter_H_
0012
0013 #include "Math/IFunction.h"
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023 namespace ROOT {
0024
0025 namespace Fit {
0026
0027 class FcnAdapter : public ROOT::Math::IMultiGenFunction {
0028
0029 public:
0030
0031 FcnAdapter(void (*fcn)(int&, double*, double&, double*, int ), int dim = 0) :
0032 fDim(dim),
0033 fFCN(fcn)
0034 {}
0035
0036 ~FcnAdapter() override {}
0037
0038 unsigned int NDim() const override { return fDim; }
0039
0040 ROOT::Math::IMultiGenFunction * Clone() const override {
0041 return new FcnAdapter(fFCN,fDim);
0042 }
0043
0044 void SetDimension(int dim) { fDim = dim; }
0045
0046 private:
0047
0048 double DoEval(const double * x) const override {
0049 double fval = 0;
0050 int dim = fDim;
0051
0052 fFCN(dim, nullptr, fval, const_cast<double *>(x), 4);
0053 return fval;
0054 }
0055
0056 private:
0057
0058 unsigned int fDim;
0059 void (*fFCN)(int&, double*, double&, double*, int);
0060
0061 };
0062
0063 }
0064
0065 }
0066
0067 #endif