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;
}
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);
}
}
}
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());
}
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);
}
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);
}
}
Aggregations