Search in sources :

Example 66 with EvalEngine

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

the class Pattern method isConditionMatched.

@Override
public boolean isConditionMatched(final IExpr expr, PatternMap patternMap) {
    if (fCondition == null || expr.head().equals(fCondition)) {
        return true;
    }
    EvalEngine engine = EvalEngine.get();
    boolean traceMode = false;
    try {
        traceMode = engine.isTraceMode();
        engine.setTraceMode(false);
        final Predicate<IExpr> matcher = Predicates.isTrue(engine, fCondition);
        if (matcher.test(expr)) {
            return true;
        }
    } finally {
        if (traceMode) {
            engine.setTraceMode(true);
        }
    }
    return false;
}
Also used : EvalEngine(org.matheclipse.core.eval.EvalEngine) IExpr(org.matheclipse.core.interfaces.IExpr)

Example 67 with EvalEngine

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

the class PatternSequence method isConditionMatchedSequence.

@Override
public boolean isConditionMatchedSequence(final IAST sequence, PatternMap patternMap) {
    if (fCondition == null) {
        patternMap.setValue(this, sequence);
        return true;
    }
    EvalEngine engine = EvalEngine.get();
    boolean traceMode = false;
    traceMode = engine.isTraceMode();
    final Predicate<IExpr> matcher = Predicates.isTrue(engine, fCondition);
    try {
        for (int i = 1; i < sequence.size(); i++) {
            if (sequence.get(i).head().equals(fCondition)) {
                continue;
            }
            engine.setTraceMode(false);
            if (matcher.test(sequence.get(i))) {
                continue;
            }
            return false;
        }
        patternMap.setValue(this, sequence);
        return true;
    } finally {
        if (traceMode) {
            engine.setTraceMode(true);
        }
    }
}
Also used : EvalEngine(org.matheclipse.core.eval.EvalEngine) IExpr(org.matheclipse.core.interfaces.IExpr)

Example 68 with EvalEngine

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

the class Surd method e2ApfloatArg.

@Override
public IExpr e2ApfloatArg(final ApfloatNum af0, final ApfloatNum af1) {
    if (af1.isZero()) {
        EvalEngine ee = EvalEngine.get();
        ee.printMessage("Surd(a,b) division by zero");
        return F.Indeterminate;
    }
    if (af0.isNegative()) {
        return af0.negate().pow(af1.inverse()).negate();
    }
    return af0.pow(af1.inverse());
}
Also used : EvalEngine(org.matheclipse.core.eval.EvalEngine)

Example 69 with EvalEngine

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

the class Surd method doubleSurd.

private double doubleSurd(double val, double r) {
    if (r == 0.0d) {
        EvalEngine ee = EvalEngine.get();
        ee.printMessage("Surd(a,b) division by zero");
        return Double.NaN;
    }
    if (val < 0.0d) {
        return -Math.pow(-val, 1.0d / r);
    }
    return Math.pow(val, 1.0d / r);
}
Also used : EvalEngine(org.matheclipse.core.eval.EvalEngine)

Example 70 with EvalEngine

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

the class Limit method evalLimitQuiet.

private static IExpr evalLimitQuiet(final IExpr expr, LimitData data) {
    EvalEngine engine = EvalEngine.get();
    boolean quiet = engine.isQuietMode();
    try {
        engine.setQuietMode(true);
        return evalLimit(expr, data, true);
    } finally {
        engine.setQuietMode(quiet);
    }
}
Also used : EvalEngine(org.matheclipse.core.eval.EvalEngine)

Aggregations

EvalEngine (org.matheclipse.core.eval.EvalEngine)131 IExpr (org.matheclipse.core.interfaces.IExpr)71 IAST (org.matheclipse.core.interfaces.IAST)39 IASTAppendable (org.matheclipse.core.interfaces.IASTAppendable)20 ISymbol (org.matheclipse.core.interfaces.ISymbol)20 IOException (java.io.IOException)13 F (org.matheclipse.core.expression.F)12 ExprEvaluator (org.matheclipse.core.eval.ExprEvaluator)11 S (org.matheclipse.core.expression.S)11 IInteger (org.matheclipse.core.interfaces.IInteger)11 ASTNode (org.matheclipse.parser.client.ast.ASTNode)11 LogManager (org.apache.logging.log4j.LogManager)10 Logger (org.apache.logging.log4j.Logger)10 AST2Expr (org.matheclipse.core.convert.AST2Expr)9 ExprParser (org.matheclipse.core.parser.ExprParser)9 IBuiltInSymbol (org.matheclipse.core.interfaces.IBuiltInSymbol)8 MathException (org.matheclipse.parser.client.math.MathException)8 ArrayList (java.util.ArrayList)7 Config (org.matheclipse.core.basic.Config)7 IASTMutable (org.matheclipse.core.interfaces.IASTMutable)7