ca.nengo.math.impl
Class PostfixFunction
java.lang.Object
ca.nengo.math.impl.PostfixFunction
- All Implemented Interfaces:
- Function, java.io.Serializable, java.lang.Cloneable
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 networks
- Author:
- Bryan Tripp
- See Also:
- Serialized Form
Constructor Summary |
PostfixFunction(java.util.List<java.io.Serializable> expressionList,
java.lang.String expression,
int dimension)
|
PostfixFunction(java.lang.String expression,
int dimension)
|
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
PostfixFunction
public PostfixFunction(java.util.List<java.io.Serializable> expressionList,
java.lang.String expression,
int dimension)
- Parameters:
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)
PostfixFunction
public PostfixFunction(java.lang.String expression,
int dimension)
- Parameters:
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)
getExpressionList
protected java.util.List<java.io.Serializable> getExpressionList()
- Returns:
- Postfix expression list
getDimension
public int getDimension()
- Specified by:
getDimension
in interface Function
- Returns:
- Dimension of the space that the Function maps from
- See Also:
Function.getDimension()
setDimension
public void setDimension(int dimension)
- Parameters:
dimension
- Dimension of the function (must be at least as great as any operand
placeholders that appear in the expression)
getExpression
public java.lang.String getExpression()
- Returns:
- A human-readable string representation of the function
setExpression
public void setExpression(java.lang.String expression)
- Parameters:
expression
- String representation of the expression (infix)
map
public float map(float[] from)
- Specified by:
map
in interface Function
- Parameters:
from
- Must have same length as getDimension()
- Returns:
- result of function operation on arg
- See Also:
Function.map(float[])
multiMap
public float[] multiMap(float[][] from)
- Specified by:
multiMap
in interface Function
- Parameters:
from
- An array of arguments; each element must have length getDimension().
- Returns:
- Array of results of function operation on each arg
- See Also:
Function.multiMap(float[][])
clone
public Function clone()
throws java.lang.CloneNotSupportedException
- Specified by:
clone
in interface Function
- Overrides:
clone
in class java.lang.Object
- Throws:
java.lang.CloneNotSupportedException