mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[poincare/power] Fix infinite loop in reduction
Fix the broken simplification test 1/identity(2)^500
This commit is contained in:
@@ -439,6 +439,12 @@ Expression Power::shallowReduce(ExpressionNode::ReductionContext reductionContex
|
||||
if (exponent.isNegative()) {
|
||||
index.setSign(ExpressionNode::Sign::Positive, reductionContext);
|
||||
Expression reducedPositiveExponentMatrix = shallowReduce(reductionContext);
|
||||
if (reducedPositiveExponentMatrix.type() == ExpressionNode::Type::Power) {
|
||||
/* The shallowReduce did not work, stop here so we do not get in an
|
||||
* infinite loop. */
|
||||
static_cast<Power &>(reducedPositiveExponentMatrix).childAtIndex(1).setSign(ExpressionNode::Sign::Negative, reductionContext);
|
||||
return reducedPositiveExponentMatrix;
|
||||
}
|
||||
Expression dummyExpression = Undefined::Builder();
|
||||
MatrixInverse inv = MatrixInverse::Builder(dummyExpression);
|
||||
reducedPositiveExponentMatrix.replaceWithInPlace(inv);
|
||||
|
||||
Reference in New Issue
Block a user