47 if (computeD1_ && variables_.size() > 0)
50 function1_->enableFirstOrderDerivatives(
false);
52 function2_->enableSecondOrderDerivatives(
false);
53 function_->setParameters(parameters);
54 f3_ = function_->getValue();
56 bool functionChanged =
false;
59 for (
unsigned int i = 0; i < variables_.size(); i++)
61 string var = variables_[i];
62 if (!parameters.hasParameter(var))
66 vector<string> vars(2);
77 functionChanged =
true;
79 double h = (1. + std::abs(value)) * h_;
83 p[0].setValue(value - 2 * h);
85 f1_ = function_->getValue();
88 p[0].setValue(value + 2 * h);
90 f5_ = function_->getValue();
92 p[0].setValue(value - h);
94 f2_ = function_->getValue();
95 p[0].setValue(value + h);
97 f4_ = function_->getValue();
98 der1_[i] = (f1_ - 8. * f2_ + 8. * f4_ - f5_) / (12. * h);
99 der2_[i] = (-f1_ + 16. * f2_ - 30. * f3_ + 16. * f4_ - f5_) / (12. * h * h);
104 p[0].setValue(value - h);
106 f2_ = function_->getValue();
107 p[0].setValue(value - 2 * h);
109 f1_ = function_->getValue();
110 der1_[i] = (f3_ - f2_) / h;
111 der2_[i] = (f3_ - 2. * f2_ + f1_) / (h * h);
117 p[0].setValue(value + h);
119 f4_ = function_->getValue();
120 p[0].setValue(value + 2 * h);
122 f5_ = function_->getValue();
123 der1_[i] = (f4_ - f3_) / h;
124 der2_[i] = (f5_ - 2. * f4_ + f3_) / (h * h);
129 function1_->enableFirstOrderDerivatives(computeD1_);
131 function2_->enableSecondOrderDerivatives(computeD2_);
133 function_->setParameters(parameters.subList(lastVar));
139 function1_->enableFirstOrderDerivatives(computeD1_);
141 function2_->enableSecondOrderDerivatives(computeD2_);
142 function_->setParameters(parameters);
144 f3_ = function_->getValue();
Exception thrown when a parameter is not found, for instance in a ParameterList.
virtual ParameterList subList(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.
This class allows to perform a correspondence analysis.
The parameter list object.
void updateDerivatives(const ParameterList parameters)
Compute derivatives.
virtual void setParameters(const ParameterList ¶ms)
Update the parameters from params.
Exception thrown when a value do not match a given constraint.