public class EvalEngine extends java.lang.Object implements java.io.Serializable, IEvaluationEngine
| Modifier and Type | Field and Description | 
|---|---|
| static boolean | DEBUG | 
| static int | DOUBLE_PRECISIONUse  Numobjects for numeric calculations up to 15 digits
 precision. | 
| protected IExpr | fAnswerContains the last result ("answer") expression of this
 evaluation engine or  nullif no answer is stored in the
 evaluation engine. | 
| protected int | fIterationLimit | 
| protected java.util.Set<ISymbol> | fModifiedVariablesList | 
| protected LastCalculationsHistory | fOutListThe history list for the  Out[]function. | 
| protected boolean | fPackageMode | 
| protected int | fRecursionLimit | 
| Constructor and Description | 
|---|
| EvalEngine() | 
| EvalEngine(boolean relaxedSyntax)Constructor for an evaluation engine | 
| EvalEngine(boolean relaxedSyntax,
          boolean outListDisabled)Constructor for an evaluation engine | 
| EvalEngine(java.lang.String sessionID,
          int recursionLimit,
          int iterationLimit,
          java.io.PrintStream out,
          boolean relaxedSyntax,
          boolean outListDisabled)Constructor for an evaluation engine | 
| EvalEngine(java.lang.String sessionID,
          int recursionLimit,
          java.io.PrintStream out,
          boolean relaxedSyntax,
          boolean outListDisabled)Constructor for an evaluation engine | 
| EvalEngine(java.lang.String sessionID,
          java.io.PrintStream out) | 
| Modifier and Type | Method and Description | 
|---|---|
| boolean | addModifiedVariable(ISymbol arg0)For every evaluation store the list of modified variables in an internal
 list. | 
| void | addOut(IExpr arg0)Add an expression to the  Out[]list. | 
| void | addRules(IAST ruleList) | 
| IExpr | evalAST(IAST ast)Evaluate an AST. | 
| IExpr | evalAttributes(ISymbol symbol,
              IAST ast)Evaluate an AST according to the attributes set in the header symbol. | 
| IExpr | evalBlock(IExpr expr,
         IAST localVariablesList)Evaluate an expression for the given "local variables list". | 
| IAST | evalFlatOrderlessAttributesRecursive(IAST ast)Evaluate the Flat and Orderless attributes of the given  astrecursively. | 
| IExpr | evalLoop(IExpr expr)Evaluate an object, if evaluation is not possible return
  F.NIL. | 
| IExpr | evalN(IExpr expr) | 
| IExpr | evalPattern(IExpr expr)
 Store the current numeric mode and evaluate the expression
  expr. | 
| IPatternMatcher | evalPatternMatcher(IExpr expr)
 Store the current numeric mode and evaluate the expression
  expr. | 
| IExpr | evalQuiet(IExpr expr)Evaluate an expression in "quiet mode". | 
| IExpr | evalQuietNull(IExpr expr)Evaluate an expression in "quiet mode". | 
| IExpr | evalRules(ISymbol symbol,
         IAST ast)Evaluate the rules for an AST. | 
| IExpr | evalSetAttributes(IAST ast)Evaluate the ast recursively, according to the attributes Flat, HoldAll,
 HoldFirst, HoldRest, Orderless to create pattern-matching expressions
 directly or for the left-hand-side of a  Set[],SetDelayed[],UpSet[]orUpSetDelayed[]expression | 
| IExpr | evalSetAttributes(IAST ast,
                 boolean noEvaluation)Evaluate the ast recursively, according to the attributes Flat, HoldAll,
 HoldFirst, HoldRest, Orderless to create pattern-matching expressions
 directly or for the left-hand-side of a  Set[],SetDelayed[],UpSet[]orUpSetDelayed[]expression | 
| IAST | evalTrace(IExpr expr,
         java.util.function.Predicate<IExpr> matcher,
         IAST list)Evaluate the expression and return the  Trace[expr](i.e. all
 (sub-)expressions needed to calculate the result). | 
| boolean | evalTrue(IExpr expr)Test if  exprcould be evaluated toTrue. | 
| IExpr | evaluate(IExpr expr)Store the current numeric mode and evaluate the expression
  expr. | 
| IExpr | evaluate(java.lang.String expression)Parse the given  expression Stringinto an IExpr and evaluate
 it. | 
| IExpr | evaluateNull(IExpr expr)Evaluate an object and reset the numeric mode to the value before the
 evaluation step. | 
| IExpr | evalWithoutNumericReset(IExpr expr)Evaluate an object without resetting the numeric mode after the
 evaluation step. | 
| static EvalEngine | get()Get the thread local evaluation engine instance | 
| IExpr | getAnswer()Get the last result ("answer") expression of this evaluation
 engine. | 
| IAssumptions | getAssumptions()Get the currently available assumptions if possible. | 
| Context | getContext() | 
| ContextPath | getContextPath() | 
| int | getIterationLimit() | 
| java.util.Map<ISymbol,java.util.List<IExpr>> | getLocalVariableStackMap() | 
| java.util.Set<ISymbol> | getModifiedVariables()Get the list of modified variables | 
| static int | getNextAnonymousCounter() | 
| static java.lang.String | getNextCounter() | 
| int | getNumericPrecision() | 
| LastCalculationsHistory | getOutList() | 
| java.io.PrintStream | getOutPrintStream() | 
| IAST | getReapList() | 
| int | getRecursionCounter() | 
| int | getRecursionLimit() | 
| java.lang.String | getSessionID() | 
| IEvalStepListener | getStepListener()Get the defined step listener or  nullif no listener is
 assigned. | 
| ISymbol | getUserVariable(java.lang.String symbolName)Returns the  ISymbolvariable created in this thread to which
 the specifiedsymbolNameis mapped, ornullif
 this map contains no mapping for thesymbolName. | 
| int | incModuleCounter()Increment the module counter by 1 and return the result. | 
| void | init()Resets internal flags and states: | 
| boolean | isApfloat()Check if the  ApfloatNumnumber type should be used instead
 of theNumtype and theApcomplexxNumnumber
 type should be used instead of theComplexNumtype for
 numeric evaluations. | 
| static boolean | isApfloat(int precision)Check if the  ApfloatNumnumber type should be used instead
 of theNumtype and theApcomplexxNumnumber
 type should be used instead of theComplexNumtype for
 numeric evaluations. | 
| boolean | isEvalLHSMode()The engine evaluates the left-hand-side of a
  Set, SetDelayed,... | 
| boolean | isNumericMode() | 
| boolean | isOutListDisabled()Check if the appending of expressions to the history list for the
  Out[]function is enabled. | 
| boolean | isPackageMode() | 
| boolean | isQuietMode()If  truethe engine evaluates in "quiet" mode (i.e. | 
| boolean | isRelaxedSyntax() | 
| boolean | isStopRequested() | 
| 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. | 
| static java.util.List<IExpr> | localStack(ISymbol symbol)Get the local variable stack for a given symbol name. | 
| static java.util.List<IExpr> | localStackCreate(ISymbol symbol)Get the local variable stack for a given symbol name. | 
| IExpr | parse(java.lang.String expression)Parse the given  expression Stringinto an IExpr without
 evaluation. | 
| void | printMessage(java.lang.String str)Print a message to the  Outstream, if the engine is not in
 "quiet mode". | 
| ISymbol | putUserVariable(java.lang.String symbolName,
               ISymbol symbol)Associates the  symbolNamekey with theISymbolvalue. | 
| static void | remove()Removes the current thread's value for the EvalEngine's thread-local
 variable. | 
| void | removeUserVariables(java.util.Map<ISymbol,ISymbol> moduleVariables)Remove all  moduleVariablesfrom this evaluation engine. | 
| void | reset()Reset the numeric mode flag and the recursion counter | 
| static void | set(EvalEngine engine)Set the thread local evaluation engine instance | 
| void | setAssumptions(IAssumptions assumptions)Set the assumptions for this evaluation engine | 
| void | setContextPath(ContextPath fContextPath) | 
| void | setIterationLimit(int i) | 
| void | setNumericMode(boolean b) | 
| void | setNumericMode(boolean b,
              int precision) | 
| void | setNumericPrecision(int precision) | 
| void | setOutListDisabled(boolean outListDisabled,
                  int historyCapacity) | 
| void | setOutPrintStream(java.io.PrintStream outPrintStream) | 
| void | setPackageMode(boolean packageMode) | 
| void | setQuietMode(boolean quietMode)If  truethe engine evaluates in "quiet" mode (i.e. | 
| void | setReapList(IAST reapList) | 
| void | setRecursionLimit(int i) | 
| void | setRelaxedSyntax(boolean fRelaxedSyntax) | 
| void | setSessionID(java.lang.String string) | 
| void | setStepListener(IEvalStepListener stepListener)Set the step listener for this evaluation engine. | 
| void | setStopRequested(boolean stopRequested) | 
| void | setTraceMode(boolean b) | 
| int | sizeOut()The size of the  Out[]list | 
| void | stopRequest() | 
| static IAST | threadASTListArgs(IAST ast) | 
| java.lang.String | toString() | 
protected int fRecursionLimit
protected int fIterationLimit
protected boolean fPackageMode
protected java.util.Set<ISymbol> fModifiedVariablesList
protected transient LastCalculationsHistory fOutList
Out[] function.org.matheclipse.core.reflection.Outprotected transient IExpr fAnswer
null if no answer is stored in the
 evaluation engine.public static final int DOUBLE_PRECISION
Num objects for numeric calculations up to 15 digits
 precision.public static final boolean DEBUG
public EvalEngine()
public EvalEngine(boolean relaxedSyntax)
relaxedSyntax - if true, the parser doesn't distinguish between
            upper and lower case identifierspublic EvalEngine(boolean relaxedSyntax,
                  boolean outListDisabled)
relaxedSyntax - if true, the parser doesn't distinguidh between
            upper and lower case identifiersoutListDisabled - if true, no output history for the
            Out() function is stored in the evaluation
            engine.public EvalEngine(java.lang.String sessionID,
                  int recursionLimit,
                  int iterationLimit,
                  java.io.PrintStream out,
                  boolean relaxedSyntax,
                  boolean outListDisabled)
sessionID - an ID which uniquely identifies this sessioniterationLimit - the maximum allowed iteration limit (if set to zero, no limit
            will be checked)recursionLimit - the maximum allowed recursion limit (if set to zero, no limit
            will be checked)out - the output print streamrelaxedSyntax - if true, the parser doesn't distinguidh between
            upper and lower case identifiersoutListDisabled - if true, no output history for the
            Out() function is stored in the evaluation
            engine.public EvalEngine(java.lang.String sessionID,
                  int recursionLimit,
                  java.io.PrintStream out,
                  boolean relaxedSyntax,
                  boolean outListDisabled)
sessionID - an ID which uniquely identifies this sessionrecursionLimit - the maximum allowed recursion limit (if set to zero, no limit
            will be checked)out - the output print streamrelaxedSyntax - if true, the parser doesn't distinguidh between
            upper and lower case identifiersoutListDisabled - if true, no output history for the
            Out() function is stored in the evaluation
            engine.public EvalEngine(java.lang.String sessionID,
                  java.io.PrintStream out)
public final IExpr evalQuiet(IExpr expr)
expr - the expression which should be evaluatedevalWithoutNumericReset(IExpr)public final IExpr evalQuietNull(IExpr expr)
F.NIL. In "quiet mode" all
 warnings would be suppressed.expr - the expression which should be evaluatedF.NUIL if no evaluation was
         possibleevalWithoutNumericReset(IExpr)public static EvalEngine get()
public static int getNextAnonymousCounter()
public static java.lang.String getNextCounter()
public static boolean isApfloat(int precision)
ApfloatNum number type should be used instead
 of the Num type and the ApcomplexxNum number
 type should be used instead of the ComplexNum type for
 numeric evaluations.precision - the given precisiontrue if the given precision is greater than
         EvalEngine.DOUBLE_PRECISIONApfloatNum, 
ApcomplexNumpublic static final java.util.List<IExpr> localStack(ISymbol symbol)
nullsymbolName - null if the stack doesn't existpublic static java.util.List<IExpr> localStackCreate(ISymbol symbol)
symbolName - public static void remove()
ThreadLocal.remove()public static void set(EvalEngine engine)
public boolean addModifiedVariable(ISymbol arg0)
arg0 - public void addOut(IExpr arg0)
Out[] list. To avoid memory leaks
 you can disable the appending of expressions to the output history.#setOutListDisabled(boolean)public void addRules(IAST ruleList)
public IExpr evalAST(IAST ast)
ast - F.NIL if no evaluation happenedpublic IExpr evalAttributes(ISymbol symbol, IAST ast)
ast - public IExpr evalBlock(IExpr expr, IAST localVariablesList)
expr - the expression which should be evaluatedlocalVariablesList - a list of symbols which should be used as local variables
            inside the blockpublic IAST evalFlatOrderlessAttributesRecursive(IAST ast)
ast
 recursively.ast - F.NIL if no evaluation was possiblepublic IExpr evalLoop(IExpr expr)
F.NIL.expr - the expression which should be evaluatedF.NIL if evaluation
         isn't possibleevalWithoutNumericReset(IExpr)public final IExpr evalPattern(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.
 
 Note: if this method catches exception
 org.matheclipse.parser.client.math.MathException, it returns
 the input expression.
 
expr - the object which should be evaluatedpublic final IPatternMatcher evalPatternMatcher(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.
 
expr - the object which should be evaluatedIPatterMatcher cretaed from the given expression.public IExpr evalRules(ISymbol symbol, IAST ast)
symbol - ast - F.NIL if no evaluation happenedpublic IExpr evalSetAttributes(IAST ast)
Set[],
 SetDelayed[], UpSet[] or
 UpSetDelayed[] expressionast - ast if no evaluation was executed.public IExpr evalSetAttributes(IAST ast, boolean noEvaluation)
Set[],
 SetDelayed[], UpSet[] or
 UpSetDelayed[] expressionast - noEvaluation - (sub-)expressions which contain no patterns should not be
            evaluatedast if no evaluation was executed.public final IAST evalTrace(IExpr expr, java.util.function.Predicate<IExpr> matcher, IAST list)
Trace[expr] (i.e. all
 (sub-)expressions needed to calculate the result).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.public final boolean evalTrue(IExpr expr)
expr could be evaluated to True. If a
 org.matheclipse.parser.client.math.MathException occurs
 during evaluation, return False.expr - true if the expression could be evaluated to symbol
         True and false in all other casespublic final IExpr evaluate(IExpr expr)
expr. After evaluation reset the numeric mode to the value
 stored before the evaluation starts. If evaluation is not possible return
 the input object.expr - the object which should be evaluatedpublic final IExpr evaluate(java.lang.String expression)
expression String into an IExpr and evaluate
 it.astString - an expression in math formula notationSyntaxError - if a parsing error occurspublic final IExpr evaluateNull(IExpr expr)
F.NIL.expr - the object which should be evaluatedF.NIL if no evaluation was
         possiblepublic final IExpr evalWithoutNumericReset(IExpr expr)
evalWithoutNumericReset in interface IEvaluationEngineexpr - the object which should be evaluatedpublic IExpr getAnswer()
null if no answer is stored in the evaluation
         engine.public IAssumptions getAssumptions()
null if no assumptions are availablepublic Context getContext()
public ContextPath getContextPath()
public int getIterationLimit()
public final java.util.Map<ISymbol,java.util.List<IExpr>> getLocalVariableStackMap()
public java.util.Set<ISymbol> getModifiedVariables()
public int getNumericPrecision()
public LastCalculationsHistory getOutList()
public java.io.PrintStream getOutPrintStream()
public IAST getReapList()
public int getRecursionCounter()
public int getRecursionLimit()
public java.lang.String getSessionID()
public IEvalStepListener getStepListener()
null if no listener is
 assigned.null if no step listener is assigned.public ISymbol getUserVariable(java.lang.String symbolName)
ISymbol variable created in this thread to which
 the specified symbolName is mapped, or null if
 this map contains no mapping for the symbolName.name - public int incModuleCounter()
public final void init()
IEvaluationEngineinit in interface IEvaluationEnginepublic boolean isApfloat()
ApfloatNum number type should be used instead
 of the Num type and the ApcomplexxNum number
 type should be used instead of the ComplexNum type for
 numeric evaluations.true if the required precision is greater than
         EvalEngine.DOUBLE_PRECISIONApfloatNum, 
ApcomplexNumpublic boolean isEvalLHSMode()
Set, SetDelayed,... expression.public boolean isNumericMode()
true if the EvalEngine runs in numeric mode.public boolean isOutListDisabled()
Out[] function is enabled. If enabled, the special variable
 $ans returns the result from the last evluation done with
 this evaluation engine.org.matheclipse.core.reflection.Outpublic boolean isPackageMode()
public boolean isQuietMode()
true the engine evaluates in "quiet" mode (i.e.
 no warning messages are showw in the evaluation).Quietpublic boolean isRelaxedSyntax()
public boolean isStopRequested()
public boolean isTraceMode()
org.matheclipse.core.reflection.system.Tracepublic final IExpr parse(java.lang.String expression)
expression String into an IExpr without
 evaluation.astString - an expression in math formula notationSyntaxError - if a parsing error occurspublic void printMessage(java.lang.String str)
Out stream, if the engine is not in
 "quiet mode".str - the message which should be printedpublic ISymbol putUserVariable(java.lang.String symbolName, ISymbol symbol)
symbolName key with the ISymbol
 value.symbolName - symbol - public void removeUserVariables(java.util.Map<ISymbol,ISymbol> moduleVariables)
moduleVariables from this evaluation engine.moduleVariables - public void reset()
public void setAssumptions(IAssumptions assumptions)
assumptions - public void setContextPath(ContextPath fContextPath)
public void setIterationLimit(int i)
public void setNumericMode(boolean b)
b - public void setNumericMode(boolean b,
                           int precision)
b - public void setNumericPrecision(int precision)
public void setOutListDisabled(boolean outListDisabled,
                               int historyCapacity)
outListDisabled - if false create a
            LastCalculationsHistory(historyCapacity),
            otherwise no history of the last calculations will be saved
            and the Out() function (or % operator) will be
            unevaluated.historyCapacity - the number of last entries of the calculations which should be
            stored.public void setOutPrintStream(java.io.PrintStream outPrintStream)
public void setPackageMode(boolean packageMode)
public void setQuietMode(boolean quietMode)
true the engine evaluates in "quiet" mode (i.e.
 no warning messages are showw in the evaluation).quietMode - public void setReapList(IAST reapList)
reapList - the reapList to setpublic void setRecursionLimit(int i)
i - public void setRelaxedSyntax(boolean fRelaxedSyntax)
fRelaxedSyntax - the fRelaxedSyntax to setpublic void setSessionID(java.lang.String string)
string - public void setStepListener(IEvalStepListener stepListener)
setTraceMode(true) to enable the trace mode. The caller is
 responsible for calling setTraceMode(false) if no further
 listening is desirable.stepListener - the listener which should listen to the evaluation steps.public void setStopRequested(boolean stopRequested)
stopRequested - The stopRequested to set.public void setTraceMode(boolean b)
b - public int sizeOut()
Out[] listpublic void stopRequest()
public java.lang.String toString()
toString in class java.lang.Object