Package com.singularsys.jep.functions
Class NaryFunction
- java.lang.Object
-
- com.singularsys.jep.functions.PostfixMathCommand
-
- com.singularsys.jep.functions.NaryFunction
-
- All Implemented Interfaces:
PostfixMathCommandI
,java.io.Serializable
- Direct Known Subclasses:
Apply
,BinomialCdf
,BinomialDist
,Ele
,ExtensionsConsole.PrintfFunction
,ExtensionsConsole.PrintFunction
,FieldConsole.RationalPFMC
,FromBase
,Iterate
,JepTest.AddFractionsNary
,JepTest.MyNary
,ListReturningFunction
,MatrixId
,MatrixList
,Merge
,Mid
,NormalDist
,NormalInverse
,NullWrappedNary
,NullWrappedNaryBinary
,Round
,RoundSF
,StructuredConsole.PrintfFunction
,StructuredConsole.PrintFunction
,Substring
,ToBase
public abstract class NaryFunction extends PostfixMathCommand
Convenient base class for nary functions. Defines anObject eval(Object[] args)
method for calculating the result.- Author:
- Richard Morris
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class com.singularsys.jep.functions.PostfixMathCommand
curNumberOfParameters, name, NaN, numberOfParameters
-
-
Constructor Summary
Constructors Constructor Description NaryFunction()
Standard constructor where any number of arguments is allowed.NaryFunction(int nArgs)
Constructor where a fixed number of arguments is allowed
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract java.lang.Object
eval(java.lang.Object[] args)
Evaluate the functionvoid
run(java.util.Stack<java.lang.Object> stack)
Creates an array of object then callseval(Object[])
-
Methods inherited from class com.singularsys.jep.functions.PostfixMathCommand
asArray, asBool, asDouble, asInt, asLong, asStrictInt, asString, checkNumberOfParameters, getName, getNumberOfParameters, setCurNumberOfParameters, setName, toString, toString
-
-
-
-
Constructor Detail
-
NaryFunction
public NaryFunction()
Standard constructor where any number of arguments is allowed. Use the PostfixMathCommand.checkNumberOfParameters(int) method to restrict the number of arguments allowed.
-
NaryFunction
public NaryFunction(int nArgs)
Constructor where a fixed number of arguments is allowed- Parameters:
nArgs
- number of arguments allowed
-
-
Method Detail
-
run
public void run(java.util.Stack<java.lang.Object> stack) throws EvaluationException
Creates an array of object then callseval(Object[])
- Specified by:
run
in interfacePostfixMathCommandI
- Overrides:
run
in classPostfixMathCommand
- Parameters:
stack
- arguments for function- Throws:
EvaluationException
- if function cannot be evaluated
-
eval
public abstract java.lang.Object eval(java.lang.Object[] args) throws EvaluationException
Evaluate the function- Parameters:
args
- arguments to the function- Returns:
- value returned by the function
- Throws:
EvaluationException
- if the calculation cannot be performed
-
-