diff --git a/lib/Model.cpp b/lib/Model.cpp index 37d1e5c..a517316 100644 --- a/lib/Model.cpp +++ b/lib/Model.cpp @@ -93,11 +93,27 @@ double DoubleModel::operator()(const double *data, const double *par) const } // model bind ////////////////////////////////////////////////////////////////// -DoubleFunction DoubleModel::getBind(const DVec &par) const +DoubleFunction DoubleModel::fixArg(const DVec &arg) const { - auto modelWithVec = [this](const double *_arg, const DVec &_par) - {return (*this)(_arg, _par.data());}; + auto modelWithVec = [this](const DVec &x, const double *p) + {return (*this)(x.data(), p);}; + auto modelBind = bind(modelWithVec, arg, _1); + + return DoubleFunction(getNPar(), modelBind); +} + +DoubleFunction DoubleModel::fixPar(const DVec &par) const +{ + auto modelWithVec = [this](const double *x, const DVec &p) + {return (*this)(x, p.data());}; auto modelBind = bind(modelWithVec, _1, par); return DoubleFunction(getNArg(), modelBind); } + +DoubleFunction DoubleModel::toFunction(void) const +{ + auto func = [this](const double *x){return (*this)(x, x + getNArg());}; + + return DoubleFunction(getNArg() + getNPar(), func); +} diff --git a/lib/Model.hpp b/lib/Model.hpp index 970c6e5..20c5a4a 100644 --- a/lib/Model.hpp +++ b/lib/Model.hpp @@ -52,8 +52,10 @@ public: double operator()(const std::vector &data, const std::vector &par) const; virtual double operator()(const double *data, const double *par) const; - // model bind - DoubleFunction getBind(const DVec &par) const; + // bind + DoubleFunction fixArg(const DVec &arg) const; + DoubleFunction fixPar(const DVec &par) const; + DoubleFunction toFunction(void) const; private: // error checking void checkSize(const Index nArg, const Index nPar) const; diff --git a/lib/XYStatData.cpp b/lib/XYStatData.cpp index 2b2f6e3..c5f1910 100644 --- a/lib/XYStatData.cpp +++ b/lib/XYStatData.cpp @@ -247,7 +247,7 @@ FitResult XYStatData::fit(Minimizer &minimizer, const DVec &init, result.model_.resize(modelVector.size()); for (unsigned int j = 0; j < modelVector.size(); ++j) { - result.model_[j] = modelVector[j]->getBind(result); + result.model_[j] = modelVector[j]->fixPar(result); } return result;