bpp-core3  3.0.0
ConstantOperator.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_CONSTANTOPERATOR_H
6 #define BPP_NUMERIC_FUNCTION_OPERATORS_CONSTANTOPERATOR_H
7 
8 #include <memory>
9 
10 #include "../../../Text/TextTools.h"
11 
12 namespace bpp
13 {
20  public Operator
21 {
22 private:
23  const double value_;
24 
25 public:
26  ConstantOperator(double value) :
27  value_(value) {}
28 
30  {
31  return new ConstantOperator(*this);
32  }
33 
34  double getValue() const
35  {
36  return value_;
37  }
38 
39  double getFirstOrderDerivative(const std::string& variable) const
40  {
41  return 0;
42  }
43 
44  double getSecondOrderDerivative(const std::string& variable) const
45  {
46  return 0;
47  }
48 
49  std::string output() const
50  {
51  return TextTools::toString(value_);
52  }
53 };
54 } // end of namespace bpp.
55 #endif // BPP_NUMERIC_FUNCTION_OPERATORS_CONSTANTOPERATOR_H
double getSecondOrderDerivative(const std::string &variable) const
double getValue() const
ConstantOperator(double value)
ConstantOperator * clone() const
Create a copy of this object and send a pointer to it.
std::string output() const
double getFirstOrderDerivative(const std::string &variable) const
std::string toString(T t)
General template method to convert to a string.
Definition: TextTools.h:115
Constant (ie leaf) operator.
Interface of operator for numerical computation.
Definition: Operator.h:19