Search in sources :

Example 81 with EvalEngine

use of org.matheclipse.core.eval.EvalEngine in project symja_android_library by axkr.

the class BasicPatternPropertiesTestCase method comparePriority.

public void comparePriority(String patternString1, String patternString2, int result) {
    try {
        EvalEngine engine = EvalEngine.get();
        ASTNode node = fParser.parse(patternString1);
        IExpr pat1 = new AST2Expr(false, engine).convert(node);
        PatternMatcher matcher1 = new PatternMatcher(pat1);
        node = fParser.parse(patternString2);
        IExpr pat2 = new AST2Expr(false, engine).convert(node);
        PatternMatcher matcher2 = new PatternMatcher(pat2);
        assertEquals(matcher1.equivalentTo(matcher2), result);
    } catch (Exception e) {
        e.printStackTrace();
        assertEquals(Integer.MAX_VALUE, result);
    }
}
Also used : EvalEngine(org.matheclipse.core.eval.EvalEngine) ASTNode(org.matheclipse.parser.client.ast.ASTNode) IExpr(org.matheclipse.core.interfaces.IExpr) PatternMatcher(org.matheclipse.core.patternmatching.PatternMatcher) AST2Expr(org.matheclipse.core.convert.AST2Expr)

Example 82 with EvalEngine

use of org.matheclipse.core.eval.EvalEngine in project symja_android_library by axkr.

the class BasicPatternPropertiesTestCase method setUp.

/**
 * The JUnit setup method
 */
@Override
protected void setUp() {
    try {
        // setup the evaluation engine (and bind to current thread)
        // EvalEngine.get();
        EvalEngine engine = new EvalEngine();
        EvalEngine.set(engine);
        engine.setSessionID("BasicPatternPropertiesTestCase");
        engine.setRecursionLimit(256);
        engine.setIterationLimit(1024 * 1024);
        fParser = new Parser();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : EvalEngine(org.matheclipse.core.eval.EvalEngine) Parser(org.matheclipse.parser.client.Parser)

Example 83 with EvalEngine

use of org.matheclipse.core.eval.EvalEngine in project symja_android_library by axkr.

the class ConstantTest method setUp.

/**
 * The JUnit setup method
 */
@Override
protected void setUp() {
    Config.BUILTIN_PROTECTED = ISymbol.PROTECTED;
    super.setUp();
    Config.SHORTEN_STRING_LENGTH = 1024;
    Config.MAX_AST_SIZE = 1000000;
    // // dummy eval
    // try {
    // fScriptEngine.eval("");
    // } catch (ScriptException e) {
    // }
    EvalEngine engine = (EvalEngine) fScriptEngine.get("EVAL_ENGINE");
    engine.setIterationLimit(50000);
    engine.setRecursionLimit(256);
}
Also used : EvalEngine(org.matheclipse.core.eval.EvalEngine)

Example 84 with EvalEngine

use of org.matheclipse.core.eval.EvalEngine in project symja_android_library by axkr.

the class ExpandTestCase method testExpandPerformance002.

public void testExpandPerformance002() {
    // Expand((a+b+2*c+x+y+3*z)^12)
    IAST ast = Power(Plus(a, b, F.Times(C2, c), x, y, F.Times(F.C3, z)), F.ZZ(12));
    IAST temp = (IAST) Algebra.expand(ast, null, false, false, false);
    EvalEngine engine = EvalEngine.get();
    temp = (IAST) engine.evaluate(temp);
    // number of terms
    assertEquals(temp.argSize(), 6188);
    assertEquals(temp.get(6188).toString(), "531441*z^12");
    assertEquals(temp.get(462).toString(), "5544*a^5*b^6*y");
}
Also used : EvalEngine(org.matheclipse.core.eval.EvalEngine) IAST(org.matheclipse.core.interfaces.IAST)

Example 85 with EvalEngine

use of org.matheclipse.core.eval.EvalEngine in project symja_android_library by axkr.

the class SerializableTest method testPowerSeries.

public void testPowerSeries() {
    equalsCopy(new ASTSeriesData(F.x, F.a, F.List(F.C0, F.C1, F.C3), 0, 10, 1));
    // Series(Log(x),{x,a,4})
    EvalEngine engine = EvalEngine.get();
    IExpr result = engine.evaluate(F.Series(F.Log(F.x), F.List(F.x, F.a, F.C4)));
    equalsCopy(result);
}
Also used : EvalEngine(org.matheclipse.core.eval.EvalEngine) ASTSeriesData(org.matheclipse.core.expression.ASTSeriesData) IExpr(org.matheclipse.core.interfaces.IExpr)

Aggregations

EvalEngine (org.matheclipse.core.eval.EvalEngine)131 IExpr (org.matheclipse.core.interfaces.IExpr)71 IAST (org.matheclipse.core.interfaces.IAST)39 IASTAppendable (org.matheclipse.core.interfaces.IASTAppendable)20 ISymbol (org.matheclipse.core.interfaces.ISymbol)20 IOException (java.io.IOException)13 F (org.matheclipse.core.expression.F)12 ExprEvaluator (org.matheclipse.core.eval.ExprEvaluator)11 S (org.matheclipse.core.expression.S)11 IInteger (org.matheclipse.core.interfaces.IInteger)11 ASTNode (org.matheclipse.parser.client.ast.ASTNode)11 LogManager (org.apache.logging.log4j.LogManager)10 Logger (org.apache.logging.log4j.Logger)10 AST2Expr (org.matheclipse.core.convert.AST2Expr)9 ExprParser (org.matheclipse.core.parser.ExprParser)9 IBuiltInSymbol (org.matheclipse.core.interfaces.IBuiltInSymbol)8 MathException (org.matheclipse.parser.client.math.MathException)8 ArrayList (java.util.ArrayList)7 Config (org.matheclipse.core.basic.Config)7 IASTMutable (org.matheclipse.core.interfaces.IASTMutable)7