An ExpressionNode that handles mathematical functions. More...


Public Member Functions | |
| FunctionExpressionNode (int function, ExpressionNode argument) | |
| Construct a function by id and argument. | |
| int | getType () |
| Returns the type of the node, in this case ExpressionNode.FUNCTION_NODE. | |
| double | getValue () |
| Returns the value of the sub-expression that is rooted at this node. | |
| void | accept (ExpressionNodeVisitor visitor) |
| Implementation of the visitor design pattern. | |
Static Public Member Functions | |
| static int | stringToFunction (String str) |
| Converts a string to a function id. | |
| static String | getAllFunctions () |
| Returns a string with all the function names concatenated by a | symbol. | |
Static Public Attributes | |
| static final int | SIN = 1 |
| function id for the sin function | |
| static final int | COS = 2 |
| function id for the cos function | |
| static final int | TAN = 3 |
| function id for the tan function | |
| static final int | ASIN = 4 |
| function id for the asin function | |
| static final int | ACOS = 5 |
| function id for the acos function | |
| static final int | ATAN = 6 |
| function id for the atan function | |
| static final int | SQRT = 7 |
| function id for the sqrt function | |
| static final int | EXP = 8 |
| function id for the exp function | |
| static final int | LN = 9 |
| function id for the ln function | |
| static final int | LOG = 10 |
| function id for the log function | |
| static final int | LOG2 = 11 |
| function id for the log2 function | |
Static Public Attributes inherited from uk.co.cogitolearning.cogpar.ExpressionNode | |
| static final int | VARIABLE_NODE = 1 |
| Node id for variable nodes. | |
| static final int | CONSTANT_NODE = 2 |
| Node id for constant nodes. | |
| static final int | ADDITION_NODE = 3 |
| Node id for addition nodes. | |
| static final int | MULTIPLICATION_NODE = 4 |
| Node id for multiplication nodes. | |
| static final int | EXPONENTIATION_NODE = 5 |
| Node id for exponentiation nodes. | |
| static final int | FUNCTION_NODE = 6 |
| Node id for function nodes. | |
Private Attributes | |
| int | function |
| the id of the function to apply to the argument | |
| ExpressionNode | argument |
| the argument of the function | |
An ExpressionNode that handles mathematical functions.
Some pre-defined functions are handled, others can easily be added.
Definition at line 32 of file FunctionExpressionNode.java.
| uk.co.cogitolearning.cogpar.FunctionExpressionNode.FunctionExpressionNode | ( | int | function, |
| ExpressionNode | argument | ||
| ) |
Construct a function by id and argument.
| function | the id of the function to apply |
| argument | the argument of the function |
Definition at line 74 of file FunctionExpressionNode.java.
| void uk.co.cogitolearning.cogpar.FunctionExpressionNode.accept | ( | ExpressionNodeVisitor | visitor | ) |
Implementation of the visitor design pattern.
Calls visit on the visitor and then passes the visitor on to the accept method of the argument.
| visitor | the visitor |
Implements uk.co.cogitolearning.cogpar.ExpressionNode.
Definition at line 188 of file FunctionExpressionNode.java.
|
static |
Returns a string with all the function names concatenated by a | symbol.
This string is used in Tokenizer.createExpressionTokenizer to create a regular expression for recognizing function names.
Definition at line 137 of file FunctionExpressionNode.java.
| double uk.co.cogitolearning.cogpar.FunctionExpressionNode.getValue | ( | ) |
Returns the value of the sub-expression that is rooted at this node.
The argument is evaluated and then the function is applied to the resulting value.
Implements uk.co.cogitolearning.cogpar.ExpressionNode.
Definition at line 148 of file FunctionExpressionNode.java.
|
static |
Converts a string to a function id.
If the function is not found this method throws an error.
| str | the name of the function |
Definition at line 98 of file FunctionExpressionNode.java.
1.8.1.2