Search in sources :

Example 76 with EvalEngine

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

the class ExpandTestCase method testExpandPerformance001.

public void testExpandPerformance001() {
    // ExpandAll((a+b+2*c+x+y+3*z)^6)
    IAST ast = Power(Plus(a, b, F.Times(C2, c), x, y, F.Times(F.C3, z)), F.ZZ(6));
    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(), 462);
    assertEquals(temp.get(462).toString(), "729*z^6");
}
Also used : EvalEngine(org.matheclipse.core.eval.EvalEngine) IAST(org.matheclipse.core.interfaces.IAST)

Example 77 with EvalEngine

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

the class ExprEvaluatorTest method testSmallValueEvalEnginge.

public void testSmallValueEvalEnginge() {
    // github #208
    ExprEvaluator exprEvaluator = new ExprEvaluator();
    EvalEngine evalEngine = exprEvaluator.getEvalEngine();
    evalEngine.setNumericMode(true, 100, -1);
    assertEquals(evalEngine.evaluate("N( 1/(1602176620898*10^(-31)) ,100)").toString(), "6.241509125501484852088071665173164020252959820255548406024372975427711002340001391293975286331422182*10^18");
    assertEquals(evalEngine.evaluate("1/(N(0.0000000000000000001602176620898, 100))").toString(), "6.241509125501484852088071665173164020252959820255548406024372975427711002340001391293975286331422182*10^18");
    assertEquals(evalEngine.evaluate("N(1/(N(0.0000000000000000001602176620898, 100)), 100)").toString(), "6.241509125501484852088071665173164020252959820255548406024372975427711002340001391293975286331422182*10^18");
}
Also used : ExprEvaluator(org.matheclipse.core.eval.ExprEvaluator) EvalEngine(org.matheclipse.core.eval.EvalEngine)

Example 78 with EvalEngine

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

the class ExprEvaluatorTest method testEvalF.

public void testEvalF() {
    EvalEngine engine = new EvalEngine(true);
    ExprEvaluator eval = new ExprEvaluator(engine, true, (short) 20);
    String str = "Sqrt(2)*Pi";
    double d = eval.evalf(str);
    assertEquals("4.442882938158366", Double.toString(d));
}
Also used : ExprEvaluator(org.matheclipse.core.eval.ExprEvaluator) EvalEngine(org.matheclipse.core.eval.EvalEngine)

Example 79 with EvalEngine

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

the class ExprParserTestCase method testIntegerMIN_VALUE.

public void testIntegerMIN_VALUE() {
    // Integer.MIN_VALUE
    EvalEngine engine = new EvalEngine("", 256, 256, System.out, System.err, true);
    ExprParser parser = new ExprParser(engine, true);
    IExpr expr = parser.parse("-2147483648");
    assertEquals(expr.toMMA(), "-2147483648");
}
Also used : EvalEngine(org.matheclipse.core.eval.EvalEngine) IExpr(org.matheclipse.core.interfaces.IExpr) ExprParser(org.matheclipse.core.parser.ExprParser)

Example 80 with EvalEngine

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

the class ExprParserTestCase method testLongMIN_VALUE.

public void testLongMIN_VALUE() {
    // Long.MIN_VALUE
    EvalEngine engine = new EvalEngine("", 256, 256, System.out, System.err, true);
    ExprParser parser = new ExprParser(engine, true);
    IExpr expr = parser.parse("-9223372036854775808");
    assertEquals(expr.toMMA(), "-9223372036854775808");
}
Also used : EvalEngine(org.matheclipse.core.eval.EvalEngine) IExpr(org.matheclipse.core.interfaces.IExpr) ExprParser(org.matheclipse.core.parser.ExprParser)

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