Search in sources :

Example 11 with IAST

use of org.matheclipse.core.interfaces.IAST in project symja_android_library by axkr.

the class PatternMatchingTestCase method check.

public void check(EvalEngine engine, boolean configMode, IAST ast, String strResult) {
    try {
        StringWriter buf = new StringWriter();
        Config.SERVER_MODE = configMode;
        if (Config.SERVER_MODE) {
            IAST inExpr = ast;
            TimeConstrainedEvaluator utility = new TimeConstrainedEvaluator(engine, false, Config.FOREVER);
            utility.constrainedEval(buf, inExpr);
        } else {
            if (ast != null) {
                OutputFormFactory off = OutputFormFactory.get();
                off.setIgnoreNewLine(true);
                OutputFormFactory.get().convert(buf, ast);
            }
        }
        assertEquals(buf.toString(), strResult);
    } catch (Exception e) {
        e.printStackTrace();
        assertEquals(e, "");
    }
}
Also used : TimeConstrainedEvaluator(org.matheclipse.core.eval.TimeConstrainedEvaluator) StringWriter(java.io.StringWriter) IAST(org.matheclipse.core.interfaces.IAST) OutputFormFactory(org.matheclipse.core.form.output.OutputFormFactory)

Example 12 with IAST

use of org.matheclipse.core.interfaces.IAST in project symja_android_library by axkr.

the class CompareToTestCase method testIssue122c.

public void testIssue122c() {
    ISymbol b = F.$s("b");
    ISymbol c = F.$s("c");
    ISymbol x1 = F.$s("x1");
    ISymbol x3 = F.$s("x3");
    ISymbol x4 = F.$s("x4");
    ISymbol x5 = F.$s("x5");
    IPattern x1_c = F.$p(x1, c);
    IPattern x3_b = F.$p(x3, b);
    IPattern x3_c = F.$p(x3, c);
    IPattern x5_c = F.$p(x5, c);
    IAST ast1 = F.Times(x3, x5, x5_c);
    IAST ast2 = F.Times(F.CN1, x1_c, x3_b, x3_c);
    int res = ast1.compareTo(ast2);
    assertEquals(2, res);
    res = ast2.compareTo(ast1);
    assertEquals(-2, res);
    check("-Infinity+b+a", "-Infinity+a+b");
}
Also used : IPattern(org.matheclipse.core.interfaces.IPattern) ISymbol(org.matheclipse.core.interfaces.ISymbol) IAST(org.matheclipse.core.interfaces.IAST)

Example 13 with IAST

use of org.matheclipse.core.interfaces.IAST in project symja_android_library by axkr.

the class CompareToTestCase method testIssue122a.

public void testIssue122a() {
    ISymbol b = F.$s("b");
    ISymbol c = F.$s("c");
    ISymbol x1 = F.$s("x1");
    ISymbol x3 = F.$s("x3");
    ISymbol x4 = F.$s("x4");
    ISymbol x5 = F.$s("x5");
    IPattern x1_c = F.$p(x1, c);
    IPattern x3_b = F.$p(x3, b);
    IPattern x3_c = F.$p(x3, c);
    IPattern x4_c = F.$p(x4, c);
    IAST ast1 = F.Times(F.CN1, x1_c, x3_b, x3_c);
    IAST ast2 = F.Times(F.CN1, x3, x5, x1_c, x4_c);
    int res = ast1.compareTo(ast2);
    assertEquals(-1, res);
    res = ast2.compareTo(ast1);
    assertEquals(1, res);
    check("-Infinity+b+a", "-Infinity+a+b");
}
Also used : IPattern(org.matheclipse.core.interfaces.IPattern) ISymbol(org.matheclipse.core.interfaces.ISymbol) IAST(org.matheclipse.core.interfaces.IAST)

Example 14 with IAST

use of org.matheclipse.core.interfaces.IAST in project symja_android_library by axkr.

the class AbstractTestCase method check.

public void check(EvalEngine engine, boolean configMode, IAST ast, String strResult) {
    boolean mode = Config.SERVER_MODE;
    try {
        StringWriter buf = new StringWriter();
        Config.SERVER_MODE = configMode;
        if (Config.SERVER_MODE) {
            IAST inExpr = ast;
            TimeConstrainedEvaluator utility = new TimeConstrainedEvaluator(engine, false, Config.FOREVER);
            utility.constrainedEval(buf, inExpr);
        } else {
            if (ast != null) {
                OutputFormFactory off = OutputFormFactory.get();
                off.setIgnoreNewLine(true);
                off.convert(buf, ast);
            }
        }
        assertEquals(strResult, buf.toString());
    } catch (Exception e) {
        e.printStackTrace();
        assertEquals("", e);
    } finally {
        Config.SERVER_MODE = mode;
    }
}
Also used : TimeConstrainedEvaluator(org.matheclipse.core.eval.TimeConstrainedEvaluator) StringWriter(java.io.StringWriter) IAST(org.matheclipse.core.interfaces.IAST) OutputFormFactory(org.matheclipse.core.form.output.OutputFormFactory)

Example 15 with IAST

use of org.matheclipse.core.interfaces.IAST in project symja_android_library by axkr.

the class PatternsTest method testPriority002.

public void testPriority002() {
    IAST ast1 = ast(f);
    ast1.append(Times(a, x));
    IAST ast2 = ast(f);
    ast2.append(Times(a_, x_));
    PatternMatcher pm1 = new PatternMatcher(ast1);
    PatternMatcher pm2 = new PatternMatcher(ast2);
    int cpr = pm1.compareTo(pm2);
    assertEquals(cpr, -1);
}
Also used : IAST(org.matheclipse.core.interfaces.IAST) PatternMatcher(org.matheclipse.core.patternmatching.PatternMatcher)

Aggregations

IAST (org.matheclipse.core.interfaces.IAST)413 IExpr (org.matheclipse.core.interfaces.IExpr)248 ISymbol (org.matheclipse.core.interfaces.ISymbol)76 IInteger (org.matheclipse.core.interfaces.IInteger)34 WrongArgumentType (org.matheclipse.core.eval.exception.WrongArgumentType)30 ISignedNumber (org.matheclipse.core.interfaces.ISignedNumber)22 ExpVector (edu.jas.poly.ExpVector)15 ArrayList (java.util.ArrayList)14 BigRational (edu.jas.arith.BigRational)13 JASIExpr (org.matheclipse.core.convert.JASIExpr)13 VariablesSet (org.matheclipse.core.convert.VariablesSet)13 INum (org.matheclipse.core.interfaces.INum)13 ExprPolynomial (org.matheclipse.core.polynomials.ExprPolynomial)12 GenPolynomial (edu.jas.poly.GenPolynomial)11 JASConversionException (org.matheclipse.core.eval.exception.JASConversionException)11 IFraction (org.matheclipse.core.interfaces.IFraction)11 INumber (org.matheclipse.core.interfaces.INumber)11 IComplex (org.matheclipse.core.interfaces.IComplex)10 ModLong (edu.jas.arith.ModLong)9 ExprPolynomialRing (org.matheclipse.core.polynomials.ExprPolynomialRing)9