41 #ifndef BPP_NUMERIC_FUNCTION_OPERATORS_MATHOPERATOR_H
42 #define BPP_NUMERIC_FUNCTION_OPERATORS_MATHOPERATOR_H
69 std::shared_ptr<Operator>
son_;
72 MathOperator(
double (*func)(
double), std::string name, std::shared_ptr<Operator> son) :
91 return son_->getValue();
105 double v =
son_->getValue();
106 double d =
son_->getFirstOrderDerivative(variable);
110 else if (
name_ ==
"log")
113 throw Exception(
"MathOperator::getFirstOrderDerivative : unknown function " +
name_);
118 double v =
son_->getValue();
119 double d =
son_->getFirstOrderDerivative(variable);
120 double d2 =
son_->getSecondOrderDerivative(variable);
123 return (d2 + d * d) * exp(v);
124 else if (
name_ ==
"log")
125 return (d2 * v - d * d) / (v * v);
127 throw Exception(
"MathOperator::getFirstOrderDerivative : unknown function " +
name_);
134 return name_ +
"(" +
son_->output() +
")";
Exception base class. Overload exception constructor (to control the exceptions mechanism)....
Implements a unary operator that applies a math (described in cmath) operator.
std::string output() const
double getFirstOrderDerivative(const std::string &variable) const
1st order derivative
std::string getName() const
MathOperator(double(*func)(double), std::string name, std::shared_ptr< Operator > son)
std::shared_ptr< Operator > getSon()
double getSecondOrderDerivative(const std::string &variable) const
MathOperator * clone() const
Create a copy of this object and send a pointer to it.
std::shared_ptr< Operator > son_
Interface of operator for numerical computation.