Package ptolemy.data
Class FunctionToken
- java.lang.Object
-
- ptolemy.data.Token
-
- ptolemy.data.FunctionToken
-
- Direct Known Subclasses:
FactorOracle.ChordFunction.ChordFunctionToken
,FactorOracle.ChordFunctionToken
public class FunctionToken extends Token
A token that contains a function. The function takes a fixed number of arguments, supplied as a list of tokens. Currently, no operations between function tokens (add, multiply, etc.) are supported.- Since:
- Ptolemy II 2.1
- Version:
- $Id$
- Author:
- Xiaojun Liu, Steve Neuendorffer
- Pt.AcceptedRating:
- Red (liuxj)
- Pt.ProposedRating:
- Yellow (liuxj)
-
-
Constructor Summary
Constructors Constructor Description FunctionToken(java.lang.String init)
Create a new FunctionToken from the given string.FunctionToken(Function f, FunctionType type)
Create a new FunctionToken that applies the given function.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Token
apply(Token[] args)
Apply this function to the given list of arguments.Function
getFunction()
Return the function of this token.int
getNumberOfArguments()
Return the number of arguments of the function.Type
getType()
Return the type of this token.BooleanToken
isCloseTo(Token rightArgument, double epsilon)
Test for closeness of the values of this Token and the argument Token.BooleanToken
isEqualTo(Token rightArgument)
Test for equality of the values of this Token and the argument Token.java.lang.String
toString()
Return a String representation of this function.-
Methods inherited from class ptolemy.data.Token
add, addReverse, divide, divideReverse, isCloseTo, isNil, modulo, moduloReverse, multiply, multiplyReverse, notSupportedConversionMessage, notSupportedIncomparableConversionMessage, notSupportedIncomparableMessage, notSupportedMessage, notSupportedNullNilStringMessage, one, pow, subtract, subtractReverse, zero, zeroReturnType
-
-
-
-
Constructor Detail
-
FunctionToken
public FunctionToken(Function f, FunctionType type)
Create a new FunctionToken that applies the given function. The type of the function token will be the same as the given type.- Parameters:
f
- The function.type
- The function type.
-
FunctionToken
public FunctionToken(java.lang.String init) throws IllegalActionException
Create a new FunctionToken from the given string.- Parameters:
init
- The initialization string, for examplefunction(x,y) 4+x+y
.- Throws:
IllegalActionException
- If an error occurs, or the string cannot be parsed into a function.
-
-
Method Detail
-
apply
public Token apply(Token[] args) throws IllegalActionException
Apply this function to the given list of arguments.- Parameters:
args
- the arguments to which the function is applied- Returns:
- The results of applying the arguments to this function.
- Throws:
IllegalActionException
- If the arguments are not compatible with this function, or an error occurs during evaluation.
-
getFunction
public Function getFunction()
Return the function of this token.- Returns:
- A Function.
-
getNumberOfArguments
public int getNumberOfArguments()
Return the number of arguments of the function.- Returns:
- The number of arguments of the function.
-
getType
public Type getType()
Return the type of this token.
-
isCloseTo
public BooleanToken isCloseTo(Token rightArgument, double epsilon)
Test for closeness of the values of this Token and the argument Token. For function tokens, checking for closeness is the same as checking for equality.
-
isEqualTo
public BooleanToken isEqualTo(Token rightArgument)
Test for equality of the values of this Token and the argument Token. Two function tokens are equal if they correspond to the same expression, under renaming of any bound variables.
-
-