13 #ifndef ROOT_Math_WrappedParamFunction 14 #define ROOT_Math_WrappedParamFunction 40 template<
typename FuncPtr = FreeParamMultiFunctionPtr >
74 template<
class Iterator>
139 template<
typename FuncPtr = FreeMultiFunctionPtr >
153 fParIndices(
std::vector<unsigned int>(idx, idx + npar) ),
154 fX(
std::vector<double>(npar+dim) )
167 fParIndices(
std::vector<unsigned int>(idx, idx + npar) ),
168 fX(
std::vector<double>(npar+dim) )
190 unsigned int npar =
NPar();
191 std::copy(p, p+ npar,
fParams.begin() );
192 SetParValues(npar, p);
220 for (
unsigned int i = 0; i <
fDim; ++i) {
221 unsigned int j = fVarIndices[i];
222 assert ( j <
NPar() + fDim);
230 return (*
fFunc)( &fX.front() );
237 double DoEvalPar(
const double *
x,
const double * p )
const {
238 SetParValues(
NPar(), p);
245 fVarIndices.reserve(
fDim);
246 unsigned int npar =
NPar();
247 for (
unsigned int i = 0; i < npar +
fDim; ++i) {
249 for (
unsigned int j = 0; j < npar; ++j) {
250 if (fParIndices[j] == i) {
255 if (isVar) fVarIndices.push_back(i);
257 assert ( fVarIndices.size() ==
fDim);
267 SetParValues(npar, &
fParams.front() );
268 for (
unsigned int i = 0; i < npar; ++i) {
269 unsigned int j = fParIndices[i];
270 assert ( j < npar + fDim);
279 for (
unsigned int i = 0; i < npar; ++i) {
280 unsigned int j = fParIndices[i];
281 assert ( j < npar +
fDim);
292 mutable std::vector<double>
fX;
void SetParValues(unsigned int npar, const double *p) const
double DoEvalPar(const double *x, const double *p) const
implement the required IParamFunction interface
Namespace for new ROOT classes and functions.
WrappedParamFunction(FuncPtr func, unsigned int dim, Iterator begin, Iterator end)
Constructor a wrapped function from a non-const pointer to a callable object, the function dimension ...
unsigned int NDim() const
Retrieve the dimension of the function.
double DoEval(const double *x) const
evaluate the function (re-implement for being more efficient)
std::vector< double > fParams
WrappedParamFunction(FuncPtr func, unsigned int dim=1, unsigned int npar=0, double *par=0)
Constructor a wrapped function from a pointer to a callable object, the function dimension and number...
const double * Parameters() const
Access the parameter values.
WrappedParamGenFunction class to wrap any multi-dimensional function implementing the operator()(cons...
virtual T DoEval(const T *x) const
Implement the ROOT::Math::IBaseFunctionMultiDim interface DoEval(x) using the cached parameter values...
std::vector< unsigned int > fVarIndices
WrappedParamFunctionGen(FuncPtr &func, unsigned int dim, unsigned int npar, const double *par, const unsigned int *idx)
Constructor as before but taking now a non - const pointer to a callable object.
std::vector< double > fParams
const double * Parameters() const
Access the parameter values.
void SetParameters(const double *p)
Set the parameter values.
Documentation for the abstract class IBaseFunctionMultiDim.
WrappedParamFunctionGen(const FuncPtr &func, unsigned int dim, unsigned int npar, const double *par, const unsigned int *idx)
Constructor a wrapped function from a pointer to a generic callable object implemention operator()(co...
double(* FreeParamMultiFunctionPtr)(const double *, const double *)
double func(double *x, double *p)
std::vector< unsigned int > fParIndices
Namespace for new Math classes and functions.
IMultiGenFunction * Clone() const
Constructor a wrapped function from a non - const pointer to a callable object, the function dimensio...
Binding & operator=(OUT(*fun)(void))
double DoEvalPar(const double *x, const double *p) const
evaluate the function given values and parameters (requested interface)
unsigned int NPar() const
Return the number of Parameters.
IMultiGenFunction * Clone() const
clone the function
void SetParameters(const double *p)
Set the parameter values.
unsigned int NPar() const
Return the number of Parameters.
unsigned int NDim() const
Retrieve the dimension of the function.
double(* FreeMultiFunctionPtr)(const double *)
WrappedParamFunction class to wrap any multi-dimensional function pbject implementing the operator()(...