Documentation of 'org.matheclipse.core.eval.EvalEngine' Java class
EvalEngine
org.matheclipse.core.eval

Class EvalEngine

    • Constructor Detail

      • EvalEngine

        public EvalEngine()
        Public constructor for serialization.
      • EvalEngine

        public EvalEngine(boolean relaxedSyntax)
      • EvalEngine

        public EvalEngine(boolean relaxedSyntax,
                          boolean outListDisabled)
      • EvalEngine

        public EvalEngine(F f,
                          java.io.PrintStream out)
      • EvalEngine

        public EvalEngine(java.lang.String sessionID,
                          int recursionLimit,
                          int iterationLimit,
                          java.io.PrintStream out,
                          boolean relaxedSyntax,
                          boolean outListDisabled)
      • EvalEngine

        public EvalEngine(java.lang.String sessionID,
                          int recursionLimit,
                          java.io.PrintStream out,
                          boolean relaxedSyntax,
                          boolean outListDisabled)
        Constructor for an EvaluationEngine
        Parameters:
        sessionID - an ID which uniquely identifies this session
        recursionLimit - the maximum allowed recursion limit (if set to zero, no limit will be proofed)
        out -
        relaxedSyntax -
        See Also:
        javax.servlet.http.HttpSession#getID()
      • EvalEngine

        public EvalEngine(java.lang.String sessionID,
                          java.io.PrintStream out)
    • Method Detail

      • eval

        public static final IExpr eval(IExpr expr)
        Evaluate an expression. If evaluation is not possible return the input object.
        Parameters:
        expr - the expression which should be evaluated
        Returns:
        the evaluated object
        See Also:
        evalWithoutNumericReset(IExpr)
      • evalNull

        public static final IExpr evalNull(IExpr expr)
        Evaluate an expression. If evaluation is not possible return the input object.
        Parameters:
        expr - the expression which should be evaluated
        Returns:
        the evaluated object or null if no evaluation was possible
        See Also:
        evalWithoutNumericReset(IExpr)
      • getNextAnonymousCounter

        public static int getNextAnonymousCounter()
      • getNextCounter

        public static java.lang.String getNextCounter()
      • localStack

        public static final java.util.Stack<IExpr> localStack(ISymbol symbol)
        Get the local variable stack for a given symbol name. If the local variable stack doesn't exist, return null
        Parameters:
        symbolName -
        Returns:
        null if the stack doesn't exist
      • localStackCreate

        public static java.util.Stack<IExpr> localStackCreate(ISymbol symbol)
        Get the local variable stack for a given symbol name. If the local variable stack doesn't exist, create a new one for the symbol.
        Parameters:
        symbolName -
        Returns:
      • set

        public static void set(EvalEngine engine)
        Set the thread local evaluation engine instance
      • threadASTListArgs

        public static IAST threadASTListArgs(IAST ast)
      • get

        public static EvalEngine get()
        Get the thread local evaluation engine instance
        Returns:
      • remove

        public static void remove()
        Removes the current thread's value for the EvalEngine's thread-local variable.
        See Also:
        ThreadLocal.remove()
      • addModifiedVariable

        public boolean addModifiedVariable(ISymbol arg0)
        For every evaluation store the list of modified variables in an internal list.
        Parameters:
        arg0 -
        Returns:
      • addOut

        public boolean addOut(IExpr arg0)
        Add an expression to the Out[] list. To avoid memory leaks you can disable the appending of expressions to the output history.
        See Also:
        setOutListDisabled(boolean)
      • addRules

        public void addRules(IAST ruleList)
      • endTrace

        public IAST endTrace()
      • evalAST

        public IExpr evalAST(IAST ast)
        Evaluate an AST. The evaluation steps are controlled by the header attributes.
        Parameters:
        ast -
        Returns:
      • evalLoop

        public IExpr evalLoop(IExpr expr)
        Evaluate an object, if evaluation is not possible return null.
        Parameters:
        expr - the expression which should be evaluated
        Returns:
        the evaluated expression or null is evasluation isn't possible
        See Also:
        evalWithoutNumericReset(IExpr)
      • evalSetAttributes

        public IAST evalSetAttributes(IAST ast)
        Transform the ast recursively, according to the attributes Flat, HoldAll, HoldFirst, HoldRest, Orderless for the left-hand-side of a Set[] or SetDelayed[] expression
        Parameters:
        ast -
        Returns:
      • evalTrace

        public final IAST evalTrace(IExpr expr,
                                    Predicate<IExpr> matcher,
                                    IAST list)
        Evaluate the expression and return the Trace[expr] (i.e. all (sub-)expressions needed to calculate the result).
        Parameters:
        expr - the expression which should be evaluated.
        matcher - a filter which determines the expressions which should be traced, If the matcher is set to null, all expressions are traced.
        list - an IAST object which will be cloned for containing the traced expressions. Typically a F.List() will be used.
        Returns:
      • evalTrue

        public final boolean evalTrue(IExpr expr)
        Test if expr could be evaluated to True. If a org.matheclipse.parser.client.math.MathException occurs during evaluation, return False.
        Parameters:
        expr -
        Returns:
      • evaluate

        public final IExpr evaluate(IExpr expr)
        Store the current numeric mode and evaluate the expression expr. After evaluation reset the numeric mode to the value stored before the evaluation starts. If evaluation is not possible return the input object.
        Parameters:
        expr - the object which should be evaluated
        Returns:
        the evaluated object
      • evaluate

        public final IExpr evaluate(java.lang.String expression)
        Parse the given expression String into an IExpr and evaluate it.
        Parameters:
        astString - an expression in math formula notation
        Returns:
        Throws:
        SyntaxError - if a parsing error occurs
      • evaluateNull

        public final IExpr evaluateNull(IExpr expr)
        Evaluate an object and reset the numeric mode to the value before the evaluation step. If evaluation is not possible return null.
        Parameters:
        expr - the object which should be evaluated
        Returns:
        the evaluated object of null if no evaluation was possible
      • evalWithoutNumericReset

        public final IExpr evalWithoutNumericReset(IExpr expr)
        Evaluate an object without resetting the numeric mode after the evaluation step. If evaluation is not possible return the input object,
        Specified by:
        evalWithoutNumericReset in interface IEvaluationEngine
        Parameters:
        expr - the object which should be evaluated
        Returns:
        the evaluated object
      • getAnswer

        public IExpr getAnswer()
        Get the last result ("answer") expression of this evaluation engine.
        Returns:
        null if no answer is stored in the evaluation engine.
      • getIterationLimit

        public int getIterationLimit()
      • getLocalVariableStackMap

        public final java.util.Map<ISymbol,java.util.Stack<IExpr>> getLocalVariableStackMap()
      • getModifiedVariables

        public java.util.Set<ISymbol> getModifiedVariables()
        Get the list of modified variables
        Returns:
      • getOut

        public IExpr getOut(int index)
        Get the expression of the Out[] list at the given index
        Parameters:
        index -
        Returns:
      • getOutList

        public java.util.List<IExpr> getOutList()
      • getOutPrintStream

        public java.io.PrintStream getOutPrintStream()
      • getReapList

        public IAST getReapList()
        Returns:
        the reapList
      • getRecursionLimit

        public int getRecursionLimit()
        Returns:
      • getSessionID

        public java.lang.String getSessionID()
        Returns:
      • getUserVariable

        public ISymbol getUserVariable(java.lang.String symbolName)
        Returns the ISymbol variable created in this thread to which the specified symbolName is mapped, or null if this map contains no mapping for the symbolName.
        Parameters:
        name -
        Returns:
      • putUserVariable

        public ISymbol putUserVariable(java.lang.String symbolName,
                                       ISymbol symbol)
        Associates the symbolName key with the ISymbol value.
        Parameters:
        symbolName -
        symbol -
        Returns:
      • removeUserVariables

        public void removeUserVariables(java.util.Map<ISymbol,ISymbol> moduleVariables)
        Remove all moduleVariables from this evaluation engine.
        Parameters:
        moduleVariables -
      • incModuleCounter

        public int incModuleCounter()
        Increment the module counter by 1 and return the result.
        Returns:
        the module counter
      • isEvalLHSMode

        public boolean isEvalLHSMode()
        The engine evaluates the left-hand-side of a Set, SetDelayed,... expression.
        Returns:
      • isNumericMode

        public boolean isNumericMode()
        Returns:
      • isOutListDisabled

        public boolean isOutListDisabled()
      • isPackageMode

        public boolean isPackageMode()
      • isQuietMode

        public boolean isQuietMode()
        If true the engine evaluates in "quiet" mode (i.e. no warning messages are showw in the evaluation).
        See Also:
        Quiet
      • isRelaxedSyntax

        public boolean isRelaxedSyntax()
        Returns:
        the fRelaxedSyntax
      • isStopRequested

        public boolean isStopRequested()
        Returns:
        Returns the stopRequested.
      • isTraceMode

        public boolean isTraceMode()
        If the trace mode is set the system writes an evaluation trace list or if additionally the stop after evaluation mode is set returns the first evaluated result.
        Returns:
        See Also:
        Trace
      • parse

        public final IExpr parse(java.lang.String expression)
        Parse the given expression String into an IExpr without evaluation.
        Parameters:
        astString - an expression in math formula notation
        Returns:
        Throws:
        SyntaxError - if a parsing error occurs
      • parseNode

        public final ASTNode parseNode(java.lang.String expression)
        Parse the given expression String into an ASTNode without evaluation.
        Parameters:
        astString - an expression in math formula notation
        Returns:
        Throws:
        SyntaxError - if a parsing error occurs
      • reset

        public void reset()
        Reset the numeric mode flag and the recursion counter
      • setIterationLimit

        public void setIterationLimit(int i)
      • setNumericMode

        public void setNumericMode(boolean b)
        Parameters:
        b -
      • setOutListDisabled

        public void setOutListDisabled(boolean outListDisabled)
      • setOutPrintStream

        public void setOutPrintStream(java.io.PrintStream outPrintStream)
      • setPackageMode

        public void setPackageMode(boolean packageMode)
      • setQuietMode

        public void setQuietMode(boolean quietMode)
        If true the engine evaluates in "quiet" mode (i.e. no warning messages are showw in the evaluation).
        Parameters:
        quietMode -
      • setReapList

        public void setReapList(IAST reapList)
        Parameters:
        reapList - the reapList to set
      • setRecursionLimit

        public void setRecursionLimit(int i)
        Parameters:
        i -
      • setRelaxedSyntax

        public void setRelaxedSyntax(boolean fRelaxedSyntax)
        Parameters:
        fRelaxedSyntax - the fRelaxedSyntax to set
      • setSessionID

        public void setSessionID(java.lang.String string)
        Parameters:
        string -
      • setStopRequested

        public void setStopRequested(boolean stopRequested)
        Parameters:
        stopRequested - The stopRequested to set.
      • setTraceMode

        public void setTraceMode(boolean b)
        Parameters:
        b -
      • sizeOut

        public int sizeOut()
        The size of the Out[] list
        Returns:
      • stopRequest

        public void stopRequest()
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.