Skip to content

Commit

Permalink
WIP #932 StackOverflowError - check if filterNIL method is not empty
Browse files Browse the repository at this point in the history
  • Loading branch information
axkr committed Mar 10, 2024
1 parent 0dd1f4b commit 69e64a2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5498,9 +5498,13 @@ public static Optional<IExpr[]> fractionalPartsPower(final IAST powerAST, boolea
// base ^ (a+b+c...)
IAST plusAST = (IAST) exponent;
IAST[] result = plusAST.filterNIL(AbstractFunctionEvaluator::getNormalizedNegativeExpression);
parts[1] = base.power(result[0].oneIdentity0());
parts[0] = base.power(result[1].oneIdentity0());
return Optional.of(parts);
IAST plus = result[0];
if (plus.argSize() > 0) {
parts[1] = base.power(plus.oneIdentity0());
parts[0] = base.power(result[1].oneIdentity0());
return Optional.of(parts);
}
return Optional.empty();
}
IExpr positiveExpr = AbstractFunctionEvaluator.getNormalizedNegativeExpression(exponent);
if (positiveExpr.isPresent()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,14 @@ public void testDot() {
check("Norm(a)^2", //
"12");
}
@Test
public void testDotIssue932() {
// issue #932 StackOverflowError
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}}", //
"{{-1+2^m,2-2^m,2-2^m},\n" //
+ " {0,3-2^m,4-2^(1+m)},\n" //
+ " {0,-2+2^m,-2+2^(1+m)}}");
}

@Test
public void testEigensystem() {
Expand Down

0 comments on commit 69e64a2

Please sign in to comment.