Skip to content

Commit 69e64a2

Browse files
committed
WIP #932 StackOverflowError - check if filterNIL method is not empty
1 parent 0dd1f4b commit 69e64a2

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

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

+7-3
Original file line numberDiff line numberDiff line change
@@ -5498,9 +5498,13 @@ public static Optional<IExpr[]> fractionalPartsPower(final IAST powerAST, boolea
54985498
// base ^ (a+b+c...)
54995499
IAST plusAST = (IAST) exponent;
55005500
IAST[] result = plusAST.filterNIL(AbstractFunctionEvaluator::getNormalizedNegativeExpression);
5501-
parts[1] = base.power(result[0].oneIdentity0());
5502-
parts[0] = base.power(result[1].oneIdentity0());
5503-
return Optional.of(parts);
5501+
IAST plus = result[0];
5502+
if (plus.argSize() > 0) {
5503+
parts[1] = base.power(plus.oneIdentity0());
5504+
parts[0] = base.power(result[1].oneIdentity0());
5505+
return Optional.of(parts);
5506+
}
5507+
return Optional.empty();
55045508
}
55055509
IExpr positiveExpr = AbstractFunctionEvaluator.getNormalizedNegativeExpression(exponent);
55065510
if (positiveExpr.isPresent()) {

symja_android_library/matheclipse-core/src/test/java/org/matheclipse/core/system/LinearAlgebraTestCase.java

+8
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,14 @@ public void testDot() {
504504
check("Norm(a)^2", //
505505
"12");
506506
}
507+
@Test
508+
public void testDotIssue932() {
509+
// issue #932 StackOverflowError
510+
check("{{0,1,-1+2^m},{1-2^m,2,-1+2^m},{2^m,-2,-2^m}}.{{1,0,1},{0,1,1},{1,-1,-1}}", //
511+
"{{-1+2^m,2-2^m,2-2^m},\n" //
512+
+ " {0,3-2^m,4-2^(1+m)},\n" //
513+
+ " {0,-2+2^m,-2+2^(1+m)}}");
514+
}
507515

508516
@Test
509517
public void testEigensystem() {

0 commit comments

Comments
 (0)