The Node class structures a binary tree by storing pointers to a left Node and a right Node, and storing its content as a Function::Element, the name of an InputVariable or OutputVariable, or a constant value.
More...
#include <Function.h>
The Node class structures a binary tree by storing pointers to a left Node and a right Node, and storing its content as a Function::Element, the name of an InputVariable or OutputVariable, or a constant value.
Definition at line 139 of file Function.h.
◆ Node() [1/4]
◆ Node() [2/4]
fl::Function::Node::Node |
( |
const std::string & |
variable | ) |
|
|
explicit |
◆ Node() [3/4]
fl::Function::Node::Node |
( |
scalar |
value | ) |
|
|
explicit |
◆ Node() [4/4]
fl::Function::Node::Node |
( |
const Node & |
source | ) |
|
◆ ~Node()
virtual fl::Function::Node::~Node |
( |
| ) |
|
|
virtual |
◆ clone()
virtual Node* fl::Function::Node::clone |
( |
| ) |
const |
|
virtual |
Creates a clone of the node.
- Returns
- a clone of the node
◆ evaluate()
virtual scalar fl::Function::Node::evaluate |
( |
const std::map< std::string, scalar > * |
variables = fl::null | ) |
const |
|
virtual |
Evaluates the node and substitutes the variables therein for the values passed in the map.
The expression tree is evaluated recursively.
- Parameters
-
variables | is a map of substitutions of variable names for fl::scalars |
- Returns
- a fl::scalar indicating the result of the evaluation of the node
◆ operator=()
Node& fl::Function::Node::operator= |
( |
const Node & |
rhs | ) |
|
◆ toInfix()
virtual std::string fl::Function::Node::toInfix |
( |
const Node * |
node = fl::null | ) |
const |
|
virtual |
Returns an infix representation of the expression tree under the given node.
- Parameters
-
node | is the node to start the infix representation from. If the node is fl::null , then the starting point is this node |
- Returns
- an infix representation of the expression tree under the given node
◆ toPostfix()
virtual std::string fl::Function::Node::toPostfix |
( |
const Node * |
node = fl::null | ) |
const |
|
virtual |
Returns a postfix representation of the expression tree under the given node.
- Parameters
-
node | is the node to start the postfix representation from. If the node is fl::null , then the starting point is this node |
- Returns
- a postfix representation of the expression tree under the given node
◆ toPrefix()
virtual std::string fl::Function::Node::toPrefix |
( |
const Node * |
node = fl::null | ) |
const |
|
virtual |
Returns a prefix representation of the expression tree under the given node.
- Parameters
-
node | is the node to start the prefix representation from. If the node is fl::null , then the starting point is this node |
- Returns
- a prefix representation of the expression tree under the given node
◆ toString()
virtual std::string fl::Function::Node::toString |
( |
| ) |
const |
|
virtual |
Returns a string with the name of the element, the name of the variable, or the constant value, accordingly.
- Returns
- a string with the name of the element, the name of the variable, or the constant value, accordingly.
◆ treeSize() [1/2]
virtual std::size_t fl::Function::Node::treeSize |
( |
const Node * |
node = fl::null | ) |
const |
|
virtual |
Computes the size of the subtree under the given node.
The complexity of calling this method is O(n).
- Parameters
-
node | is the root of the subtree, which is this node if fl::null is given |
- Returns
- the size of the subtree under the given node
◆ treeSize() [2/2]
Computes the size of the subtree under the given node whose elements are of the given type.
The complexity of calling this method is O(n).
- Parameters
-
type | is the type of elements to account for |
node | is the root of the subtree, which is this node if fl::null is given |
- Returns
◆ element
The node takes an operation or a function.
Definition at line 141 of file Function.h.
◆ left
The node can have an expression tree on the left.
Definition at line 143 of file Function.h.
◆ right
The node can have an expression tree on the right.
Definition at line 145 of file Function.h.
◆ value
scalar fl::Function::Node::value |
The node can take an arbitrary floating-point value.
Definition at line 149 of file Function.h.
◆ variable
std::string fl::Function::Node::variable |
The node can refer to a variable by name.
Definition at line 147 of file Function.h.
The documentation for this struct was generated from the following file: