public interface FunctionInterpreter
Modifier and Type | Method and Description |
---|---|
java.util.Map<java.lang.String,Function> |
getRegisteredFunctions()
Returns a map of registered functions.
|
Function |
parse(java.lang.String expression,
int dimension)
Parses a mathematical expression into a Function instance.
|
void |
registerFunction(java.lang.String name,
Function function)
Registers a non-standard function for use in future interpretation of
function expressions.
|
void |
removeRegisteredFunction(java.lang.String name)
Removes a registered function.
|
void registerFunction(java.lang.String name, Function function)
name
- Short name of function as it is to appear in parsed expressionsfunction
- Function instancevoid removeRegisteredFunction(java.lang.String name)
name
- Name of function to be removedjava.util.Map<java.lang.String,Function> getRegisteredFunctions()
Function parse(java.lang.String expression, int dimension)
Parses a mathematical expression into a Function instance. The function can include the unary operators - and !, the binary operators +-/^*&|, the standard functions sin() cos() tan() asin(), acos(), atan(), exp(), and ln(), and user-defined unary functions functions that have been registered with the registerFunction(...) method. The constant "pi" and literal constants are also allowed. The logical operators produce 1f or 0f, on the basis of whether their operands are > 1/2. Functions must be given in infix notation and can include brackets.
Function operands have the form x0, x1, etc., which serve as placeholders for values that are given at each dimension of the map() method of the resulting function.
An example of a valid expression would be "x0 * (x1 + x2)^x3 * ln(x4/3)"
expression
- Mathematical expressiondimension
- Input dimension of the desired Function (must be at least as great
as any referenced inputs, eg if x3 appears in the expression, the dimension
must be at least 4)