vmm3d.functions
Class Function
- java.lang.Object
-
- vmm3d.functions.Function
-
- Direct Known Subclasses:
- Expression, Function1, Function2, Function3
public class Function extends java.lang.ObjectRepresents a real-valued function of any number of real arguments. A Function can only be created by aParser. This class has subclassesExpression,Function1,Function2, andFunction3, that represent functions of zero, one, two, and three arguments; the subclasses exist only to provide more naturalvalue()methods that take the expected number of arguments.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description intgetArity()Get the number of arguments required by this function.java.lang.StringgetName()Get the name of the Function.voidsetName(java.lang.String name)Change the name of this function.doublevalue(double[] argumentValues)Find the value of this function for a specified list of arguments.doublevalue(double[] argumentValues, EvalStack stack)Find the value of this function for a specified list of arguments.
-
-
-
Method Detail
-
getName
public java.lang.String getName()
Get the name of the Function. The name was specified in the call toParser.parseFunction(String, String, String[])that created this function. It can be null. A non-null name is really only required if this Function is to be added to a Parser so that it can be used in expressions that are parsed by that parser.
-
setName
public void setName(java.lang.String name)
Change the name of this function. It should not be changed after the function has been added to a Parser; even if it is changed, the Parser will continue to use the old name.
-
getArity
public int getArity()
Get the number of arguments required by this function.
-
value
public double value(double[] argumentValues)
Find the value of this function for a specified list of arguments. This method evaluates the function using an EvalStack that is unique to the current Thread, which allows thread-safe evaluation.- Parameters:
argumentValues- The length of this array must be the same as the number of arguments of the function. If the function has arrity zero, then the argumentValues array can be null.- Returns:
- the value of the function at the specified arguments.
- Throws:
java.lang.IllegalArgumentException- if the number of arguments is incorrect.
-
value
public double value(double[] argumentValues, EvalStack stack)Find the value of this function for a specified list of arguments. This method evaluates the function using an EvalStack that is provided as a parameter to this method.- Parameters:
argumentValues- the values of the arguments. The length of this array must be the same as the number of arguments of the function. If the function has arrity zero, then the argumentValues array can be null.stack- a non-null EvalStack that will be used for computing the value of this Function- Returns:
- the value of the function at the specified arguments.
- Throws:
java.lang.IllegalArgumentException- if the number of arguments is incorrect.
-
-
DMelt 3.0 © DataMelt by jWork.ORG