mirror of
https://github.com/aportelli/LatAnalyze.git
synced 2024-11-10 00:45:36 +00:00
Model: binding functions
This commit is contained in:
parent
c0d717bcb6
commit
9c6dedd3d6
@ -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);
|
||||
}
|
||||
|
@ -52,8 +52,10 @@ public:
|
||||
double operator()(const std::vector<double> &data,
|
||||
const std::vector<double> &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;
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user