41 #ifndef BPP_NUMERIC_FUNCTION_ABSTRACTNUMERICALDERIVATIVE_H
42 #define BPP_NUMERIC_FUNCTION_ABSTRACTNUMERICALDERIVATIVE_H
45 #include "../Matrix/Matrix.h"
76 mutable std::map<std::string, size_t>
index_;
148 for (
size_t i = 0; i <
variables_.size(); i++)
167 std::map<std::string, size_t>::iterator it =
index_.find(variable);
169 return der1_[it->second];
174 throw Exception(
"First order derivative not computed for variable " + variable +
".");
188 std::map<std::string, size_t>::iterator it =
index_.find(variable);
190 return der2_[it->second];
195 throw Exception(
"Second order derivative not computed for variable " + variable +
".");
200 std::map<std::string, size_t>::iterator it1 =
index_.find(variable1);
201 std::map<std::string, size_t>::iterator it2 =
index_.find(variable2);
207 throw Exception(
"Cross second order derivative not computed for variables " + variable1 +
" and " + variable2 +
".");
Numerical derivative function wrapper, partial implementation.
void enableSecondOrderCrossDerivatives(bool yn)
void setParametersValues(const ParameterList ¶meters)
Update the parameters from parameters.
AbstractNumericalDerivative(DerivableFirstOrder *function)
AbstractNumericalDerivative(const AbstractNumericalDerivative &ad)
AbstractNumericalDerivative & operator=(const AbstractNumericalDerivative &ad)
DerivableFirstOrder * function1_
void enableSecondOrderDerivatives(bool yn)
Tell if derivatives must be computed.
double getInterval() const
std::vector< double > der1_
void setParameterValue(const std::string &name, double value)
Set the value of parameter with name name to be equal to value.
void setParametersToDerivate(const std::vector< std::string > &variables)
Set the list of parameters to derivate numerically.
bool enableSecondOrderDerivatives() const
Tell if derivatives must be computed.
void setParameters(const ParameterList ¶meters)
Set the point where the function must be computed.
void setInterval(double h)
Set the interval value used in numerical approximation.
AbstractNumericalDerivative(DerivableSecondOrder *function)
AbstractNumericalDerivative(Function *function)
RowMatrix< double > crossDer2_
void setAllParametersValues(const ParameterList ¶meters)
Set the parameters values to be equals to those of parameters.
AbstractNumericalDerivative * clone() const =0
Create a copy of this object and send a pointer to it.
void enableFirstOrderDerivatives(bool yn)
Tell if derivatives must be computed.
double getFirstOrderDerivative(const std::string &variable) const
Get the derivative of the function at the current point.
std::map< std::string, size_t > index_
bool enableSecondOrderCrossDerivatives() const
double f(const ParameterList ¶meters)
Get the value of the function according to a given set of parameters.
virtual ~AbstractNumericalDerivative()
std::vector< std::string > variables_
double getSecondOrderDerivative(const std::string &variable1, const std::string &variable2) const
Get the value of the cross derivative of the function according to a given set of parameters.
bool enableFirstOrderDerivatives() const
Tell if derivatives must be computed.
double getSecondOrderDerivative(const std::string &variable) const
Get the second order derivative of the function at the current point.
bool matchParametersValues(const ParameterList ¶meters)
Update the parameters from parameters.
DerivableSecondOrder * function2_
std::vector< double > der2_
virtual void updateDerivatives(const ParameterList parameters)=0
Compute derivatives.
This is the abstract class for first order derivable functions.
virtual double getFirstOrderDerivative(const std::string &variable) const =0
Get the derivative of the function at the current point.
This is the abstract class for second order derivable functions.
virtual double getSecondOrderDerivative(const std::string &variable) const =0
Get the second order derivative of the function at the current point.
Exception base class. Overload exception constructor (to control the exceptions mechanism)....
General class that wraps a function into another one. This class is meant to be derivated and just pr...
FunctionWrapper & operator=(const FunctionWrapper &fw)
double getValue() const
Get the value of the function at the current point.
This is the function abstract class.
virtual void setParameters(const ParameterList ¶meters)=0
Set the point where the function must be computed.
The parameter list object.
virtual ParameterList createSubList(const std::vector< std::string > &names) const
Get given parameters as a sublist.
virtual bool matchParametersValues(const ParameterList ¶meters)=0
Update the parameters from parameters.
virtual void setAllParametersValues(const ParameterList ¶meters)=0
Set the parameters values to be equals to those of parameters.
virtual const ParameterList & getParameters() const =0
Get all parameters available.
virtual void setParameterValue(const std::string &name, double value)=0
Set the value of parameter with name name to be equal to value.
virtual void setParametersValues(const ParameterList ¶meters)=0
Update the parameters from parameters.
void resize(size_t nRows, size_t nCols)
Resize the matrix.