use of org.matheclipse.core.eval.EvalEngine in project symja_android_library by axkr.
the class IntervalSym method abs.
public static IExpr abs(final IAST ast) {
IAST interval = normalize(ast);
if (interval.isPresent()) {
IASTAppendable result = F.IntervalAlloc(interval.size());
EvalEngine engine = EvalEngine.get();
for (int i = 1; i < interval.size(); i++) {
IAST list = (IAST) interval.get(i);
IExpr min = list.arg1();
IExpr max = list.arg2();
if (min.isRealResult() && max.isRealResult()) {
result.append(F.list(mig(min, max, engine), mag(min, max, engine)));
} else {
return F.NIL;
}
}
return result;
}
return F.NIL;
}
use of org.matheclipse.core.eval.EvalEngine in project symja_android_library by axkr.
the class IntervalSym method sin.
public static IAST sin(final IAST ast) {
EvalEngine engine = EvalEngine.get();
return mutableProcessorConditions(ast, (min, max, result, index) -> {
IAST difference = F.Subtract(max, min);
if (engine.evalGreaterEqual(difference, F.C2Pi)) {
// difference >= 2 * Pi
result.append(index, F.list(F.CN1, F.C1));
} else {
// slope from 1st derivative
double dMin = engine.evalDouble(F.Cos(min));
double dMax = engine.evalDouble(F.Cos(max));
if (engine.evalLessEqual(difference, S.Pi)) {
if (dMin >= 0) {
if (dMax >= 0) {
result.append(index, F.list(F.Sin(min), F.Sin(max)));
} else {
result.append(index, F.list(F.Min(F.Sin(min), F.Sin(max)), F.C1));
}
} else {
if (dMax < 0) {
result.append(index, F.list(F.Sin(max), F.Sin(min)));
} else {
result.append(index, F.list(F.CN1, F.Max(F.Sin(min), F.Sin(max))));
}
}
} else {
// difference between {Pi, 2*Pi}
if (dMin >= 0) {
if (dMax > 0) {
result.append(index, F.list(F.CN1, F.C1));
} else {
result.append(index, F.list(F.Min(F.Sin(min), F.Sin(max)), F.C1));
}
} else {
if (dMax < 0) {
result.append(index, F.list(F.CN1, F.C1));
} else {
result.append(index, F.list(F.CN1, F.Max(F.Sin(min), F.Sin(max))));
}
}
}
}
return true;
});
}
use of org.matheclipse.core.eval.EvalEngine in project symja_android_library by axkr.
the class IntervalSym method log.
public static IAST log(final IAST ast) {
EvalEngine engine = EvalEngine.get();
return mutableProcessorConditions(ast, (min, max, result, index) -> {
if (min.isNonNegativeResult() && max.isNonNegativeResult()) {
min = S.Log.of(engine, min);
max = S.Log.of(engine, max);
result.append(index, F.list(min, max));
return true;
}
return false;
});
}
use of org.matheclipse.core.eval.EvalEngine in project symja_android_library by axkr.
the class IntervalSym method arccot.
public static IExpr arccot(final IAST ast) {
EvalEngine engine = EvalEngine.get();
return mutableProcessorConditions(ast, (min, max, result, index) -> {
if (engine.evalGreaterEqual(min, F.C0) && engine.evalGreaterEqual(max, F.C0)) {
result.append(F.list(F.ArcCot(min), F.ArcCot(max)));
return true;
}
return false;
}, (min, max, result, index) -> {
if (engine.evalLess(min, F.C0) && engine.evalGreaterEqual(max, F.C0)) {
result.append(F.list(F.CNPiHalf, F.ArcCot(min)));
result.append(F.list(F.ArcCot(max), F.CPiHalf));
return true;
}
return false;
}, (min, max, result, index) -> {
if (engine.evalLess(min, F.C0) && engine.evalLess(max, F.C0)) {
result.append(F.list(F.ArcCot(min), F.ArcCot(max)));
return true;
}
return false;
});
}
use of org.matheclipse.core.eval.EvalEngine in project symja_android_library by axkr.
the class RepeatedPattern method matchPatternSequence.
@Override
public boolean matchPatternSequence(final IAST sequence, IPatternMap patternMap, ISymbol optionsPatternHead) {
final int size = sequence.argSize();
if (size < fMin || size > fMax) {
return false;
}
EvalEngine engine = EvalEngine.get();
for (int i = 1; i < sequence.size(); i++) {
if (!fMatcher.testBlank(sequence.get(i), engine)) {
return false;
}
}
return true;
}
Aggregations