Package com.singularsys.jep.functions


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.
The 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.
  • Class
    Description
    Absolute value function.
    Addition function.
    The acos function.
    Implements the arcCosH function.
     
    Implements the arcSinH function.
     
    atan2(y, x) Returns the angle whose tangent is y/x.
    Implements the arcTanH function.
    Argument of a complex number
    Base class for functions that operate on arrays such as Average, MinMax, and VSum.
    How to respond to a zero length array as argument
    An assignment operator so we can do x=3+4.
    Average function class, calculates the average of all its arguments.
    Convenient base class for binary functions.
    Binomial coefficients: binom(n,i).
    Functions which require greater control over their evaluation should implement this interface.
    A PostfixMathCommandI which find the smallest integer above the number ceil(pi) give 4 ceil(-i) give -3
    Implements the comparative operations <, >, <=, >=, != and ==.
    Converts a pair of real numbers to a complex number Complex(x,y)=x+i y.
    The complex conjugate of a number conj(c)
     
     
     
    The cotangent function.
    The cross product of two 3D vectors.
     
    The dot product of two vectors.
    Function which allows array access using the a[3] notation on left and right-hand side.
    The exp function.
    A PostfixMathCommandI which find the largest integer above the number floor(pi) give 3 floor(-i) give -4
    A Unary operator which does nothing, used for unary plus +x.
    The if(condExpr, posExpr, negExpr) function.
    Represents an illegal parameter
    Finds the imaginary part of a complex number.
    A version of the logical operators which use lazy evaluation.
    The list function.
    Log base 10.
    Log base 2.
    Logical operators AND and OR.
     
    Minimum and Maximum functions.
    Calculates the modulus x % y of the arguments.
     
    Convenient base class for n-ary functions backed by a binary operation.
    Convenient base class for nary functions.
    Natural logarithm.
    Implementation of the not function.
    Convenient base class for zero-argument nullary functions, like random().
    Converts an [r,theta] pair to a complex number r * e^(i theta).
    Function classes extend this class.
    Computes the power of a number.
    Encapsulates the Math.random() function.
    Finds the real part of a complex number.
    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).
    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.
    Rounding functions using BigDecimal.setScale(int, RoundingMode) this should handle tricky cases like round(265.335,2) correctly.
    The secant function.
    The signum function returns -1 if x<0, 1 if x>0, 0 if x==0.
     
    Hyperbolic sin.
    Square root function.
    Converts an object into its string representation.
    A strict version of Natural logarithm.
     
    Adds it arguments sum(1,2,3,4,5) will be 15.
    The tan function.
    Hyperbolic tan.
     
    Convenient base class for unary functions.
    Summation function which expands the arguments.