Class AbstractEval

java.lang.Object
com.singularsys.extensions.fastreal.AbstractEval
All Implemented Interfaces:
GenericVisitor<Void,Void,ParseException>, JepComponent, Serializable
Direct Known Subclasses:
MrpEval, RpEval

public abstract class AbstractEval extends Object implements GenericVisitor<Void,Void,ParseException>, JepComponent
Abstract base class for rpe-base evaluation routines.

Since Jep 4.1, extension 2.2, this now implements GenericVisitor some method signatures have changed to be more specific.

See Also:
  • Field Details

    • opSet

      protected transient OperatorTableI opSet
    • jep

      protected transient Jep jep
    • functionHash

      protected final Map<String,Short> functionHash
      HashMap for function name lookup. Can't be static for cases when a function is renamed.
    • customFunctionCommands

      protected final List<PostfixMathCommandI> customFunctionCommands
      List of additional PFMC's needed for evaluation. Most function like sin are hard coded so don't appear here.
    • ls

      protected static final String ls
  • Constructor Details

    • AbstractEval

      public AbstractEval(Jep jep)
    • AbstractEval

      protected AbstractEval()
  • Method Details

    • getUserFunction

      protected short getUserFunction(String name, PostfixMathCommandI pfmc)
    • getFunction

      public String getFunction(int ref)
      Returns the name of the function with a given reference number.
      Parameters:
      ref - reference number, one of those in RpConstants or
      Returns:
      the name of the function
    • staticGetFunction

      public static String staticGetFunction(int ref)
      A static version of the function to retrieve names of functions. As this is static names may not reflect names changed by chargeFunctionName(String, String).
      Parameters:
      ref - reference number, one of those in RpConstants
      Returns:
    • getConstantValue

      protected abstract Object getConstantValue(short ref)
    • init

      public void init(Jep j)
      Calls JepComponent.init(Jep) for any custom function which implements JepComponent.
      Specified by:
      init in interface JepComponent
      Parameters:
      j - the current Jep instance
    • duplicateCustomFunctions

      protected void duplicateCustomFunctions(AbstractEval rpe, Jep jep)
      Copies the set of custom functions. If a function implements JepComponent then its JepComponent.getLightWeightInstance() method is called, otherwise the same instance is used.
      Parameters:
      rpe - rpe instance to copy functions to
      jep - jep instance for new context, can be null. If not null the JepComponent.init(Jep) is called.
    • chargeFunctionName

      public void chargeFunctionName(String oldname, String newname) throws JepException
      Changes the name of the standard set functions used. The standard names are "sin, cos, tan, asin, acos, atan, sinh, cosh, tanh, asinh, acosh, atanh, abs, exp, log, ln, sqrt, sec, cosec, cot, atan2, if" which are implemented internally.
      Parameters:
      oldname - name from list
      newname - replacement name
      Throws:
      JepException - if oldname is not found
    • makeException

      public ParseException makeException(String message)
      Description copied from interface: GenericVisitor
      Create an Exception of the correct type. A typical implementation is
      @Override
      public JepException makeException(String message) {
       return new JepException(message);
      }
      
      Specified by:
      makeException in interface GenericVisitor<Void,Void,ParseException>
      Parameters:
      message - error message
      Returns:
      an Exception