29 #include <unordered_map> 84 bool isLeaf()
const {
return false; }
195 Binary(
'/', one, two, parent, neg, s)
198 m_first->setDrawParenthesis(
false);
m_second->setDrawParenthesis(
false);
224 const std::string&
getName()
const {
return name; }
230 std::type_index
getType()
const {
return type; }
254 static const std::type_index
type;
314 Binary(
'^', one, two, parent, neg, s)
343 const std::string&
getName()
const {
return name; }
349 std::type_index
getType()
const {
return type; }
380 static const std::type_index
type;
448 Node(parent, neg, s), m_name(name), m_value(value) {}
472 std::string
toString()
const {
return std::string() + m_name; }
478 const std::string&
getName()
const {
return name; }
484 std::type_index
getType()
const {
return type; }
488 static const std::type_index
type;
565 Node(parent, neg, s), m_name(name)
567 values.emplace(name,
Complex(0, 0));
584 using var_map = std::unordered_map<char, Complex>;
592 std::string
toString()
const {
return std::string(1, m_name); }
598 const std::string&
getName()
const {
return name; }
604 std::type_index
getType()
const {
return type; }
608 static const std::type_index
type;
623 static void setValue(
char name,
Complex value);
692 Node(parent, neg, s), m_value(stod(real)), m_isInteger(isInteger(real)) {}
702 Node(parent, neg, s), m_value(n), m_isInteger(true) {}
712 Node(parent, neg, s), m_value(d), m_isInteger(isInteger(d)) {}
732 void getNumber(
Parser& p);
746 const std::string&
getName()
const {
return name; }
752 std::type_index
getType()
const {
return type; }
762 static const std::type_index
type;
784 static std::string getInteger(
Parser& p);
835 using func_map = std::unordered_map<std::string, func_ptr>;
852 std::string
toString()
const {
return m_name + m_arg->toString(); }
900 const std::string&
getName()
const {
return name; }
906 std::type_index
getType()
const {
return type; }
910 static const std::type_index
type;
924 bool neg =
false,
Node::Select s = Node::Select::NONE) :
925 Node(parent, neg, s), m_name(name), m_func(fp), m_arg(new
Expression(p, this)) {}
1075 const std::string&
getName()
const {
return name; }
int numFactors() const
Definition: nodes.h:106
Power(EqnXMLParser &in, Node *parent)
Definition: nodes.h:326
Function(const std::string &name, func_ptr fp, Parser &p, Node *parent, bool neg=false, Node::Select s=Node::Select::NONE)
Definition: nodes.h:923
Binary(char op, Node *one, Node *two, Node *parent, bool neg, Node::Select s)
Definition: nodes.h:53
Box m_internal
Bounding box of this node.
Definition: nodes.h:134
ExpressionPtr getSecondExpression()
Definition: symbol.cpp:358
virtual Complex getNodeValue() const =0
char m_variable
Variable of Differential.
Definition: nodes.h:1109
const std::string & getName() const
Definition: nodes.h:478
NodePtr m_second
Second expression owned by this object.
Definition: nodes.h:133
static const std::string name
Name of Power class.
Definition: nodes.h:379
virtual ~Binary()
Definition: nodes.h:68
const std::string & getName() const
Definition: nodes.h:746
Node * downRight()
Definition: nodes.h:151
double m_value
Value of Number.
Definition: nodes.h:773
static const const_map constants
Mapping of all constant name to their values.
Definition: nodes.h:502
std::string m_name
Name of function.
Definition: nodes.h:941
char m_name
Name of constant.
Definition: nodes.h:498
Complex m_value
Value of constant.
Definition: nodes.h:499
NodePtr m_first
First expression owned by this object.
Definition: nodes.h:132
static const std::type_index type
Type of Function type.
Definition: nodes.h:910
~Variable()
Definition: nodes.h:581
const std::string & getName() const
Definition: nodes.h:343
static const std::string name
Name of Variable class.
Definition: nodes.h:607
static const std::type_index type
Type of Number class.
Definition: nodes.h:762
std::complex< double > Complex
Specialized as complex double.
Definition: milo.h:58
bool isLeaf() const
Definition: nodes.h:1041
typename std::vector< SmartPtr< Node > >::iterator iterator
Definition: smart.h:88
virtual void normalize()
Definition: milo.h:175
const std::string & getName() const
Definition: nodes.h:224
Box m_internal
Bounding box of this node.
Definition: nodes.h:1108
~Constant()
Definition: nodes.h:461
~Number()
Definition: nodes.h:725
Constant(char name, Complex value, Node *parent, bool neg=false, Node::Select s=Node::Select::NONE)
Definition: nodes.h:447
Definition: parser.cpp:85
std::type_index getType() const
Definition: nodes.h:349
Divide(Node *one, Node *two, Node *parent, bool neg=false, Node::Select s=Node::Select::NONE)
Definition: nodes.h:194
virtual bool simplify()
Definition: milo.h:181
Complex getNodeValue() const
Definition: nodes.h:537
Node * downRight()
Definition: nodes.h:960
std::string toString() const
Definition: nodes.h:852
std::unordered_map< char, Complex > var_map
Specialization for mapping name to value.
Definition: nodes.h:584
std::string toString() const
Definition: nodes.h:472
Number(std::string real, Node *parent, bool neg=false, Node::Select s=Node::Select::NONE)
Definition: nodes.h:691
Divide(EqnXMLParser &in, Node *parent)
Definition: nodes.h:207
virtual void drawNode(UI::Graphics &gc) const =0
Box m_internal
Bounding box of this node.
Definition: nodes.h:500
Power(Node *one, Node *two, Node *parent, bool neg=false, Node::Select s=Node::Select::NONE)
Definition: nodes.h:313
Complex getNodeValue() const
Definition: nodes.h:817
static const std::string name
Name of Divide class.
Definition: nodes.h:253
Node * downLeft()
Definition: nodes.h:953
Number(int n, Node *parent, bool neg=false, Node::Select s=Node::Select::NONE)
Definition: nodes.h:701
void normalize()
Definition: nodes.h:886
ExpressionPtr getFirstExpression()
Definition: symbol.cpp:352
Node * findNode(int x, int y)
Definition: nodes.cpp:582
virtual void calcOrig(UI::Graphics &gc, int x, int y)=0
const std::string & getName() const
Definition: nodes.h:900
static const std::type_index type
Type of Differential class.
Definition: nodes.h:1097
static const func_map functions
Definition: nodes.h:997
static Node * parse(Parser &p, Node *one, Node *parent)
Definition: parser.cpp:433
Node * downLeft()
Definition: nodes.h:144
~Power()
Definition: nodes.h:334
static const std::string name
Name of constant.
Definition: nodes.h:487
int numFactors() const
Definition: nodes.h:880
Node * findNode(int x, int y)
Definition: nodes.h:1055
Complex getNodeValue() const
Definition: nodes.h:664
std::string toString() const
Definition: nodes.h:592
virtual Node * findNode(int x, int y)
Definition: milo.cpp:393
char m_name
Name of Variable.
Definition: nodes.h:626
Number(Parser &p, Node *parent)
Definition: nodes.h:682
Complex getNodeValue() const
Definition: nodes.h:1158
Box m_internal
Bounding box of this node.
Definition: nodes.h:944
Node * downLeft()
Definition: nodes.h:1119
std::type_index getType() const
Definition: nodes.h:752
static const std::string name
Name of Differential class.
Definition: nodes.h:1096
std::unordered_map< std::string, func_ptr > func_map
Map that associates function name with its function call.
Definition: nodes.h:835
void xml_out(XML::Stream &xml) const
Definition: parser.cpp:356
std::type_index getType() const
Definition: nodes.h:1081
bool m_isInteger
True, if integer.
Definition: nodes.h:774
bool simplify()
Definition: nodes.h:1093
static const std::type_index type
Type of Variable class.
Definition: nodes.h:608
static const std::type_index type
Type of Divide class.
Definition: nodes.h:254
virtual bool less(NodePtr b) const
Definition: milo.h:189
Node * getLeftSibling(Node *node)
Definition: nodes.h:159
~Divide()
Definition: nodes.h:215
std::type_index getType() const
Definition: nodes.h:230
Node * getRightSibling(Node *node)
Definition: nodes.h:167
std::type_index getType() const
Definition: nodes.h:604
const std::string & getName() const
Definition: nodes.h:1075
static Node * create(EqnXMLParser &in, Node *parent)
Definition: parser.cpp:272
static const std::string name
Name of Function class.
Definition: nodes.h:909
Select
Definition: milo.h:86
char m_op
Character repesentation of operator.
Definition: nodes.h:131
std::type_index getType() const
Definition: nodes.h:906
static var_map values
Mapping of all variable name to their values.
Definition: nodes.h:629
Box m_internal
Bounding box of this node.
Definition: nodes.h:775
NodePtr m_function
Function to be differentiated.
Definition: nodes.h:1110
~Function()
Definition: nodes.h:938
std::string toString() const
Definition: nodes.h:78
func_ptr m_func
Function pointer to evaluate function.
Definition: nodes.h:942
static const std::string name
Name of Number class.
Definition: nodes.h:761
NodePtr m_arg
Function own this tree.
Definition: nodes.h:943
~Differential()
Definition: nodes.h:1032
std::unordered_map< char, Complex > const_map
Specialization for mapping name to value.
Definition: nodes.h:464
Number(double d, Node *parent, bool neg=false, Node::Select s=Node::Select::NONE)
Definition: nodes.h:711
Variable(char name, Node *parent, bool neg=false, Node::Select s=Node::Select::NONE)
Definition: nodes.h:564
void normalize()
Definition: nodes.h:1087
Box m_internal
Bounding box of this node.
Definition: nodes.h:627
static const std::type_index type
Type of Power class.
Definition: nodes.h:380
static const std::type_index type
Type of constant.
Definition: nodes.h:488
Definition: parser.cpp:43
const std::string & getName() const
Definition: nodes.h:598
std::type_index getType() const
Definition: nodes.h:484
Node * downRight()
Definition: nodes.h:1126
virtual Frame calcSize(UI::Graphics &gc)=0
bool isLeaf() const
Definition: nodes.h:84
bool isLeaf() const
Definition: nodes.h:858
Complex(*)(Complex) func_ptr
Definition: nodes.h:830
int numFactors() const
Definition: nodes.h:1047