Package com.singularsys.jep.functions
Classes that implement the built-in functions and operators.
There are several base classes and interfaces which can be used:
PostfixMathCommandI
- The basic interface all functions should implement. Defines a
void run(Stack<Object> aStack)
method. PostfixMathCommand
- Base class for most functions
UnaryFunction
- Base class for unary functions, just need to implement a
Object eval(Object arg)
method. BinaryFunction
- Base class for binary functions, just need to implement
Object eval(Object l,Object r)
method. NaryBinaryFunction
- Base class for n-ary functions backed by an associative operation like +,*. just need to implement
Object eval(Object l,Object r)
method. CallbackEvaluationI
- Interface for classes which need access to the parse-tree, for example lazy evaluation functions like && and || which do not need to evaluate all their arguments, or assignment operators which need access to a variable and not just its value.
com.singularsys.jep.reals
package also define some interfaces for functions which take double
arguments and
return double
results, which can be quicker in special purpose evaluators.-
Interface Summary Interface Description CallbackEvaluationI Functions which require greater control over their evaluation should implement this interface.LValueI -
Class Summary Class Description Abs Absolute value function.Add Addition function.ArcCosine The acos function.ArcCosineH Implements the arcCosH function.ArcSine ArcSineH Implements the arcSinH function.ArcTangent ArcTangent2 atan2(y, x) Returns the angle whose tangent is y/x.ArcTanH Implements the arcTanH function.Arg Argument of a complex numberArrayFunctionBase Base class for functions that operate on arrays such as Average, MinMax, and VSum.Assign An assignment operator so we can do x=3+4.Average Average function class, calculates the average of all its arguments.BinaryFunction Convenient base class for binary functions.Binomial Binomial coefficients: binom(n,i).Ceil A PostfixMathCommandI which find the smallest integer above the number ceil(pi) give 4 ceil(-i) give -3Comparative Implements the comparative operations <, >, <=, >=, !ComplexPFMC Converts a pair of real numbers to a complex number Complex(x,y)=x+i y.Conjugate The complex conjugate of a number conj(c)Cosecant Cosine CosineH Cotangent The cotangent function.Cross The cross product of two 3D vectors.Divide Dot The dot product of two vectors.Ele Function which allows array access using the a[3] notation on left and right hand side.Exp The exp function.Floor A PostfixMathCommandI which find the largest integer above the number floor(pi) give 3 floor(-i) give -4Identity A Unary operator which does nothing, used for unary plus +x.If The if(condExpr, posExpr, negExpr) function.Imaginary Finds the imaginary part of a complex number.LazyLogical A version of the logical operators which use lazy evaluation.List The list function.Logarithm Log base 10.LogBase2 Log base 2.Logical Logical operators AND and OR.MinMax Minimum and Maximum functions.Modulus Calculates the modulus x % y of the arguments.Multiply NaryBinaryFunction Convenient base class for n-ary functions backed by a binary operation.NaryFunction Convenient base class for nary functions.NaturalLogarithm Natural logarithm.Not Implementation of the not function.NullaryFunction Convenient base class for zero-argument nullary functions, likerandom()
.Polar Converts an [r,theta] pair to a complex number r * e^(i theta).PostfixMathCommand Function classes extend this class.Power Computes the power of an number.Random Encapsulates the Math.random() function.Real Finds the real part of a complex number.RInt A PostfixMathCommandI which rounds a number to the closest integer.
rint(2.4) finds the closest integer to the argument (2).
rint(2.1234, 3) rounds the argument to 3 decimal places (2.123).Round A PostfixMathCommandI which rounds a number.
round(a) adds 0.5 to the argument and returns the closest integer.
round(a,3) rounds the argument to 3 decimal places.Secant The secant function. sec(x)=1/cos(x).Signum The signum function returns -1 if x<0, 1 if x>0, 0 if x==0.Sine SineH Hyperbolic sin.SquareRoot Square root function.Str Converts an object into its string representation.StrictNaturalLogarithm A strict version of Natural logarithm.Subtract Sum Adds it argumentssum(1,2,3,4,5)
will be 15.Tangent The tan function.TanH Hyperbolic tan.UMinus UnaryFunction Convenient base class for unary functions.VSum Summation function which expands the arguments. -
Enum Summary Enum Description ArrayFunctionBase.ZeroLengthErrorBehaviour How to respond to a zero length array as argument -
Exception Summary Exception Description IllegalParameterException Represents an illegal parameter