Search in sources :

Example 6 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
    Config.PARSER_USE_LOWERCASE_SYMBOLS = true;
    EvalUtilities util = new EvalUtilities(false, true);
    IAST function = Sinc(Times(CI, CInfinity));
    IExpr result = PatternMatcher.evalLeftHandSide(function);
    assertEquals(result.internalFormString(true, -1), "Sinc(DirectedInfinity(CI))");
    result = util.evaluate(function);
    assertEquals(result.internalFormString(true, -1), "oo");
}
Also used : EvalUtilities(org.matheclipse.core.eval.EvalUtilities) IAST(org.matheclipse.core.interfaces.IAST) IExpr(org.matheclipse.core.interfaces.IExpr)

Example 7 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
    Config.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 8 with EvalUtilities

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

the class AssumptionTestCase method testTensorDimensions001.

public void testTensorDimensions001() {
    // don't distinguish between lower- and uppercase identifiers
    ParserConfig.PARSER_USE_LOWERCASE_SYMBOLS = true;
    EvalUtilities util = new EvalUtilities(false, true);
    // Element(M, Matrices({3, 3}, Reals))
    // define "m" with "m" assumed to be a 3x3 matrix
    // use #1 (Slot1) as placeholder for a new symbol!
    ISymbol t = F.symbol("m", F.Element(F.Slot1, F.Matrices(F.List(3, 3), S.Reals)));
    IAST function = F.TensorDimensions(t);
    IExpr result = util.evaluate(function);
    assertEquals(result.toString(), "{3,3}");
}
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 9 with EvalUtilities

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

the class AssumptionTestCase method testFloor001.

public void testFloor001() {
    // 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 to be an element of the integers
    // use #1 (Slot1) as placeholder for a new symbol!
    ISymbol t = F.symbol("t", F.Element(F.Slot1, F.Integers));
    IAST function = F.Floor(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 10 with EvalUtilities

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

the class JavaFormTestCase method testJavaForm002_fullyQualifiedName.

public void testJavaForm002_fullyQualifiedName() {
    // 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("org.matheclipse.core.expression.F.Sinc(org.matheclipse.core.expression.F.DirectedInfinity(org.matheclipse.core.expression.F.CI))", result.internalJavaString(SYMBOL_FACTORY_PROPERTIES_FULL_NAMES, -1, x -> null).toString());
    result = util.evaluate(function);
    assertEquals("org.matheclipse.core.expression.F.oo", result.internalJavaString(SYMBOL_FACTORY_PROPERTIES_FULL_NAMES, -1, x -> null).toString());
}
Also used : EvalUtilities(org.matheclipse.core.eval.EvalUtilities) IAST(org.matheclipse.core.interfaces.IAST) IExpr(org.matheclipse.core.interfaces.IExpr)

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