public class PostfixFunction extends java.lang.Object implements Function
A Function based on a mathematical expression and on other functions. The expression must be given as a list of list of operators, literal operands, and operand placeholders.
An operator can be any Function. A literal operand must be a Float.
An operand placeholder is an Integer, which points to the dimension of the input vector from which the corresponding operand is to be drawn. For example the expression for a PostfixFunction with 2 dimensions can include the Integers 0 and 1. When map(float[] from) is called, Integer 0 will be replaced with from[0] and so on.
The expression list must be given in postfix order.
TODO: need a way to manage user-defined functions that ensures they can be accessed from saved networksConstructor and Description |
---|
PostfixFunction(java.util.List<java.io.Serializable> expressionList,
java.lang.String expression,
int dimension) |
PostfixFunction(java.lang.String expression,
int dimension) |
Modifier and Type | Method and Description |
---|---|
Function |
clone() |
int |
getDimension() |
java.lang.String |
getExpression() |
protected java.util.List<java.io.Serializable> |
getExpressionList() |
float |
map(float[] from) |
float[] |
multiMap(float[][] from) |
void |
setDimension(int dimension) |
void |
setExpression(java.lang.String expression) |
public PostfixFunction(java.util.List<java.io.Serializable> expressionList, java.lang.String expression, int dimension)
expressionList
- Postfix expression list (as described in class docs)expression
- String representation of the expressiondimension
- Dimension of the function (must be at least as great as any operand
placeholders that appear in the expression)public PostfixFunction(java.lang.String expression, int dimension)
expression
- String representation of the expression (infix)dimension
- Dimension of the function (must be at least as great as any operand
placeholders that appear in the expression)protected java.util.List<java.io.Serializable> getExpressionList()
public int getDimension()
getDimension
in interface Function
Function.getDimension()
public void setDimension(int dimension)
dimension
- Dimension of the function (must be at least as great as any operand
placeholders that appear in the expression)public java.lang.String getExpression()
public void setExpression(java.lang.String expression)
expression
- String representation of the expression (infix)public float map(float[] from)
map
in interface Function
from
- Must have same length as getDimension()Function.map(float[])
public float[] multiMap(float[][] from)
multiMap
in interface Function
from
- An array of arguments; each element must have length getDimension().Function.multiMap(float[][])