bpp-core3  3.0.0
NegativeOperator.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_OPERATORS_NEGATIVEOPERATOR_H
6 #define BPP_NUMERIC_FUNCTION_OPERATORS_NEGATIVEOPERATOR_H
7 
8 #include <memory>
9 
10 
11 namespace bpp
12 {
19  public Operator
20 {
21 private:
22  std::shared_ptr<Operator> son_;
23 
24 public:
25  NegativeOperator(std::shared_ptr<Operator> son) :
26  son_(son)
27  {}
28 
30  {
31  return new NegativeOperator(*this);
32  }
33 
34  std::shared_ptr<Operator> getSon()
35  {
36  return son_;
37  }
38 
39  double getValue() const
40  {
41  return -son_->getValue();
42  }
43 
44  double getFirstOrderDerivative(const std::string& variable) const
45  {
46  return -son_->getFirstOrderDerivative(variable);
47  }
48 
49  double getSecondOrderDerivative(const std::string& variable) const
50  {
51  return -son_->getSecondOrderDerivative(variable);
52  }
53 
54  std::string output() const
55  {
56  return "-" + son_->output();
57  }
58 };
59 } // end of namespace bpp.
60 #endif // BPP_NUMERIC_FUNCTION_OPERATORS_NEGATIVEOPERATOR_H
NegativeOperator(std::shared_ptr< Operator > son)
NegativeOperator * clone() const
Create a copy of this object and send a pointer to it.
std::shared_ptr< Operator > getSon()
double getFirstOrderDerivative(const std::string &variable) const
std::shared_ptr< Operator > son_
Negative value for an operator.
double getSecondOrderDerivative(const std::string &variable) const
Interface of operator for numerical computation.
Definition: Operator.h:19
double getValue() const
std::string output() const