mirror of
https://github.com/aportelli/LatAnalyze.git
synced 2025-04-10 19:20:44 +01: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 //////////////////////////////////////////////////////////////////
|
// 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)
|
auto modelWithVec = [this](const DVec &x, const double *p)
|
||||||
{return (*this)(_arg, _par.data());};
|
{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);
|
auto modelBind = bind(modelWithVec, _1, par);
|
||||||
|
|
||||||
return DoubleFunction(getNArg(), modelBind);
|
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,
|
double operator()(const std::vector<double> &data,
|
||||||
const std::vector<double> &par) const;
|
const std::vector<double> &par) const;
|
||||||
virtual double operator()(const double *data, const double *par) const;
|
virtual double operator()(const double *data, const double *par) const;
|
||||||
// model bind
|
// bind
|
||||||
DoubleFunction getBind(const DVec &par) const;
|
DoubleFunction fixArg(const DVec &arg) const;
|
||||||
|
DoubleFunction fixPar(const DVec &par) const;
|
||||||
|
DoubleFunction toFunction(void) const;
|
||||||
private:
|
private:
|
||||||
// error checking
|
// error checking
|
||||||
void checkSize(const Index nArg, const Index nPar) const;
|
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());
|
result.model_.resize(modelVector.size());
|
||||||
for (unsigned int j = 0; j < modelVector.size(); ++j)
|
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;
|
return result;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user