Search in sources :

Example 41 with ASTNode

use of org.matheclipse.parser.client.ast.ASTNode in project symja_android_library by axkr.

the class ParserTestCase method testParser15.

public void testParser15() {
    try {
        Parser p = new Parser();
        ASTNode obj = p.parse("Integrate[Sin[a_.*x_]^n_IntegerQ, x_Symbol]:= -Sin[a*x]^(n-1)*Cos[a*x]/(n*a)+(n-1)/n*Integrate[Sin[a*x]^(n-2),x]/;Positive[n]&&FreeQ[a,x]");
        assertEquals(obj.toString(), "SetDelayed(Integrate(Power(Sin(Times(a_., x_)), n_IntegerQ), x_Symbol), Condition(Plus(Times(Times(-1, Power(Sin(Times(a, x)), Plus(n, Times(-1, 1)))), Times(Cos(Times(a, x)), Power(Times(n, a), -1))), Times(Times(Plus(n, Times(-1, 1)), Power(n, -1)), Integrate(Power(Sin(Times(a, x)), Plus(n, Times(-1, 2))), x))), And(Positive(n), FreeQ(a, x))))");
    } catch (Exception e) {
        e.printStackTrace();
        assertEquals("", e.getMessage());
    }
}
Also used : ASTNode(org.matheclipse.parser.client.ast.ASTNode) Parser(org.matheclipse.parser.client.Parser)

Example 42 with ASTNode

use of org.matheclipse.parser.client.ast.ASTNode in project symja_android_library by axkr.

the class ParserTestCase method testParserFunction.

public void testParserFunction() {
    try {
        Parser p = new Parser(true);
        ASTNode obj = p.parse("#^2-3#-1&");
        assertEquals(obj.toString(), "Function(Plus(Plus(Power(Slot(1), 2), Times(-1, Times(3, Slot(1)))), Times(-1, 1)))");
    } catch (RuntimeException e) {
        e.printStackTrace();
        assertEquals("", e.getMessage());
    }
}
Also used : ASTNode(org.matheclipse.parser.client.ast.ASTNode) Parser(org.matheclipse.parser.client.Parser)

Example 43 with ASTNode

use of org.matheclipse.parser.client.ast.ASTNode in project symja_android_library by axkr.

the class ParserTestCase method testParser19.

public void testParser19() {
    try {
        Parser p = new Parser();
        ASTNode obj = p.parse("B[[;; 2]]");
        assertEquals(obj.toString(), "Part(B, Span(1, 2))");
    } catch (Exception e) {
        e.printStackTrace();
        assertEquals("", e.getMessage());
    }
}
Also used : ASTNode(org.matheclipse.parser.client.ast.ASTNode) Parser(org.matheclipse.parser.client.Parser)

Example 44 with ASTNode

use of org.matheclipse.parser.client.ast.ASTNode in project symja_android_library by axkr.

the class ParserTestCase method testParser22.

public void testParser22() {
    try {
        Parser p = new Parser();
        ASTNode obj = p.parse("a+b;");
        assertEquals(obj.toString(), "CompoundExpression(Plus(a, b), Null)");
    } catch (Exception e) {
        e.printStackTrace();
        assertEquals("", e.getMessage());
    }
}
Also used : ASTNode(org.matheclipse.parser.client.ast.ASTNode) Parser(org.matheclipse.parser.client.Parser)

Example 45 with ASTNode

use of org.matheclipse.parser.client.ast.ASTNode in project symja_android_library by axkr.

the class ParserTestCase method testParser21.

public void testParser21() {
    try {
        Parser p = new Parser();
        ASTNode obj = p.parse("B[[3;;1;;-1]]");
        assertEquals(obj.toString(), "Part(B, Span(3, 1, -1))");
    } catch (Exception e) {
        e.printStackTrace();
        assertEquals("", e.getMessage());
    }
}
Also used : ASTNode(org.matheclipse.parser.client.ast.ASTNode) Parser(org.matheclipse.parser.client.Parser)

Aggregations

ASTNode (org.matheclipse.parser.client.ast.ASTNode)56 Parser (org.matheclipse.parser.client.Parser)32 IExpr (org.matheclipse.core.interfaces.IExpr)10 FunctionNode (org.matheclipse.parser.client.ast.FunctionNode)8 MathException (org.matheclipse.parser.client.math.MathException)6 PatternMatcher (org.matheclipse.core.patternmatching.PatternMatcher)5 SymbolNode (org.matheclipse.parser.client.ast.SymbolNode)5 IAST (org.matheclipse.core.interfaces.IAST)4 IOException (java.io.IOException)3 AST2Expr (org.matheclipse.core.convert.AST2Expr)3 NumberNode (org.matheclipse.parser.client.ast.NumberNode)3 FileReader (java.io.FileReader)2 ISymbol (org.matheclipse.core.interfaces.ISymbol)2 ArithmeticMathException (org.matheclipse.parser.client.math.ArithmeticMathException)2 InfixOperator (org.matheclipse.parser.client.operator.InfixOperator)2 PostfixOperator (org.matheclipse.parser.client.operator.PostfixOperator)2 PrefixOperator (org.matheclipse.parser.client.operator.PrefixOperator)2 BufferedReader (java.io.BufferedReader)1 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1