Class StandardFunctionTable

java.lang.Object
com.singularsys.jep.FunctionTable
com.singularsys.jep.standard.StandardFunctionTable
All Implemented Interfaces:
JepComponent, Serializable

public class StandardFunctionTable extends FunctionTable
The standard function table. This is the default function table used by Jep.

It includes:

Trigonometric functions:
sin, cos, tan, asin, acos, atan, atan2, cosec, sec, cot
Hyperbolic functions:
sinh, cosh, tanh, asinh, acosh, atanh
Logarithmic and exponential functions:
log, ln, lg (log base 2), sqrt, pow,
Rounding functions:
round, rint, floor, ceil,
round(x) rounds x to the nearest integer, rint(x) rounds x to the nearest integer preferring even numbers in the case of a tie. It has a two argument version rint(x,dp) which rounds x to a specific number of decimal places.
Complex functions:
re, im, arg, cmod, complex, polar, conj,
array and statistical functions:
avg, min, max, sum, vsum, count
These functions can take an arbitrary number of arguments and return the average, minimum, maximum, sum or count of the arguments respectively. The vsum function expands any vector or matrix argument and sums the elements, so for example vsum(1, [2,3], [[4,5],[6,7]]) returns 28.
Miscellaneous functions,
abs, mod, rand, if, str, binom, signum
mod(x,y) implemented by Modulus is equivalent to the java operator x % y with the same sign conventions.
rand() give the is implemented using Random returns a random number between 0 and 1.
The if functions implemented by If can be used with three argument if(cond, trueval, falseval) and four argument if(condExpr, posExpr, negExpr, zeroExpr) versions.
binom(n,k) implemented by Binomial returns the binomial coefficient n choose k.
signum(x) implemented by Signum returns -1, 0 or 1 depending on the sign of x.
Since Jep 4.1, names used can be changed in the properties file
StandardFunctionTable.arcsin=asin
Use an ! in the property value to prevent the function being added, e.g.
StandardFunctionTable.if=!if
See Also:
  • Constructor Details

    • StandardFunctionTable

      public StandardFunctionTable()
    • StandardFunctionTable

      protected StandardFunctionTable(Map<String,PostfixMathCommandI> tbl)
  • Method Details

    • shallowCopy

      public FunctionTable shallowCopy()
      Description copied from class: FunctionTable
      Returns a new shallow copy of this function table. Calls the FunctionTable.threadSafeMapCopy() method to ensure the table is safe to use a separate thread. All subclasses should override this method to create a function table of the matching type. A typical implementation would be
       @Override
       public FunctionTable shallowCopy() {
           Map<String,PostfixMathCommandI> newMap = this.threadSafeMapCopy();
           return new myFunctionTable(newMap);
       }
       
      using the FunctionTable.threadSafeMapCopy() method to return a copy of the map of functions and a constructor taking this map which uses the FunctionTable(Map) constructor.
      Overrides:
      shallowCopy in class FunctionTable
      Returns:
      a new shallow copy of this function table