Skip to content

Commit 50f2b40

Browse files
committed
Clean up usage of IBuiltinSymbols #of() and #funEval() methods
1 parent 24f251b commit 50f2b40

40 files changed

Lines changed: 114 additions & 116 deletions

symja_android_library/matheclipse-api/src/main/java/org/matheclipse/api/Pods.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1533,7 +1533,7 @@ private static int integerPods(ArrayNode podsArray, IExpr inExpr, final IInteger
15331533
}
15341534
}
15351535

1536-
IAST range = (IAST) S.Range.of(F.C2, F.C9);
1536+
IAST range = (IAST) S.Range.funEval(F.C2, F.C9);
15371537
inExpr = F.Mod(n, range);
15381538
podOut = engine.evaluate(inExpr);
15391539
// StringBuilder tableForm = new StringBuilder();

symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/builtin/Algebra.java

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2689,17 +2689,8 @@ public IExpr evaluate(IAST ast, int argSize, IExpr[] options, EvalEngine engine,
26892689
IExpr arg2 = ast.arg2();
26902690

26912691
try {
2692-
// IExpr denom1 = S.Denominator.of(engine, arg1);
2693-
// IExpr denom2 = S.Denominator.of(engine, arg2);
2694-
// if (!denom1.isOne() || !denom2.isOne()) {
2695-
// IExpr numer1 = S.Numerator.of(engine, arg1);
2696-
// IExpr numer2 = S.Numerator.of(engine, arg2);
2697-
// arg1 = F.ExpandAll.of(engine, F.Times(numer1, denom2));
2698-
// arg2 = F.ExpandAll.of(engine, F.Times(denom1, numer2));
2699-
// } else {
27002692
arg1 = F.ExpandAll.of(engine, arg1);
27012693
arg2 = F.ExpandAll.of(engine, arg2);
2702-
// }
27032694

27042695
if (arg1.isZero() || arg2.isZero()) {
27052696
return F.NIL;
@@ -2866,17 +2857,9 @@ public IExpr evaluate(IAST ast, int argSize, IExpr[] options, EvalEngine engine,
28662857
}
28672858

28682859
try {
2869-
// IExpr denom1 = S.Denominator.of(engine, arg1);
2870-
// IExpr denom2 = S.Denominator.of(engine, arg2);
2871-
// if (!denom1.isOne() || !denom2.isOne()) {
2872-
// IExpr numer1 = S.Numerator.of(engine, arg1);
2873-
// IExpr numer2 = S.Numerator.of(engine, arg2);
2874-
// arg1 = F.ExpandAll.of(engine,numer1);// F.Times(numer1, denom2));
2875-
// arg2 = F.ExpandAll.of(engine,numer2);// F.Times(denom1, numer2));
2876-
// } else {
28772860
arg1 = F.ExpandAll.of(engine, arg1);
28782861
arg2 = F.ExpandAll.of(engine, arg2);
2879-
// }
2862+
28802863
if (arg2.isZero()) {
28812864
return F.NIL;
28822865
}

symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/builtin/Arithmetic.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2242,7 +2242,7 @@ public IExpr evaluate(final IAST ast, EvalEngine engine) {
22422242
if (directedInfininty.isInfinity()) {
22432243
return F.C0;
22442244
}
2245-
IExpr im = S.Im.of(engine, directedInfininty.arg1());
2245+
IExpr im = S.Im.funEval(engine, directedInfininty.arg1());
22462246
if (im.isNumber()) {
22472247
if (im.isZero()) {
22482248
return F.C0;
@@ -4222,8 +4222,8 @@ private static IExpr powerEBase(final IExpr exponent) {
42224222
IRational t2 = rat.multiply(F.C4).normalize();
42234223
if (t1.isInteger() || t2.isInteger()) {
42244224
// Cos(- I*times) + I*Sin(- I*times)
4225-
return S.Plus.of(F.Cos(F.Times(F.CNI, times)),
4226-
F.Times(F.CI, F.Sin(F.Times(F.CNI, times))));
4225+
IExpr v1 = F.CNI.times(times);
4226+
return S.Plus.of(F.Cos(v1), F.Times(F.CI, F.Sin(v1)));
42274227
}
42284228
}
42294229
}

symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/builtin/ClusteringFunctions.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.matheclipse.core.interfaces.IDistance;
2929
import org.matheclipse.core.interfaces.IEvaluator;
3030
import org.matheclipse.core.interfaces.IExpr;
31+
import org.matheclipse.core.interfaces.IFraction;
3132
import org.matheclipse.core.interfaces.INumber;
3233
import org.matheclipse.core.interfaces.ISymbol;
3334

@@ -317,8 +318,9 @@ public IExpr distance(IExpr arg1, IExpr arg2, EvalEngine engine) {
317318
factorV1.append(v1Arg);
318319
factorV2.append(v2Arg);
319320
}
320-
IExpr timesV1 = S.Times.of(engine, F.QQ(-1, v1Length), factorV1);
321-
IExpr timesV2 = S.Times.of(engine, F.QQ(-1, v1Length), factorV2);
321+
final IFraction v3 = F.QQ(-1, v1Length);
322+
IExpr timesV1 = S.Times.of(engine, v3, factorV1);
323+
IExpr timesV2 = S.Times.of(engine, v3, factorV2);
322324

323325
IASTAppendable plusNumerator = F.PlusAlloc(v1Length);
324326
IASTAppendable plusV1 = F.PlusAlloc(v1Length);

symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/builtin/Combinatoric.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ public IExpr evaluate(final IAST ast, EvalEngine engine) {
551551
if (ast1.size() == 1) {
552552
return F.Cycles(F.CEmptyList);
553553
}
554-
IExpr ordering = S.Ordering.of(engine, ast1);
554+
IExpr ordering = S.Ordering.funEval(engine, ast1);
555555
if (ordering.isList()) {
556556
return CombinatoricUtil.permutationCycles((IAST) ordering);
557557
}

symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/builtin/EllipticIntegrals.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ public IExpr evaluate(IAST ast, EvalEngine engine) {
121121

122122
private static IExpr carlsonRC(EvalEngine engine, IExpr x, IExpr y) {
123123
if (x.equals(y)) {
124-
IExpr reCondition = S.LessEqual.of(engine, F.Re(x), F.C0);
125-
IExpr imCondition = S.Equal.of(engine, F.Im(x), F.C0);
124+
final IExpr reCondition = S.LessEqual.of(engine, F.Re(x), F.C0);
125+
final IExpr imCondition = S.Equal.of(engine, F.Im(x), F.C0);
126126
if (reCondition.isTrue() && imCondition.isTrue()) {
127127
return F.CComplexInfinity;
128128
}

symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/builtin/IntegerFunctions.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ public IExpr evaluate(final IAST ast, EvalEngine engine) {
666666
IExpr result = F.NIL;
667667
int radix = 10;
668668
if (ast.isAST1()) {
669-
result = S.IntegerDigits.of(engine, ast.arg1());
669+
result = S.IntegerDigits.funEval(engine, ast.arg1());
670670
} else if (ast.size() >= 3) {
671671
if (ast.isAST3() && ast.arg3().isList()) {
672672
return ast.arg3().mapThread(ast, 3);
@@ -676,7 +676,7 @@ public IExpr evaluate(final IAST ast, EvalEngine engine) {
676676
if (radix <= 0) {
677677
return F.NIL;
678678
}
679-
result = S.IntegerDigits.of(engine, ast.arg1(), ast.arg2());
679+
result = S.IntegerDigits.funEval(engine, ast.arg1(), ast.arg2());
680680
}
681681
if (result.isList()) {
682682
IAST list = (IAST) result;
@@ -1110,7 +1110,7 @@ public IExpr evaluate(final IAST ast, EvalEngine engine) {
11101110
}
11111111
if (arg1.isQuantity()) {
11121112
IQuantity quantity = (IQuantity) arg1;
1113-
IExpr fractionalPart = S.FractionalPart.of(quantity.value());
1113+
IExpr fractionalPart = S.FractionalPart.funEval(engine, quantity.value());
11141114
return quantity.ofUnit(fractionalPart);
11151115
}
11161116
IExpr negExpr = AbstractFunctionEvaluator.getNormalizedNegativeExpression(arg1);
@@ -1390,7 +1390,7 @@ public IExpr evaluate(final IAST ast, EvalEngine engine) {
13901390
}
13911391
if (arg1.isQuantity()) {
13921392
IQuantity quantity = (IQuantity) arg1;
1393-
IExpr fractionalPart = S.IntegerPart.of(quantity.value());
1393+
IExpr fractionalPart = S.IntegerPart.funEval(engine, quantity.value());
13941394
return quantity.ofUnit(fractionalPart);
13951395
}
13961396

@@ -1549,8 +1549,8 @@ private static IExpr mod(IExpr m, IExpr n, IExpr d, EvalEngine engine) {
15491549
|| n.isComplexNumeric() || d.isComplexNumeric()) {
15501550
// https://mathematica.stackexchange.com/a/114373/21734
15511551
IExpr subExpr = engine.evaluate(F.Divide(F.Subtract(m, d), n));
1552-
IExpr re = S.Round.of(subExpr.re());
1553-
IExpr im = S.Round.of(subExpr.im());
1552+
IExpr re = S.Round.funEval(engine, subExpr.re());
1553+
IExpr im = S.Round.funEval(engine, subExpr.im());
15541554
return F.Plus(m, F.Times(F.CN1, n, re), F.Times(F.CI, im));
15551555
}
15561556
}
@@ -2008,8 +2008,8 @@ private static IExpr quotient(IExpr m, IExpr n, IExpr d, EvalEngine engine) {
20082008
|| n.isComplexNumeric() || d.isComplexNumeric()) {
20092009
// https://mathematica.stackexchange.com/a/114373/21734
20102010
IExpr subExpr = engine.evaluate(F.Divide(F.Subtract(m, d), n));
2011-
IExpr re = S.Round.of(engine, subExpr.re());
2012-
IExpr im = S.Round.of(engine, subExpr.im());
2011+
IExpr re = S.Round.funEval(engine, subExpr.re());
2012+
IExpr im = S.Round.funEval(engine, subExpr.im());
20132013
return F.Plus(re, F.Times(F.CI, im));
20142014
}
20152015
// Floor((-d+m)/n)
@@ -2365,7 +2365,7 @@ private IExpr round(EvalEngine engine, IExpr expr, IExpr k) {
23652365
IExpr n = S.Divide.ofNIL(engine, expr, k);
23662366
if (n.isPresent()) {
23672367
if (n.isRealResult() || n.isComplex() || n.isComplexNumeric()) {
2368-
n = S.Round.of(engine, n);
2368+
n = S.Round.ofNIL(engine, n);
23692369
if (n.isPresent()) {
23702370
return F.Times(n, k);
23712371
}

symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/builtin/LinearAlgebra.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3239,8 +3239,8 @@ private static class LeastSquares extends AbstractFunctionEvaluator {
32393239
@Override
32403240
public IExpr evaluate(final IAST ast, EvalEngine engine) {
32413241
if (ast.arg1().isMatrix() != null && ast.arg2().isVector() >= 0) {
3242-
IAST matrix = (IAST) ast.arg1().normal(false);
3243-
IAST vector = (IAST) ast.arg2().normal(false);
3242+
final IAST matrix = (IAST) ast.arg1().normal(false);
3243+
final IAST vector = (IAST) ast.arg2().normal(false);
32443244
if (matrix.isList() && vector.isList()) {
32453245
try {
32463246
if (matrix.isNumericMode() || vector.isNumericMode()) {
@@ -3269,8 +3269,8 @@ public IExpr evaluate(final IAST ast, EvalEngine engine) {
32693269
return Errors.printMessage(ast.topHead(), e, engine);
32703270
}
32713271
try {
3272-
IAST matrixTransposed = (IAST) S.ConjugateTranspose.of(engine, matrix);
3273-
return F.Expand(F.LinearSolve(F.ConjugateTranspose(F.Dot(matrixTransposed, matrix)),
3272+
IAST matrixTransposed = (IAST) S.ConjugateTranspose.funEval(engine, matrix);
3273+
return F.Expand.of(F.LinearSolve(F.ConjugateTranspose(F.Dot(matrixTransposed, matrix)),
32743274
F.Dot(matrixTransposed, vector)));
32753275
} catch (final ClassCastException | IndexOutOfBoundsException e) {
32763276
return Errors.printMessage(ast.topHead(), e, engine);

symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/builtin/ManipulateFunction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2027,7 +2027,7 @@ public IExpr evaluate(final IAST ast, EvalEngine engine) {
20272027

20282028
private static IExpr redirectToManipulate(final IAST ast, EvalEngine engine) {
20292029
if (Config.USE_MANIPULATE_JS) {
2030-
IExpr temp = S.Manipulate.of(engine, ast);
2030+
IExpr temp = S.Manipulate.funEval(engine, ast);
20312031
if (temp.headID() == ID.JSFormData) {
20322032
return temp;
20332033
}

symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/builtin/MinMaxFunctions.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2006,19 +2006,19 @@ private static IExpr maximize(ISymbol head, IExpr function, IExpr x, EvalEngine
20062006
return temp;
20072007
}
20082008

2009-
IExpr yNInf = S.Limit.of(function, F.Rule(x, F.CNInfinity));
2009+
IExpr yNInf = S.Limit.funEval(function, F.Rule(x, F.CNInfinity));
20102010
if (yNInf.isInfinity()) {
20112011
LOGGER.log(engine.getLogLevel(), "{}: the maximum cannot be found.", head);
20122012
return F.list(F.CInfinity, F.list(F.Rule(x, F.CNInfinity)));
20132013
}
2014-
IExpr yInf = S.Limit.of(function, F.Rule(x, F.CInfinity));
2014+
IExpr yInf = S.Limit.funEval(function, F.Rule(x, F.CInfinity));
20152015
if (yInf.isInfinity()) {
20162016
LOGGER.log(engine.getLogLevel(), "{}: the maximum cannot be found.", head);
20172017
return F.list(F.CInfinity, F.list(F.Rule(x, F.CInfinity)));
20182018
}
20192019

20202020
IExpr first_derivative = S.D.of(engine, function, x);
2021-
IExpr second_derivative = S.D.of(engine, first_derivative, x);
2021+
IExpr second_derivative = S.D.funEval(engine, first_derivative, x);
20222022
IExpr candidates = S.Solve.of(engine, F.Equal(first_derivative, F.C0), x, S.Reals);
20232023
if (candidates.isFree(S.Solve)) {
20242024
IExpr maxCandidate = F.NIL;
@@ -2167,19 +2167,19 @@ private static final IExpr minimize(ISymbol head, IExpr function, IExpr x, EvalE
21672167
return temp;
21682168
}
21692169

2170-
IExpr yNInf = S.Limit.of(function, F.Rule(x, F.CNInfinity));
2170+
IExpr yNInf = S.Limit.funEval(function, F.Rule(x, F.CNInfinity));
21712171
if (yNInf.isNegativeInfinity()) {
21722172
LOGGER.log(engine.getLogLevel(), "{}: the maximum cannot be found.", head);
21732173
return F.list(F.CNInfinity, F.list(F.Rule(x, F.CNInfinity)));
21742174
}
2175-
IExpr yInf = S.Limit.of(function, F.Rule(x, F.CInfinity));
2175+
IExpr yInf = S.Limit.funEval(function, F.Rule(x, F.CInfinity));
21762176
if (yInf.isNegativeInfinity()) {
21772177
LOGGER.log(engine.getLogLevel(), "{}: the maximum cannot be found.", head);
21782178
return F.list(F.CNInfinity, F.list(F.Rule(x, F.CInfinity)));
21792179
}
21802180

21812181
IExpr first_derivative = S.D.of(engine, function, x);
2182-
IExpr second_derivative = S.D.of(engine, first_derivative, x);
2182+
IExpr second_derivative = S.D.funEval(engine, first_derivative, x);
21832183
IExpr candidates = S.Solve.of(engine, F.Equal(first_derivative, F.C0), x, S.Reals);
21842184
if (candidates.isFree(S.Solve)) {
21852185
IExpr minCandidate = F.NIL;

0 commit comments

Comments
 (0)