Search in sources :

Example 16 with EvalEngine

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

the class Blank method isConditionMatched.

@Override
public boolean isConditionMatched(final IExpr expr, PatternMap patternMap) {
    if (fCondition == null || expr.head().equals(fCondition)) {
        patternMap.setValue(this, expr);
        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)) {
            patternMap.setValue(this, 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 17 with EvalEngine

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

the class Symbol method clearAttributes.

/** {@inheritDoc} */
@Override
public final void clearAttributes(final int attributes) {
    fAttributes &= (0xffff ^ attributes);
    if (fSymbolName.charAt(0) == '$' && Config.SERVER_MODE) {
        EvalEngine engine = EvalEngine.get();
        engine.addModifiedVariable(this);
    }
}
Also used : EvalEngine(org.matheclipse.core.eval.EvalEngine)

Example 18 with EvalEngine

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

the class Symbol method addAttributes.

/** {@inheritDoc} */
@Override
public final void addAttributes(final int attributes) {
    fAttributes |= attributes;
    if (fSymbolName.charAt(0) == '$' && Config.SERVER_MODE) {
        EvalEngine engine = EvalEngine.get();
        engine.addModifiedVariable(this);
    }
}
Also used : EvalEngine(org.matheclipse.core.eval.EvalEngine)

Example 19 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 20 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)

Aggregations

EvalEngine (org.matheclipse.core.eval.EvalEngine)32 IExpr (org.matheclipse.core.interfaces.IExpr)15 IAST (org.matheclipse.core.interfaces.IAST)5 ISymbol (org.matheclipse.core.interfaces.ISymbol)5 IRational (org.matheclipse.core.interfaces.IRational)3 IOException (java.io.IOException)2 RecursionLimitExceeded (org.matheclipse.core.eval.exception.RecursionLimitExceeded)2 Num (org.matheclipse.core.expression.Num)2 IInteger (org.matheclipse.core.interfaces.IInteger)2 INum (org.matheclipse.core.interfaces.INum)2 Parser (org.matheclipse.parser.client.Parser)2 File (java.io.File)1 InputStream (java.io.InputStream)1 ObjectInputStream (java.io.ObjectInputStream)1 PrintWriter (java.io.PrintWriter)1 Apint (org.apfloat.Apint)1 UnivariateFunction (org.hipparchus.analysis.UnivariateFunction)1 RombergIntegrator (org.hipparchus.analysis.integration.RombergIntegrator)1 SimpsonIntegrator (org.hipparchus.analysis.integration.SimpsonIntegrator)1 TrapezoidIntegrator (org.hipparchus.analysis.integration.TrapezoidIntegrator)1