Search in sources :

Example 26 with IExpr

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

the class ASCIIPrintTest method testTen.

public void testTen() {
    IExpr expr = F.C10;
    String s1 = "  ";
    String s2 = "10";
    String s3 = "  ";
    check(expr, s1, s2, s3);
}
Also used : IExpr(org.matheclipse.core.interfaces.IExpr)

Example 27 with IExpr

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

the class ASCIIPrintTest method testOne.

public void testOne() {
    IExpr expr = F.C1;
    String s1 = " ";
    String s2 = "1";
    String s3 = " ";
    check(expr, s1, s2, s3);
}
Also used : IExpr(org.matheclipse.core.interfaces.IExpr)

Example 28 with IExpr

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

the class ASCIIPrintTest method testMinusOne.

public void testMinusOne() {
    IExpr expr = F.CN1;
    String s1 = "  ";
    String s2 = "-1";
    String s3 = "  ";
    check(expr, s1, s2, s3);
}
Also used : IExpr(org.matheclipse.core.interfaces.IExpr)

Example 29 with IExpr

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

the class EvalComplex method evalSymbol.

public static double[] evalSymbol(final ISymbol symbol) {
    if (symbol.hasLocalVariableStack()) {
        final IExpr expr = symbol.get();
        if (expr instanceof ISignedNumber) {
            final double[] result = new double[2];
            result[0] = ((ISignedNumber) expr).doubleValue();
            result[1] = 0.0;
            return result;
        }
        if (expr instanceof ComplexNum) {
            final double[] result = new double[2];
            result[0] = ((ComplexNum) expr).getRealPart();
            result[1] = ((ComplexNum) expr).getImaginaryPart();
            return result;
        }
    }
    if (symbol.isSignedNumberConstant()) {
        // fast evaluation path
        final double[] result = new double[2];
        result[0] = ((ISignedNumberConstant) ((IBuiltInSymbol) symbol).getEvaluator()).evalReal();
        result[1] = 0.0;
        return result;
    }
    if (symbol.isBuiltInSymbol()) {
        final IEvaluator module = ((IBuiltInSymbol) symbol).getEvaluator();
        if (module instanceof INumericComplexConstant) {
            // fast evaluation path
            return ((INumericComplexConstant) module).evalComplex();
        }
    }
    // slow evaluation path
    final IExpr result = F.evaln(symbol);
    if (result instanceof ComplexNum) {
        final double[] res = new double[2];
        res[0] = ((ComplexNum) result).getRealPart();
        res[1] = ((ComplexNum) result).getImaginaryPart();
        return res;
    }
    if (result instanceof Num) {
        final double[] res = new double[2];
        res[0] = ((Num) result).doubleValue();
        res[1] = 0.0;
        return res;
    }
    throw new UnsupportedOperationException();
}
Also used : IBuiltInSymbol(org.matheclipse.core.interfaces.IBuiltInSymbol) IEvaluator(org.matheclipse.core.interfaces.IEvaluator) ISignedNumber(org.matheclipse.core.interfaces.ISignedNumber) ComplexNum(org.matheclipse.core.expression.ComplexNum) ComplexNum(org.matheclipse.core.expression.ComplexNum) Num(org.matheclipse.core.expression.Num) IExpr(org.matheclipse.core.interfaces.IExpr) INumericComplexConstant(org.matheclipse.core.eval.interfaces.INumericComplexConstant)

Example 30 with IExpr

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

the class EvalComplex method evalAST.

public static double[] evalAST(final DoubleStack stack, final int top, final IAST ast) {
    final int newTop = top;
    final ISymbol symbol = (ISymbol) ast.get(0);
    if (symbol.isBuiltInSymbol()) {
        final IEvaluator module = ((IBuiltInSymbol) symbol).getEvaluator();
        if (module instanceof INumericComplex) {
            // fast evaluation path
            stack.ensureCapacity(top + ast.size() * 2);
            for (int i = 1; i < ast.size(); i++) {
                final double[] result = eval(stack, newTop, ast.get(i));
                stack.push(result[0]);
                stack.push(result[1]);
            }
            return ((INumericComplex) module).evalComplex(stack, ast.size() - 1);
        }
    }
    // slow evaluation path
    final IExpr result = F.evaln(ast);
    if (result instanceof ComplexNum) {
        final double[] res = new double[2];
        res[0] = ((ComplexNum) result).getRealPart();
        res[1] = ((ComplexNum) result).getImaginaryPart();
        return res;
    }
    if (result instanceof Num) {
        final double[] res = new double[2];
        res[0] = ((Num) result).doubleValue();
        res[1] = 0.0;
        return res;
    }
    throw new UnsupportedOperationException();
}
Also used : IBuiltInSymbol(org.matheclipse.core.interfaces.IBuiltInSymbol) IEvaluator(org.matheclipse.core.interfaces.IEvaluator) INumericComplex(org.matheclipse.core.eval.interfaces.INumericComplex) ISymbol(org.matheclipse.core.interfaces.ISymbol) ComplexNum(org.matheclipse.core.expression.ComplexNum) ComplexNum(org.matheclipse.core.expression.ComplexNum) Num(org.matheclipse.core.expression.Num) IExpr(org.matheclipse.core.interfaces.IExpr)

Aggregations

IExpr (org.matheclipse.core.interfaces.IExpr)487 IAST (org.matheclipse.core.interfaces.IAST)248 ISymbol (org.matheclipse.core.interfaces.ISymbol)79 JASIExpr (org.matheclipse.core.convert.JASIExpr)50 ISignedNumber (org.matheclipse.core.interfaces.ISignedNumber)31 Map (java.util.Map)30 WrongArgumentType (org.matheclipse.core.eval.exception.WrongArgumentType)29 IInteger (org.matheclipse.core.interfaces.IInteger)29 SortedMap (java.util.SortedMap)27 TreeMap (java.util.TreeMap)27 ArrayList (java.util.ArrayList)18 MathException (org.matheclipse.parser.client.math.MathException)17 INum (org.matheclipse.core.interfaces.INum)16 EvalEngine (org.matheclipse.core.eval.EvalEngine)15 IFraction (org.matheclipse.core.interfaces.IFraction)14 ExprPolynomialRing (org.matheclipse.core.polynomials.ExprPolynomialRing)14 PrettyPrint (edu.jas.kern.PrettyPrint)13 SyntaxError (org.matheclipse.parser.client.SyntaxError)13 IOException (java.io.IOException)12 INumber (org.matheclipse.core.interfaces.INumber)12