bpp-core3  3.0.0
TwoPointsNumericalDerivative.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: The Bio++ Development Group
2 //
3 // SPDX-License-Identifier: CECILL-2.1
4 
5 #ifndef BPP_NUMERIC_FUNCTION_TWOPOINTSNUMERICALDERIVATIVE_H
6 #define BPP_NUMERIC_FUNCTION_TWOPOINTSNUMERICALDERIVATIVE_H
7 
8 
9 #include "NumericalDerivative.h"
10 #include "Functions.h"
11 
12 // From the STL:
13 #include <map>
14 #include <vector>
15 #include <string>
16 
17 namespace bpp
18 {
42 {
43 private:
44  double f1_, f2_;
45 
46 public:
47  TwoPointsNumericalDerivative(std::shared_ptr<FunctionInterface> function) :
49  f1_(),
50  f2_() {}
51  TwoPointsNumericalDerivative(std::shared_ptr<FirstOrderDerivable> function) :
53  f1_(),
54  f2_() {}
56 
58  {
59  return new TwoPointsNumericalDerivative(*this);
60  }
61 
62 public:
63  double getValue() const override { return f1_; }
64 
70  double getSecondOrderDerivative(const std::string& variable) const override
71  {
72  throw Exception("Second order derivative not avalaible with two points method.");
73  }
74 
75  double getSecondOrderDerivative(const std::string& variable1, const std::string& variable2) const override
76  {
77  throw Exception("Unimplemented cross derivative.");
78  }
81 protected:
82  void updateDerivatives(const ParameterList& parameters) override;
83 };
84 } // end of namespace bpp.
85 #endif // BPP_NUMERIC_FUNCTION_TWOPOINTSNUMERICALDERIVATIVE_H
double getValue() const override
Get the value of the function at the current point.
TwoPointsNumericalDerivative(std::shared_ptr< FunctionInterface > function)
Numerical derivative function wrapper, partial implementation.
The parameter list object.
Definition: ParameterList.h:27
TwoPointsNumericalDerivative * clone() const override
Create a copy of this object and send a pointer to it.
void updateDerivatives(const ParameterList &parameters) override
Compute derivatives.
double getSecondOrderDerivative(const std::string &variable1, const std::string &variable2) const override
Get the value of the cross derivative of the function according to a given set of parameters...
Exception base class. Overload exception constructor (to control the exceptions mechanism). Destructor is already virtual (from std::exception)
Definition: Exceptions.h:20
TwoPointsNumericalDerivative(std::shared_ptr< FirstOrderDerivable > function)
Two points numerical derivative function wrapper.
double getSecondOrderDerivative(const std::string &variable) const override
Get the second order derivative of the function at the current point.