Search in sources :

Example 1 with EvalUtilities

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

the class PatternMatchingTestCase method setUp.

//	public void testSlotPatternMatching() {
//		checkPattern("b_.* #+c_.*#^2", "#-1*#^2", "");
//		checkPattern("b_.* #+c_.*#^2", "#+#^2", "[1, 1]");
//		checkPattern("a_. + b_.* #+c_.*#^2", "-1+#+#^2", "[-1, 1, 1]");
//	}
/**
	 * The JUnit setup method
	 */
protected void setUp() {
    try {
        // setup the evaluation engine (and bind to current thread)
        //			F.initSymbols();
        // EvalEngine.get();
        EvalEngine engine = new EvalEngine();
        EvalEngine.set(engine);
        engine.setSessionID("SpecialTestCase");
        engine.setRecursionLimit(256);
        engine.setIterationLimit(1024 * 1024);
        util = new EvalUtilities(engine, false, false);
        // setup a parser for the math expressions
        fParser = new Parser();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : EvalUtilities(org.matheclipse.core.eval.EvalUtilities) EvalEngine(org.matheclipse.core.eval.EvalEngine) Parser(org.matheclipse.parser.client.Parser)

Example 2 with EvalUtilities

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

the class AssumptionTestCase method testGreaterZeroOrInteger001.

public void testGreaterZeroOrInteger001() {
    // don't distinguish between lower- and uppercase identifiers
    ParserConfig.PARSER_USE_LOWERCASE_SYMBOLS = true;
    EvalUtilities util = new EvalUtilities(false, true);
    util.getEvalEngine().setAssumptions(new XGreaterZeroOrYInteger());
    IAST function = Abs(x);
    IExpr result = util.evaluate(function);
    assertEquals(result.toString(), "x");
    function = Abs(y);
    result = util.evaluate(function);
    assertEquals(result.toString(), "Abs(y)");
    function = Floor(x);
    result = util.evaluate(function);
    assertEquals(result.toString(), "Floor(x)");
    function = Floor(y);
    result = util.evaluate(function);
    assertEquals(result.toString(), "y");
}
Also used : EvalUtilities(org.matheclipse.core.eval.EvalUtilities) IAST(org.matheclipse.core.interfaces.IAST) IExpr(org.matheclipse.core.interfaces.IExpr)

Example 3 with EvalUtilities

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

the class AssumptionTestCase method testSqrt001.

public void testSqrt001() {
    // don't distinguish between lower- and uppercase identifiers
    ParserConfig.PARSER_USE_LOWERCASE_SYMBOLS = true;
    EvalUtilities util = new EvalUtilities(false, true);
    // define "t" with "t" assumed greater than 0
    // use #1 (Slot1) as placeholder for a new symbol!
    ISymbol t = F.symbol("t", F.Greater(F.Slot1, F.C10));
    // (t^2) ^ (1/2)
    IAST function = F.Sqrt(F.Sqr(t));
    IExpr result = util.evaluate(function);
    assertEquals(result.toString(), "t");
}
Also used : EvalUtilities(org.matheclipse.core.eval.EvalUtilities) ISymbol(org.matheclipse.core.interfaces.ISymbol) IAST(org.matheclipse.core.interfaces.IAST) IExpr(org.matheclipse.core.interfaces.IExpr)

Example 4 with EvalUtilities

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

the class JavaFormTestCase method testJavaForm001.

public void testJavaForm001() {
    // don't distinguish between lower- and uppercase identifiers
    ParserConfig.PARSER_USE_LOWERCASE_SYMBOLS = true;
    EvalUtilities util = new EvalUtilities(false, true);
    IAST function = Sinc(Times(CI, CInfinity));
    IExpr result = EvalEngine.get().evalHoldPattern(function);
    assertEquals("Sinc(DirectedInfinity(CI))", result.internalFormString(true, -1).toString());
    result = util.evaluate(function);
    assertEquals("oo", result.internalFormString(true, -1).toString());
}
Also used : EvalUtilities(org.matheclipse.core.eval.EvalUtilities) IAST(org.matheclipse.core.interfaces.IAST) IExpr(org.matheclipse.core.interfaces.IExpr)

Example 5 with EvalUtilities

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

the class PatternMatchingTestCase method setUp.

// public void testSlotPatternMatching() {
// checkPattern("b_.* #+c_.*#^2", "#-1*#^2", "");
// checkPattern("b_.* #+c_.*#^2", "#+#^2", "[1, 1]");
// checkPattern("a_. + b_.* #+c_.*#^2", "-1+#+#^2", "[-1, 1, 1]");
// }
/**
 * The JUnit setup method
 */
@Override
protected void setUp() {
    try {
        // setup the evaluation engine (and bind to current thread)
        // F.initSymbols();
        // EvalEngine.get();
        EvalEngine engine = new EvalEngine();
        EvalEngine.set(engine);
        engine.setSessionID("SpecialTestCase");
        engine.setRecursionLimit(256);
        engine.setIterationLimit(1024 * 1024);
        util = new EvalUtilities(engine, false, false);
        // setup a parser for the math expressions
        fParser = new Parser();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : EvalUtilities(org.matheclipse.core.eval.EvalUtilities) EvalEngine(org.matheclipse.core.eval.EvalEngine) Parser(org.matheclipse.parser.client.Parser)

Aggregations

EvalUtilities (org.matheclipse.core.eval.EvalUtilities)11 IAST (org.matheclipse.core.interfaces.IAST)9 IExpr (org.matheclipse.core.interfaces.IExpr)9 ISymbol (org.matheclipse.core.interfaces.ISymbol)3 EvalEngine (org.matheclipse.core.eval.EvalEngine)2 Parser (org.matheclipse.parser.client.Parser)2