org.matheclipse.core.eval
Class EvalUtilities
- java.lang.Object
-
- org.matheclipse.core.eval.MathMLUtilities
-
- org.matheclipse.core.eval.EvalUtilities
-
- Direct Known Subclasses:
- SymjaInterpreter, TimeConstrainedEvaluator
public class EvalUtilities extends MathMLUtilities
Utility to evaluate math expressions.
-
-
Constructor Summary
Constructors Constructor and Description EvalUtilities()Constructor for an object which evaluates an expression.EvalUtilities(boolean mathMTagPrefix, boolean relaxedSyntax)Constructor for an object which evaluates an expression.EvalUtilities(EvalEngine evalEngine, boolean mathMTagPrefix, boolean relaxedSyntax)Constructor for an object which evaluates an expression.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description static IExpreval(java.lang.String inputExpression, EvalEngine evalEngine)Evaluate theinputExpressionand return the resulting expression.IASTevalTrace(IExpr parsedExpression, Predicate<IExpr> matcher, IAST list)Evaluate theparsedExpressionand return theTrace[parsedExpression](i.e.IASTevalTrace(java.lang.String inputExpression, Predicate<IExpr> matcher, IAST list)Evaluate theinputExpressionand return theTrace[inputExpression](i.e.IExprevaluate(IExpr parsedExpression)Evaluate theparsedExpressionand return the resulting expression.IExprevaluate(java.lang.String inputExpression)Evaluate theinputExpressionand return the resulting expression.java.lang.StringtoJavaForm(java.lang.String inputExpression)Converts the inputExpression string into a MathML expression and writes the result to the givenWritervoidtoMathML(java.lang.String inputExpression, java.io.Writer out)Converts the inputExpression string into a MathML expression and writes the result to the givenWriter-
Methods inherited from class org.matheclipse.core.eval.MathMLUtilities
startRequest, stopRequest, toJava, toMathML
-
-
-
-
Constructor Detail
-
EvalUtilities
public EvalUtilities()
Constructor for an object which evaluates an expression. By default the internalEvalEnginedidn't create a history list for theOut[]function.- Parameters:
evalEngine-mathMTagPrefix- if set totrueuse "m:" as tag prefix for the MathML output.relaxedSyntax-
-
EvalUtilities
public EvalUtilities(boolean mathMTagPrefix, boolean relaxedSyntax)Constructor for an object which evaluates an expression.- Parameters:
mathMTagPrefix- if set totrueuse "m:" as tag prefix for the MathML output.relaxedSyntax- if set totrueuse "(...)" instead of "[...]" for function arguments (i.e. sin(...) instead of sin[...]).
-
EvalUtilities
public EvalUtilities(EvalEngine evalEngine, boolean mathMTagPrefix, boolean relaxedSyntax)
Constructor for an object which evaluates an expression.- Parameters:
evalEngine-mathMTagPrefix- if set totrueuse "m:" as tag prefix for the MathML output.relaxedSyntax- if set totrueuse "(...)" instead of "[...]" for function arguments (i.e. sin(...) instead of sin[...]).
-
-
Method Detail
-
evaluate
public IExpr evaluate(java.lang.String inputExpression) throws MathException
Evaluate theinputExpressionand return the resulting expression.- Parameters:
inputExpression- the expression which should be evaluated.- Returns:
null, if the inputExpression isnull- Throws:
MathException
-
eval
public static IExpr eval(java.lang.String inputExpression, EvalEngine evalEngine) throws MathException
Evaluate theinputExpressionand return the resulting expression.
The parser first tries (independently from the settings in theevalEngine) to parse the expression in the "relaxed mode" (i.e. "common math expression syntax" with parentheses for function arguments) and if that results in aSyntaxErrorexception it tries to parse in the "stronger mode" (i.e. with square brackets for function arguments).
Note that after the second parser step this method may also throw aSyntaxErrorexception.- Parameters:
inputExpression- the expression which should be evaluated.evalEngine- the evaluation engine which should be used- Returns:
null, if the inputExpression isnull- Throws:
MathException
-
evaluate
public IExpr evaluate(IExpr parsedExpression) throws MathException
Evaluate theparsedExpressionand return the resulting expression.- Parameters:
parsedExpression- the expression which should be evaluated.- Returns:
- Throws:
MathException
-
toJavaForm
public java.lang.String toJavaForm(java.lang.String inputExpression) throws MathExceptionConverts the inputExpression string into a MathML expression and writes the result to the givenWriter- Parameters:
inputExpression-out-- Throws:
MathException
-
evalTrace
public IAST evalTrace(java.lang.String inputExpression, Predicate<IExpr> matcher, IAST list) throws MathException
Evaluate theinputExpressionand return theTrace[inputExpression](i.e. all (sub-)expressions needed to calculate the result).- Parameters:
inputExpression- the expression which should be evaluated.matcher- a filter which determines the expressions which should be traced, If the matcher is set tonull, all expressions are traced.list- an IAST object which will be cloned for containing the traced expressions. Typically aF.List()will be used.- Returns:
- Throws:
MathException
-
evalTrace
public IAST evalTrace(IExpr parsedExpression, Predicate<IExpr> matcher, IAST list) throws java.lang.RuntimeException
Evaluate theparsedExpressionand return theTrace[parsedExpression](i.e. all (sub-)expressions needed to calculate the result).- Parameters:
parsedExpression- the expression which should be evaluated.matcher- a filter which determines the expressions which should be traced, If the matcher is set tonull, all expressions are traced.list- an IAST object which will be cloned for containing the traced expressions. Typically aF.List()will be used.- Returns:
- Throws:
java.lang.RuntimeException
-
toMathML
public void toMathML(java.lang.String inputExpression, java.io.Writer out)Converts the inputExpression string into a MathML expression and writes the result to the givenWriter- Overrides:
toMathMLin classMathMLUtilities
-
-
DMelt 3.0 © DataMelt by jWork.ORG