diff --git a/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/builtin/Algebra.java b/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/builtin/Algebra.java index b45816e95..482642c19 100644 --- a/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/builtin/Algebra.java +++ b/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/builtin/Algebra.java @@ -561,15 +561,15 @@ private static void calculateNumeratorGCD(IExpr arg, int position, IASTAppendabl */ private static Optional cancelPlusIntegerGCD(IAST numeratorPlus, IInteger denominator) { - IASTAppendable plus = numeratorPlus.copyAppendable(); - IASTAppendable gcd = F.ast(S.GCD, plus.size() + 1); + IASTAppendable gcd = F.ast(S.GCD, numeratorPlus.size() + 1); gcd.append(denominator); - boolean evaled = !plus.exists((IExpr x) -> collectGCDFactors(x, gcd)); + boolean evaled = !numeratorPlus.exists((IExpr x) -> collectGCDFactors(x, gcd)); if (evaled) { // GCD() has attribute Orderless, so the arguments will // be sorted by evaluation! IExpr igcd = F.eval(gcd); if (igcd.isInteger() && !igcd.isOne()) { + IASTAppendable plus = numeratorPlus.copyAppendable(); return calculatePlusIntegerGCD(plus, denominator, (IInteger) igcd); } } @@ -615,7 +615,7 @@ private static IExpr cancelPowerTimes(IExpr powerTimesAST, EvalEngine engine) IExpr p10 = parts.get()[1]; IExpr p11 = F.C1; if (p00.isPlus()) { - IAST numParts = ((IAST) p00).partitionPlus(x -> isPolynomial(x), F.C0, F.C1, S.List); + IAST numParts = p00.partitionPlus(x -> isPolynomial(x), F.C0, F.C1, S.List); if (numParts.isPresent() && !numParts.arg1().isOne()) { p00 = numParts.arg1(); p01 = numParts.arg2(); @@ -623,7 +623,7 @@ private static IExpr cancelPowerTimes(IExpr powerTimesAST, EvalEngine engine) } if (p10.isPlus()) { - IAST denParts = ((IAST) p10).partitionPlus(x -> isPolynomial(x), F.C0, F.C1, S.List); + IAST denParts = p10.partitionPlus(x -> isPolynomial(x), F.C0, F.C1, S.List); if (denParts.isPresent() && !denParts.arg1().isOne()) { p10 = denParts.arg1(); p11 = denParts.arg2(); @@ -918,8 +918,9 @@ private IExpr collectSingleVariableRecursive(IExpr expr, IExpr x, final IAST lis // "rest" variable IPatternSequence blankNullRest = F.$ps(F.Dummy("§rest§" + EvalEngine.incModuleCounter()), true); - IASTAppendable newLHS = ((IAST) x).copyAppendable(); - newLHS.append(blankNullRest); + IASTAppendable newLHS = ((IAST) x).appendClone(blankNullRest); + // newLHS.append(blankNullRest); + final IPatternMatcher matcher = engine.evalPatternMatcher(newLHS); collectTimesToMap(x, poly, matcher, defaultdict, rest, blankNullRest); @@ -1271,8 +1272,8 @@ public void distributePositionRecursive(IASTAppendable stepResult, int position) } private void distributeStep(IExpr x, IAST stepResult, int position) { - IASTAppendable res2 = stepResult.copyAppendable(); - res2.append(x); + IASTAppendable res2 = stepResult.appendClone(x); + // res2.append(x); distributePositionRecursive(res2, position + 1); } } @@ -4233,7 +4234,7 @@ public IExpr evaluate(final IAST ast, EvalEngine engine) { } if (arg1.isAST()) { ToRadicalsVisitor visitor = new ToRadicalsVisitor(ast); - temp = ((IAST) arg1).accept(visitor); + temp = arg1.accept(visitor); if (temp.isPresent()) { return temp; } @@ -5012,9 +5013,8 @@ public static IExpr cancelFractionalParts(IExpr powerTimesAST) throws JASConvers } if (numerator.isPlus() && denominator.isPlus()) { - IAST numParts = ((IAST) numerator).partitionPlus(x -> isPolynomial(x), F.C0, F.C1, S.List); - IAST denParts = - ((IAST) denominator).partitionPlus(x -> isPolynomial(x), F.C0, F.C1, S.List); + IAST numParts = numerator.partitionPlus(x -> isPolynomial(x), F.C0, F.C1, S.List); + IAST denParts = denominator.partitionPlus(x -> isPolynomial(x), F.C0, F.C1, S.List); if (denParts.isPresent() && !denParts.arg1().isOne()) { Optional result = cancelGCD(numParts.arg1(), denParts.arg1()); if (result.isPresent()) { diff --git a/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/builtin/Arithmetic.java b/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/builtin/Arithmetic.java index 940eda551..bae606942 100644 --- a/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/builtin/Arithmetic.java +++ b/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/builtin/Arithmetic.java @@ -3613,7 +3613,7 @@ public static IExpr binaryOperator(IAST ast, final IExpr base, final IExpr expon IExpr x = ((IAST) base).arg1(); IExpr mNeg = exponent.negate(); boolean disabledTrigRules = engine.isDisabledTrigRules(); - int id = ((IAST) base).headID(); + int id = base.headID(); switch (id) { case ID.Tan: // Tan(x_)^m_?(IntegerQ(#)&&#<0 &):=Cot(x)^(-m), @@ -4153,7 +4153,7 @@ private static IExpr powerRealBaseOrRealExponent(final IExpr base, final IExpr e } try { long n = ((IInteger) exponent).toLong(); - return ((INumber) base).power(n); + return base.power(n); } catch (ArithmeticException ae) { } diff --git a/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/builtin/BooleanFunctions.java b/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/builtin/BooleanFunctions.java index 0ffa68386..7d5326b50 100644 --- a/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/builtin/BooleanFunctions.java +++ b/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/builtin/BooleanFunctions.java @@ -2242,15 +2242,14 @@ public IExpr evaluate(IAST ast, EvalEngine engine) { } boolean evaled = false; - IASTAppendable result = astEvaled.copyAppendable(); IExpr.COMPARE_TERNARY[] cResult = new IExpr.COMPARE_TERNARY[astEvaled.size()]; cResult[0] = IExpr.COMPARE_TERNARY.TRUE; for (int i = 1; i < astEvaled.argSize(); i++) { - IExpr arg = result.get(i); + IExpr arg = astEvaled.get(i); if (arg.equals(S.Undefined)) { return S.Undefined; } - final IExpr.COMPARE_TERNARY b = prepareCompare(arg, result.get(i + 1), engine); + final IExpr.COMPARE_TERNARY b = prepareCompare(arg, astEvaled.get(i + 1), engine); if (b == IExpr.COMPARE_TERNARY.FALSE) { return S.False; } @@ -2266,6 +2265,7 @@ public IExpr evaluate(IAST ast, EvalEngine engine) { } int i = 2; evaled = false; + IASTAppendable result = astEvaled.copyAppendable(); for (int j = 1; j < astEvaled.size(); j++) { if (cResult[j - 1] == IExpr.COMPARE_TERNARY.TRUE && cResult[j] == IExpr.COMPARE_TERNARY.TRUE) { diff --git a/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/builtin/Combinatoric.java b/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/builtin/Combinatoric.java index e930624f3..429a8d335 100644 --- a/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/builtin/Combinatoric.java +++ b/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/builtin/Combinatoric.java @@ -157,8 +157,8 @@ public synchronized IAST next() { if (empty) { throw new RuntimeException("invalid call of next()"); } - // IAST res = (IAST) current.clone(); - IAST res = current.copyAppendable(); + + final IAST res = current.copy(); // search iterator which hasNext int i = compit.size() - 1; for (; i >= 0; i--) { @@ -2687,10 +2687,9 @@ private static void tuples(final IAST originalList, final int n, IASTAppendable RecursionLimitExceeded.throwIt(counter, ast); } } - IASTAppendable temp; for (int j = 1; j < originalList.size(); j++) { - temp = subResult.copyAppendable(); - temp.append(originalList.get(j)); + IASTAppendable temp = subResult.appendClone(originalList.get(j)); + // temp.append(originalList.get(j)); tuples(originalList, n - 1, result, temp, ast, engine); } } finally { diff --git a/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/builtin/ListFunctions.java b/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/builtin/ListFunctions.java index 3c7c22b28..570b545cd 100644 --- a/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/builtin/ListFunctions.java +++ b/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/builtin/ListFunctions.java @@ -984,7 +984,7 @@ public MultipleArrayFunction(final EvalEngine engine, final IAST headAST) { @Override public IExpr evaluate(final ISymbol[] variables, final IExpr[] index) { - final IASTAppendable ast = fHeadAST.copyAppendable(); + final IASTAppendable ast = fHeadAST.copyAppendable(index.length); return fEngine.evaluate(ast.appendArgs(0, index.length, i -> index[i])); } } diff --git a/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/builtin/ManipulateFunction.java b/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/builtin/ManipulateFunction.java index e36a6b6c4..16ad1675d 100644 --- a/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/builtin/ManipulateFunction.java +++ b/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/builtin/ManipulateFunction.java @@ -674,7 +674,7 @@ private static void setBoxRatios(StringBuilder graphicControl, double[] rangeXY) private static IExpr sliderWithFormulas(IExpr formula, IAST sliderRange, EvalEngine engine) { JavaScriptFormFactory toJS = new JavaScriptFormFactory(true, false, -1, -1, JavaScriptFormFactory.USE_MATHCELL); - IASTAppendable newsliderRange = sliderRange.copyAppendable(); + IASTAppendable newsliderRange = sliderRange.copyAppendable(1); double stepValue = 1.0; double minValue = sliderRange.arg2().evalf(); double maxValue = sliderRange.arg3().evalf(); diff --git a/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/builtin/OutputFunctions.java b/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/builtin/OutputFunctions.java index 5dcb808c4..43cea6c17 100644 --- a/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/builtin/OutputFunctions.java +++ b/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/builtin/OutputFunctions.java @@ -584,8 +584,7 @@ public IExpr evaluate(final IAST ast, EvalEngine engine) { } IExpr arg1 = ast.arg1(); if (arg1.isFunctionID(ID.Plot, ID.ParametricPlot, ID.ParametricPlot)) { - IASTAppendable temp = ((IAST) arg1).copyAppendable(); - temp.append(F.Rule(S.JSForm, S.True)); + IASTAppendable temp = ((IAST) arg1).appendClone(F.Rule(S.JSForm, S.True)); arg1 = temp; } arg1 = engine.evaluate(arg1); diff --git a/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/builtin/SeriesFunctions.java b/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/builtin/SeriesFunctions.java index 2575d7529..468b1a925 100644 --- a/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/builtin/SeriesFunctions.java +++ b/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/builtin/SeriesFunctions.java @@ -974,7 +974,7 @@ private static IExpr powerLimit(final IAST powerAST, LimitData data, EvalEngine } } if (base.isTimes()) { - IAST isFreeResult = ((IAST) base).partitionTimes(x -> x.isFree(data.variable(), true), + IAST isFreeResult = base.partitionTimes(x -> x.isFree(data.variable(), true), F.C1, F.C1, S.List); if (!isFreeResult.arg2().isOne()) { return F.Times(F.Power(isFreeResult.arg1(), exponent), @@ -1886,7 +1886,7 @@ public static IExpr polynomialSeriesCoefficient(IExpr univariatePolynomial, IExp } } for (int i = 1; i < rest.size(); i++) { - IASTAppendable term = seriesTemplate.copyAppendable(); + IASTMutable term = seriesTemplate.copy(); term.set(1, rest.get(i)); coefficientPlus.append(term); } diff --git a/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/builtin/StructureFunctions.java b/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/builtin/StructureFunctions.java index e39e438b4..1b9ffc627 100644 --- a/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/builtin/StructureFunctions.java +++ b/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/builtin/StructureFunctions.java @@ -191,7 +191,7 @@ public IExpr evaluate(IAST ast, EvalEngine engine) { if (ast.argSize() < 2 || ast.argSize() > 4) { return Errors.printArgMessage(ast, ARGS_2_4, engine); } - IASTAppendable evaledAST = ast.copyAppendable(); + IASTMutable evaledAST = ast.copy(); evaledAST.setArgs(evaledAST.size(), (int i) -> engine.evaluate(evaledAST.get(i))); int lastIndex = evaledAST.argSize(); @@ -575,7 +575,7 @@ public IExpr evaluate(IAST ast, EvalEngine engine) { int[] positions = null; if (arg2.isInteger()) { positions = new int[1]; - positions[0] = ((IInteger) arg2).toIntDefault(); + positions[0] = arg2.toIntDefault(); if (positions[0] == Integer.MIN_VALUE) { return F.NIL; } @@ -2211,7 +2211,7 @@ public static IAST threadList(final IAST list, IExpr head, IExpr mapHead) { int listLength = -1; for (int i = 1; i < list.size(); i++) { - if ((list.get(i).isAST()) && (((IAST) list.get(i)).head().equals(head))) { + if ((list.get(i).isAST()) && (list.get(i).head().equals(head))) { if (listLength == -1) { listLength = ((IAST) list.get(i)).argSize(); } else { diff --git a/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/combinatoric/KPartitionsList.java b/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/combinatoric/KPartitionsList.java index b9ae0471c..4cc52a61a 100644 --- a/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/combinatoric/KPartitionsList.java +++ b/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/combinatoric/KPartitionsList.java @@ -36,10 +36,9 @@ public IAST next() { return null; } IASTAppendable part = fResultList.copyAppendable(); - IASTAppendable temp; int j = 0; for (int i = 1; i < partitionsIndex.length; i++) { - temp = fResultList.copyAppendable(); + IASTAppendable temp = fResultList.copyAppendable(); for (int m = j; m < partitionsIndex[i]; m++) { temp.append(fList.get(m + fOffset)); } @@ -47,7 +46,7 @@ public IAST next() { part.append(temp); } - temp = fResultList.copyAppendable(); + IASTAppendable temp = fResultList.copyAppendable(); int n = fList.size() - fOffset; for (int m = j; m < n; m++) { temp.append(fList.get(m + fOffset)); diff --git a/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/eval/interfaces/AbstractFunctionEvaluator.java b/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/eval/interfaces/AbstractFunctionEvaluator.java index 0ca552f6d..2c6845032 100644 --- a/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/eval/interfaces/AbstractFunctionEvaluator.java +++ b/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/eval/interfaces/AbstractFunctionEvaluator.java @@ -173,7 +173,7 @@ public static IExpr extractImaginaryUnit(final IExpr expression) { */ public static IExpr extractImaginaryUnit(final IExpr expression, boolean checkTimes) { if (expression.isNumber()) { - if (((INumber) expression).isImaginaryUnit()) { + if (expression.isImaginaryUnit()) { return F.C1; } if ((expression.isComplex() || expression.isComplexNumeric())// @@ -186,7 +186,7 @@ public static IExpr extractImaginaryUnit(final IExpr expression, boolean checkTi IAST timesAST = ((IAST) expression); IExpr arg1 = timesAST.arg1(); if (arg1.isNumber()) { - if (((INumber) arg1).isImaginaryUnit()) { + if (arg1.isImaginaryUnit()) { return timesAST.rest().oneIdentity1(); } if ((arg1.isComplex() || arg1.isComplexNumeric())// diff --git a/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/expression/AbstractAST.java b/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/expression/AbstractAST.java index e296e3842..73489fe71 100644 --- a/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/expression/AbstractAST.java +++ b/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/expression/AbstractAST.java @@ -1466,7 +1466,7 @@ public final IAST addEvalFlags(final int i) { /** {@inheritDoc} */ @Override public IASTAppendable appendAtClone(int position, IExpr expr) { - IASTAppendable ast = copyAppendable(); + IASTAppendable ast = copyAppendable(1); ast.append(position, expr); return ast; } @@ -5172,7 +5172,11 @@ public IAST map(final Function function, final int start temp = function.apply(get(i)); if (temp.isPresent()) { // something was evaluated - return a new IAST: - result = copyAppendable(); + if (i > 1) { + result = copy(); + } else { + result = copyAppendable(); + } result.set(i++, temp); break; } @@ -5216,7 +5220,11 @@ public IAST mapLeaf(IExpr testHead, final Function function, } if (temp.isPresent()) { // something was evaluated - return a new IAST: - result = copyAppendable(); + if (i > 0) { + result = copy(); + } else { + result = copyAppendable(); + } result.set(i++, temp); } if (result.isPresent()) { diff --git a/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/generic/Predicates.java b/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/generic/Predicates.java index a1c0171b4..31b885b7e 100644 --- a/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/generic/Predicates.java +++ b/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/generic/Predicates.java @@ -302,8 +302,7 @@ public static Predicate toFreeQ(IExpr pattern) { if (pattern.isOrderlessAST() && pattern.isFreeOfPatterns()) { // append a BlankNullSequence[] to match the parts of an Orderless expression IPatternSequence blankNullRest = F.$ps(null, true); - IASTAppendable newPattern = ((IAST) pattern).copyAppendable(); - newPattern.append(blankNullRest); + IASTAppendable newPattern = ((IAST) pattern).appendClone(blankNullRest); matcher = new PatternMatcher(newPattern); } else { matcher = new PatternMatcher(pattern); diff --git a/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/patternmatching/Matcher.java b/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/patternmatching/Matcher.java index a755f7782..194a1262a 100644 --- a/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/patternmatching/Matcher.java +++ b/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/patternmatching/Matcher.java @@ -10,7 +10,6 @@ import org.matheclipse.core.expression.F; import org.matheclipse.core.expression.S; import org.matheclipse.core.interfaces.IAST; -import org.matheclipse.core.interfaces.IASTAppendable; import org.matheclipse.core.interfaces.IASTMutable; import org.matheclipse.core.interfaces.IExpr; import org.matheclipse.core.interfaces.IPattern; @@ -51,13 +50,13 @@ public IExpr visit(IASTMutable ast) { return temp; } } - IASTAppendable result = F.NIL; + IASTMutable result = F.NIL; int i = 1; while (i < list.size()) { temp = list.get(i).accept(this); if (temp.isPresent()) { // something was evaluated - return a new IAST: - result = list.copyAppendable(); + result = list.copy(); result.set(i++, temp); break; } diff --git a/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/polynomials/longexponent/ExprPolynomialRing.java b/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/polynomials/longexponent/ExprPolynomialRing.java index 77d4d68d1..8f4acb2e1 100644 --- a/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/polynomials/longexponent/ExprPolynomialRing.java +++ b/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/polynomials/longexponent/ExprPolynomialRing.java @@ -312,7 +312,7 @@ public ExprPolynomialRing(ExprRingFactory cf, IAST listOfVariables, int n, ExprT nvar = n; tord = t; partial = false; - vars = listOfVariables.copyAppendable(); + vars = listOfVariables.copy(); ZERO = new ExprPolynomial(this); IExpr coeff = coFac.getONE(); evzero = new ExpVectorLong(nvar); @@ -910,7 +910,7 @@ public IAST setVars(IAST v) { "v not matching number of variables: " + v.toString() + ", nvar " + nvar); } IAST t = vars; - vars = v.copyAppendable(); // Arrays.copyOf(v, v.length); // > Java-5 + vars = v.copy(); // Arrays.copyOf(v, v.length); // > Java-5 return t; } diff --git a/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/polynomials/symbolicexponent/SymbolicPolynomialRing.java b/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/polynomials/symbolicexponent/SymbolicPolynomialRing.java index fe1788c34..098f693e9 100644 --- a/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/polynomials/symbolicexponent/SymbolicPolynomialRing.java +++ b/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/polynomials/symbolicexponent/SymbolicPolynomialRing.java @@ -378,7 +378,7 @@ public SymbolicPolynomialRing(ExprRingFactory cf, IAST listOfVariables, int n, nvar = n; tord = t; partial = false; - vars = listOfVariables.copyAppendable(); + vars = listOfVariables.copy(); ZERO = new SymbolicPolynomial(this); IExpr coeff = coFac.getONE(); evzero = new ExpVectorSymbolic(nvar); @@ -968,7 +968,7 @@ public IAST setVars(IAST v) { "v not matching number of variables: " + v.toString() + ", nvar " + nvar); } IAST t = vars; - vars = v.copyAppendable(); // Arrays.copyOf(v, v.length); // > Java-5 + vars = v.copy(); // Arrays.copyOf(v, v.length); // > Java-5 return t; } diff --git a/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/reflection/system/D.java b/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/reflection/system/D.java index 31cfc7530..60294dd47 100644 --- a/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/reflection/system/D.java +++ b/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/reflection/system/D.java @@ -286,7 +286,7 @@ private static IAST createDerivativeN(final IExpr header, final IAST args, IExpr private static IAST addDerivative(final int pos, IAST deriveHead, final IExpr header, final IAST args) { - IASTMutable derivativeHead1 = deriveHead.copyAppendable(); + IASTMutable derivativeHead1 = deriveHead.copy(); for (int i = 1; i < derivativeHead1.size(); i++) { if (i == pos) { derivativeHead1.set(i, derivativeHead1.get(i).inc()); diff --git a/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/reflection/system/Integrate.java b/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/reflection/system/Integrate.java index 2a7bdec7a..c932b3b0a 100644 --- a/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/reflection/system/Integrate.java +++ b/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/reflection/system/Integrate.java @@ -88,6 +88,7 @@ public class Integrate extends AbstractFunctionOptionEvaluator { private static final Logger LOGGER = LogManager.getLogger(); + private static Thread INIT_THREAD = null; private static final CountDownLatch COUNT_DOWN_LATCH = new CountDownLatch(1); @@ -350,7 +351,6 @@ public IExpr evaluate(IAST holdallAST, final int argSize, final IExpr[] option, } boolean showSteps = false; if (showSteps) { - LOGGER.info(arg1); // if (DEBUG_EXPR.contains(arg1)) { // System.exit(-1); // } @@ -820,11 +820,6 @@ private static IExpr integrateByRubiRules(IAST arg1, IExpr x, IAST ast, EvalEngi IExpr temp = S.Integrate.evalDownRule(EvalEngine.get(), ast); if (temp.isPresent()) { if (temp.equals(ast)) { - if (LOGGER.isDebugEnabled()) { - engine.setQuietMode(false); - Errors.printMessage(S.Integrate, "rubiendless", - F.list(temp, F.stringx("UNKNOWN")), engine); - } return F.NIL; } if (temp.isAST()) { diff --git a/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/visit/VisitorReplaceArgs.java b/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/visit/VisitorReplaceArgs.java index fd55b2463..0e2184028 100644 --- a/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/visit/VisitorReplaceArgs.java +++ b/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/visit/VisitorReplaceArgs.java @@ -2,7 +2,6 @@ import org.matheclipse.core.expression.F; import org.matheclipse.core.interfaces.IAST; -import org.matheclipse.core.interfaces.IASTAppendable; import org.matheclipse.core.interfaces.IASTMutable; import org.matheclipse.core.interfaces.IExpr; import org.matheclipse.core.interfaces.ISymbol; @@ -33,7 +32,7 @@ public IExpr visit(ISymbol element) { @Override public IExpr visit(IASTMutable ast) { IExpr temp; - IASTAppendable result = F.NIL; + IASTMutable result = F.NIL; int size = ast.size(); boolean evaled = false; for (int i = 1; i < size; i++) { @@ -42,7 +41,7 @@ public IExpr visit(IASTMutable ast) { for (int j = 1; i < astSlots.size(); i++) { if (astSlots.get(j).equals(temp)) { if (result.isNIL()) { - result = ast.copyAppendable(); + result = ast.copy(); } result.set(i, F.Slot(F.ZZ(j))); evaled = true; @@ -55,7 +54,7 @@ public IExpr visit(IASTMutable ast) { if (temp.isPresent()) { if (result.isNIL()) { // something was evaluated - return a new IAST: - result = ast.copyAppendable(); + result = ast.copy(); } result.set(i, temp); } diff --git a/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/visit/VisitorReplacePart.java b/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/visit/VisitorReplacePart.java index 26b661dc4..c5c028283 100644 --- a/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/visit/VisitorReplacePart.java +++ b/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/visit/VisitorReplacePart.java @@ -189,24 +189,23 @@ private IASTAppendable patternIndexRecursive(IPatternMatcher matcher, IAST ast, if (matcher.getLHS().isSequence()) { IExpr temp = matcher.eval(positionsToMatch, engine); if (temp.isPresent()) { - if (result.isNIL()) { + if (position == 0 && ast.isAssociation()) { + result = ((IAssociation) ast).copyAST(); + } else if (result.isNIL()) { result = ast.copyAppendable(); } - if (position == 0 && result.isAssociation()) { - result = ((IAssociation) result).copyAST(); - } result.setValue(position, temp); return result; } else { if (ast.get(position).isASTOrAssociation()) { temp = visitPatternIndexList((IAST) ast.get(position), positionsToMatch); if (temp.isPresent()) { - if (result.isNIL()) { + if (position == 0 && ast.isAssociation()) { + result = ((IAssociation) ast).copyAST(); + } else if (result.isNIL()) { result = ast.copyAppendable(); } - if (position == 0 && result.isAssociation()) { - result = ((IAssociation) result).copyAST(); - } + result.setValue(position, temp); return result; }