-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDerivative.hpp
63 lines (47 loc) · 1.49 KB
/
Derivative.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//
// Created by Lennart Oymanns on 14.07.17.
//
#ifndef Derivative_hpp
#define Derivative_hpp
#include <map>
#include <string>
#include <vector>
#include "UserFunction.hpp"
namespace Equation {
class Number;
typedef std::shared_ptr<Number> NumberPtr;
class Variable;
typedef std::shared_ptr<Variable> VariablePtr;
class Summand;
typedef std::shared_ptr<Summand> SummandPtr;
class Power;
typedef std::shared_ptr<Power> PowerPtr;
class UnaryMinus;
typedef std::shared_ptr<UnaryMinus> UnaryMinusPtr;
class Factor;
typedef std::shared_ptr<Factor> FactorPtr;
class Function;
typedef std::shared_ptr<Function> FunctionPtr;
class Derivative : public UserFunction {
public:
Derivative();
virtual size_t NumArgs() const { return 2; }
virtual NodePtr Eval(const std::list<NodePtr> &args, bool numeric = false);
virtual NodePtr EvalNum(const std::vector<std::complex<NumberRepr>> &args) {
return 0;
}
virtual bool SpecialValues(const std::list<NodePtr> &args, NodePtr *result) {
return false;
}
private:
NodePtr Dnumber(const NumberPtr &nb);
NodePtr Dvariable(const VariablePtr &v, const std::string &var);
NodePtr Dsum(const SummandPtr &v, const std::string &var);
NodePtr Dpower(const PowerPtr &v, const std::string &var);
NodePtr Dminus(const UnaryMinusPtr &v, const std::string &var);
NodePtr Dmul(const FactorPtr &v, const std::string &var);
NodePtr Dfunc(const FunctionPtr &v, const std::string &var);
std::map<std::string, NodePtr> functions;
};
} // namespace Equation
#endif