12 if (computeD1_ && variables_.size() > 0)
15 function1_->enableFirstOrderDerivatives(
false);
17 function2_->enableSecondOrderDerivatives(
false);
18 function_->setParameters(parameters);
19 f3_ = function_->getValue();
21 bool functionChanged =
false;
24 for (
size_t i = 0; i < variables_.size(); ++i)
26 string var = variables_[i];
31 vector<string> vars(2);
42 functionChanged =
true;
44 double h = (1. + std::abs(value)) * h_;
48 p[0].setValue(value - 2 * h);
50 f1_ = function_->getValue();
53 p[0].setValue(value + 2 * h);
55 f5_ = function_->getValue();
57 p[0].setValue(value - h);
59 f2_ = function_->getValue();
60 p[0].setValue(value + h);
62 f4_ = function_->getValue();
63 der1_[i] = (f1_ - 8. * f2_ + 8. * f4_ - f5_) / (12. * h);
64 der2_[i] = (-f1_ + 16. * f2_ - 30. * f3_ + 16. * f4_ - f5_) / (12. * h * h);
69 p[0].setValue(value - h);
71 f2_ = function_->getValue();
72 p[0].setValue(value - 2 * h);
74 f1_ = function_->getValue();
75 der1_[i] = (f3_ - f2_) / h;
76 der2_[i] = (f3_ - 2. * f2_ + f1_) / (h * h);
82 p[0].setValue(value + h);
84 f4_ = function_->getValue();
85 p[0].setValue(value + 2 * h);
87 f5_ = function_->getValue();
88 der1_[i] = (f4_ - f3_) / h;
89 der2_[i] = (f5_ - 2. * f4_ + f3_) / (h * h);
94 function1_->enableFirstOrderDerivatives(computeD1_);
96 function2_->enableSecondOrderDerivatives(computeD2_);
104 function1_->enableFirstOrderDerivatives(computeD1_);
106 function2_->enableSecondOrderDerivatives(computeD2_);
107 function_->setParameters(parameters);
109 f3_ = function_->getValue();
virtual ParameterList createSubList(const std::vector< std::string > &names) const
Get given parameters as a sublist.
virtual double getParameterValue(const std::string &name) const
Get the value of the parameter with name name.
The parameter list object.
void updateDerivatives(const ParameterList ¶meters) override
Compute derivatives.
virtual bool hasParameter(const std::string &name) const
virtual void setParameters(const ParameterList ¶ms)
Update the parameters from params.
Exception thrown when a value do not match a given constraint.