49 if (computeD1_ && variables_.size() > 0)
52 function1_->enableFirstOrderDerivatives(
false);
54 function2_->enableSecondOrderDerivatives(
false);
55 function_->setParameters(parameters);
56 f3_ = function_->getValue();
58 bool functionChanged =
false;
61 for (
unsigned int i = 0; i < variables_.size(); i++)
63 string var = variables_[i];
68 vector<string> vars(2);
79 functionChanged =
true;
81 double h = (1. + std::abs(value)) * h_;
85 p[0].setValue(value - 2 * h);
87 f1_ = function_->getValue();
90 p[0].setValue(value + 2 * h);
92 f5_ = function_->getValue();
94 p[0].setValue(value - h);
96 f2_ = function_->getValue();
97 p[0].setValue(value + h);
99 f4_ = function_->getValue();
100 der1_[i] = (f1_ - 8. * f2_ + 8. * f4_ - f5_) / (12. * h);
101 der2_[i] = (-f1_ + 16. * f2_ - 30. * f3_ + 16. * f4_ - f5_) / (12. * h * h);
106 p[0].setValue(value - h);
108 f2_ = function_->getValue();
109 p[0].setValue(value - 2 * h);
111 f1_ = function_->getValue();
112 der1_[i] = (f3_ - f2_) / h;
113 der2_[i] = (f3_ - 2. * f2_ + f1_) / (h * h);
119 p[0].setValue(value + h);
121 f4_ = function_->getValue();
122 p[0].setValue(value + 2 * h);
124 f5_ = function_->getValue();
125 der1_[i] = (f4_ - f3_) / h;
126 der2_[i] = (f5_ - 2. * f4_ + f3_) / (h * h);
131 function1_->enableFirstOrderDerivatives(computeD1_);
133 function2_->enableSecondOrderDerivatives(computeD2_);
141 function1_->enableFirstOrderDerivatives(computeD1_);
143 function2_->enableSecondOrderDerivatives(computeD2_);
144 function_->setParameters(parameters);
146 f3_ = function_->getValue();
Exception thrown when a value do not match a given constraint.
void updateDerivatives(const ParameterList parameters)
Compute derivatives.
The parameter list object.
virtual bool hasParameter(const std::string &name) const
virtual void setParameters(const ParameterList ¶ms)
Update the parameters from params.
virtual double getParameterValue(const std::string &name) const
Get the value of the parameter with name name.
virtual ParameterList createSubList(const std::vector< std::string > &names) const
Get given parameters as a sublist.