mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[poincare] When simplification has been interrupted, escape the end of
simplification. Otherwise we can be stuck in infinite loop. This fixes the following bug: when simplifying an expression as 'bigRational1^x*bigRational2^x', we use the rule a^x*b^x --> (a¨b)^x. However, in this case, a*b can't be reduce (resulting rational would be too big) and we're stuck in the loop a^x*b^x --> (a¨b)^x --> a^x*b^x --> (a¨b)^x...
This commit is contained in:
committed by
LeaNumworks
parent
c0f73e97d2
commit
7c79c70890
@@ -321,18 +321,22 @@ void Expression::defaultDeepReduceChildren(ExpressionNode::ReductionContext redu
|
||||
|
||||
Expression Expression::defaultShallowReduce() {
|
||||
Expression result;
|
||||
const int childrenCount = numberOfChildren();
|
||||
for (int i = 0; i < childrenCount; i++) {
|
||||
/* The reduction is shortcut if one child is unreal or undefined:
|
||||
* - the result is unreal if at least one child is unreal
|
||||
* - the result is undefined if at least one child is undefined but no child
|
||||
* is unreal */
|
||||
ExpressionNode::Type childIType = childAtIndex(i).type();
|
||||
if (childIType == ExpressionNode::Type::Unreal) {
|
||||
result = Unreal::Builder();
|
||||
break;
|
||||
} else if (childIType == ExpressionNode::Type::Undefined) {
|
||||
result = Undefined::Builder();
|
||||
if (sSimplificationHasBeenInterrupted) {
|
||||
result = Undefined::Builder();
|
||||
} else {
|
||||
const int childrenCount = numberOfChildren();
|
||||
for (int i = 0; i < childrenCount; i++) {
|
||||
/* The reduction is shortcut if one child is unreal or undefined:
|
||||
* - the result is unreal if at least one child is unreal
|
||||
* - the result is undefined if at least one child is undefined but no child
|
||||
* is unreal */
|
||||
ExpressionNode::Type childIType = childAtIndex(i).type();
|
||||
if (childIType == ExpressionNode::Type::Unreal) {
|
||||
result = Unreal::Builder();
|
||||
break;
|
||||
} else if (childIType == ExpressionNode::Type::Undefined) {
|
||||
result = Undefined::Builder();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!result.isUninitialized()) {
|
||||
|
||||
Reference in New Issue
Block a user