10 #ifndef MN_GaussianModelFunction_H_ 11 #define MN_GaussianModelFunction_H_ 13 #define _USE_MATH_DEFINES 76 std::vector<double> param;
94 assert(params.size() == 1);
120 assert(x.size() == 3);
147 double operator()(
const std::vector<double>&
x,
const std::vector<double>& param)
const {
149 assert(param.size() == 1);
150 assert(x.size() == 3);
151 return x[2]*
exp(-0.5*(param[0]-x[0])*(param[0]-x[0])/(x[1]*x[1]))/(
sqrt(2.*
M_PI)*
fabs(x[1]));
163 virtual double Up()
const {
return 1.0; }
171 assert(param.size() == 1);
172 std::vector<double> grad(x.size());
174 double y = (param[0]-x[0])/x[1];
178 grad[0] = y/(x[1])*gaus*x[2];
179 grad[1] = x[2]*gaus*( y*y - 1.0)/x[1];
195 #endif // MN_GaussianModelFunction_H_ This namespace contains pre-defined functions to be used in conjuction with TExecutor::Map and TExecu...
double operator()(const std::vector< double > &x, const std::vector< double > ¶m) const
Calculates the Gaussian as a function of the given input.
Sample implementation of a parametric function.
GaussianModelFunction(const std::vector< double > ¶ms)
Constructor which initializes the ParametricFunction with the parameters given as input...
VecExpr< UnaryOp< Fabs< T >, VecExpr< A, T, D >, T >, T, D > fabs(const VecExpr< A, T, D > &rhs)
virtual void SetParameters(const std::vector< double > ¶ms) const
Sets the parameters of the ParametricFunction.
Function which has parameters.
std::vector< double > GetGradient(const std::vector< double > &x) const
Member function returning the Gradient of the function with respect to its variables (but without inc...
double operator()(const std::vector< double > &x) const
Calculates the Gaussian as a function of the given input.
virtual const std::vector< double > & GetParameters() const
Accessor for the state of the parameters.
std::vector< double > par
The vector containing the parameters of the function It is mutable for "historical reasons" as in the...
virtual double Up() const
THAT SHOULD BE REMOVED, IT IS ONLY HERE, BECAUSE AT PRESENT FOR GRADIENT CALCULATION ONE NEEDS TO INH...
GaussianModelFunction()
Constructor which initializes the normalized Gaussian with x = 0.0.