24 double relativeDifference(
double a,
double b)
26 constexpr
double eps = std::numeric_limits<double>::epsilon();
27 const double avg_abs = (std::abs(a) + std::abs(b)) / 2.0;
29 if (std::abs(a - b) <= eps * avg_abs)
31 return std::abs(a - b) / avg_abs;
54 result.
add(plan.fitParameter());
63 std::vector<double> result;
65 result.push_back(plan.expectedValue());
77 throw std::runtime_error(
"FunctionTestPlan::valuesAsExpected() -> Error. Sizes differ.");
80 std::ostringstream text;
82 double diff = relativeDifference(values[index], plan.expectedValue());
85 if (diff > plan.tolerance())
88 text << plan.fitParameter().name() <<
" found:" << values[index]
89 <<
" expected:" << plan.expectedValue() <<
" diff:" << diff <<
" "
90 << (diff_ok ?
"OK" :
"FAILED") <<
"\n";
97 std::cout << text.str();
Defines class MinimizerTestPlan.
Defines class Parameters.
std::vector< double > expectedValues() const
Return vector of expected parameter values.
MinimizerTestPlan(const std::string &name)
bool valuesAsExpected(const std::vector< double > &values) const
Returns true if given values coincide with expected fit parameter values.
mumufit::Parameters parameters() const
Returns fit parameters which will be used as initial one for the minimization.
virtual ~MinimizerTestPlan()
std::vector< ParameterPlan > m_parameter_plan
void addParameter(const mumufit::Parameter ¶m, double expected_value, double tolerance=0.01)
Defines initial settings of single fit parameter and the final value which has to be found in the cou...
A fittable parameter with value, error, step, and limits.
A collection of fit parameters.
void add(const Parameter &par)
QString const & name(EShape k)
The multi-library, multi-algorithm fit wrapper library.