23 throw std::range_error(
"Function domain index is out of range.");
38 for (
int i = 0; i <
n; ++i) {
43 throw std::runtime_error(
"CostFunction: undefined FunctionValues.");
45 costFunction.
addVal(domain, values);
60 std::vector<API::IFunction_sptr> funs;
62 for (
int i = 0; i <
n; ++i) {
66 auto simpleValues = std::dynamic_pointer_cast<API::FunctionValues>(values);
68 throw std::runtime_error(
"CostFunction: undefined FunctionValues.");
72 if (k >= funs.size()) {
79 costFunction.
addValDerivHessian(funs[k], domain, simpleValues, evalDeriv, evalHessian);
#define PARALLEL_THREAD_NUMBER
#define PARALLEL_FOR_NO_WSP_CHECK()
#define PARALLEL_CRITICAL(name)
#define PARALLEL_SET_DYNAMIC(val)
A semi-abstract class for a cost function for fitting functions.
virtual void addVal(API::FunctionDomain_sptr domain, API::FunctionValues_sptr values) const =0
Increment to the cost function by evaluating it on a domain.
virtual void addValDerivHessian(API::IFunction_sptr function, API::FunctionDomain_sptr domain, API::FunctionValues_sptr values, bool evalDeriv=true, bool evalHessian=true) const =0
Increments the cost function and its derivatives by evaluating them on a domain.
virtual API::IFunction_sptr getFittingFunction() const
Get fitting function.
void getDomainAndValues(size_t i, API::FunctionDomain_sptr &domain, API::FunctionValues_sptr &values) const override
Create and return i-th domain and i-th values, (i-1)th domain is released.
void additiveCostFunctionVal(const CostFunctions::CostFuncFitting &costFunction) override
Calculate the value of an additive cost function.
void additiveCostFunctionValDerivHessian(const CostFunctions::CostFuncFitting &costFunction, bool evalDeriv, bool evalHessian) override
Calculate the value, first and second derivatives of an additive cost function.
std::vector< API::FunctionDomain_sptr > m_domain
Currently active domain.
std::vector< API::FunctionValues_sptr > m_values
Currently active values.
virtual size_t getNDomains() const
Return the number of parts in the domain.
std::vector< std::shared_ptr< API::IDomainCreator > > m_creators
Domain creators.
std::shared_ptr< FunctionValues > FunctionValues_sptr
typedef for a shared pointer
std::shared_ptr< FunctionDomain > FunctionDomain_sptr
typedef for a shared pointer